aboutsummaryrefslogtreecommitdiff
path: root/devices/mouse.c
blob: a03388a6fe2af81e583c00f43a5d1a32ff4c294b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "mouse.h"
#include "ps2_controller.h"
#include <stdint.h>
#include <stdio.h>
#include <sys/io.h>

void
mouse_init()
{
  int i;

  /* Sending a command or data byte to the mouse (to port 0x60) must be preceded by sending a 0xD4 byte to port 0x64
   * (with appropriate waits on port 0x64, bit 1, before sending each output byte). Note: this 0xD4 byte does not
   * generate any ACK, from either the keyboard or mouse. */

  /* enable second ps/2 */
  /* outb(0xa8, 0x64); */

  /* outb(0x64, 0xd4); */
  /* outb(0x60, 0xf4); */
  /* printf("mouse_init: enable streaming(0xf4): %x\n", inb(0x60)); */

  outb(0xd4, 0x64);
  outb(0xeb, 0x60); /* single packet */
  printf("mouse_init: single packet 0xeb\n");
  while ((inb(0x64) & 0x01) == 0) {}
  for (i = 0; i < 10; ++i) printf("%x ", inb(0x60));
  printf("\n");
}

void
mouse_packet()
{
  int i;

  printf("mouse packet: ");
  for (i = 0; i < 4; ++i) printf("%x ", ps2_read_port2());
  printf("\n");
}