Skip to content

Commit f1f563c

Browse files
committed
Minor renaming of PS2 interfaces
1 parent 8c7a169 commit f1f563c

File tree

7 files changed

+28
-29
lines changed

7 files changed

+28
-29
lines changed

include/drivers/x86/pc/8042_ps2.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
bool ps2_init();
5656
bool ps2_wait_read (UINT ioport, U8* data);
5757
bool ps2_wait_write (UINT ioport, U8 data);
58-
void ps2_write_device_data (UINT device_id, U8 data);
59-
bool ps2_write_device_cmd (UINT device_id, U8 cmd);
60-
bool ps2_configuration (U8 enabled, U8 disabled, U8 *original_config);
58+
void ps2_write_device_data_no_ack (UINT device_id, U8 data);
59+
bool ps2_write_device_data_wait_ack (UINT device_id, U8 cmd);
60+
bool ps2_configuration (U8 enabled, U8 disabled, U8* original_config);
6161
INT ps2_identify_device (UINT device_id);
6262

6363
static inline U8 ps2_no_wait_read (UINT ioport)

include/drivers/x86/pc/ps2_devices.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ typedef struct MousePositionData {
3838
bool middle_button;
3939
} MousePositionData;
4040

41-
bool ps2mouse_init();
42-
bool ps2kb_init();
43-
MousePositionData mouse_get_packet();
41+
bool ps2_mouse_init();
42+
bool ps2_kb_init();
43+
MousePositionData ps2_mouse_get_packet();

src/kernel/drivers/x86/pc/8042_ps2.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool ps2_wait_write (UINT ioport, U8 data)
6969
return true;
7070
}
7171

72-
void ps2_write_device_data (UINT device_id, U8 data)
72+
void ps2_write_device_data_no_wait (UINT device_id, U8 data)
7373
{
7474
k_assert (device_id < DEVICE_COUNT, "Device ID is invalid.");
7575

@@ -84,12 +84,12 @@ void ps2_write_device_data (UINT device_id, U8 data)
8484
ps2_wait_write (PS2_DATA_PORT, data);
8585
}
8686

87-
bool ps2_write_device_cmd (UINT device_id, U8 cmd)
87+
bool ps2_write_device_data_wait_ack (UINT device_id, U8 cmd)
8888
{
8989
U8 ack, retrycount = 0;
9090

9191
do {
92-
ps2_write_device_data (device_id, cmd);
92+
ps2_write_device_data_no_wait (device_id, cmd);
9393
if (!ps2_wait_read (PS2_DATA_PORT, &ack)) {
9494
RETURN_ERROR (ERROR_PASSTHROUGH, false); // Possible timeout
9595
}
@@ -142,11 +142,11 @@ INT ps2_identify_device (UINT device_id)
142142
PS2_CONFIG_FIRST_PORT_TRANSLATION_ENABLE,
143143
&config);
144144

145-
if (!ps2_write_device_cmd (device_id, PS2_DEV_CMD_DISABLE_SCANNING)) {
145+
if (!ps2_write_device_data_wait_ack (device_id, PS2_DEV_CMD_DISABLE_SCANNING)) {
146146
RETURN_ERROR (ERROR_PASSTHROUGH, KERNEL_EXIT_FAILURE);
147147
}
148148

149-
if (!ps2_write_device_cmd (device_id, PS2_DEV_CMD_IDENTIFY)) {
149+
if (!ps2_write_device_data_wait_ack (device_id, PS2_DEV_CMD_IDENTIFY)) {
150150
RETURN_ERROR (ERROR_PASSTHROUGH, KERNEL_EXIT_FAILURE);
151151
}
152152

src/kernel/drivers/x86/pc/ps2kb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static bool iskeyboard()
3838
return true;
3939
}
4040

41-
bool ps2kb_init()
41+
bool ps2_kb_init()
4242
{
4343
FUNC_ENTRY();
4444

@@ -51,12 +51,12 @@ bool ps2kb_init()
5151
}
5252

5353
// Set defaults
54-
if (!ps2_write_device_cmd (PS2_FIRST_DEVICE, PS2_DEV_CMD_SET_TO_DEFAULT)) {
54+
if (!ps2_write_device_data_wait_ack (PS2_FIRST_DEVICE, PS2_DEV_CMD_SET_TO_DEFAULT)) {
5555
RETURN_ERROR (ERROR_PASSTHROUGH, false);
5656
}
5757

5858
// Interrupt when keys are pressed
59-
if (!ps2_write_device_cmd (PS2_FIRST_DEVICE, PS2_DEV_CMD_ENABLE_SCANNING)) {
59+
if (!ps2_write_device_data_wait_ack (PS2_FIRST_DEVICE, PS2_DEV_CMD_ENABLE_SCANNING)) {
6060
RETURN_ERROR (ERROR_PASSTHROUGH, false);
6161
}
6262

src/kernel/drivers/x86/pc/ps2mouse.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef struct MouseStatus {
2727
U8 sample_rate;
2828
} MouseStatus;
2929

30-
void mouse_interrupt_asm_handler();
30+
void ps2_mouse_interrupt_asm_handler();
3131
static bool ismouse();
3232
static MouseStatus get_mouse_state();
3333

@@ -57,18 +57,18 @@ static MouseStatus get_mouse_state()
5757
{
5858
MouseStatus status = { 0 };
5959

60-
ps2_write_device_cmd (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_GET_ID);
60+
ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_GET_ID);
6161
ps2_wait_read (PS2_DATA_PORT, &status.id);
6262

63-
ps2_write_device_cmd (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_STATUS_REQ);
63+
ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_STATUS_REQ);
6464
ps2_wait_read (PS2_DATA_PORT, &status.status);
6565
ps2_wait_read (PS2_DATA_PORT, &status.resolution);
6666
ps2_wait_read (PS2_DATA_PORT, &status.sample_rate);
6767

6868
return status;
6969
}
7070

71-
bool ps2mouse_init()
71+
bool ps2_mouse_init()
7272
{
7373
FUNC_ENTRY();
7474

@@ -81,20 +81,20 @@ bool ps2mouse_init()
8181
}
8282

8383
// Set defaults
84-
if (!ps2_write_device_cmd (PS2_SECOND_DEVICE, PS2_DEV_CMD_SET_TO_DEFAULT)) {
84+
if (!ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, PS2_DEV_CMD_SET_TO_DEFAULT)) {
8585
RETURN_ERROR (ERROR_PASSTHROUGH, false);
8686
}
8787

8888
// Set sample rate
89-
if (!ps2_write_device_cmd (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_SET_SAMPLE_RATE)) {
89+
if (!ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, PS2_MOUSE_CMD_SET_SAMPLE_RATE)) {
9090
RETURN_ERROR (ERROR_PASSTHROUGH, false);
9191
}
92-
if (!ps2_write_device_cmd (PS2_SECOND_DEVICE, CONFIG_PS2_MOUSE_SAMPLE_RATE)) {
92+
if (!ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, CONFIG_PS2_MOUSE_SAMPLE_RATE)) {
9393
RETURN_ERROR (ERROR_PASSTHROUGH, false);
9494
}
9595

9696
// Enable scanning by the device
97-
if (!ps2_write_device_cmd (PS2_SECOND_DEVICE, PS2_DEV_CMD_ENABLE_SCANNING)) {
97+
if (!ps2_write_device_data_wait_ack (PS2_SECOND_DEVICE, PS2_DEV_CMD_ENABLE_SCANNING)) {
9898
RETURN_ERROR (ERROR_PASSTHROUGH, false);
9999
}
100100

@@ -113,7 +113,7 @@ bool ps2mouse_init()
113113
ps2_configuration (PS2_CONFIG_SECOND_PORT_INTERRUPT_ENABLE, 0, NULL);
114114

115115
// Add handlers for keyboard interrupts
116-
kidt_edit (0x2C, mouse_interrupt_asm_handler, GDT_SELECTOR_KCODE,
116+
kidt_edit (0x2C, ps2_mouse_interrupt_asm_handler, GDT_SELECTOR_KCODE,
117117
IDT_DES_TYPE_32_INTERRUPT_GATE, 0);
118118

119119
// Enable Mouse IRQ
@@ -122,13 +122,13 @@ bool ps2mouse_init()
122122
return true;
123123
}
124124

125-
MousePositionData mouse_get_packet()
125+
MousePositionData ps2_mouse_get_packet()
126126
{
127127
return mouse_position;
128128
}
129129

130-
INTERRUPT_HANDLER (mouse_interrupt)
131-
void mouse_interrupt_handler (InterruptFrame* frame)
130+
INTERRUPT_HANDLER (ps2_mouse_interrupt)
131+
void ps2_mouse_interrupt_handler (InterruptFrame* frame)
132132
{
133133
(void)frame;
134134

src/kernel/kgraphics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void arch_waitForNextVerticalRetrace()
8181

8282
static void draw_cursor (const KGraphicsArea* g)
8383
{
84-
MousePositionData mdata = mouse_get_packet();
84+
MousePositionData mdata = ps2_mouse_get_packet();
8585

8686
INT mouse_y = (INT)g->height_px / 2 - mdata.y;
8787
INT mouse_x = (INT)g->width_px / 2 + mdata.x;

src/kernel/x86/kernel.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,9 @@ void kernel_main ()
177177

178178
ps2_init();
179179

180-
if (!ps2mouse_init()) {
180+
if (!ps2_mouse_init()) {
181181
k_panic ("PS2 Mouse initialization falied");
182182
}
183-
184183
run_root_process();
185184
k_halt();
186185
}

0 commit comments

Comments
 (0)