Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
164 serge 1
;
2
;   This file is part of the Infinity sound AC97 driver.
3
;   (C) copyright Serge 2006
4
;   email: infinity_sound@mail.ru
5
;
6
;   This program is free software; you can redistribute it and/or modify
7
;   it under the terms of the GNU General Public License as published by
8
;   the Free Software Foundation; either version 2 of the License, or
9
;   (at your option) any later version.
10
;
11
;   This program is distributed in the hope that it will be useful,
12
;   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
;   GNU General Public License for more details.
15
 
16
align 4
17
proc attach_int_handler stdcall, irq:dword, handler:dword
18
 
19
	 mov ebx, [irq]        ;irq num
20
	 test ebx, ebx
21
	 jz .err
22
	 mov eax, [handler]
23
	 test eax, eax
24
	 jz .err
25
	 mov [irq_tab+ebx*4], eax
26
         stdcall enable_irq, [irq]
27
	 ret
28
.err:
29
	 xor eax, eax
30
	 ret
31
endp
32
 
33
align 4
34
proc  detach_int_handler
35
 
36
	   ret
37
endp
38
 
39
align 4
40
proc enable_irq stdcall, irq_line:dword
41
           mov ebx, [irq_line]
42
           mov edx, 0x21
43
           cmp ebx, 8
44
           jb @F
45
           mov edx, 0xA1
46
           sub ebx,8
47
@@:
48
           in al,dx
49
           btr eax, ebx
50
           out dx, al
51
           ret
52
endp
53
 
54
align 16
55
;; proc irq_serv
56
 
57
irq_serv:
58
 
59
.irq_1:
60
	   push eax
61
	   mov eax, 1
62
	   jmp .main
63
align 4
64
.irq_2:
65
	   push eax
66
	   mov eax, 2
67
	   jmp .main
68
align 4
69
.irq_3:
70
	   push eax
71
	   mov eax, 3
72
	   jmp .main
73
align 4
74
.irq_4:
75
	   push eax
76
	   mov eax, 4
77
	   jmp .main
78
align 4
79
.irq_5:
80
	   push eax
81
	   mov eax, 5
82
	   jmp .main
83
align 4
84
.irq_6:
85
	   push eax
86
	   mov eax, 6
87
	   jmp .main
88
align 4
89
.irq_7:
90
	   push eax
91
	   mov eax, 7
92
	   jmp .main
93
align 4
94
.irq_8:
95
	   push eax
96
	   mov eax, 8
97
	   jmp .main
98
align 4
99
.irq_9:
100
	   push eax
101
	   mov eax, 9
102
	   jmp .main
103
align 4
104
.irq_10:
105
	   push eax
106
	   mov eax, 10
107
	   jmp .main
108
align 4
109
.irq_11:
110
	   push eax
111
	   mov eax, 11
112
	   jmp .main
113
align 4
114
.irq_12:
115
	   push eax
116
	   mov eax, 12
117
	   jmp .main
118
align 4
119
.irq_13:
120
	   push eax
121
	   mov eax, 13
122
	   jmp .main
123
align 4
124
.irq_14:
125
	   push eax
126
	   mov eax, 14
127
	   jmp .main
128
align 4
129
.irq_15:
130
	   push eax
131
	   mov eax, 15
132
	   jmp .main
133
 
134
align 16
135
.main:
136
	   save_ring3_context
137
	   mov	 bx, os_data
138
	   mov	 ds, bx
139
	   mov	 es, bx
140
 
141
	   mov ebx, [irq_tab+eax*4]
142
	   test ebx, ebx
143
	   jz .exit
144
 
145
           call ebx
146
 
147
.exit:
148
	   restore_ring3_context
149
 
150
           cmp eax, 8
151
	   mov al, 0x20
152
           jb @f
153
	   out 0xa0, al
154
@@:
155
           out 0x20, al
156
 
157
           pop eax
158
	   iret
159
 
160
align 4
161
proc get_notify stdcall, p_ev:dword
162
 
163
.wait:
164
           mov ebx,[CURRENT_TASK]
165
           shl ebx,8
166
           test dword [ebx+PROC_BASE+0xA8],EVENT_NOTIFY
167
	   jz @f
168
           and dword [ebx+PROC_BASE+0xA8], not EVENT_NOTIFY
169
	   mov edi, [p_ev]
170
	   mov dword [edi], EV_INTR
171
           mov eax, [ebx+PROC_BASE+APPDATA.event]
172
	   mov dword [edi+4], eax
173
	   ret
174
@@:
175
	   call change_task
176
	   jmp .wait
177
endp
178
 
179
align 4
180
proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword
181
	   xor eax, eax
182
	   xor ebx, ebx
183
	   mov ah, byte [bus]
184
           mov al, 6
185
	   mov bh, byte [devfn]
186
	   mov bl, byte [reg]
187
	   call pci_read_reg
188
	   ret
189
endp
190
 
191
align 4
192
proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword
193
	   xor eax, eax
194
	   xor ebx, ebx
195
	   mov ah, byte [bus]
196
           mov al, 4
197
	   mov bh, byte [devfn]
198
	   mov bl, byte [reg]
199
	   call pci_read_reg
200
	   ret
201
endp
202
 
203
align 4
204
proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
205
	   xor eax, eax
206
	   xor ebx, ebx
207
	   mov ah, byte [bus]
208
           mov al, 8
209
	   mov bh, byte [devfn]
210
	   mov bl, byte [reg]
211
           mov ecx, [val]
212
           call pci_write_reg
213
	   ret
214
endp
215
 
216
handle     equ  IOCTL.handle
217
io_code    equ  IOCTL.io_code
218
input      equ  IOCTL.input
219
inp_size   equ  IOCTL.inp_size
220
output     equ  IOCTL.output
221
out_size   equ  IOCTL.out_size
222
 
223
 
224
align 4
225
proc srv_handler stdcall, ioctl:dword
226
           mov esi, [ioctl]
227
           test esi, esi
228
           jz .err
229
 
230
           mov edi, [esi+handle]
231
           cmp [edi+SRV.magic], ' SRV'
232
	   jne .fail
233
 
234
           cmp [edi+SRV.size], SRV_SIZE
235
	   jne .fail
236
 
237
           stdcall [edi+SRV.srv_proc], esi
238
           ret
239
.fail:
240
           xor eax, eax
241
           not eax
242
           mov [esi+output], eax
243
           mov [esi+out_size], 4
244
           ret
245
.err:
246
           xor eax, eax
247
           not eax
248
           ret
249
endp
250
 
251
align 4
252
proc srv_handlerEx stdcall, ioctl:dword
253
           mov esi, [ioctl]
254
           test esi, esi
255
           jz .err
256
           add esi, new_app_base
257
 
258
           mov edi, [esi+handle]
259
           cmp [edi+SRV.magic], ' SRV'
260
	   jne .fail
261
 
262
           cmp [edi+SRV.size], SRV_SIZE
263
	   jne .fail
264
 
265
           add [esi+input], new_app_base
266
           add [esi+output], new_app_base
267
 
268
           stdcall [edi+SRV.srv_proc], esi
269
           ret
270
.fail:
271
           xor eax, eax
272
           not eax
273
           mov [esi+output], eax
274
           mov [esi+out_size], 4
275
           ret
276
.err:
277
           xor eax, eax
278
           not eax
279
           ret
280
endp
281
 
282
restore  handle
283
restore  io_code
284
restore  input
285
restore  inp_size