OSDev.org
https://forum.osdev.org/

Keyboard
https://forum.osdev.org/viewtopic.php?f=1&t=9746
Page 1 of 4

Author:  Stephen [ Thu Jul 29, 2004 4:43 am ]
Post subject:  Keyboard

Hi!
Can anyone tell me how to make the keyboard work in an OS, using C and compiling it with DJGPP?? I am using Proteced mode, with A20 Enabled.

Thanx, :) ;D 8)

Author:  Legend [ Thu Jul 29, 2004 5:44 am ]
Post subject:  Re:Keyboard

First thing: Get your interrupt handling working (set up PIC and IDT) ...

Author:  Adek336 [ Thu Jul 29, 2004 6:01 am ]
Post subject:  Re:Keyboard

Stephen, Legend: Feel free to register ;)

http://osdever.net/documents.php?cat=8&sort=1 is your friend. So much docs you won't probably need in your whole life :) If you want a serious keyboard driver, you'll need interrupt support. http://osdever.net/tutorials.php?cat=5&sort=1

However you can toy with a non-interrupt driver for a while by reading from port 0x60.

Cheers

Author:  Whatever5k [ Thu Jul 29, 2004 6:35 am ]
Post subject:  Re:Keyboard

Adek336 wrote:
However you can toy with a non-interrupt driver for a while by reading from port 0x60.

Argh, ugly ;)
Being you, I would directly implement interrupt service routines. Do not go the long way.

Author:  srg_13 [ Thu Jul 29, 2004 7:22 pm ]
Post subject:  Re:Keyboard

I have tried those webpages, but I still can't understand any of it....

Author:  Adek336 [ Fri Jul 30, 2004 7:39 am ]
Post subject:  Re:Keyboard

What did you start to code from, how much did you implement it and where are you stuck?

Author:  srg_13 [ Fri Jul 30, 2004 11:59 pm ]
Post subject:  Re:Keyboard

Adek336 wrote:
What did you start to code from, how much did you implement it and where are you stuck?

I started my OS from tutorials, and I implemented most of it. I only have a little knoledge of coding in C, but not bios stuff. All the code I have found on the internet is either for dos programming or in assembly.

Author:  Brendan [ Sat Jul 31, 2004 12:47 am ]
Post subject:  Re:Keyboard

Hi,

Stephen wrote:
Adek336 wrote:
What did you start to code from, how much did you implement it and where are you stuck?

I started my OS from tutorials, and I implemented most of it. I only have a little knoledge of coding in C, but not bios stuff. All the code I have found on the internet is either for dos programming or in assembly.


I think what Adek336 is asking is:
- does your OS use 16 bit real mode or is the BIOS useless
- does your OS have support for interrupts, IRQs and IO ports yet
- how much of the keyboard code have you already done
- where exactly in the keyboard code are you stuck

Cheers,

Brendan

Author:  srg_13 [ Mon Aug 02, 2004 12:50 am ]
Post subject:  Re:Keyboard

Hello!
I am using 32 bit Protected Mode, I dont have support for ICQs or for interrupts (I tried enabling them with the codes on the websites (http://osdever.net/tutorials.php?cat=5&sort=1) but i got heaps of errors when I tried to link the compiled C and ASM Files) and I dont have any keyboard code.

Author:  Pype.Clicker [ Mon Aug 02, 2004 3:30 am ]
Post subject:  Re:Keyboard

You'll have to enable interrupts sooner or later... what kind of "compile error" do you encounter ? could that come from the fact you're trying to compile something that was MS-targetted (e.g. pre-pending underscores) on a non-MS platform ?

what tools do you use for compiling ?

Author:  srg_13 [ Mon Aug 02, 2004 5:44 am ]
Post subject:  Re:Keyboard

I use DJGPP to compile the C part of my OS, NASM to compile the ASM part, and ld to link the two files. When I try to link the two files, I get this error.

kernel_c.o(.text+0x12):kernel_c.c: undefined reference to `_outb'
kernel_c.o(.text+0x20):kernel_c.c: undefined reference to `_outb'
kernel_c.o(.text+0x2a):kernel_c.c: undefined reference to `_outb'
kernel_c.o(.text+0x37):kernel_c.c: undefined reference to `_outb'
kernel_c.o(.text+0x42):kernel_c.c: undefined reference to `_outb'
kernel_c.o(.text+0x50):kernel_c.c: more undefined references to `_outb' follow

These errors are all from the code to remap the PICS as follows:

#define PIC1 0x20
#define PIC2 0xA0

#define ICW1 0x11
#define ICW4 0x01

void init_pics(int pic1, int pic2)
{
   /* send ICW1 */
   outb(PIC1, ICW1);
   outb(PIC2, ICW1);

   /* send ICW2 */
   outb(PIC1 + 1, pic1);   
   outb(PIC2 + 1, pic2);   

   /* send ICW3 */
   outb(PIC1 + 1, 4);   
   outb(PIC2 + 1, 2);

   /* send ICW4 */
   outb(PIC1 + 1, ICW4);
   outb(PIC2 + 1, ICW4);

   /* disable all IRQs */
   outb(PIC1 + 1, 0xFF);
}

Author:  srg_13 [ Mon Aug 02, 2004 5:48 am ]
Post subject:  Re:Keyboard

Quote:
These errors are all from the code to remap the PICS as follows:

All this code is in my C kernel.

The code that calls the function:

init_pics(0x20, 0x28);

is in the main function

Author:  DennisCGc [ Mon Aug 02, 2004 6:16 am ]
Post subject:  Re:Keyboard

Seems like you didn't implement the outb function ::)

Author:  Pype.Clicker [ Mon Aug 02, 2004 7:02 am ]
Post subject:  Re:Keyboard

Where do i get inb, outb etc ?

Seems like the FAQ is there for you once again :P

Author:  srg_13 [ Tue Aug 03, 2004 2:39 am ]
Post subject:  Re:Keyboard

Ok, I fixed that one up and now the interupts are set up, but I have no keyboard code. How yould you write this?? :)

Page 1 of 4 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/