#define NB_COLS 80 #define NB_ROWS 25 #define BPC 2 #define VIDEO_BUFFER 0xB8000 /* XXX doest not always handle memory overlaps */ static void my_memmove(void *_dest, const void *_src, int n) { char *dest = _dest; const char *src = _src; for (int i = 0; i < n; ++i) { dest[i] = src[i]; } } static void my_memset(void *_dest, int c, int n) { char *dest = _dest; for (int i = 0; i < n; ++i) { dest[i] = c; } } int printk(const char *str) { static const long int offset = VIDEO_BUFFER; static char *addr = (char *) VIDEO_BUFFER; int count = 0; for (int i = 0; str[i]; ++i) { /* TODO add the serial port handling */ if ((long)addr >= offset + NB_COLS * NB_ROWS * BPC) { /* shift up */ addr -= NB_COLS * BPC; my_memmove((void *)offset, (void *)offset + NB_COLS * BPC, NB_COLS * (NB_ROWS - 1) * BPC); my_memset((void *)offset + NB_COLS * (NB_ROWS - 1) * BPC, ' ', NB_COLS * BPC); } *addr = str[i]; addr += BPC; ++count; } return count; } int main(void) { }