Skip to content

Commit

Permalink
Fix: NDEBUG build failure after f2f1998
Browse files Browse the repository at this point in the history
Error: 'Unused parameter'
  • Loading branch information
coderarjob committed Sep 8, 2024
1 parent f2f1998 commit 5b0db95
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
18 changes: 4 additions & 14 deletions src/kernel/drivers/x86/pc/8042_ps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ UINT ps2_read_data()
if (ps2_canRead()) {
return ps2_read_data_no_wait();
}
k_assert (false, "PS2: Long wait for read");
// TODO: Should not panic. It is very much possible for device to ready.
k_panic ("PS2: Long wait for read");
}

void ps2_write_data (UINT port, UINT data)
Expand All @@ -87,7 +88,8 @@ void ps2_write_data (UINT port, UINT data)
outb (port, data);
return;
}
k_assert (false, "PS2: Long wait for write");
// TODO: Should not panic. It is very much possible for device to ready.
k_panic ("PS2: Long wait for write");
}

bool ps2_write_device_cmd (const PS2PortInfo* const port, bool checkAck, UINT data)
Expand All @@ -109,13 +111,6 @@ bool ps2_write_device_cmd (const PS2PortInfo* const port, bool checkAck, UINT da
return true;
}

static void read_configuration_byte (char* s)
{
ps2_write_controller_cmd (CMD_READ_CONFIGURATION_BYTE);
UINT config = ps2_read_data();
kdebug_println ("%s: %x", s, config);
}

PS2DeviceType ps2_identify_device (PS2PortInfo* const port)
{
k_assert (port != NULL, "PS2 port cannot be null");
Expand Down Expand Up @@ -159,14 +154,11 @@ bool ps2_init()
k_memset (&port2, 0, sizeof (port2));
port2.isSecondPort = true;

read_configuration_byte ("First");

// Step 1: Disable both PS/2 ports
// --------------------------------------------------------
ps2_write_controller_cmd (CMD_DISABLE_FIRST_PORT);
ps2_write_controller_cmd (CMD_DISABLE_SECOND_PORT);

read_configuration_byte ("second");
// Step 2: Flush the output (from device perspective) buffer
// --------------------------------------------------------
U8 discard;
Expand Down Expand Up @@ -203,8 +195,6 @@ bool ps2_init()
ps2_write_controller_cmd (CMD_ENABLE_FIRST_PORT); // This will turn on the clock for port 1
ps2_write_controller_cmd (CMD_ENABLE_SECOND_PORT); // This will turn on the clock for port 2

read_configuration_byte ("final init");

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernel/drivers/x86/pc/ps2kb.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ void kb_interrupt_handler (InterruptFrame* frame)
{
(void)frame;
U8 scancode = (U8)ps2_read_data_no_wait();
kdebug_println ("Keyboard ISR: Scancode: %x", scancode);
kearly_println ("Keyboard ISR: Scancode: %x", scancode);
pic_send_eoi (X86_PC_IRQ_KEYBOARD);
}
2 changes: 1 addition & 1 deletion src/kernel/drivers/x86/pc/ps2mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ void mouse_interrupt_handler (InterruptFrame* frame)
U8 data1, data2, data3 = 0;
data1 = (U8)ps2_read_data_no_wait();
data2 = (U8)ps2_read_data_no_wait();
kdebug_println ("Mouse handler: %x, %x, %x", data1, data2, data3);
kearly_println ("Mouse handler: %x, %x, %x", data1, data2, data3);
pic_send_eoi (X86_PC_IRQ_PS2_MOUSE);
}

0 comments on commit 5b0db95

Please sign in to comment.