Rev 387 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
444 | serge | 1 | $Revision: 431 $ |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3 | ;; ;; |
||
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
5 | ;; Distributed under terms of the GNU General Public License ;; |
||
6 | ;; ;; |
||
7 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
8 | |||
33 | mario79 | 9 | MouseSearch_PS2: |
121 | poddubny | 10 | jmp MouseSearch_PS2_begin |
33 | mario79 | 11 | |
121 | poddubny | 12 | mouse_error equ MouseSearch_PS2_begin.error |
33 | mario79 | 13 | |
121 | poddubny | 14 | kb_cmd_c: |
15 | call kb_cmd |
||
16 | jmp check_kbd |
||
33 | mario79 | 17 | |
121 | poddubny | 18 | kb_write_c: |
19 | call kb_write |
||
20 | jmp check_kbd |
||
33 | mario79 | 21 | |
121 | poddubny | 22 | kb_read_c: |
23 | call kb_read |
||
24 | ;jmp check_kbd |
||
33 | mario79 | 25 | |
121 | poddubny | 26 | check_kbd: |
27 | cmp ah, 1 |
||
28 | je mouse_error |
||
29 | ret |
||
33 | mario79 | 30 | |
121 | poddubny | 31 | uglobal |
32 | mouse_cmd_byte db 0 |
||
33 | mouse_nr_tries db 0 |
||
34 | mouse_nr_resends db 0 |
||
116 | poddubny | 35 | |
121 | poddubny | 36 | mouse_error_esp dd 0 |
37 | endg |
||
116 | poddubny | 38 | |
39 | |||
121 | poddubny | 40 | mouse_cmd: |
41 | mov [mouse_cmd_byte], al |
||
42 | mov [mouse_nr_resends], 5 |
||
43 | .resend: |
||
44 | mov bl, 0xd4 |
||
45 | call kb_cmd_c |
||
46 | mov al, [mouse_cmd_byte] |
||
47 | call kb_write_c |
||
116 | poddubny | 48 | |
121 | poddubny | 49 | call mouse_read |
116 | poddubny | 50 | |
121 | poddubny | 51 | cmp al, 0xFA ; ack |
52 | jne .noack |
||
53 | ret |
||
54 | .noack: |
||
55 | cmp al, 0xFE ; resend |
||
56 | jne .noresend |
||
57 | dec [mouse_nr_resends] |
||
58 | jnz .resend |
||
59 | .noresend: |
||
60 | jmp mouse_error |
||
116 | poddubny | 61 | |
62 | |||
121 | poddubny | 63 | mouse_read: |
64 | mov [mouse_nr_tries], 100 |
||
65 | .repeat: |
||
66 | call kb_read |
||
67 | cmp ah, 1 |
||
68 | jne .fin |
||
69 | mov esi, 10 |
||
70 | call delay_ms |
||
71 | dec [mouse_nr_tries] |
||
72 | jnz .repeat |
||
73 | jmp mouse_error |
||
74 | .fin: |
||
75 | ret |
||
116 | poddubny | 76 | |
77 | |||
121 | poddubny | 78 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
79 | MouseSearch_PS2_begin: |
||
80 | pushad |
||
116 | poddubny | 81 | |
121 | poddubny | 82 | mov [mouse_error_esp], esp |
116 | poddubny | 83 | |
121 | poddubny | 84 | mov bl, 0xAD ; disable keyboard interface |
85 | call kb_cmd_c |
||
444 | serge | 86 | |
121 | poddubny | 87 | mov bl, 0xA8 ; enable mouse interface |
88 | call kb_cmd_c |
||
116 | poddubny | 89 | |
121 | poddubny | 90 | mov al, 0xFF ; reset |
91 | call mouse_cmd |
||
92 | |||
93 | ; now the mouse is in Reset Mode |
||
94 | ; get the Basic Assurance Test completion code |
||
95 | call mouse_read |
||
96 | cmp al, 0xAA |
||
97 | jne .error ; dead mouse |
||
98 | |||
99 | ; get device ID |
||
100 | call mouse_read |
||
101 | cmp al, 0x00 |
||
102 | jne .error ; unknown device |
||
103 | |||
104 | ; reset completed successfully |
||
105 | |||
106 | ; enable mouse interrupt - IRQ12 |
||
107 | mov bl, 0x20 ; read command byte |
||
108 | call kb_cmd_c |
||
109 | call kb_read_c |
||
110 | or al, 10b |
||
111 | push eax |
||
112 | mov bl, 0x60 ; write command byte |
||
113 | call kb_cmd_c |
||
114 | pop eax |
||
115 | call kb_write_c |
||
116 | |||
117 | mov al, 0xF4 ; enable data reporting |
||
118 | call mouse_cmd |
||
119 | |||
120 | mov [ps2_mouse_detected], 1 |
||
121 | mov bl, 0xAE ; enable keyboard interface |
||
122 | call kb_cmd |
||
123 | |||
124 | mov esi, boot_setmouse_type |
||
125 | call boot_log |
||
126 | |||
127 | jmp .finish |
||
128 | |||
129 | |||
130 | .error: |
||
131 | mov esp, [mouse_error_esp] ; clear stack frame |
||
132 | mov [ps2_mouse_detected], 0 |
||
133 | mov bl, 0xA7 ; disable mouse interface |
||
134 | call kb_cmd |
||
135 | mov bl, 0xAE ; enable keyboard interface |
||
136 | call kb_cmd |
||
137 | |||
116 | poddubny | 138 | .finish: |
121 | poddubny | 139 | popad |