aboutsummaryrefslogtreecommitdiff
path: root/devices/mouse.c
diff options
context:
space:
mode:
Diffstat (limited to 'devices/mouse.c')
-rw-r--r--devices/mouse.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/devices/mouse.c b/devices/mouse.c
index 92f3f08..a950e8c 100644
--- a/devices/mouse.c
+++ b/devices/mouse.c
@@ -1,11 +1,9 @@
#include "mouse.h"
+#include "ps2_controller.h"
#include <stdint.h>
#include <stdio.h>
#include <sys/io.h>
-// TODO: All output to port 0x60 or 0x64 must be preceded by waiting for bit 1 (value=2) of port 0x64 to become clear.
-// TODO: Similarly, bytes cannot be read from port 0x60 until bit 0 (value=1) of port 0x64 is set.
-
void
mouse_init()
{
@@ -14,17 +12,24 @@ mouse_init()
// generate any ACK, from either the keyboard or mouse.
// enable second ps/2
- // outb(0x64, 0xa8);
+ // outb(0xa8, 0x64);
// outb(0x64, 0xd4);
// outb(0x60, 0xf4);
// printf("mouse_init: enable streaming(0xf4): %x\n", inb(0x60));
- /*
- outb(0x64, 0xd4);
- while (inb(0x64) & 0x1)
- ;
- outb(0x60, 0xf2);
- printf("mouse_init: mouse_id(0xf2 %x): %x\n", inb(0x60), inb(0x60));
- */
+ outb(0xd4, 0x64);
+ outb(0xeb, 0x60); // single packet
+ printf("mouse_init: single packet 0xeb\n");
+ while ((inb(0x64) & 0x01) == 0) {}
+ for (int i = 0; i < 10; ++i) printf("%x ", inb(0x60));
+ printf("\n");
+}
+
+void
+mouse_packet()
+{
+ printf("mouse packet: ");
+ for (int i = 0; i < 4; ++i) printf("%x ", ps2_read_port2());
+ printf("\n");
}