Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <kernel/tty.h>
- #include <kernel/gdt.h>
- #include <kernel/idt.h>
- #include <kernel/timer.h>
- #include <kernel/port_io.h>
- #define PORT 0x3F8
- void kernel_main(void) {
- outb(PORT + 1, 0x00); // Disable all interrupts
- outb(PORT + 3, 0x80); // Enable DLAB (set baud rate divisor)
- outb(PORT + 0, 0x03); // Set divisor to 3 (lo byte) 38400 baud
- outb(PORT + 1, 0x00); // (hi byte)
- outb(PORT + 3, 0x03); // 8 bits, no parity, one stop bit
- outb(PORT + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold
- outb(PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set
- outb(PORT + 4, 0x1E); // Set in loopback mode, test the serial chip
- outb(PORT + 0, 0xAE); // Test serial chip (send byte 0xAE and check if serial returns same byte)
- outb(PORT + 4, 0x0F);
- tty_init();
- gdt_init();
- printf("Initialised GDT.\n");
- idt_init();
- printf("Initialised IDT.\n");
- timer_init();
- while (1) {
- outb(0x43, 0x00);
- uint8_t res = inb(0x40);
- outb(0x3F8, res);
- }
- }
- (ran with qemu-system-i386 -serial file:log.txt -cdrom sillyos.iso)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement