From e8c6577617bffa4402c07c7aa20e3c24f03c1c20 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 6 Sep 2020 00:48:07 -0400 Subject: program loading, others big kernel additions: paging, elf loading, separate kernel and user page allocation it now properly loads and runs sd0:bin/init.elf still need to determine which disk was booted from, and start the init on that disk --- src/kernel/vga.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/kernel/vga.c') diff --git a/src/kernel/vga.c b/src/kernel/vga.c index 7506416..c03e5f0 100644 --- a/src/kernel/vga.c +++ b/src/kernel/vga.c @@ -2,9 +2,8 @@ #include #define VGA_COLUMNS 80 -#define VGA_LINES 25 #define VGA_START (uint16_t *)0x000b8000 -#define VGA_END (VGA_START + VGA_COLUMNS * VGA_LINES) +#define VGA_END (VGA_START + VGA_COLUMNS * 25) static uint16_t *cursor = VGA_START; static uint16_t mask; @@ -12,12 +11,12 @@ void vga_set_color(uint8_t new_color) { mask = new_color << 8; } -void vga_scroll() { +static void vga_scroll() { for (uint32_t *i = (uint32_t *)VGA_START; i < (uint32_t *)(VGA_END - VGA_COLUMNS); ++i) *i = *(i + VGA_COLUMNS / 2); uint32_t f = (mask | (uint8_t)' ') * 0x00010001; for (uint32_t *i = (uint32_t *)(VGA_END - VGA_COLUMNS); i < (uint32_t *)VGA_END; ++i) - *i++ = f; + *i = f; cursor -= VGA_COLUMNS; } @@ -30,12 +29,10 @@ void vga_blank() { } void vga_printch(char ch) { - if (ch == '\n') { - if ((cursor = cursor - (cursor - VGA_START) % VGA_COLUMNS + VGA_COLUMNS) == VGA_END) - vga_scroll(); - return; - } - *cursor++ = mask | (uint8_t)ch; + if (ch == '\n') + cursor = ((cursor - VGA_START) / VGA_COLUMNS + 1) * VGA_COLUMNS + VGA_START; + else + *cursor++ = mask | (uint8_t)ch; if (cursor == VGA_END) vga_scroll(); } \ No newline at end of file -- cgit v1.2.3