Subversion Repositories Kolibri OS

Rev

Rev 425 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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