From: Duje Mihanović Date: Fri, 13 May 2022 14:30:18 +0000 (+0200) Subject: Fix device initialization X-Git-Url: http://git.dujemihanovic.xyz/img/%7B%7B?a=commitdiff_plain;h=cb9e7e764ed6b14d0b90c27a276193a2011bf399;p=nameless-os.git Fix device initialization Before doing a ps2_input_wait(), the code now first reads from the data port once (for port 1 device) or twice (for port 2 device). This makes the PS/2 initialization work. --- diff --git a/kernel/drivers/input/ps2.c b/kernel/drivers/input/ps2.c index 0507024..e765b24 100644 --- a/kernel/drivers/input/ps2.c +++ b/kernel/drivers/input/ps2.c @@ -85,7 +85,6 @@ int ps2_initialize() int dev_1_test, dev_2_test; -/* if (port_1_test) { uint8_t resp; @@ -106,17 +105,20 @@ int ps2_initialize() } else { dev_1_test = 1; kprint("ps2: Port 1 device test successful\n", 0); } } + inb(PS2_DATA_PORT); + ps2_input_wait(); + if (port_2_test) { - int resp = RESEND; + uint8_t resp; - while (resp == RESEND) { + do { ps2_input_wait(); outb(PS2_CMD_STS_PORT, PS2_CMD_PORT_2_WRITE); ps2_input_wait(); outb(PS2_DATA_PORT, PS2_DEV_RESET); ps2_output_wait(); resp = inb(PS2_DATA_PORT); - } + } while (resp == RESEND); if (resp == SELF_TEST_BAD || resp == SELF_TEST_BAD_2) { dev_2_test = 0; @@ -125,10 +127,11 @@ int ps2_initialize() kprint("ps2: No functioning devices, exiting!\n", 0); return -1; } - } else { dev_2_test = 1; kprint("ps2: Port 2 test successful\n", 0); } + } else { dev_2_test = 1; kprint("ps2: Port 2 device test successful\n", 0); } } -*/ + inb(PS2_DATA_PORT); + inb(PS2_DATA_PORT); ps2_input_wait(); outb(PS2_CMD_STS_PORT, PS2_CMD_READ_CCB); ps2_output_wait();