Keyboards......

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
vbbrett

Keyboards......

Post by vbbrett »

I have used your info to use Grub.
So, after hours of playing with that (stinking) boot loader, I have loaded my C kernel, but I have only written a few video routines for it. How do I access and decode my keyboard? I have searched this and a few other forums and websites but to no avail. I can't seem to find some C code to do this?
Brett
Tim

Re:Keyboards......

Post by Tim »

1. Set up an IDT.
2. Reconfigure the PICs so that the interrupts they issue don't conflict with the CPU's built-in exception vectors.
3. Install a handler for IRQ 1.
4. In your IRQ 1 handler, read a scan code from port 0x60, then acknowledge the interrupt at the PIC.
5. Translate scan codes to ASCII codes or Unicode characters or whatever you want.

The FAQ on this site or http://www.osdever.net/ should be able to help you with all of these.

PS: what stinks about GRUB?
vbbrett

Re:Keyboards......

Post by vbbrett »

Well, grubs not bad. It's just the time it takes to figure and install it! After you spend your few hours configuring it, It works like a dream.

As to what tutorial on this site where you talking about? I've been to osdever, can't seem to find too much sample code there.

Brett
BI lazy

Re:Keyboards......

Post by BI lazy »

You can look into Minix source code for a pretty good sample of how it can be done.

You know Minix and the Minix Book (Operating Systems Development and Implementation., 2nd edition), do you?

Well, as for grub and needing hours to configure it properly: I canna follow this one. RTFM and do as it tells you to do and there you go. Where's the problem?

as for your Keybard problem: ere you do this, take care that you are able to

1. set up a GDT
2. set up a IDT
3. create and register handlers(actually the asm-stubs) in IDT
4. configure the PIC
5. mask/unmask IRQ lines of the PIC at needs.
6. register/unregister IRQ-Handlers (the implemenation) at needs.

You see, there is quite some work ere you can start with the Keyboard driver itself - it is as Tim haws pointed out already.

Stay safe and Take time to read the texts www.osdever.net offers carefully.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Keyboards......

Post by Solar »

vbbrett wrote: Well, grubs not bad. It's just the time it takes to figure and install it!
*Nothing* compared to writing a bootloader that enables protected mode yourself... 8)
Every good solution is obvious once you've found it.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Keyboards......

Post by Candy »

Solar wrote:
vbbrett wrote: Well, grubs not bad. It's just the time it takes to figure and install it!
*Nothing* compared to writing a bootloader that enables protected mode yourself... 8)
Must say I've figured out writing a boot sequence before being able to use grub. Could just be my incompatibility with gnu-ish software & manuals :)
vbbrett

Re:Keyboards......

Post by vbbrett »

Tim Robinson wrote: 4. In your IRQ 1 handler, read a scan code from port 0x60, then acknowledge the interrupt at the PIC.
How do I acknowledge that I have recieved something?
I read from port 0x60 then I'm not sure what to do next?
Brett
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:Keyboards......

Post by bubach »

Maybe you should download M?bius and/or Clicker and check how they did it?

/ Christoffer
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
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:Keyboards......

Post by Pype.Clicker »

vbbrett wrote:
Tim Robinson wrote: 4. In your IRQ 1 handler, read a scan code from port 0x60, then acknowledge the interrupt at the PIC.
How do I acknowledge that I have recieved something?
I read from port 0x60 then I'm not sure what to do next?
Brett
or simply read an interrupt tutorial (there are some on Bona Fide) and discover outport(0x20,0x20) ;D
Post Reply