Subversion Repositories Kolibri OS

Rev

Rev 492 | Rev 5044 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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