diff --git a/include/drivers/x86/pc/8042_ps2.h b/include/drivers/x86/pc/8042_ps2.h index add1eaf..b9ee920 100644 --- a/include/drivers/x86/pc/8042_ps2.h +++ b/include/drivers/x86/pc/8042_ps2.h @@ -55,9 +55,9 @@ bool ps2_init(); bool ps2_wait_read (UINT ioport, U8* data); bool ps2_wait_write (UINT ioport, U8 data); -void ps2_write_device_data (UINT device_id, U8 data); -bool ps2_write_device_cmd (UINT device_id, U8 cmd); -bool ps2_configuration (U8 enabled, U8 disabled, U8 *original_config); +void ps2_write_device_data_no_ack (UINT device_id, U8 data); +bool ps2_write_device_data_wait_ack (UINT device_id, U8 cmd); +bool ps2_configuration (U8 enabled, U8 disabled, U8* original_config); INT ps2_identify_device (UINT device_id); static inline U8 ps2_no_wait_read (UINT ioport) diff --git a/include/drivers/x86/pc/ps2_devices.h b/include/drivers/x86/pc/ps2_devices.h index dee5f17..35a29a1 100644 --- a/include/drivers/x86/pc/ps2_devices.h +++ b/include/drivers/x86/pc/ps2_devices.h @@ -38,6 +38,6 @@ typedef struct MousePositionData { bool middle_button; } MousePositionData; -bool ps2mouse_init(); -bool ps2kb_init(); -MousePositionData mouse_get_packet(); +bool ps2_mouse_init(); +bool ps2_kb_init(); +MousePositionData ps2_mouse_get_packet(); diff --git a/src/kernel/drivers/x86/pc/8042_ps2.c b/src/kernel/drivers/x86/pc/8042_ps2.c index 644578f..edeab61 100644 --- a/src/kernel/drivers/x86/pc/8042_ps2.c +++ b/src/kernel/drivers/x86/pc/8042_ps2.c @@ -69,7 +69,7 @@ bool ps2_wait_write (UINT ioport, U8 data) return true; } -void ps2_write_device_data (UINT device_id, U8 data) +void ps2_write_device_data_no_wait (UINT device_id, U8 data) { k_assert (device_id < DEVICE_COUNT, "Device ID is invalid."); @@ -84,12 +84,12 @@ void ps2_write_device_data (UINT device_id, U8 data) ps2_wait_write (PS2_DATA_PORT, data); } -bool ps2_write_device_cmd (UINT device_id, U8 cmd) +bool ps2_write_device_data_wait_ack (UINT device_id, U8 cmd) { U8 ack, retrycount = 0; do { - ps2_write_device_data (device_id, cmd); + ps2_write_device_data_no_wait (device_id, cmd); if (!ps2_wait_read (PS2_DATA_PORT, &ack)) { RETURN_ERROR (ERROR_PASSTHROUGH, false); // Possible timeout } @@ -142,11 +142,11 @@ INT ps2_identify_device (UINT device_id) PS2_CONFIG_FIRST_PORT_TRANSLATION_ENABLE, &config); - if (!ps2_write_device_cmd (device_id, PS2_DEV_CMD_DISABLE_SCANNING)) { + if (!ps2_write_device_data_wait_ack (device_id, PS2_DEV_CMD_DISABLE_SCANNING)) { RETURN_ERROR (ERROR_PASSTHROUGH, KERNEL_EXIT_FAILURE); } - if (!ps2_write_device_cmd (device_id, PS2_DEV_CMD_IDENTIFY)) { + if (!ps2_write_device_data_wait_ack (device_id, PS2_DEV_CMD_IDENTIFY)) { RETURN_ERROR (ERROR_PASSTHROUGH, KERNEL_EXIT_FAILURE); } diff --git a/src/kernel/drivers/x86/pc/ps2kb.c b/src/kernel/drivers/x86/pc/ps2kb.c index b6f9ad3..aa789fa 100644 --- a/src/kernel/drivers/x86/pc/ps2kb.c +++ b/src/kernel/drivers/x86/pc/ps2kb.c @@ -38,7 +38,7 @@ static bool iskeyboard() return true; } -bool ps2kb_init() +bool ps2_kb_init() { FUNC_ENTRY(); @@ -51,12 +51,12 @@ bool ps2kb_init() } // Set defaults - if (!ps2_write_device_cmd (PS2_FIRST_DEVICE, PS2_DEV_CMD_SET_TO_DEFAULT)) { + if (!ps2_write_device_data_wait_ack (PS2_FIRST_DEVICE, PS2_DEV_CMD_SET_TO_DEFAULT)) { RETURN_ERROR (ERROR_PASSTHROUGH, false); } // Interrupt when keys are pressed - if (!ps2_write_device_cmd (PS2_FIRST_DEVICE, PS2_DEV_CMD_ENABLE_SCANNING)) { + if (!ps2_write_device_data_wait_ack (PS2_FIRST_DEVICE, PS2_DEV_CMD_ENABLE_SCANNING)) { RETURN_ERROR (ERROR_PASSTHROUGH, false); } diff --git a/src/kernel/drivers/x86/pc/ps2mouse.c b/src/kernel/drivers/x86/pc/ps2mouse.c index f6ed13f..158d9f9 100644 --- a/src/kernel/drivers/x86/pc/ps2mouse.c +++ b/src/kernel/drivers/x86/pc/ps2mouse.c @@ -27,7 +27,7 @@ typedef struct MouseStatus { U8 sample_rate; } MouseStatus; -void mouse_interrupt_asm_handler(); +void ps2_mouse_interrupt_asm_handler(); static bool ismouse(); static MouseStatus get_mouse_state(); @@ -57,10 +57,10 @@ static MouseStatus get_mouse_state() { MouseStatus status = { 0 }; - ps2_write_device_cmd (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_GET_ID); + ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_GET_ID); ps2_wait_read (PS2_DATA_PORT, &status.id); - ps2_write_device_cmd (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_STATUS_REQ); + ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_STATUS_REQ); ps2_wait_read (PS2_DATA_PORT, &status.status); ps2_wait_read (PS2_DATA_PORT, &status.resolution); ps2_wait_read (PS2_DATA_PORT, &status.sample_rate); @@ -68,7 +68,7 @@ static MouseStatus get_mouse_state() return status; } -bool ps2mouse_init() +bool ps2_mouse_init() { FUNC_ENTRY(); @@ -81,20 +81,20 @@ bool ps2mouse_init() } // Set defaults - if (!ps2_write_device_cmd (PS2_SECOND_DEVICE, PS2_DEV_CMD_SET_TO_DEFAULT)) { + if (!ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, PS2_DEV_CMD_SET_TO_DEFAULT)) { RETURN_ERROR (ERROR_PASSTHROUGH, false); } // Set sample rate - if (!ps2_write_device_cmd (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_SET_SAMPLE_RATE)) { + if (!ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_SET_SAMPLE_RATE)) { RETURN_ERROR (ERROR_PASSTHROUGH, false); } - if (!ps2_write_device_cmd (PS2_SECOND_DEVICE, CONFIG_PS2_MOUSE_SAMPLE_RATE)) { + if (!ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, CONFIG_PS2_MOUSE_SAMPLE_RATE)) { RETURN_ERROR (ERROR_PASSTHROUGH, false); } // Enable scanning by the device - if (!ps2_write_device_cmd (PS2_SECOND_DEVICE, PS2_DEV_CMD_ENABLE_SCANNING)) { + if (!ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, PS2_DEV_CMD_ENABLE_SCANNING)) { RETURN_ERROR (ERROR_PASSTHROUGH, false); } @@ -113,7 +113,7 @@ bool ps2mouse_init() ps2_configuration (PS2_CONFIG_SECOND_PORT_INTERRUPT_ENABLE, 0, NULL); // Add handlers for keyboard interrupts - kidt_edit (0x2C, mouse_interrupt_asm_handler, GDT_SELECTOR_KCODE, + kidt_edit (0x2C, ps2_mouse_interrupt_asm_handler, GDT_SELECTOR_KCODE, IDT_DES_TYPE_32_INTERRUPT_GATE, 0); // Enable Mouse IRQ @@ -122,13 +122,13 @@ bool ps2mouse_init() return true; } -MousePositionData mouse_get_packet() +MousePositionData ps2_mouse_get_packet() { return mouse_position; } -INTERRUPT_HANDLER (mouse_interrupt) -void mouse_interrupt_handler (InterruptFrame* frame) +INTERRUPT_HANDLER (ps2_mouse_interrupt) +void ps2_mouse_interrupt_handler (InterruptFrame* frame) { (void)frame; diff --git a/src/kernel/kgraphics.c b/src/kernel/kgraphics.c index 47f5232..9fddbf7 100644 --- a/src/kernel/kgraphics.c +++ b/src/kernel/kgraphics.c @@ -81,7 +81,7 @@ static void arch_waitForNextVerticalRetrace() static void draw_cursor (const KGraphicsArea* g) { - MousePositionData mdata = mouse_get_packet(); + MousePositionData mdata = ps2_mouse_get_packet(); INT mouse_y = (INT)g->height_px / 2 - mdata.y; INT mouse_x = (INT)g->width_px / 2 + mdata.x; diff --git a/src/kernel/x86/kernel.c b/src/kernel/x86/kernel.c index 7e077c3..cdb251f 100644 --- a/src/kernel/x86/kernel.c +++ b/src/kernel/x86/kernel.c @@ -177,10 +177,9 @@ void kernel_main () ps2_init(); - if (!ps2mouse_init()) { + if (!ps2_mouse_init()) { k_panic ("PS2 Mouse initialization falied"); } - run_root_process(); k_halt(); }