Keyboard in Protected Mode

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.
Post Reply
kernel

Keyboard in Protected Mode

Post by kernel »

I'm moving from real mode ;D to protected mode, but My procedure I used in rmode for detecting keypresses won't work in pmode because it uses interrupts! How do I get keyboard input in protected mode? (i sure hope it doesn't involve v86 mode or programming the PIC ;) )

[glow=red,2,300]Thanx[/glow]
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Keyboard in Protected Mode

Post by Pype.Clicker »

well, the most basic technique you can do is polling the 0x60 port for new datas:

char waitkey()
{ char k;
while ((k=inb(0x60))<128);
while (inb(0x60)>128);
}

Otherwise, you'll have to remap the interrupt vectors of 8259a to avoid collision with pmode exception and then ... you're back in terra cognita ;)

sample code for 8259a re-programming can be found in my SOS system here
xSlendiX
Posts: 20
Joined: Tue Jan 08, 2019 7:20 am

Re: Re:Keyboard in Protected Mode

Post by xSlendiX »

Pype.Clicker wrote:well, the most basic technique you can do is polling the 0x60 port for new datas:

char waitkey()
{ char k;
while ((k=inb(0x60))<128);
while (inb(0x60)>128);
}

Otherwise, you'll have to remap the interrupt vectors of 8259a to avoid collision with pmode exception and then ... you're back in terra cognita ;)

sample code for 8259a re-programming can be found in my SOS system here
What's the inb function doing?
Hello world!
User avatar
zity
Member
Member
Posts: 99
Joined: Mon Jul 13, 2009 5:52 am
Location: Denmark

Re: Keyboard in Protected Mode

Post by zity »

Reviving a 17 year old post? :shock:

The inb function reads a byte from an I/O port. It is an assembly instruction, have look in the wiki to see how it can be used from C: https://wiki.osdev.org/Inline_Assembly/ ... 2FO_access
User avatar
thomtl
Member
Member
Posts: 66
Joined: Mon Sep 03, 2018 2:25 am

Re: Keyboard in Protected Mode

Post by thomtl »

Please don't bump old posts, especially posts from almost 17 years ago. I'll assume you haven't been on a lot of forums, so please read the forum rules so this won't happen again

viewtopic.php?f=1&t=16944

-thomtl
User avatar
MichaelFarthing
Member
Member
Posts: 167
Joined: Thu Mar 10, 2016 7:35 am
Location: Lancaster, England, Disunited Kingdom

Re: Keyboard in Protected Mode

Post by MichaelFarthing »

Well let's consider one of those rules:
The Official Forum Rules

1: Please try not to ask answered questions.
Many questions have been asked, and many have been answered. Before you post it's a very good idea to search the forum, the wiki, and even the entire web.
Strikes me that is exactly what has been done here. The answer sought for and found didn't quite answer everything and clarification was sought.
That proper behaviour has been rewarded with two put downs.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Keyboard in Protected Mode

Post by iansjack »

You're ignoring the fact that the simplest of searches (Google "inb function") will give a wealth of results showing exactly what the function does.

I agree with the "put downs" - bumping a seventeen-year old thread is not good practice. If necessary start a new thread.
Post Reply