extern char getkb() apparently has no effect(MEATY SKELETON)
Posted: Mon Feb 08, 2016 2:38 pm
Please see the modified version of file tty.c below from MEATY SKELETON.
This question concerns 1) the statement at the beginning:
extern char getkb();
and 2) the third function from the bottom: void terminal_getkb(void).
Label getkb is the entry point to an assembly routine.
The function line: c = getkb()
gets the error: undefined reference to `getkb'
as though the statement: extern char getkb() has no effect.
It should not get that error even if the assembly routine is deleted.
If the compile or link lines in the makefile were wrong I would expect
a different message like: file foo.bar not found. I suspect I cannot
use the line: extern char getkb(void) in this code because it violates
something about these OS programming files.
MY QUESTION: why the error: undefined reference to getkb
TIA Bill S.
This question concerns 1) the statement at the beginning:
extern char getkb();
and 2) the third function from the bottom: void terminal_getkb(void).
Label getkb is the entry point to an assembly routine.
The function line: c = getkb()
gets the error: undefined reference to `getkb'
as though the statement: extern char getkb() has no effect.
It should not get that error even if the assembly routine is deleted.
If the compile or link lines in the makefile were wrong I would expect
a different message like: file foo.bar not found. I suspect I cannot
use the line: extern char getkb(void) in this code because it violates
something about these OS programming files.
MY QUESTION: why the error: undefined reference to getkb
TIA Bill S.
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <kernel/vga.h>
extern char getkb(void);
char c='A';
size_t terminal_row;
size_t terminal_column;
uint8_t terminal_color;
uint16_t* terminal_buffer;
void terminal_initialize(void)
{
terminal_row = 0;
terminal_column = 0;
terminal_color = make_color(COLOR_MAGENTA, COLOR_BLACK);
terminal_buffer = VGA_MEMORY;
for ( size_t y = 0; y < VGA_HEIGHT; y++ )
{
for ( size_t x = 0; x < VGA_WIDTH; x++ )
{
const size_t index = y * VGA_WIDTH + x;
terminal_buffer[index] = make_vgaentry(' ', terminal_color);
}
}
}
void scrolldn(){
for (size_t i = 0; i<VGA_WIDTH*VGA_HEIGHT; i++)
terminal_buffer = terminal_buffer[i+VGA_WIDTH];
}
void terminal_setcolor(uint8_t color)
{
terminal_color = color;
}
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y)
{
const size_t index = y * VGA_WIDTH + x;
terminal_buffer[index] = make_vgaentry(c, color);
}
void terminal_putchar(char c) {
if (c != '\n'){
terminal_putentryat(c, terminal_color, terminal_column, terminal_row);
if (++terminal_column == VGA_WIDTH) {
terminal_column = 0;
if (++terminal_row == VGA_HEIGHT)
scrolldn();
}
}
else
{
terminal_column = 0;
terminal_row++;
if (terminal_row == VGA_HEIGHT)
scrolldn();
}
}
void terminal_getkb(void)
{
while (1)
{ c = getkb();
terminal_putchar(c);
}
}
void terminal_write(const char* data, size_t size)
{
for ( size_t i = 0; i < size; i++ )
terminal_putchar(data);
}
//void terminal_writestring(const char* data)
//{
// terminal_write(data, strlen(data));
//}