OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 3:30 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: IRQ won't fire, checked the wiki page, can't find any errors
PostPosted: Thu Aug 06, 2020 7:30 am 
Offline
Member
Member

Joined: Tue Jul 14, 2020 4:01 am
Posts: 70
I'm developing my own legacy bios implementation for bochs, and got stuck at INT 16h. The keyboard IRQ just won't fire(bochs reported keyboard buffer full,ignoring scancode). The PIC initialization code looks really fine, the handlers looks fine, but it just wont fire. I checked everything, and I just can't find the reason why(interrupt flag is present, proper segment, ivt does have int 0x9 according to bochs's info ivt 0x9 command).Here's the pic initialization code, which set an irq offset of 0x8 for master and 0x70 for slave:
Code:
initpic:
    mov al,0x11
    out 0x20,al
    out 0xa0,al
    mov al,0x8
    out 0x21,al
    mov al,0x70
    out 0xa1,al
    mov al,4
    out 0x21,al
    mov al,0x2
    out 0xa1,al
    mov al,1
    out 0x21,al
    out 0xa1,al
    mov al,0xfd
    out 0x21,al
    mov al,0xff
    out 0xa1,al

Here's the handler code, which is a dummy code for now:
Code:
irq1:
   pusha
   mov al,0x20 ;the acknowledge interrupt code
   out 0x20,al
   in al,60h
   popa
   iret

And here's the code for setting the ivt:
Code:
setivt:
   xor dx,dx
   mov gs,dx
   mov [gs:0x9*4+2],cs
   mov [gs:0x9*4],irq1

and the code looked perfectly fine to me.
EDIT: Added the acknowledge interrupt code


Last edited by clementttttttttt on Thu Aug 06, 2020 10:01 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: IRQ won't fire, checked the wiki page, can't find any er
PostPosted: Thu Aug 06, 2020 8:45 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
Your interrupt handler doesn't acknowledge the interrupt.


Top
 Profile  
 
 Post subject: Re: IRQ won't fire, checked the wiki page, can't find any er
PostPosted: Thu Aug 06, 2020 9:20 am 
Offline
Member
Member

Joined: Tue Jul 14, 2020 4:01 am
Posts: 70
The problem is, even with acknowledge interrupt, I still can't receive any IRQs.

EDIT:
I inserted the initialization code in the startup code of NetDOS(my os), and it works fine, so the initialization code was definitely not the problem


Top
 Profile  
 
 Post subject: Re: IRQ won't fire, checked the wiki page, can't find any er
PostPosted: Thu Aug 06, 2020 9:57 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
Could you publish the code of the interrupt handler that now acknowledges the interrupt?


Top
 Profile  
 
 Post subject: Re: IRQ won't fire, checked the wiki page, can't find any er
PostPosted: Thu Aug 06, 2020 10:28 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1604
clementttttttttt wrote:
(bochs reported keyboard buffer full,ignoring scancode)
Something is already in the keyboard buffer. Your keyboard initialization routine fails to empty the buffer. Therefore no new scan code can be put into the buffer. The initialization routine must read port 0x64 and test if bit 0 is set. If so, it must read port 0x60 until that bit is clear. Since at that point you cannot know where you are in a multi-byte scan code, just discard the data.

The interrupt handler also must read port 0x60 to clear the buffer. Else the PS/2 controller will not send another code byte, even if the PIC has been satisfied.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: IRQ won't fire, checked the wiki page, can't find any er
PostPosted: Thu Aug 06, 2020 12:07 pm 
Offline
Member
Member

Joined: Tue Jul 14, 2020 4:01 am
Posts: 70
I knew that, and its intended only for placeholder purposes and only intended for single byte scancodes.I tried to replace my os's keyboard handler with that one, smashed the keyboard, and that buffer full message never appeared, so i think its not the problem of the handler too.


Top
 Profile  
 
 Post subject: Re: IRQ won't fire, checked the wiki page, can't find any er
PostPosted: Thu Aug 06, 2020 12:57 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
Just to clarify - you are now sending the EOI signal to the PIC?


Top
 Profile  
 
 Post subject: Re: IRQ won't fire, checked the wiki page, can't find any er
PostPosted: Thu Aug 06, 2020 6:27 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5143
How did you initialize the keyboard controller?


Top
 Profile  
 
 Post subject: Re: IRQ won't fire, checked the wiki page, can't find any er
PostPosted: Thu Aug 06, 2020 8:40 pm 
Offline
Member
Member

Joined: Tue Jul 14, 2020 4:01 am
Posts: 70
How clumsy am I... It appears that I forgot to initialize the keyboard controller.

UPDATE: After setting the configure byte of the keyboard controller, NO, it still didn't work. Here's the code for setting the configure byte:
Code:
initps2:
    mov al,0x60
    out 0x64,al
    mov al,0b01000111 ;enable clocks on all ps2 ports and enable all interrupts
    out 0x60,al
    mov al,0xae
    out 0x64,al



UPDATE 2: The code suddenly works, but only when it wanted to. It might be because of I initialized the PIC way too quickly.

UPDATE 3: FINALLY, I FOUND THE REASON WHY IT DOESN'T WORK. Somehow, the damn keyboard buffer have something in it, and it caused the keyboard to not sent interrupts. FINALLY SETTLED THIS FRUSTRATING PROBLEM.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 118 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group