io.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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_HEADER_ROWS 1
  5. /* Row 0: banner left, datetime right (19 chars "YYYY-MM-DD HH:MM:SS") */
  6. #define IO_DATETIME_LEN 19
  7. unsigned int io_get_cols(void);
  8. unsigned int io_get_rows(void);
  9. #define IO_VGA_COLS (io_get_cols())
  10. #define IO_VGA_ROWS (io_get_rows())
  11. #define IO_CONTENT_OFFSET (IO_HEADER_ROWS * io_get_cols())
  12. #define IO_CONTENT_ROWS (io_get_rows() - IO_HEADER_ROWS)
  13. #define IO_CONTENT_SIZE (IO_CONTENT_ROWS * io_get_cols())
  14. #define IO_DATETIME_POS (io_get_cols() - IO_DATETIME_LEN)
  15. void io_init(void);
  16. void io_clear_screen(void);
  17. int io_did_scroll(void); /* returns 1 once after a scroll, then 0 until next scroll */
  18. void io_putchar(char c);
  19. void io_putstr(const char *s);
  20. void io_puthex(unsigned int n); /* print n as 8 hex digits, no 0x prefix */
  21. unsigned int io_get_cursor(void);
  22. void io_set_cursor(unsigned int pos);
  23. void io_cursor_show_block(void);
  24. void io_cursor_hide_block(void);
  25. void io_vga_write(unsigned int pos, unsigned short value);
  26. void io_drain_keyboard(void);
  27. /* Poll keyboard; returns 0 = no key, 1..255 = ASCII, or IO_KEY_LEFT/IO_KEY_RIGHT. */
  28. #define IO_KEY_LEFT 0x100
  29. #define IO_KEY_RIGHT 0x101
  30. int io_poll_key(void);
  31. /* Same as io_poll_key but also reads port 0x60 when buffer empty (for full-screen programs). */
  32. int io_poll_key_with_hw(void);
  33. unsigned char io_last_scancode(void);
  34. #endif