OSDev.org https://forum.osdev.org/ |
|
PIT not working https://forum.osdev.org/viewtopic.php?f=1&t=33688 |
Page 1 of 1 |
Author: | KSMb [ Fri May 10, 2019 9:08 am ] |
Post subject: | PIT not working |
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:
Code: 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); }
Code: 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); } }
Code: 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: 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. |
Author: | nullplan [ Fri May 10, 2019 10:03 am ] |
Post subject: | Re: PIT not working |
KSMb wrote: Code: void irq_handler(registers_t regs) { Not this old chestnut again. Since I highly doubt you are handing a structure over correctly (according to the ABI, that is), I suggest you make the parameter into a pointer and hand that over. KSMb wrote: Code: 03150576036e[CPU0 ] check_cs(0x0206): not a valid code segment ! .The hint is in the message. There are only two ways how a code segment would be loaded: far jump or interrupt. So if you can exclude far jumps, this message is caused by an interrupt. And it means that either the CS reference in the relevant IDT entry is wrong, or the CS entry in the GDT is wrong. Happy debugging! |
Author: | MichaelPetch [ Fri May 10, 2019 12:08 pm ] |
Post subject: | Re: PIT not working |
The issue you had with registers_t vs. registers_t * previously with isr_handler also applies to irq_handler |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |