Page 1 of 1
Unable to use PIT
Posted: Wed Mar 18, 2020 4:17 am
by Bonfra
So, i've merged some tutorials from github and the osdev wiki and got all setted and working: gdt idt isr pic and irqs. now i'm trying to setup the pit but the irq handler is never called. have i Forgot to init something? on what does the pit depends?
Re: Unable to use PIT
Posted: Wed Mar 18, 2020 4:22 am
by AJ
Hi,
I'm afraid more detail is going to be needed than that. Are you on an emulator or real hardware. Is a legacy PIC / PIT even present? Post either a link to your code or post minimal relevant code in code tags.
Cheers,
Adam
Re: Unable to use PIT
Posted: Wed Mar 18, 2020 5:28 am
by Bonfra
AJ wrote:Hi,
I'm afraid more detail is going to be needed than that. Are you on an emulator or real hardware. Is a legacy PIC / PIT even present? Post either a link to your code or post minimal relevant code in code tags.
Cheers,
Adam
sure! I caccidentally deleted the link before posting XD
https://github.com/Bonfra04/OS-DEV
Re: Unable to use PIT
Posted: Thu Mar 19, 2020 10:31 am
by Bonfra
my thought is that i need to set or enable something first since it does not throw any errors but i really can't get what that is... i am totally stuck
Re: Unable to use PIT
Posted: Thu Mar 19, 2020 5:30 pm
by zecarlos
I run BonsOS.img with BochsDBG and it seemed to me that in the pic.c file in the pic_set_enable (...) function, the parameter sent to the "master_set_mask (mask)" function has the value of 0xfb. If I am right this will be the reason, but you will have to confirm the value of this parameter (first bit to zero enables the timer int0, value 1 disables it. At begin all interrupt are disable master = slave = 0xff.
Re: Unable to use PIT
Posted: Thu Mar 19, 2020 7:00 pm
by zecarlos
You have a error in line 62 from pic.h file. Delete extern "C" from there
Re: Unable to use PIT
Posted: Thu Mar 19, 2020 10:02 pm
by nullplan
Some remarks: Your PIC driver should ensure that IRQ 2 is never used, and never masked. IRQ2 is the chaining IRQ for the slave PIC. It must remain enabled, else IRQs 8-15 can never fire. Also, according to the Linux source code, the port I/O with the PIC is slow, so you should strive to do as little of it as possible. To that end, maybe save the interrupt mask in software. You can probably afford another sixteen bit static variable.
But your problem probably is that you hook your PIT interrupt to IRQ2. The PIT is on IRQ0.
Re: Unable to use PIT
Posted: Fri Mar 20, 2020 2:27 am
by Bonfra
nullplan wrote:Some remarks: Your PIC driver should ensure that IRQ 2 is never used, and never masked. IRQ2 is the chaining IRQ for the slave PIC. It must remain enabled, else IRQs 8-15 can never fire. Also, according to the Linux source code, the port I/O with the PIC is slow, so you should strive to do as little of it as possible. To that end, maybe save the interrupt mask in software. You can probably afford another sixteen bit static variable.
But your problem probably is that you hook your PIT interrupt to IRQ2. The PIT is on IRQ0.
it really was just this... using IRQ 0 works fine! the funny thing is that i tried from 2 to 15 but leaved 0 alone
... i'm so dumb thank you very much.