keyboard problem(interrupts are working, keyboard is not)
Re: keyboard problem(interrupts are working, keyboard is not
I think that it must be something in my C code, because i have tried calling my kmain from various different assembly files and booting in both qemu and virtualbox, also removing or adding sti or cli to my assembly loader and it is always the same.
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: keyboard problem(interrupts are working, keyboard is not
If an interrupt causes a GPF, there's probably something wrong with your IDT. Have you checked whether your IDT entries are correct?
Re: keyboard problem(interrupts are working, keyboard is not
If there is anything wrong with it, I sure don't see it...My interrupt and IDt structs look like this
first, I turn off interrupts, then I re-map the pic( you have already seen that functions), then i mask IRQs, then i load make all of my descriptors with the addint function, then I load my IDT with this:
then I unmask IRQs and turn on interrupts and thine erything should be fine, but the cli in my loader is run so I think that it stops the interrupts from the keyboard, or when I remove some strange error in my IDT gets a gpf. Thanks for your help, should i use lidt in my asm loader after i call the kernel and then turn interrupts on, do you think? maybe that would change something, but i don't know much of the effects of inline assembly...
Code: Select all
/* structure for an interrupt */
typedef struct
{
word low_offset; // low nibble of offset to handler of interrupt
word selector; // GDT selector used
word settings; // settings for int
word high_offset; // high nibble to handler code
} __attribute__ ((packed)) x86_interrupt;
/* structure for the IDTR */
typedef struct
{
word limit; // limit or Size of IDT
x86_interrupt *base; // a pointer to the base of the IDT
} __attribute__ ((packed)) idtr;
Code: Select all
idtr IDTR;
x86_interrupt IDT
void loadIDTR()
{
IDTR.limit = 256*(sizeof(x86_interrupt)-1);
IDTR.base = IDT;
idtr *IDTRptr = &IDTR;
/* load IDTR with lidt */
asm volatile("LIDT (%0) ": :"p" (IDTRptr));
}
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: keyboard problem(interrupts are working, keyboard is not
Code: Select all
x86_interrupt IDT
Code: Select all
x86_interrupt IDT[256];
Code: Select all
IDTR.limit = 256*(sizeof(x86_interrupt)-1);
Code: Select all
IDTR.limit = 256*sizeof(x86_interrupt);
I am not 100% sure about the LGDT instruction in inline assembly (it is rarely used, and I load the IDT in a separate asm file).
Re: keyboard problem(interrupts are working, keyboard is not
I fixed it. It works now, but its not really the same IDT...I completely re-did my kernel (it wasn't very far along anyway) using Bran's kernel development tutorial on osdever.net as a reference and the keyboard works now. Thanks alot for all of your help! I will change those lines anyway and see if it works but it is fine now with my new kernel. Now on to the next part of operating system development... thanks again
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: keyboard problem(interrupts are working, keyboard is not
I remember that we had this discussion a while ago. It seems that the Intel and AMD manuals are a bit insonsistent whether limit = size or limit = size - 1. But you're probably right, I just checked the output of sidt on my Core i7 and I get limit = 4095.berkus wrote:, since limit is one less than the size.