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.
Js2xxx
Member
Posts: 48 Joined: Sat Dec 31, 2016 1:43 am
Libera.chat IRC: wrgq
Location: China
Post
by Js2xxx » Tue Jun 27, 2017 8:28 am
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.
Last edited by
Js2xxx on Tue Jun 27, 2017 7:08 pm, edited 1 time in total.
Doing steadfastly, or doing nil.
LtG
Member
Posts: 384 Joined: Thu Aug 13, 2015 4:57 pm
Post
by LtG » Tue Jun 27, 2017 2:56 pm
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...
Sik
Member
Posts: 251 Joined: Wed Aug 17, 2016 4:55 am
Post
by Sik » Tue Jun 27, 2017 6:28 pm
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
Js2xxx
Member
Posts: 48 Joined: Sat Dec 31, 2016 1:43 am
Libera.chat IRC: wrgq
Location: China
Post
by Js2xxx » Tue Jun 27, 2017 6:29 pm
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?
Doing steadfastly, or doing nil.
Js2xxx
Member
Posts: 48 Joined: Sat Dec 31, 2016 1:43 am
Libera.chat IRC: wrgq
Location: China
Post
by Js2xxx » Tue Jun 27, 2017 6:39 pm
Sik wrote: In other words: reprogram the PIC.
I'm programming I/O APIC. So should I initialize 8259 and disable all the irqs?
Doing steadfastly, or doing nil.
Sik
Member
Posts: 251 Joined: Wed Aug 17, 2016 4:55 am
Post
by Sik » Tue Jun 27, 2017 6:45 pm
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
Js2xxx
Member
Posts: 48 Joined: Sat Dec 31, 2016 1:43 am
Libera.chat IRC: wrgq
Location: China
Post
by Js2xxx » Tue Jun 27, 2017 6:55 pm
Thanks a lot. It makes sense.
Doing steadfastly, or doing nil.