PIT not working
Posted: Fri May 10, 2019 9:08 am
Hello,
I have another problem with my "OS": i'm unable to get the PIT to work.
This is what i've tried to do:.
Otherwise(with QEMU or even with Bochs, pressing "enter" from GRUB's menu)nothing gets printed at all.
This is the repo, just in case.
I have another problem with my "OS": i'm unable to get the PIT to work.
This is what i've tried to do:
- Remapped PICs using:
Code: Select all
void irq_remap() { outb(0x20, 0x11); outb(0xA0, 0x11); outb(0x21, 0x20); outb(0xA1, 0x28); outb(0x21, 0x04); outb(0xA1, 0x02); outb(0x21, 0x01); outb(0xA1, 0x01); outb(0x21, 0x0); outb(0xA1, 0x0); }
- An IRQ handler that is being called from assembly irq_common_stub:
Code: Select all
void irq_handler(registers_t regs) { if(regs.int_no >= 40) // If IRQ > 7(int_no > 40) reset slave PIC outb(0xA0, 0x20); outb(0x20, 0x20); // In either cases, reset master PIC // Register a new interrupt handler if(interrupt_handlers[regs.int_no] != 0) { isr_t handler = interrupt_handlers[regs.int_no]; handler(regs); } }
- A timer initializer
Code: Select all
void init_timer(uint32_t frequency) { register_interrupt_handler(32, &timer_callback); uint32_t divisor = 1193180 / frequency; outb(0x43, 0x36); uint8_t low = (uint8_t)(divisor & 0xFF); uint8_t high = (uint8_t)((divisor >> 8) & 0xFF); outb(0x40, low); outb(0x40, high); }
Code: Select all
03150576036e[CPU0 ] check_cs(0x0206): not a valid code segment !
Otherwise(with QEMU or even with Bochs, pressing "enter" from GRUB's menu)nothing gets printed at all.
This is the repo, just in case.