Subversion Repositories Kolibri OS

Rev

Rev 5044 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5044 Rev 6241
1
kbd_read:
1
kbd_read:
2
    push    ecx edx
2
    push    ecx edx
3
 
3
 
4
    mov     ecx,0xfffff ; last 0xffff, new value in view of fast CPU's
4
    mov     ecx,0xfffff ; last 0xffff, new value in view of fast CPU's
5
  kr_loop:
5
  kr_loop:
6
    in      al,0x64
6
    in      al,0x64
7
    test    al,1
7
    test    al,1
8
    jnz     kr_ready
8
    jnz     kr_ready
9
    loop    kr_loop
9
    loop    kr_loop
10
    mov     ah,1
10
    mov     ah,1
11
    jmp     kr_exit
11
    jmp     kr_exit
12
  kr_ready:
12
  kr_ready:
13
    in      al,0x60
13
    in      al,0x60
14
    xor     ah,ah
14
    xor     ah,ah
15
  kr_exit:
15
  kr_exit:
16
    pop     edx ecx
16
    pop     edx ecx
17
    ret
17
    ret
18
 
18
 
19
 
19
 
20
kbd_write:
20
kbd_write:
21
 
21
 
22
    push    ecx edx
22
    push    ecx edx
23
 
23
 
24
    mov     dl,al
24
    mov     dl,al
25
    mov     ecx,0x1ffff
25
    mov     ecx,0x1ffff
26
@@:
26
@@:
27
    in      al,0x64
27
    in      al,0x64
28
    test    al,2
28
    test    al,2
29
    jz      @f
29
    jz      @f
30
    loop    @b
30
    loop    @b
31
    mov     ah,1
31
    mov     ah,1
32
    jmp     .nothing
32
    jmp     .nothing
33
@@:
33
@@:
34
    mov     al,dl
34
    mov     al,dl
35
    out     0x60,al
35
    out     0x60,al
36
    mov     ah,0
36
    mov     ah,0
37
.nothing:
37
.nothing:
38
    pop     edx ecx
38
    pop     edx ecx
39
    ret
39
    ret
40
 
40
 
41
 
41
 
42
kbd_cmd:
42
kbd_cmd:
43
 
43
 
44
    mov     ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
44
    mov     ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
45
  c_wait:
45
  c_wait:
46
    in      al,0x64
46
    in      al,0x64
47
    test    al,2
47
    test    al,2
48
    jz      c_send
48
    jz      c_send
49
    loop    c_wait
49
    loop    c_wait
50
    mov     ah,1
50
    mov     ah,1
51
    jmp     c_exit
51
    jmp     c_exit
52
  c_send:
52
  c_send:
53
    mov     al,bl
53
    mov     al,bl
54
    out     0x64,al
54
    out     0x64,al
55
    xor     ah,ah
55
    xor     ah,ah
56
  c_exit:
56
  c_exit:
57
    ret
57
    ret
58
 
58
 
59
mouse_cmd:
59
mouse_cmd:
60
    mov  [mouse_cmd_byte], al
60
    mov  [mouse_cmd_byte], al
61
    mov  [mouse_nr_resends], 5
61
    mov  [mouse_nr_resends], 5
62
 .resend:
62
 .resend:
63
    mov  bl, 0xd4
63
    mov  bl, 0xd4
64
    call kbd_cmd
64
    call kbd_cmd
65
    cmp  ah,1
65
    cmp  ah,1
66
    je   .fail
66
    je   .fail
67
 
67
 
68
    mov  al, [mouse_cmd_byte]
68
    mov  al, [mouse_cmd_byte]
69
    call kbd_write
69
    call kbd_write
70
    cmp  ah, 1
70
    cmp  ah, 1
71
    je   .fail
71
    je   .fail
-
 
72
 
-
 
73
    cmp  [mouse_cmd_byte], 0xF5
72
 
74
    je .ok
73
    call mouse_read
75
    call mouse_read
74
 
76
 
75
    cmp  al, 0xFA
77
    cmp  al, 0xFA
76
    jne  .noack
78
    jne  .noack
-
 
79
.ok:
77
    clc
80
    clc
78
    ret
81
    ret
79
  .noack:
82
  .noack:
80
    cmp  al, 0xFE	; resend
83
    cmp  al, 0xFE	; resend
81
    jne  .noresend
84
    jne  .noresend
82
    dec  [mouse_nr_resends]
85
    dec  [mouse_nr_resends]
83
    jnz  .resend
86
    jnz  .resend
84
  .noresend:
87
  .noresend:
85
  .fail:
88
  .fail:
86
    stc
89
    stc
87
    ret
90
    ret
88
  
91
 
89
  
92
 
90
mouse_read:
93
mouse_read:
91
    mov  [mouse_nr_tries], 100
94
    mov  [mouse_nr_tries], 100
92
  .repeat:
95
  .repeat:
93
    call kbd_read
96
    call kbd_read
94
	  cmp  ah, 1
97
	  cmp  ah, 1
95
	  jne  .fin
98
	  jne  .fin
96
	  mov  esi, 10
99
	  mov  esi, 10
97
    invoke Sleep
100
    invoke Sleep
98
    dec  [mouse_nr_tries]
101
    dec  [mouse_nr_tries]
99
    jnz  .repeat
102
    jnz  .repeat
100
 
103
 
101
    stc
104
    stc
102
    ret
105
    ret
103
 
106
 
104
  .fin:
107
  .fin:
105
    clc
108
    clc
106
    ret
109
    ret