Problem with interrupts after setup keyboard

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
guest

Problem with interrupts after setup keyboard

Post by guest »

My AMD Duron (1 GHz) restarts when I enable interrupts after I had setup the keyboard

Code: Select all

enable_irq(1, keyboardInt, INT_GATE|BITS_32|PRESENT|RING_2);
   
SendData(0xFF);      //Restart keyboard
SendData(0xF4);      //Enables keyboard and Scanning
SetRate(KDefault);     //Sets default scanning rate]

// if I enable interrups yet the cpu restart
// else it goes on
the funny thing is that it all works in my AMD K6 (586, 133MHz)
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:Problem with interrupts after setup keyboard

Post by Pype.Clicker »

this is likely to be a problem with delays ...
petrusss

Re:Problem with interrupts after setup keyboard

Post by petrusss »

What do the SendData and SetRate functions look like?
guest

Re:Problem with interrupts after setup keyboard

Post by guest »

The SendData function:

Code: Select all

void SendData(unsigned char data) //Sends a command or data to keyboard
{
   WaitForReady();      //MicroDelay((unsigned long) 10);
   outportb(0x60, data);
}
The SetRate function:

Code: Select all

void SetRate(unsigned char rate)   //Sets the typing rate and delay
{
   SendData(0xF3);
   SendData(rate);
}
the WaitForReady function:

Code: Select all

void WaitForReady(void)   //determines if the keyboard is ready to accept a command
{
    volatile long i = MAX_TRYES_FOR_READY;
    while(i-- && (inportb(0x64) & 0x02));
}
the inportb and outportb function:

Code: Select all

inline static unsigned char inportb(int port)
{
   register unsigned char r;
   
      asm volatile
   ( 
      "inb %%dx, %%al\n\t" 
      : "=a" (r) 
      : "d" (port)
   );

      return (r);
}

inline static void outportb(int port, unsigned char data)
{
   asm volatile
   (
      "outb %%al, %%dx\n\t" 
      :
      : "a" (data), "d" (port)
   );
}
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Problem with interrupts after setup keyboard

Post by Candy »

guest wrote: The SendData function:

Code: Select all

void SendData(unsigned char data) //Sends a command or data to keyboard
{
   WaitForReady();      //MicroDelay((unsigned long) 10);
   outportb(0x60, data);
}
the WaitForReady function:

Code: Select all

void WaitForReady(void)   //determines if the keyboard is ready to accept a command
{
    volatile long i = MAX_TRYES_FOR_READY;
    while(i-- && (inportb(0x64) & 0x02));
}
MAX_TRYES_FOR_READY is probably a compile-time constant, and if it's large enough for a 1mhz computer bochs emulates, it might be a little low for the 1000mhz computer your real one is.

You might even have some constants swapped around, I have no experience with the keyboard programming.
Post Reply