OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:24 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: [SOLVED] Updating Keyboard LEDS & Reserved Exceptions
PostPosted: Tue Jun 27, 2017 8:28 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 31, 2016 1:43 am
Posts: 48
Location: China
I'm updating keyboard leds while there's a Coprocessor Segment Overrun on VMware (and nothing on Bochs)...??? WTF???

My code:
Code:
   // 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.

_________________
Doing steadfastly, or doing nil.


Last edited by Js2xxx on Tue Jun 27, 2017 7:08 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Updating Keyboard LEDS & Reserved Exceptions
PostPosted: Tue Jun 27, 2017 2:56 pm 
Offline
Member
Member

Joined: Thu Aug 13, 2015 4:57 pm
Posts: 384
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...


Top
 Profile  
 
 Post subject: Re: Updating Keyboard LEDS & Reserved Exceptions
PostPosted: Tue Jun 27, 2017 6:28 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 17, 2016 4:55 am
Posts: 251
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


Top
 Profile  
 
 Post subject: Re: Updating Keyboard LEDS & Reserved Exceptions
PostPosted: Tue Jun 27, 2017 6:29 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 31, 2016 1:43 am
Posts: 48
Location: China
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.


Top
 Profile  
 
 Post subject: Re: Updating Keyboard LEDS & Reserved Exceptions
PostPosted: Tue Jun 27, 2017 6:39 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 31, 2016 1:43 am
Posts: 48
Location: China
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.


Top
 Profile  
 
 Post subject: Re: Updating Keyboard LEDS & Reserved Exceptions
PostPosted: Tue Jun 27, 2017 6:45 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 17, 2016 4:55 am
Posts: 251
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


Top
 Profile  
 
 Post subject: Re: Updating Keyboard LEDS & Reserved Exceptions
PostPosted: Tue Jun 27, 2017 6:55 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 31, 2016 1:43 am
Posts: 48
Location: China
Thanks a lot. It makes sense. :D

_________________
Doing steadfastly, or doing nil.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], SemrushBot [Bot] and 69 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