diff --git a/kernel-src/arch/x86-64/ps2.c b/kernel-src/arch/x86-64/ps2.c index dbde1a90..5cada3db 100644 --- a/kernel-src/arch/x86-64/ps2.c +++ b/kernel-src/arch/x86-64/ps2.c @@ -1,5 +1,6 @@ #include #include +#include static bool reset_selftest(int port) { uint8_t r = RESEND; @@ -60,8 +61,15 @@ void arch_ps2_init() { else write_command(CTLR_CMD_DISABLEP2); // disable second port again + // self test ports int workingflag = 0; + write_command(CTLR_CMD_P1SELFTEST); + if (read_data() == 0) + workingflag |= 1; + else + printf("First PS/2 port self test failed!\n"); + if (dualport) { write_command(CTLR_CMD_P2SELFTEST); if (read_data() == 0) @@ -77,8 +85,9 @@ void arch_ps2_init() { printf("ps2: controller with %d ports\n", dualport ? 2 : 1); - write_command(CTLR_CMD_ENABLEP1); + // enable ports + write_command(CTLR_CMD_ENABLEP1); if (dualport) write_command(CTLR_CMD_ENABLEP2); @@ -101,4 +110,8 @@ void arch_ps2_init() { if (workingflag & 2 && reset_selftest(2)) connectedflag |= 2; + + // XXX should id each one for proper identification + if (connectedflag & 1) + ps2kbd_init(); }