diff options
author | Benji Dial <benji3.141@gmail.com> | 2020-05-24 11:02:43 -0400 |
---|---|---|
committer | Benji Dial <benji3.141@gmail.com> | 2020-05-24 11:02:43 -0400 |
commit | 02f14113cbf14c6f842fb43ecbc68d0c851ef3b0 (patch) | |
tree | 75d2d943d9822b3f945fd947e9b91eec1d68e900 /src/kernel/vga.c | |
parent | 31d8ae388a7ded576abd3e3d99c3d9193ea6d704 (diff) | |
download | portland-os-02f14113cbf14c6f842fb43ecbc68d0c851ef3b0.tar.gz |
very basic vga, ata, serial drivers. start of fat and fs drivers
Diffstat (limited to 'src/kernel/vga.c')
-rw-r--r-- | src/kernel/vga.c | 58 |
1 files changed, 19 insertions, 39 deletions
diff --git a/src/kernel/vga.c b/src/kernel/vga.c index 8e438a8..c387b22 100644 --- a/src/kernel/vga.c +++ b/src/kernel/vga.c @@ -1,6 +1,12 @@ #include <stdint.h> #include <stdbool.h> +#define VGA_COM_MIRROR + +#ifdef VGA_COM_MIRROR +#include "serial.h" +#endif + #define VGA_COLUMNS 80 #define VGA_LINES 25 #define VGA_START (uint16_t *)0x000b8000 @@ -8,11 +14,18 @@ uint16_t *cursor = VGA_START; uint16_t color = 0x1f00; +void vga_set_color(uint8_t new_color) { + color = new_color << 8; +} + void vga_scroll() { cursor = VGA_START; } void vga_blank() { +#ifdef VGA_COM_MIRROR + soutsz("\r\n\r\n<CLEAR>\r\n\r\n"); +#endif uint32_t f = (color << 16) | color | 0x00200020; uint32_t *p = (uint32_t *)VGA_START; while (p < (uint32_t *)VGA_END) @@ -22,10 +35,16 @@ void vga_blank() { void vga_printch(uint8_t ch) { if (ch == '\n') { +#ifdef VGA_COM_MIRROR + soutsz("\r\n"); +#endif if ((cursor = cursor - (cursor - VGA_START) % VGA_COLUMNS + VGA_COLUMNS) == VGA_END) vga_scroll(); return; } +#ifdef VGA_COM_MIRROR + sout(ch); +#endif *(cursor++) = color | ch; if (cursor == VGA_END) vga_scroll(); @@ -39,43 +58,4 @@ void vga_printsz(uint8_t *sz) { void vga_printsn(uint8_t *sn, uint8_t n) { while (n--) vga_printch(*(sn++)); -} - -void vga_printu32(uint32_t n) { - bool zero = false; - for (uint32_t m = 1000000000; m; m /= 10) { - uint8_t d = (n / m) % 10; - if (zero) - vga_printch(d + '0'); - else if (d) { - zero = true; - vga_printch(d + '0'); - } - } -} - -void vga_printu16(uint16_t n) { - bool zero = false; - for (uint16_t m = 10000; m; m /= 10) { - uint8_t d = (n / m) % 10; - if (zero) - vga_printch(d + '0'); - else if (d) { - zero = true; - vga_printch(d + '0'); - } - } -} - -void vga_printu8(uint8_t n) { - bool zero = false; - for (uint8_t m = 100; m; m /= 10) { - uint8_t d = (n / m) % 10; - if (zero) - vga_printch(d + '0'); - else if (d) { - zero = true; - vga_printch(d + '0'); - } - } }
\ No newline at end of file |