Unable to use PIT

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Unable to use PIT

Post 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?
Regards, Bonfra.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Unable to use PIT

Post 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
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Re: Unable to use PIT

Post 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
Regards, Bonfra.
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Re: Unable to use PIT

Post 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
Regards, Bonfra.
zecarlos
Posts: 11
Joined: Tue Feb 18, 2020 8:20 am

Re: Unable to use PIT

Post 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.
zecarlos
Posts: 11
Joined: Tue Feb 18, 2020 8:20 am

Re: Unable to use PIT

Post by zecarlos »

You have a error in line 62 from pic.h file. Delete extern "C" from there
nullplan
Member
Member
Posts: 1792
Joined: Wed Aug 30, 2017 8:24 am

Re: Unable to use PIT

Post 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.
Carpe diem!
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Re: Unable to use PIT

Post 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 :oops: ... i'm so dumb thank you very much.
Regards, Bonfra.
Post Reply