/*
* (C) Copyright 2002
* John W. Linville, linville@tuxdriver.com
- *
+ *
* Modified from code for support of MIP405 and PIP405 boards. Previous
* copyright follows.
*
#undef KBG_DEBUG
-//#define KBG_DEBUG
#ifdef KBG_DEBUG
#define PRINTF(fmt,args...) printf (fmt ,##args)
#define KBD_BUFFER_LEN 0x20 /* size of the keyboardbuffer */
-
-
static volatile char kbd_buffer[KBD_BUFFER_LEN];
static volatile int in_pointer = 0;
static volatile int out_pointer = 0;
'2', '3', '0', '.',0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, /* 0x50 - 0x5F */
'\r',0xff,0xff
};
-
+
static unsigned char kbd_shift_xlate[] = {
0xff,0x1b, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+','\b','\t', /* 0x00 - 0x0f */
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}','\r',0xff, 'A', 'S', /* 0x10 - 0x1f */
};
/******************************************************************
- * Init
+ * Init
******************************************************************/
int isa_kbd_init(void)
error=console_assign(stdin,DEVNAME);
if(error==0)
return 1;
- else
+ else
return error;
}
return 1;
}
/******************************************************************
- * Queue handling
+ * Queue handling
******************************************************************/
/* puts character in the queue and sets up the in and out pointer */
void kbd_put_queue(char data)
if(in_pointer==out_pointer)
return(0); /* no data */
else
- return(1);
+ return(1);
}
/* gets the character from the queue */
int kbd_getc(void)
char c;
while(in_pointer==out_pointer);
- if((out_pointer+1)==KBD_BUFFER_LEN)
+ if((out_pointer+1)==KBD_BUFFER_LEN)
out_pointer=0;
else
out_pointer++;
c=kbd_buffer[out_pointer];
return (int)c;
-
+
}
kbd_send_data(KBD_CMD_SET_LEDS);
kbd_send_data(leds);
}
-
+
void handle_keyboard_event(unsigned char scancode)
{
console_changed = 1;
}
return;
- case 0x2A:
+ case 0x2A:
case 0x36: /* shift pressed */
shift=1;
return; /* do nothing else */
- case 0xAA:
+ case 0xAA:
case 0xB6: /* shift released */
shift=0;
return; /* do nothing else */
case 0x3A: /* capslock pressed */
caps_lock=~caps_lock;
kbd_set_leds();
- return;
+ return;
case 0x45: /* numlock pressed */
num_lock=~num_lock;
kbd_set_leds();
- return;
+ return;
case 0xC6: /* scroll lock released */
case 0xC5: /* num lock released */
case 0xBA: /* caps lock released */
- return; /* just swallow */
+ return; /* just swallow */
}
if((scancode&0x80)==0x80) /* key released */
return;
PRINTF("unkown scancode %X\n",scancode);
return; /* swallow unknown codes */
}
-
+
kbd_put_queue(keycode);
PRINTF("%x\n",keycode);
}
}
-
/******************************************************************************
* Lowlevel Part of keyboard section
- */
+ */
unsigned char kbd_read_status(void)
{
return(in8(CFG_ISA_IO_BASE_ADDRESS + KDB_COMMAND_PORT));
-}
-
+}
+
unsigned char kbd_read_input(void)
{
return(in8(CFG_ISA_IO_BASE_ADDRESS + KDB_DATA_PORT));
-}
+}
void kbd_write_command(unsigned char cmd)
{
out8(CFG_ISA_IO_BASE_ADDRESS + KDB_COMMAND_PORT,cmd);
-}
-
+}
+
void kbd_write_output(unsigned char data)
{
out8(CFG_ISA_IO_BASE_ADDRESS + KDB_DATA_PORT, data);
-}
-
+}
+
int kbd_read_data(void)
{
int val;
{
unsigned long timeout;
int val;
-
+
timeout = KBD_TIMEOUT;
val=kbd_read_data();
while(val < 0)
* If the test is successful a x55 is placed in the input buffer.
*/
kbd_write_command_w(KBD_CCMD_SELF_TEST);
- if (kbd_wait_for_input() != 0x55)
+ if (kbd_wait_for_input() != 0x55)
return "Kbd: failed self test";
/*
* Perform a keyboard interface test. This causes the controller
* test are placed in the input buffer.
*/
kbd_write_command_w(KBD_CCMD_KBD_TEST);
- if (kbd_wait_for_input() != 0x00)
+ if (kbd_wait_for_input() != 0x00)
return "Kbd: interface failed self test";
/*
* Enable the keyboard by allowing the keyboard clock to run.
do {
kbd_write_output_w(KBD_CMD_RESET);
status = kbd_wait_for_input();
- if (status == KBD_REPLY_ACK)
+ if (status == KBD_REPLY_ACK)
break;
if (status != KBD_REPLY_RESEND)
{
| KBD_MODE_DISABLE_MOUSE
| KBD_MODE_KCC);
- /* ibm powerpc portables need this to use scan-code set 1 -- Cort */
+ /* AMCC powerpc portables need this to use scan-code set 1 -- Cort */
kbd_write_command_w(KBD_CCMD_READ_MODE);
if (!(kbd_wait_for_input() & KBD_MODE_KCC)) {
/*
{
handle_kbd_event();
}
-
-
-
-/* eof */
-