]> git.dujemihanovic.xyz Git - nameless-os.git/commitdiff
Fix device initialization
authorDuje Mihanović <duje.mihanovic@skole.hr>
Fri, 13 May 2022 14:30:18 +0000 (16:30 +0200)
committerDuje Mihanović <duje.mihanovic@skole.hr>
Wed, 22 Jun 2022 16:05:27 +0000 (18:05 +0200)
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.

kernel/drivers/input/ps2.c

index 050702426f39e9114ad5468e7754ba1177e0c46e..e765b24bcbcd316fa9448df3cfbacd14afaaa964 100644 (file)
@@ -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();