OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 3:36 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 58 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Keyboard
PostPosted: Thu Jul 29, 2004 4:43 am 
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)


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Thu Jul 29, 2004 5:44 am 
First thing: Get your interrupt handling working (set up PIC and IDT) ...


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Thu Jul 29, 2004 6:01 am 
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


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Thu Jul 29, 2004 6:35 am 
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.


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Thu Jul 29, 2004 7:22 pm 
I have tried those webpages, but I still can't understand any of it....


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Fri Jul 30, 2004 7:39 am 
What did you start to code from, how much did you implement it and where are you stuck?


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Fri Jul 30, 2004 11:59 pm 
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.


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Sat Jul 31, 2004 12:47 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his 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

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Mon Aug 02, 2004 12:50 am 
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.


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Mon Aug 02, 2004 3:30 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
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 ?

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Mon Aug 02, 2004 5:44 am 
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);
}


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Mon Aug 02, 2004 5:48 am 
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


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Mon Aug 02, 2004 6:16 am 
Seems like you didn't implement the outb function ::)


Top
  
 
 Post subject: Re:Keyboard
PostPosted: Mon Aug 02, 2004 7:02 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
Where do i get inb, outb etc ?

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

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Keyboard
PostPosted: Tue Aug 03, 2004 2:39 am 
Ok, I fixed that one up and now the interupts are set up, but I have no keyboard code. How yould you write this?? :)


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 58 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], SemrushBot [Bot] and 20 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group