Rename PORT_KBD_* to PORT_PS2_*
This change is in preparation for mouse support.
This commit is contained in:
parent
63dbcfbff1
commit
ee2fd7a588
|
@ -20,9 +20,9 @@
|
|||
#define PORT_PIT_COUNTER1 0x0041
|
||||
#define PORT_PIT_COUNTER2 0x0042
|
||||
#define PORT_PIT_MODE 0x0043
|
||||
#define PORT_KBD_DATA 0x0060
|
||||
#define PORT_KBD_CTRLB 0x0061
|
||||
#define PORT_KBD_STATUS 0x0064
|
||||
#define PORT_PS2_DATA 0x0060
|
||||
#define PORT_PS2_CTRLB 0x0061
|
||||
#define PORT_PS2_STATUS 0x0064
|
||||
#define PORT_CMOS_INDEX 0x0070
|
||||
#define PORT_CMOS_DATA 0x0071
|
||||
#define PORT_DIAG 0x0080
|
||||
|
|
28
src/kbd.c
28
src/kbd.c
|
@ -128,14 +128,14 @@ handle_1609(struct bregs *regs)
|
|||
static void
|
||||
handle_160a(struct bregs *regs)
|
||||
{
|
||||
outb(0xf2, PORT_KBD_DATA);
|
||||
outb(0xf2, PORT_PS2_DATA);
|
||||
/* Wait for data */
|
||||
u16 max=0xffff;
|
||||
while ( ((inb(PORT_KBD_STATUS) & 0x01) == 0) && (--max>0) )
|
||||
while ( ((inb(PORT_PS2_STATUS) & 0x01) == 0) && (--max>0) )
|
||||
outb(0x00, PORT_DIAG);
|
||||
if (!max)
|
||||
return;
|
||||
if (inb(PORT_KBD_DATA) != 0xfa) {
|
||||
if (inb(PORT_PS2_DATA) != 0xfa) {
|
||||
regs->bx = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -143,11 +143,11 @@ handle_160a(struct bregs *regs)
|
|||
u8 count = 2;
|
||||
do {
|
||||
max=0xffff;
|
||||
while ( ((inb(PORT_KBD_STATUS) & 0x01) == 0) && (--max>0) )
|
||||
while ( ((inb(PORT_PS2_STATUS) & 0x01) == 0) && (--max>0) )
|
||||
outb(0x00, PORT_DIAG);
|
||||
if (max>0x0) {
|
||||
kbd_code >>= 8;
|
||||
kbd_code |= (inb(PORT_KBD_DATA) << 8);
|
||||
kbd_code |= (inb(PORT_PS2_DATA) << 8);
|
||||
}
|
||||
} while (--count>0);
|
||||
regs->bx = kbd_code;
|
||||
|
@ -219,16 +219,16 @@ set_leds()
|
|||
if (((shift_flags >> 4) & 0x07) ^ ((led_flags & 0x07) == 0))
|
||||
return;
|
||||
|
||||
outb(0xed, PORT_KBD_DATA);
|
||||
while ((inb(PORT_KBD_STATUS) & 0x01) == 0)
|
||||
outb(0xed, PORT_PS2_DATA);
|
||||
while ((inb(PORT_PS2_STATUS) & 0x01) == 0)
|
||||
outb(0x21, PORT_DIAG);
|
||||
if (inb(PORT_KBD_DATA) == 0xfa) {
|
||||
if (inb(PORT_PS2_DATA) == 0xfa) {
|
||||
led_flags &= 0xf8;
|
||||
led_flags |= (shift_flags >> 4) & 0x07;
|
||||
outb(led_flags & 0x07, PORT_KBD_DATA);
|
||||
while ((inb(PORT_KBD_STATUS) & 0x01) == 0)
|
||||
outb(led_flags & 0x07, PORT_PS2_DATA);
|
||||
while ((inb(PORT_PS2_STATUS) & 0x01) == 0)
|
||||
outb(0x21, PORT_DIAG);
|
||||
inb(PORT_KBD_DATA);
|
||||
inb(PORT_PS2_DATA);
|
||||
SET_BDA(kbd_led, led_flags);
|
||||
}
|
||||
}
|
||||
|
@ -551,10 +551,10 @@ handle_09(struct bregs *regs)
|
|||
return;
|
||||
|
||||
// disable keyboard
|
||||
outb(0xad, PORT_KBD_STATUS);
|
||||
outb(0xad, PORT_PS2_STATUS);
|
||||
|
||||
// read key from keyboard controller
|
||||
u8 key = inb(PORT_KBD_DATA);
|
||||
u8 key = inb(PORT_PS2_DATA);
|
||||
irq_enable();
|
||||
if (CONFIG_KBD_CALL_INT15_4F) {
|
||||
// allow for keyboard intercept
|
||||
|
@ -575,5 +575,5 @@ handle_09(struct bregs *regs)
|
|||
|
||||
done:
|
||||
// enable keyboard
|
||||
outb(0xae, PORT_KBD_STATUS);
|
||||
outb(0xae, PORT_PS2_STATUS);
|
||||
}
|
||||
|
|
38
src/post.c
38
src/post.c
|
@ -108,7 +108,7 @@ static void
|
|||
kbd_wait(u8 mask, u8 code)
|
||||
{
|
||||
u16 max = 0xffff;
|
||||
while ( ((inb(PORT_KBD_STATUS) & mask) == 0) && (--max>0) )
|
||||
while ( ((inb(PORT_PS2_STATUS) & mask) == 0) && (--max>0) )
|
||||
outb(code, PORT_DIAG);
|
||||
if (!max)
|
||||
keyboard_panic(code);
|
||||
|
@ -137,8 +137,8 @@ keyboard_init()
|
|||
u16 max=0x2000;
|
||||
while (--max > 0) {
|
||||
outb(0x00, PORT_DIAG);
|
||||
if (inb(PORT_KBD_STATUS) & 0x01) {
|
||||
inb(PORT_KBD_DATA);
|
||||
if (inb(PORT_PS2_STATUS) & 0x01) {
|
||||
inb(PORT_PS2_DATA);
|
||||
max = 0x2000;
|
||||
}
|
||||
}
|
||||
|
@ -150,74 +150,74 @@ keyboard_init()
|
|||
|
||||
/* ------------------- controller side ----------------------*/
|
||||
/* send cmd = 0xAA, self test 8042 */
|
||||
outb(0xaa, PORT_KBD_STATUS);
|
||||
outb(0xaa, PORT_PS2_STATUS);
|
||||
|
||||
kbd_flush(0x00);
|
||||
kbd_waitdata(0x01);
|
||||
|
||||
/* read self-test result, 0x55 should be returned from 0x60 */
|
||||
if ((inb(PORT_KBD_DATA) != 0x55))
|
||||
if (inb(PORT_PS2_DATA) != 0x55)
|
||||
keyboard_panic(991);
|
||||
|
||||
/* send cmd = 0xAB, keyboard interface test */
|
||||
outb(0xab, PORT_KBD_STATUS);
|
||||
outb(0xab, PORT_PS2_STATUS);
|
||||
|
||||
kbd_flush(0x10);
|
||||
kbd_waitdata(0x11);
|
||||
|
||||
/* read keyboard interface test result, */
|
||||
/* 0x00 should be returned form 0x60 */
|
||||
if ((inb(PORT_KBD_DATA) != 0x00))
|
||||
if (inb(PORT_PS2_DATA) != 0x00)
|
||||
keyboard_panic(992);
|
||||
|
||||
/* Enable Keyboard clock */
|
||||
outb(0xae, PORT_KBD_STATUS);
|
||||
outb(0xa8, PORT_KBD_STATUS);
|
||||
outb(0xae, PORT_PS2_STATUS);
|
||||
outb(0xa8, PORT_PS2_STATUS);
|
||||
|
||||
/* ------------------- keyboard side ------------------------*/
|
||||
/* reset kerboard and self test (keyboard side) */
|
||||
outb(0xff, PORT_KBD_DATA);
|
||||
outb(0xff, PORT_PS2_DATA);
|
||||
|
||||
kbd_flush(0x20);
|
||||
kbd_waitdata(0x21);
|
||||
|
||||
/* keyboard should return ACK */
|
||||
if ((inb(PORT_KBD_DATA) != 0xfa))
|
||||
if (inb(PORT_PS2_DATA) != 0xfa)
|
||||
keyboard_panic(993);
|
||||
|
||||
kbd_waitdata(0x31);
|
||||
|
||||
if ((inb(PORT_KBD_DATA) != 0xaa))
|
||||
if (inb(PORT_PS2_DATA) != 0xaa)
|
||||
keyboard_panic(994);
|
||||
|
||||
/* Disable keyboard */
|
||||
outb(0xf5, PORT_KBD_DATA);
|
||||
outb(0xf5, PORT_PS2_DATA);
|
||||
|
||||
kbd_flush(0x40);
|
||||
kbd_waitdata(0x41);
|
||||
|
||||
/* keyboard should return ACK */
|
||||
if ((inb(PORT_KBD_DATA) != 0xfa))
|
||||
if (inb(PORT_PS2_DATA) != 0xfa)
|
||||
keyboard_panic(995);
|
||||
|
||||
/* Write Keyboard Mode */
|
||||
outb(0x60, PORT_KBD_STATUS);
|
||||
outb(0x60, PORT_PS2_STATUS);
|
||||
|
||||
kbd_flush(0x50);
|
||||
|
||||
/* send cmd: scan code convert, disable mouse, enable IRQ 1 */
|
||||
outb(0x61, PORT_KBD_DATA);
|
||||
outb(0x61, PORT_PS2_DATA);
|
||||
|
||||
kbd_flush(0x60);
|
||||
|
||||
/* Enable keyboard */
|
||||
outb(0xf4, PORT_KBD_DATA);
|
||||
outb(0xf4, PORT_PS2_DATA);
|
||||
|
||||
kbd_flush(0x70);
|
||||
kbd_waitdata(0x71);
|
||||
|
||||
/* keyboard should return ACK */
|
||||
if ((inb(PORT_KBD_DATA) != 0xfa))
|
||||
if (inb(PORT_PS2_DATA) != 0xfa)
|
||||
keyboard_panic(996);
|
||||
|
||||
outb(0x77, PORT_DIAG);
|
||||
|
@ -575,7 +575,7 @@ check_restart_status()
|
|||
if (status == 0x05)
|
||||
eoi_jmp_post();
|
||||
|
||||
BX_PANIC("Unimplemented shutdown status: %02x\n",(Bit8u)status);
|
||||
BX_PANIC("Unimplemented shutdown status: %02x\n", status);
|
||||
}
|
||||
|
||||
void VISIBLE
|
||||
|
|
|
@ -91,9 +91,9 @@ static void
|
|||
usleep(u32 count)
|
||||
{
|
||||
count = count / 15;
|
||||
u8 kbd = inb(PORT_KBD_CTRLB);
|
||||
u8 kbd = inb(PORT_PS2_CTRLB);
|
||||
while (count)
|
||||
if ((inb(PORT_KBD_CTRLB) ^ kbd) & KBD_REFRESH)
|
||||
if ((inb(PORT_PS2_CTRLB) ^ kbd) & KBD_REFRESH)
|
||||
count--;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue