tty.hpp 649 B

1234567891011121314151617181920212223242526272829303132
  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. struct tty;
  7. struct tty_operations {
  8. void (*put_char)(struct tty* p_tty, char c);
  9. };
  10. struct tty {
  11. char name[STRUCT_TTY_NAME_LEN];
  12. struct tty_operations* ops;
  13. union {
  14. uint8_t u8[12];
  15. uint16_t u16[6];
  16. uint32_t u32[3];
  17. void* p[12 / sizeof(void*)];
  18. } data;
  19. };
  20. // in kernel_main.c
  21. extern struct tty* console;
  22. void tty_print(struct tty* p_tty, const char* str);
  23. int make_serial_tty(struct tty* p_tty, int id, int buffered);
  24. int make_vga_tty(struct tty* p_tty);