OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 2:34 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: x86 - I can't trigger my interrupts?
PostPosted: Thu Apr 23, 2015 5:42 am 
Offline
Member
Member
User avatar

Joined: Thu Apr 16, 2015 7:37 am
Posts: 64
Hi, I'm currently trying to get input for my kernel up and running, but I'm having problems getting the keyboard to send interrupts to the CPU. I'm 99% sure I've set up the interrupts correctly, because if I do an "INT $0x21" it runs my interrupt service routine(which is just a simple printf("Key pressed\n") and an end of interrupt signal.)

Currently I'm on a Win8.1 Host using cygwin and a cross compiler, and emulating in bochs. I'm loading the kernel through GRUB (Grub 2 I think?).

I think I've followed all the steps required to get interrupts up and running, which is:
    - Make and load my own GDT (Just a flat 4GiB code and flat 4GiB data entry)
    - Make and load my own IDT, with an entry at 0x21 for my routine (I haven't written handlers to service any of the other interrupts)
    - Re-mapped the interrupts on the PICS with an offset of 0x20 and 0x28, so the hardware IRQs range from 0x20 to 0x2f
    - Cleared the mask for line 1 on the master PIC
    - And finally, to test the interrupt, I do asm("INT $0x21") and my routine runs (it outputs "Key pressed\n")
    - Then I put the kernel in an infinite loop, which I'm hoping to handle keyboard interrupts from, just to test them out.

I'm at a loss for any steps that I've missed, but one of my theories is that the keyboard isn't configured to send interrupts (maybe this is off by default, or GRUB disables it, and never re-enables it?) I'm hoping somebody can give me some suggestions to test this theory, or at least help me find a wiki page or forum post (I've already looked at the PS/2 Keyboard page, but I'm a bit confused as to how that even works, and whether I'm even using a PS/2 Keyboard.) I can provide my code if people need it, but I'm hoping I've just missed some minor detail, such as sending a command to the keyboard to begin sending interrupts.

I also have a slight hunch that maybe a virtual machine isn't the best thing to test this on, seeing as when I ran it on real hardware, I had to use a USB keyboard, my PS/2 one didn't do anything, even in the GRUB menu. I'm going to do some tests by writing an ISR for the Timer, which apparently fires 18 times every second? So hopefully, if that works, I'll make an edit which talks about the results, and I'll know it's an issue with the keyboard. In the meantime, if you think you have a solution or any other tests I could try, let me know. (Try to keep in mind I'm a bit new to this, so you may need to explain something to me if I'm not sure what you're talking about.)

In summary, I think I set up interrupts correctly, but the keyboard won't fire an IRQ? Any ideas?

Thanks for the nice forum,
Mikumiku747


Top
 Profile  
 
 Post subject: Re: x86 - I can't trigger my interrupts?
PostPosted: Thu Apr 23, 2015 5:53 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
Have you included a "STI" instruction to enable hardware interrupts?


Top
 Profile  
 
 Post subject: Re: x86 - I can't trigger my interrupts?
PostPosted: Thu Apr 23, 2015 6:39 am 
Offline
Member
Member
User avatar

Joined: Thu Apr 16, 2015 7:37 am
Posts: 64
iansjack wrote:
Have you included a "STI" instruction to enable hardware interrupts?


I can't believe I didn't think of something so simple. #-o Thanks for the suggestion. I added an STI, and now I'm getting a triple fault, but at least I know that hardware interrupts are now working. I'm pretty sure it's because I never added any other interrupt handlers, so any other interrupt is causing an exception due to there being no entry for it, which causes another exception, which causes a triple fault. In any case big thanks for the help, I had a hunch it was a minor mistake, thanks for helping out.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [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