Page 1 of 1
Keyb problems
Posted: Fri Jan 03, 2003 12:28 pm
by eL JeDi
Hi once again,
I am here trying to make the keyb works...
I Have an IDT that works ( only de faults ).. but my keyb ISR don't works I don't know why.
Here is my asm ISR:
[EXTERN keybo]
[GLOBAL irq1]
irq1:
pusha
call keybo
mov al, 0x20
out 0x20, al
popa
IRET
( i've tried a version with cli and sti too )
and the keybo function:
void keybo()
{
int kk;
kk = inportb( kbdport );
putch('o');
}
I've remaped the PIC whit this function:
void remap_pics(int pic1, int pic2)
{
byte a1, a2;
a1=inportb(PIC1_DATA);
a2=inportb(PIC2_DATA);
outportb(PIC1_COMMAND, ICW1_INIT+ICW1_ICW4);
outportb(PIC2_COMMAND, ICW1_INIT+ICW1_ICW4);
outportb(PIC1_DATA, pic1);
outportb(PIC2_DATA, pic2);
outportb(PIC1_DATA, 4);
outportb(PIC2_DATA, 2);
outportb(PIC1_DATA, ICW4_8086);
outportb(PIC2_DATA, ICW4_8086);
outportb(PIC1_DATA, a1);
outportb(PIC2_DATA, a2);
};
I call this function as remap_pics(0x20,0x28);
In the main kernel function I set all of this and enter in a while (i=0). i always is 0. But I think when I press a Key i should interrupt all and go to the IRQ1 isr, but it don't.
I also tried to remove call keybo in the ISR and use a mov [0xb8000],'D'
I don't know why it doesn't works. Can any one help me?
Thanks for all.
Re:Keyb problems
Posted: Fri Jan 03, 2003 12:33 pm
by Whatever5k
Is the Keyboard IRQ enabled?
Re:Keyb problems
Posted: Fri Jan 03, 2003 12:41 pm
by eL JeDi
i thinks it is. ???
but I don't know if it's right or not this function:
void EnableIRQ(unsigned char IRQ_No)
{
unsigned char Tmp = 0x01;
if (IRQ_No <
{
Tmp = Tmp << (IRQ_No);
IRQ_Master_Status |= Tmp;
outportb(0x21,(unsigned char)~IRQ_Master_Status);
}
else
{
IRQ_No -= 8;
Tmp = Tmp << (IRQ_No);
IRQ_Slave_Status |= Tmp;
outportb(0xA1,(unsigned char)~IRQ_Slave_Status);
IRQ_Master_Status |= 0x04;
outportb(0x21,(unsigned char)~IRQ_Master_Status);
}
}
Re:Keyb problems
Posted: Fri Jan 03, 2003 4:36 pm
by drizzt
have you performed the 'sti'? (not into the isr handler, but after you have initialized all)
Re:Keyb problems
Posted: Fri Jan 03, 2003 7:58 pm
by eL JeDi
drizzt wrote:
have you performed the 'sti'? (not into the isr handler, but after you have initialized all)
Yes, i have after all initializing function an asm("sti"). if not the other interrupt doens't work, does it is? ( I think )
Re:Keyb problems
Posted: Fri Jan 03, 2003 8:29 pm
by Tim
Maybe there are scan codes stuck in the keyboard's internal buffer. Try the following at startup to clear it:
Re:Keyb problems
Posted: Sat Jan 04, 2003 1:34 pm
by eL JeDi
Tim Robinson wrote:
Maybe there are scan codes stuck in the keyboard's internal buffer. Try the following at startup to clear it:
Hi tim,
I've proved this, and it doesn't works.
I've changed the number of the IRQ when i'm setting the entrys of the IDT, and set it Keyb ISR in the IRQ0 ( the timer ) and the ISR works correctly. But if I put this in the IRQ1, doesn't works.
Any function en the IRQ0 works. Why the IRQ0 works and the IRQ1 not?
In one of the funciotns tried, it gives me a Generla protection failure, I think it's for my stack that is soo small. what it would be a good lenght for the stack?
Thanks once agian for all.
Re:Keyb problems
Posted: Sun Jan 05, 2003 8:28 am
by jrfritz
I've tested your enable and disable irq code.
Won't work.
Don't even call those functions in your kernel because it'll mess stuff up. I've made a fix...making nulllowirq functions and nullhighirq functions like this:
global nulllowirq
nulllowirq:
pusha
mov al, 0x20
out 0x20, al
popa
iret
global nullhighirq
nullhighirq:
pusha
; from DF's code
mov al,0x20
out 0xA0, al
out 0x20, al
popa
iret
and your IDT must have irqs 2-7 using nulllowirq and 8-15 using nullhighirq.
Then it'll work.
Re:Keyb problems
Posted: Sun Jan 05, 2003 9:31 am
by eL JeDi
Hi,
Tom, sorry but i'm afraid i dont understand you well. My enable irq function don't works, ok.
I will set the IRQ2-7 with de nullowirq and the irq 8-15 with nulhiirq. is it?
But what about the enable irq function?, i don't have to use it?
thanks once again
Re:Keyb problems
Posted: Sun Jan 05, 2003 9:47 am
by Pype.Clicker
eL JeDi wrote:
In one of the funciotns tried, it gives me a Generla protection failure, I think it's for my stack that is soo small. what it would be a good lenght for the stack?
You will not get a GPF because of a too small stack ... there is the Stack Fault therefore and unless you defined a task gate to handle it, you're unlikely to handle that fault properly without a 3rd exception ...
However, if you made some soup with your pushes and pops, you may find yourself in the case of having IRET restoring a bad value in CS/DS/...
Re:Keyb problems
Posted: Sun Jan 05, 2003 10:10 am
by eL JeDi
Pype.Clicker wrote:
However, if you made some soup with your pushes and pops, you may find yourself in the case of having IRET restoring a bad value in CS/DS/...
I think it could be possible i have a good soap. I tried so many codes in the kernel and have many trash code.
Pype.Clicker wrote:
You will not get a GPF because of a too small stack
That was i've readed, don't remember where. Or maybe i was sleeping o have a nightmare with the IDT. ;D
But if you said this, i'll believe it.
And the good news.
It works!!!!!!! ;D
My IDT is fully working, well fully, ejem, with dummys but it works. Now i will debug the code and delete thas code.
Thanks all of you for all.
The force will be is you.