Keyb problems

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.
Post Reply
eL JeDi

Keyb problems

Post 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.
Whatever5k

Re:Keyb problems

Post by Whatever5k »

Is the Keyboard IRQ enabled?
eL JeDi

Re:Keyb problems

Post 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 < 8)
   {
      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);
   }
}
drizzt

Re:Keyb problems

Post by drizzt »

have you performed the 'sti'? (not into the isr handler, but after you have initialized all)
eL JeDi

Re:Keyb problems

Post 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 )
Tim

Re:Keyb problems

Post by Tim »

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);
eL JeDi

Re:Keyb problems

Post 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:

Code: Select all

while (in(0x64) & 1)
    in(0x60);
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.
jrfritz

Re:Keyb problems

Post 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.
eL JeDi

Re:Keyb problems

Post 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
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:Keyb problems

Post 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/...
eL JeDi

Re:Keyb problems

Post 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. ;)
Post Reply