pls help.
Code: Select all
#define _KbdCommand 0x64
#define _KbdRW 0x60
#define _KbdLed_cmd 0xED
#define _KbdSc_code_cmd 0xF0
#define _KbdAck 0xFA
#define _KbdResend 0xFE
#define _CapsL_val 4
#define _NumL_val 2
#define _ScrlL_val 1
void init_keyboard()
{
led_status=0;
kbd_on=true;
outbyte(' ');
kbdstatus_init();
set_irq_handler(1,irq1_keyb);
kbd_scancode_set(scancode_set);
kbd_write(0xf0,_KbdRW);
outb(0,_KbdRW);
outbyte(kbd_read(_KbdRW));
}
Code: Select all
void kbd_io_wait()
{
uint8 a;
do
{
a=inb(_KbdCommand);
}while(a&2);
}
char kbd_write(uint8 bytes, uint16 port)
{
kbd_io_wait();
outb(port,bytes);
if(inb(port)==_KbdAck)
return 1;
else if(inb(port)==_KbdResend) //{// try maximum 3 more times
return kbd_cmd_resend(port,port,bytes);
return 0;
}
uint8 kbd_read(uint16 port)
{
while(!(inb(_KbdCommand)&1)) ;//wait till output buffer is full
return inb(port);
}
char kbd_cmd_resend(uint16 inport,uint16 outport,uint8 data)
{
kbd_io_wait();
outb(outport,data);// make maximum of 3 tries
if(inb(inport)==_KbdAck)
return 1;
else if(inb(inport)==_KbdResend)
{
kbd_io_wait();
outb(outport,data);
}
if(inb(inport)==_KbdAck)
return 1;
else if(inb(inport)==_KbdResend)
{
kbd_io_wait();
outb(outport,data);
}
if(inb(inport)==_KbdAck)
return 1;
return 0;
}