diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-10-10 11:07:15 +0200 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-10-10 11:07:15 +0200 |
commit | 0abf506ae1a5e3c352c40096b20e9986623169b1 (patch) | |
tree | 865dd829304b5aee0dc2d7ecd170d16765fa4580 | |
parent | c51fa1f0e9b7ce6691d140245d48e4c843782f68 (diff) |
kfs: fixed compilation of src/main.c
multiple issues existed (mainly about cast) have been fixed.
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
-rw-r--r-- | src/main.c | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -1,38 +1,46 @@ #define NB_COLS 80 #define NB_ROWS 25 +#define VIDEO_BUFFER 0xB8000 + /* XXX doest not always handle memory overlaps */ -static void my_memmove(void *dest, const void *src, size_t n) +static void my_memmove(void *_dest, const void *_src, int n) { - for (size_t i = 0; i < n; ++i) { + 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, size_t n) +static void my_memset(void *_dest, int c, int n) { - for (size_t i = 0; i < n; ++i) { + char *dest = _dest; + + for (int i = 0; i < n; ++i) { dest[i] = c; } } int printk(const char *str) { - static char *offset = (char *) 0xb8000; - static char *addr = offset; + static const long int offset = VIDEO_BUFFER; + static char *addr = (char *) VIDEO_BUFFER; int count = 0; for (int i = 0; str[i]; ++i) { - if ((long)addr >= 0xb8000 + NB_COLS * NB_ROWS) { + /* TODO add the serial port handling */ + + if ((long)addr >= offset + NB_COLS * NB_ROWS) { /* shift up */ addr -= NB_COLS; - my_memmove(offset, offset + NB_COLS, NB_COLS * (NB_ROWS - 1)); - my_memset(offset + NB_COLS * (NB_ROWS - 1), ' ', NB_ROWS); + my_memmove((void *)offset, (void *)offset + NB_COLS, NB_COLS * (NB_ROWS - 1)); + my_memset((void *)offset + NB_COLS * (NB_ROWS - 1), ' ', NB_ROWS); } - *addr++ = str[i] + *addr++ = str[i]; ++count; - } return count; |