2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: PS/2 mouse driver.
10 #define TIMER_RPROK 3599597124UL
12 static ULONG
usec2tick(ULONG usec
)
15 ULONG prok
= TIMER_RPROK
;
16 asm volatile("movl $0,%%eax; divl %2":"=a"(ret
):"d"(usec
),"m"(prok
));
20 static void mouse_usleep(LONG usec
)
23 usec
= usec2tick(usec
);
27 oldtick
+= inb(0x42) << 8;
33 tick
+= inb(0x42) << 8;
35 usec
-= (oldtick
- tick
);
36 if (tick
> oldtick
) usec
-= 0x10000;
42 unsigned char handle_kbd_event(void)
44 unsigned char status
= kbd_read_status();
45 unsigned int work
= 10000;
47 while (status
& KBD_STATUS_OBF
)
49 unsigned char scancode
;
51 scancode
= kbd_read_input();
53 status
= kbd_read_status();
56 //printf(KERN_ERR "pc_keyb: controller jammed (0x%02X).\n",status);
65 ULONG timeout
= 1000; /* 1 sec should be enough */
69 unsigned char status
= handle_kbd_event();
70 if (! (status
& KBD_STATUS_IBF
))
78 void kbd_write_cmd(int cmd
)
81 kbd_write_command(KBD_CTRLCMD_WRITE_MODE
);
83 kbd_write_output(cmd
);
86 void aux_write_ack(int val
)
89 kbd_write_command(KBD_CTRLCMD_WRITE_MOUSE
);
91 kbd_write_output(val
);
95 void kbd_write_output_w(int data
)
98 kbd_write_output(data
);
101 void kbd_write_command_w(int data
)
104 kbd_write_command(data
);
107 #define KBD_NO_DATA (-1)
108 #define KBD_BAD_DATA (-2)
110 int kbd_read_data(void)
112 LONG retval
= KBD_NO_DATA
;
115 status
= kbd_read_status();
116 if (status
& KBD_STATUS_OBF
)
118 UBYTE data
= kbd_read_input();
121 if (status
& (KBD_STATUS_GTO
| KBD_STATUS_PERR
))
122 retval
= KBD_BAD_DATA
;
128 void kbd_clear_input(void)
134 if (kbd_read_data() == KBD_NO_DATA
)
139 int kbd_wait_for_input(void)
141 ULONG timeout
= 1000;
145 int retval
= kbd_read_data();