Keyboard IRQ

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.
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 IRQ

Post by Pype.Clicker »

elias wrote: wow. ive onyl written a boto loader and a test kjernerl, but havnt goten to test it yet cuz i dont have a working floppy drive.
here's my low-level irq/exception handlers
http://cvs.sourceforge.net/cgi-bin/view ... ontrol.asm
http://cvs.sourceforge.net/cgi-bin/view ... terrpt.inc

you will probably need some files out of http://cvs.sourceforge.net/cgi-bin/view ... /head/asm/

to make it work

the processIrqList() function does some frightening stuffs with linked list of handlers to know which function should be called according to priorities and whether the current code can handle the current event or not (so that several modules can play with the same hardware event ;)

you can also see this thread

the high-level keyboard handler for Clicker has been quickly described in this other thread
Tom

Re:Keyboard IRQ

Post by Tom »

why doesn't this code work?

IRQ_1:      ;Keyboard
   ;*****************************************************
   ;* A sample of how to handle an interrupt from IRQ 1 *
   ;*****************************************************
   PUSHA
   IN AL, 0x60
mov [keyhold], al
   CALL Keyboard_Handler
   MOV AL, 0x20
   OUT 0x20, AL
   POPA

   IRET

Keyboard_Handler:
   ;*******************************************************************
;                *
   ;*******************************************************************
   push si
   mov si, [keyhold]
   call putch
   pop si
   RET
keyhold dw 0
Curufir

Re:Keyboard IRQ

Post by Curufir »

Well what goes wrong with it? What errors do you get? Does it call the routine at all? Have you unmasked IRQ1 on the PIC? Are you aware that AL is a keyboard scancode not an ASCII code, and that you get two values for each keypress (up/down)? What's putch doing? Do you have a stack set? Are you aware that AL is a byte not a word (Won't make any difference, but it would make your code clearer)?

Without a little more information there's not a huge amount anyone can do to help fix it. BTW, the code you produced there looks ok to me, so it sounds like something else.

Curufir
Tom

Re:Keyboard IRQ

Post by Tom »

well, even If I call a C function that gets the val of keyhold and converts it to ASCII, It does't print anything. I do know it is called because when I print "1" it prints 1 forever
Curufir

Re:Keyboard IRQ

Post by Curufir »

It prints 1 forever? You sure you haven't mapped the PICs up 1 too far and this IRQ_1 code is actually being called by the timer.

Curufir
Tom

Re:Keyboard IRQ

Post by Tom »

could I take of the remaping and try?
Curufir

Re:Keyboard IRQ

Post by Curufir »

Use this, it will remap the pics to interrupt on 0x20->0x2F, and mask off everything but IRQ 0 and IRQ 1. You can turn your interrupts back on then and see what happens.

Code: Select all

      MOV AL, 0x11
      OUT 0x20, AL
      OUT 0xA0, AL

      MOV AL, 0x20
      OUT 0x21, AL
      ADD AL, 0x08
      OUT 0xA1, AL

      MOV AL, 0x04
      OUT 0x21, AL
      MOV AL, 0x02
      OUT 0xA1, AL

      MOV AL, 0x01
      OUT 0x21, AL
      MOV AL, 0x01
      OUT 0xA1, AL

      MOV AL, 0xFC
      OUT 0x21, AL
      MOV AL, 0xFF
      OUT 0xA1, AL
Curufir
Tom

Re:Keyboard IRQ

Post by Tom »

do that before or after lidt?
Curufir

Re:Keyboard IRQ

Post by Curufir »

Personally I turn off interrupts after enabling the A20 line, remap the pic, load the IDT/GDT, jump to pmode, setup the segments and pmode stack then turn the interrupts back on.

Works for me, and seems a fairly logical order.

Curufir
Tom

Re:Keyboard IRQ

Post by Tom »

I FOUND THE PROB! But don't know how to fix it!


When I call inportb in C Code, it doesn't work, I think this is the prob in the asm code to...but when I disable ints I can use inportb or in ( in asm )

How do I fix this weird thing?!
Tom

Re:Keyboard IRQ

Post by Tom »

how come I can't use in and out with the interrupts enabled?
Whatever5k

Re:Keyboard IRQ

Post by Whatever5k »

No, can't imagine that this is the problem...
Must be something else...
Tom

Re:Keyboard IRQ

Post by Tom »

it Is the problem....I get no value from ports! any type of port!(actually, i've only tried 0x64 and 0x60 also, still no value!)

Culfer, help(or someone)(I don't use my IM)
Whatever5k

Re:Keyboard IRQ

Post by Whatever5k »

i've only tried 0x64 and 0x60 also, still no value!
Well, do you inb() from those ports after having received an IRQ1? If not, you're polling the hardware and if you don't press a key you won't get anything...
Try to inb() from another port and of which you are sure to get something...
Tom

Re:Keyboard IRQ

Post by Tom »

what port could I use to see if it's working?...
Post Reply