From bb57b124d1bb385d41747f50be7dd4f3625539c1 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 24 Nov 2019 23:34:32 +0100 Subject: Major coding style reformatting -> Kernighan & Ritchie This project now (hopefully) uses the same style recommended by Kernighan and Ritchie and used in the Linux Kernel --- src/kernel/input/ps2/mouse.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/kernel/input/ps2/mouse.c') diff --git a/src/kernel/input/ps2/mouse.c b/src/kernel/input/ps2/mouse.c index 016b8b0..97ae256 100644 --- a/src/kernel/input/ps2/mouse.c +++ b/src/kernel/input/ps2/mouse.c @@ -10,19 +10,20 @@ int mouse_but_1 = 0; int mouse_but_2 = 0; int mouse_but_3 = 0; -void mouse_handler(struct regs *a_r) { +void mouse_handler(struct regs *a_r) +{ switch (mouse_cycle) { case 0: - mouse_byte[0] = receive_b(0x60); + mouse_byte[0] = inb(0x60); if (((mouse_byte[0] >> 3) & 1) == 1) mouse_cycle++; else mouse_cycle = 0; break; case 1: - mouse_byte[1] = receive_b(0x60); + mouse_byte[1] = inb(0x60); mouse_cycle++; break; case 2: - mouse_byte[2] = receive_b(0x60); + mouse_byte[2] = inb(0x60); mouse_x += mouse_byte[1]; mouse_y -= mouse_byte[2]; mouse_but_1 = mouse_byte[0] & 1; @@ -41,49 +42,53 @@ void mouse_handler(struct regs *a_r) { } } -void mouse_wait(unsigned char a_type) { +void mouse_wait(unsigned char a_type) +{ unsigned int time_out = 100000; if (a_type == 0) { while (time_out--) - if ((receive_b(0x64) & 1) == 1) + if ((inb(0x64) & 1) == 1) return; return; } else { while (time_out--) - if ((receive_b(0x64) & 2) == 0) + if ((inb(0x64) & 2) == 0) return; return; } } -void mouse_write(unsigned char a_write) { +void mouse_write(unsigned char a_write) +{ mouse_wait(1); - send_b(0x64, 0xD4); + outb(0x64, 0xD4); mouse_wait(1); - send_b(0x60, a_write); + outb(0x60, a_write); } -char mouse_read() { +char mouse_read() +{ mouse_wait(0); - return receive_b(0x60); + return inb(0x60); } -void mouse_install() { +void mouse_install() +{ unsigned char status; // Enable auxiliary mouse device mouse_wait(1); - send_b(0x64, 0xA8); + outb(0x64, 0xA8); // Enable interrupts mouse_wait(1); - send_b(0x64, 0x20); + outb(0x64, 0x20); mouse_wait(0); - status = (receive_b(0x60) | 2); + status = (inb(0x60) | 2); mouse_wait(1); - send_b(0x64, 0x60); + outb(0x64, 0x60); mouse_wait(1); - send_b(0x60, status); + outb(0x60, status); // Use default settings mouse_write(0xF6); -- cgit v1.2.3