diff options
author | Tyler Murphy <=> | 2023-07-17 19:34:52 -0400 |
---|---|---|
committer | Tyler Murphy <=> | 2023-07-17 19:34:52 -0400 |
commit | 7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5 (patch) | |
tree | 4e86ff20e73171285156631db043e12aaf63bf04 /kernel/src/arch/i686/drivers/vga.c | |
parent | paging (diff) | |
download | finix-7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5.tar.gz finix-7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5.tar.bz2 finix-7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5.zip |
refactoring
Diffstat (limited to 'kernel/src/arch/i686/drivers/vga.c')
-rw-r--r-- | kernel/src/arch/i686/drivers/vga.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/kernel/src/arch/i686/drivers/vga.c b/kernel/src/arch/i686/drivers/vga.c new file mode 100644 index 0000000..a41ce54 --- /dev/null +++ b/kernel/src/arch/i686/drivers/vga.c @@ -0,0 +1,50 @@ +#include <arch/i686/asm.h> +#include <drivers/vga.h> +#include <stddef.h> +#include <stdint.h> +#include <string.h> + +static uint16_t *buffer = (uint16_t*) 0xC03FF000; +static uint8_t start, end; + +void vgatext_write(char c, enum vga_color color, uint8_t x, uint8_t y) { + const size_t index = y * VGA_TEXT_W + x; + buffer[index] = c | (uint16_t) color << 8; +} + +void vgatext_write_data(uint16_t data, uint16_t index) { + buffer[index] = data; +} + +void vgatext_write_buf(const uint16_t *src) { + memcpy(buffer, src, VGA_TEXT_W * VGA_TEXT_H * sizeof(uint16_t)); +} + +void vgatext_cur_mov(uint8_t x, uint8_t y) { +; const uint16_t pos = y * VGA_TEXT_W + x; + + outb(0x3D4, 0x0F); + outb(0x3D5, (uint8_t) (pos & 0xFF)); + outb(0x3D4, 0x0E); + outb(0x3D5, (uint8_t) ((pos >> 8) & 0xFF)); +} + +void vgatext_cur_resize(uint8_t s, uint8_t e) { + start = s; + end = e; + + outb(0x3D4, 0x0A); + outb(0x3D5, (inb(0x3D5) & 0xC0) | start); + + outb(0x3D4, 0x0B); + outb(0x3D5, (inb(0x3D5) & 0xE0) | end); +} + +void vgatext_cur_visible(bool visible) { + if (visible) { + vgatext_cur_resize(start, end); + } else { + outb(0x3D4, 0x0A); + outb(0x3D5, 0x20); + } +} |