Advertisement
Guest User

buh

a guest
Jul 24th, 2024
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <kernel/tty.h>
  4. #include <kernel/gdt.h>
  5. #include <kernel/idt.h>
  6. #include <kernel/timer.h>
  7. #include <kernel/port_io.h>
  8.  
  9. #define PORT 0x3F8
  10.  
  11. void kernel_main(void) {
  12. outb(PORT + 1, 0x00); // Disable all interrupts
  13. outb(PORT + 3, 0x80); // Enable DLAB (set baud rate divisor)
  14. outb(PORT + 0, 0x03); // Set divisor to 3 (lo byte) 38400 baud
  15. outb(PORT + 1, 0x00); // (hi byte)
  16. outb(PORT + 3, 0x03); // 8 bits, no parity, one stop bit
  17. outb(PORT + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold
  18. outb(PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set
  19. outb(PORT + 4, 0x1E); // Set in loopback mode, test the serial chip
  20. outb(PORT + 0, 0xAE); // Test serial chip (send byte 0xAE and check if serial returns same byte)
  21. outb(PORT + 4, 0x0F);
  22. tty_init();
  23.  
  24. gdt_init();
  25. printf("Initialised GDT.\n");
  26. idt_init();
  27. printf("Initialised IDT.\n");
  28. timer_init();
  29. while (1) {
  30. outb(0x43, 0x00);
  31. uint8_t res = inb(0x40);
  32. outb(0x3F8, res);
  33. }
  34. }
  35.  
  36. (ran with qemu-system-i386 -serial file:log.txt -cdrom sillyos.iso)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement