tty.h 718 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <asm/port_io.h>
  3. #include <types/stdint.h>
  4. #define STRUCT_TTY_NAME_LEN (32)
  5. #define SERIAL_TTY_BUFFER_SIZE (4096)
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. struct tty;
  10. struct tty_operations {
  11. void (*put_char)(struct tty* p_tty, char c);
  12. };
  13. struct tty {
  14. char name[STRUCT_TTY_NAME_LEN];
  15. struct tty_operations* ops;
  16. union {
  17. uint8_t u8[12];
  18. uint16_t u16[6];
  19. uint32_t u32[3];
  20. void* p[12 / sizeof(void*)];
  21. } data;
  22. };
  23. // in kernel_main.c
  24. extern struct tty* console;
  25. void tty_print(struct tty* p_tty, const char* str);
  26. int make_serial_tty(struct tty* p_tty, int id, int buffered);
  27. int make_vga_tty(struct tty* p_tty);
  28. #ifdef __cplusplus
  29. }
  30. #endif