Page 1 of 4
Keyboard
Posted: Thu Jul 29, 2004 4:43 am
by Stephen
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
Re:Keyboard
Posted: Thu Jul 29, 2004 5:44 am
by Legend
First thing: Get your interrupt handling working (set up PIC and IDT) ...
Re:Keyboard
Posted: Thu Jul 29, 2004 6:01 am
by Adek336
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
Re:Keyboard
Posted: Thu Jul 29, 2004 6:35 am
by Whatever5k
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.
Re:Keyboard
Posted: Thu Jul 29, 2004 7:22 pm
by srg_13
I have tried those webpages, but I still can't understand any of it....
Re:Keyboard
Posted: Fri Jul 30, 2004 7:39 am
by Adek336
What did you start to code from, how much did you implement it and where are you stuck?
Re:Keyboard
Posted: Fri Jul 30, 2004 11:59 pm
by srg_13
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.
Re:Keyboard
Posted: Sat Jul 31, 2004 12:47 am
by Brendan
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
Re:Keyboard
Posted: Mon Aug 02, 2004 12:50 am
by srg_13
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.
Re:Keyboard
Posted: Mon Aug 02, 2004 3:30 am
by Pype.Clicker
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 ?
Re:Keyboard
Posted: Mon Aug 02, 2004 5:44 am
by srg_13
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);
}
Re:Keyboard
Posted: Mon Aug 02, 2004 5:48 am
by srg_13
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
Re:Keyboard
Posted: Mon Aug 02, 2004 6:16 am
by DennisCGc
Seems like you didn't implement the outb function ::)
Re:Keyboard
Posted: Mon Aug 02, 2004 7:02 am
by Pype.Clicker
Where do i get inb, outb etc ?
Seems like the FAQ is there for you once again
Re:Keyboard
Posted: Tue Aug 03, 2004 2:39 am
by srg_13
Ok, I fixed that one up and now the interupts are set up, but I have no keyboard code. How yould you write this??