io.h 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. /* I/O library: VGA text output and PS/2 keyboard. Usable by terminal and other programs. */
  2. #ifndef IO_H
  3. #define IO_H
  4. #define IO_VGA_COLS 80
  5. #define IO_VGA_ROWS 25
  6. #define IO_HEADER_ROWS 1
  7. #define IO_CONTENT_OFFSET (IO_HEADER_ROWS * IO_VGA_COLS) /* row 1 start */
  8. #define IO_CONTENT_ROWS (IO_VGA_ROWS - IO_HEADER_ROWS) /* 24 rows */
  9. #define IO_CONTENT_SIZE (IO_CONTENT_ROWS * IO_VGA_COLS)
  10. /* Row 0: banner left, datetime right (19 chars "YYYY-MM-DD HH:MM:SS") */
  11. #define IO_DATETIME_LEN 19
  12. #define IO_DATETIME_POS (IO_VGA_COLS - IO_DATETIME_LEN)
  13. void io_init(void);
  14. void io_clear_screen(void);
  15. int io_did_scroll(void); /* returns 1 once after a scroll, then 0 until next scroll */
  16. void io_putchar(char c);
  17. void io_putstr(const char *s);
  18. unsigned int io_get_cursor(void);
  19. void io_set_cursor(unsigned int pos);
  20. void io_cursor_show_block(void);
  21. void io_cursor_hide_block(void);
  22. void io_vga_write(unsigned int pos, unsigned short value);
  23. void io_drain_keyboard(void);
  24. /* Poll keyboard; returns 0 = no key, 1..255 = ASCII, or IO_KEY_LEFT/IO_KEY_RIGHT. */
  25. #define IO_KEY_LEFT 0x100
  26. #define IO_KEY_RIGHT 0x101
  27. int io_poll_key(void);
  28. unsigned char io_last_scancode(void);
  29. #endif