Page 2 of 3
Re:Keyboard IRQ
Posted: Thu Oct 31, 2002 4:14 am
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
Re:Keyboard IRQ
Posted: Thu Oct 31, 2002 6:36 pm
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
Re:Keyboard IRQ
Posted: Thu Oct 31, 2002 7:35 pm
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
Re:Keyboard IRQ
Posted: Thu Oct 31, 2002 7:51 pm
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
Re:Keyboard IRQ
Posted: Thu Oct 31, 2002 8:02 pm
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
Re:Keyboard IRQ
Posted: Thu Oct 31, 2002 8:06 pm
by Tom
could I take of the remaping and try?
Re:Keyboard IRQ
Posted: Thu Oct 31, 2002 8:09 pm
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
Re:Keyboard IRQ
Posted: Thu Oct 31, 2002 8:11 pm
by Tom
do that before or after lidt?
Re:Keyboard IRQ
Posted: Thu Oct 31, 2002 8:13 pm
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
Re:Keyboard IRQ
Posted: Thu Oct 31, 2002 8:21 pm
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?!
Re:Keyboard IRQ
Posted: Fri Nov 01, 2002 10:01 am
by Tom
how come I can't use in and out with the interrupts enabled?
Re:Keyboard IRQ
Posted: Fri Nov 01, 2002 11:28 am
by Whatever5k
No, can't imagine that this is the problem...
Must be something else...
Re:Keyboard IRQ
Posted: Fri Nov 01, 2002 4:03 pm
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)
Re:Keyboard IRQ
Posted: Sat Nov 02, 2002 12:21 pm
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...
Re:Keyboard IRQ
Posted: Sat Nov 02, 2002 8:07 pm
by Tom
what port could I use to see if it's working?...