X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/ea77b9c3fc7fb9bf9d7f9604fc187c8049212a2a..1fe5f5eb5378a47bf0f3451762743c162e40faad:/lunaix-os/kernel/tty/tty.c?ds=sidebyside diff --git a/lunaix-os/kernel/tty/tty.c b/lunaix-os/kernel/tty/tty.c index b8631b6..e90899b 100644 --- a/lunaix-os/kernel/tty/tty.c +++ b/lunaix-os/kernel/tty/tty.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -6,6 +5,8 @@ #include #include +#include + vga_attribute* tty_vga_buffer; vga_attribute tty_theme_color = VGA_COLOR_BLACK; @@ -26,11 +27,24 @@ tty_init(void* vga_buf) tty_clear(); - io_outb(0x3D4, 0x0A); - io_outb(0x3D5, (io_inb(0x3D5) & 0xC0) | 13); + port_wrbyte(0x3D4, 0x0A); + port_wrbyte(0x3D5, (port_rdbyte(0x3D5) & 0xC0) | 13); + + port_wrbyte(0x3D4, 0x0B); + port_wrbyte(0x3D5, (port_rdbyte(0x3D5) & 0xE0) | 15); +} - io_outb(0x3D4, 0x0B); - io_outb(0x3D5, (io_inb(0x3D5) & 0xE0) | 15); +void +tty_set_cursor(u8_t x, u8_t y) +{ + if (x >= TTY_WIDTH || y >= TTY_HEIGHT) { + x = y = 0; + } + u32_t pos = y * TTY_WIDTH + x; + port_wrbyte(0x3D4, 14); + port_wrbyte(0x3D5, pos / 256); + port_wrbyte(0x3D4, 15); + port_wrbyte(0x3D5, pos % 256); } void @@ -51,7 +65,7 @@ tty_flush_buffer(struct fifo_buf* buf) int state = 0; int g[2] = { 0, 0 }; vga_attribute current_theme = tty_theme_color; - while (fifo_readone_async(buf, &chr)) { + while (fifo_readone_async(buf, (u8_t*)&chr)) { if (state == 0 && chr == '\033') { state = 1; } else if (state == 1 && chr == '[') { @@ -107,19 +121,6 @@ tty_flush_buffer(struct fifo_buf* buf) tty_set_cursor(x, y); } -void -tty_set_cursor(uint8_t x, uint8_t y) -{ - if (x >= TTY_WIDTH || y >= TTY_HEIGHT) { - x = y = 0; - } - uint32_t pos = y * TTY_WIDTH + x; - io_outb(0x3D4, 14); - io_outb(0x3D5, pos / 256); - io_outb(0x3D4, 15); - io_outb(0x3D5, pos % 256); -} - void tty_clear_line(int line_num) {