Keyb problems
Keyb problems
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.
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
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);
}
}
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
have you performed the 'sti'? (not into the isr handler, but after you have initialized all)
Re:Keyb problems
Yes, i have after all initializing function an asm("sti"). if not the other interrupt doens't work, does it is? ( I think )drizzt wrote: have you performed the 'sti'? (not into the isr handler, but after you have initialized all)
Re:Keyb problems
Maybe there are scan codes stuck in the keyboard's internal buffer. Try the following at startup to clear it:
Code: Select all
while (in(0x64) & 1)
in(0x60);
Re:Keyb problems
Hi tim,Tim Robinson wrote: Maybe there are scan codes stuck in the keyboard's internal buffer. Try the following at startup to clear it:Code: Select all
while (in(0x64) & 1) in(0x60);
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
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.
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
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
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
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Keyb problems
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 ...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?
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
That was i've readed, don't remember where. Or maybe i was sleeping o have a nightmare with the IDT. ;DI 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:
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/...
Pype.Clicker wrote: You will not get a GPF because of a too small stack
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.