Page 1 of 1
[SOLVED] Updating Keyboard LEDS & Reserved Exceptions
Posted: Tue Jun 27, 2017 8:28 am
by Js2xxx
I'm updating keyboard leds while there's a
Coprocessor Segment Overrun on VMware (and nothing on Bochs)...??? WTF???
My code:
Code: Select all
// I'm sure these constants are correct.
uint8_t leds = (__capsLock << 2) | (__numLock << 1) | __scrollLock;
asm_OutByte(__8042Port::Data, __KCommand::Leds);
while(asm_InByte(__8042Port::Data) != 0xFA);
asm_OutByte(__8042Port::Data, leds);
Thanks for help.
Re: Updating Keyboard LEDS & Reserved Exceptions
Posted: Tue Jun 27, 2017 2:56 pm
by LtG
I don't understand the question, are you saying that when you get the exception you attempt to change the keyboard LEDs? If so, why?
Also, is there a reason you are using the double underscore (__)? That's reserved for the compiler...
Re: Updating Keyboard LEDS & Reserved Exceptions
Posted: Tue Jun 27, 2017 6:28 pm
by Sik
This was more confusing than I expected:
https://stackoverflow.com/questions/156 ... -exception
Before enabling interrupts in protected mode you need to make sure to tell the PIC to generate a different set of IRQs since the default ones overlap with some of the CPU exceptions. That Coprocessor Segment Overrun exception you're getting is actually an interrupt caused by the keyboard.
In other words: reprogram the PIC. The information is in the wiki, conveniently
http://wiki.osdev.org/PIC#Protected_Mode
Re: Updating Keyboard LEDS & Reserved Exceptions
Posted: Tue Jun 27, 2017 6:29 pm
by Js2xxx
So do you mean that double dashes causes multiple meanings so the compiler generates wrong code? (if so, it's amazing!! And I'll use single.)
And now I think it have a relationship with IOPL. That code runs on CPL =3 and IOPL =0 so it can't use port operations directly. Am I right?
Re: Updating Keyboard LEDS & Reserved Exceptions
Posted: Tue Jun 27, 2017 6:39 pm
by Js2xxx
Sik wrote:In other words: reprogram the PIC.
I'm programming I/O APIC. So should I initialize 8259 and disable all the irqs?
Re: Updating Keyboard LEDS & Reserved Exceptions
Posted: Tue Jun 27, 2017 6:45 pm
by Sik
Well, it does seem like the PIC is the one sending the interrupts, so yeah you may want to disable the PIC and let the APIC take over. Again,
check the wiki =P
Re: Updating Keyboard LEDS & Reserved Exceptions
Posted: Tue Jun 27, 2017 6:55 pm
by Js2xxx
Thanks a lot. It makes sense.