Skip to content

Commit 6c07680

Browse files
committed
[not ready] fix keyboard
1 parent 9599767 commit 6c07680

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/drivers/keyboard/keyboard.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ unsigned char write_to_ps2_second_port(unsigned char byte, int want_reply) {
119119
}
120120
wait_for_status_flag_timeout(STATUS_OUTPUT_BUFFER, 1, WAIT_FOR_STATUS_TIMEOUT);
121121
out = port_read(DRIVERS_KEYBOARD_PORT_DATA);
122+
return out;
122123
}
123124

124125
unsigned char read_data_reply() {
@@ -240,6 +241,11 @@ void keyboard_init() {
240241
ps2_controller_send_command(0xA8, 0);
241242
}
242243

244+
out = write_to_ps2_first_port(0xF5, 1);
245+
if (out != 0xFA) {
246+
PANIC(out, "disable scanning failed.");
247+
}
248+
243249
// enable interrupts
244250
out = ps2_controller_send_command(0X20, 1);
245251
out |= 0b11;
@@ -260,15 +266,15 @@ void keyboard_init() {
260266
// reset second port
261267
out = write_to_ps2_second_port(0xFF, 1);
262268
if (out != 0xFA) {
263-
// PANIC(out, "reset ps/2 second failed");
269+
PANIC(out, "reset ps/2 second failed");
270+
}
271+
out = read_data_reply();
272+
if (out != 0xAA) {
273+
PANIC(out, "reset ps/2 second port, mouse self test failed");
264274
}
265275
}
266276

267277
// detect device type
268-
out = write_to_ps2_first_port(0xF5, 1);
269-
if (out != 0xFA) {
270-
PANIC(out, "disable scanning failed.");
271-
}
272278
out = write_to_ps2_first_port(0xF2, 1);
273279
if (out != 0xFA) {
274280
PANIC(out, "device identity failed.");

0 commit comments

Comments
 (0)