kernel

hobby kernel
git clone git://git.evenfri.xyz/kernel.git
Log | Files | Refs | README | LICENSE

vga.c (709B)


      1 #include <dat.h>
      2 #include <fns.h>
      3 
      4 void vga_cursor_enable(uint8_t s, uint8_t e) {
      5   outb(vga_ctrl, 0x0a);
      6   outb(vga_data, (inb(vga_data) & 0xc0) | s);
      7 
      8   outb(vga_ctrl, 0x0b);
      9   outb(vga_data, (inb(vga_data) & 0xe0) | e);
     10 }
     11 
     12 void vga_cursor_disable(void) {
     13   outb(vga_ctrl, 0x0a);
     14   outb(vga_data, 0x20);
     15 }
     16 
     17 void vga_cursor_update(int x, int y) {
     18   uint16_t pos = y * vga_width + x;
     19   outb(vga_ctrl, 0x0f);
     20   outb(vga_data, (uint8_t) (pos & 0xff));
     21 
     22   outb(vga_ctrl, 0x0e);
     23   outb(vga_data, (uint8_t) ((pos >> 8) & 0xff));
     24 }
     25 
     26 uint16_t vga_cursor_get_pos(void) {
     27   uint16_t pos = 0;
     28   outb(vga_ctrl, 0x0f);
     29 
     30   pos |= inb(0x3d5);
     31   outb(vga_ctrl, 0x0e);
     32 
     33   pos |= ((uint16_t)inb(0x3d5) << 8);
     34   return pos;
     35 }
     36