Rev 769 | Rev 797 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
431 | serge | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
709 | diamond | 3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
431 | serge | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
164 | serge | 7 | |
593 | mikedld | 8 | $Revision: 774 $ |
9 | |||
10 | |||
465 | serge | 11 | DRV_COMPAT equ 5 ;minimal required drivers version |
12 | DRV_CURRENT equ 5 ;current drivers model version |
||
214 | serge | 13 | |
227 | serge | 14 | DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT |
15 | |||
164 | serge | 16 | align 4 |
774 | Rus | 17 | proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword |
164 | serge | 18 | |
769 | Rus | 19 | mov ebx, [irq] ;irq num |
20 | test ebx, ebx |
||
21 | jz .err |
||
22 | cmp ebx, 15 ; hidnplayr says: we only have 16 IRQ's |
||
23 | ja .err |
||
24 | mov eax, [handler] |
||
25 | test eax, eax |
||
26 | jz .err |
||
27 | cmp [irq_owner + 4 * ebx], 0 |
||
774 | Rus | 28 | je @f |
29 | |||
30 | mov ecx, [irq_rights + 4 * ebx] ; Rights : 0 - full access, 1 - read only, 2 - forbidden |
||
31 | test ecx, ecx |
||
32 | jnz .err |
||
33 | |||
34 | @@: |
||
769 | Rus | 35 | mov [irq_tab+ebx*4], eax |
36 | |||
774 | Rus | 37 | mov eax, [access_rights] |
38 | mov [irq_rights + 4 * ebx], eax |
||
769 | Rus | 39 | ;push eax |
40 | ;mov eax, [TASK_BASE] |
||
774 | Rus | 41 | ;mov eax, [eax + TASKDATA.pid] ; faster or smaller? :) |
42 | call get_pid |
||
43 | |||
44 | mov [irq_owner + 4 * ebx], eax |
||
769 | Rus | 45 | ;pop eax |
46 | |||
47 | stdcall enable_irq, [irq] |
||
48 | ret |
||
164 | serge | 49 | .err: |
769 | Rus | 50 | xor eax, eax |
51 | ret |
||
164 | serge | 52 | endp |
53 | |||
774 | Rus | 54 | uglobal |
55 | |||
56 | irq_rights rd 16 |
||
57 | |||
58 | endg |
||
59 | |||
60 | proc get_int_handler stdcall, irq:dword |
||
61 | |||
62 | mov eax, [irq] |
||
63 | |||
64 | cmp [irq_rights + 4 * eax], dword 1 |
||
65 | ja .err |
||
66 | |||
67 | mov eax, [irq_tab + 4 * eax] |
||
68 | ret |
||
69 | |||
70 | .err: |
||
71 | xor eax, eax |
||
72 | ret |
||
73 | |||
74 | endp |
||
75 | |||
164 | serge | 76 | align 4 |
77 | proc detach_int_handler |
||
78 | |||
79 | ret |
||
80 | endp |
||
81 | |||
82 | align 4 |
||
83 | proc enable_irq stdcall, irq_line:dword |
||
672 | hidnplayr | 84 | mov ebx, [irq_line] |
85 | mov edx, 0x21 |
||
86 | cmp ebx, 8 |
||
87 | jb @F |
||
88 | mov edx, 0xA1 |
||
89 | sub ebx,8 |
||
164 | serge | 90 | @@: |
672 | hidnplayr | 91 | in al,dx |
92 | btr eax, ebx |
||
93 | out dx, al |
||
94 | ret |
||
164 | serge | 95 | endp |
96 | |||
97 | align 16 |
||
98 | ;; proc irq_serv |
||
99 | |||
100 | irq_serv: |
||
101 | |||
102 | .irq_1: |
||
769 | Rus | 103 | push 1 |
164 | serge | 104 | jmp .main |
105 | align 4 |
||
106 | .irq_2: |
||
769 | Rus | 107 | push 2 |
164 | serge | 108 | jmp .main |
109 | align 4 |
||
110 | .irq_3: |
||
769 | Rus | 111 | push 3 |
164 | serge | 112 | jmp .main |
113 | align 4 |
||
114 | .irq_4: |
||
769 | Rus | 115 | push 4 |
164 | serge | 116 | jmp .main |
117 | align 4 |
||
118 | .irq_5: |
||
769 | Rus | 119 | push 5 |
164 | serge | 120 | jmp .main |
121 | align 4 |
||
122 | .irq_6: |
||
769 | Rus | 123 | push 6 |
164 | serge | 124 | jmp .main |
125 | align 4 |
||
126 | .irq_7: |
||
769 | Rus | 127 | push 7 |
164 | serge | 128 | jmp .main |
129 | align 4 |
||
130 | .irq_8: |
||
769 | Rus | 131 | push 8 |
164 | serge | 132 | jmp .main |
133 | align 4 |
||
134 | .irq_9: |
||
769 | Rus | 135 | push 9 |
164 | serge | 136 | jmp .main |
137 | align 4 |
||
138 | .irq_10: |
||
769 | Rus | 139 | push 10 |
164 | serge | 140 | jmp .main |
141 | align 4 |
||
142 | .irq_11: |
||
769 | Rus | 143 | push 11 |
164 | serge | 144 | jmp .main |
145 | align 4 |
||
146 | .irq_12: |
||
769 | Rus | 147 | push 12 |
164 | serge | 148 | jmp .main |
149 | align 4 |
||
150 | .irq_13: |
||
769 | Rus | 151 | push 13 |
164 | serge | 152 | jmp .main |
153 | align 4 |
||
154 | .irq_14: |
||
769 | Rus | 155 | push 14 |
164 | serge | 156 | jmp .main |
157 | align 4 |
||
158 | .irq_15: |
||
769 | Rus | 159 | push 15 |
164 | serge | 160 | jmp .main |
161 | |||
162 | align 16 |
||
163 | .main: |
||
164 | save_ring3_context |
||
769 | Rus | 165 | mov eax, [esp + 32] |
672 | hidnplayr | 166 | mov bx, app_data ;os_data |
164 | serge | 167 | mov ds, bx |
168 | mov es, bx |
||
169 | |||
769 | Rus | 170 | cmp [v86_irqhooks+eax*8], 0 |
171 | jnz v86_irq |
||
709 | diamond | 172 | |
164 | serge | 173 | mov ebx, [irq_tab+eax*4] |
174 | test ebx, ebx |
||
175 | jz .exit |
||
176 | |||
672 | hidnplayr | 177 | call ebx |
178 | mov [check_idle_semaphore],5 |
||
164 | serge | 179 | |
180 | .exit: |
||
181 | |||
769 | Rus | 182 | cmp dword [esp + 32], 8 |
164 | serge | 183 | mov al, 0x20 |
672 | hidnplayr | 184 | jb @f |
164 | serge | 185 | out 0xa0, al |
186 | @@: |
||
672 | hidnplayr | 187 | out 0x20, al |
164 | serge | 188 | |
769 | Rus | 189 | restore_ring3_context |
190 | add esp, 4 |
||
191 | |||
164 | serge | 192 | iret |
193 | |||
194 | align 4 |
||
195 | proc get_notify stdcall, p_ev:dword |
||
196 | |||
197 | .wait: |
||
672 | hidnplayr | 198 | mov ebx,[current_slot] |
199 | test dword [ebx+APPDATA.event_mask],EVENT_NOTIFY |
||
164 | serge | 200 | jz @f |
672 | hidnplayr | 201 | and dword [ebx+APPDATA.event_mask], not EVENT_NOTIFY |
164 | serge | 202 | mov edi, [p_ev] |
203 | mov dword [edi], EV_INTR |
||
672 | hidnplayr | 204 | mov eax, [ebx+APPDATA.event] |
164 | serge | 205 | mov dword [edi+4], eax |
206 | ret |
||
207 | @@: |
||
208 | call change_task |
||
209 | jmp .wait |
||
210 | endp |
||
211 | |||
212 | align 4 |
||
213 | proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword |
||
769 | Rus | 214 | push ebx |
164 | serge | 215 | xor eax, eax |
216 | xor ebx, ebx |
||
217 | mov ah, byte [bus] |
||
672 | hidnplayr | 218 | mov al, 6 |
164 | serge | 219 | mov bh, byte [devfn] |
220 | mov bl, byte [reg] |
||
221 | call pci_read_reg |
||
769 | Rus | 222 | pop ebx |
164 | serge | 223 | ret |
224 | endp |
||
225 | |||
226 | align 4 |
||
557 | serge | 227 | proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword |
769 | Rus | 228 | push ebx |
557 | serge | 229 | xor eax, eax |
230 | xor ebx, ebx |
||
231 | mov ah, byte [bus] |
||
672 | hidnplayr | 232 | mov al, 5 |
557 | serge | 233 | mov bh, byte [devfn] |
234 | mov bl, byte [reg] |
||
235 | call pci_read_reg |
||
769 | Rus | 236 | pop ebx |
557 | serge | 237 | ret |
238 | endp |
||
239 | |||
240 | align 4 |
||
164 | serge | 241 | proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword |
769 | Rus | 242 | push ebx |
164 | serge | 243 | xor eax, eax |
244 | xor ebx, ebx |
||
245 | mov ah, byte [bus] |
||
672 | hidnplayr | 246 | mov al, 4 |
164 | serge | 247 | mov bh, byte [devfn] |
248 | mov bl, byte [reg] |
||
249 | call pci_read_reg |
||
769 | Rus | 250 | pop ebx |
164 | serge | 251 | ret |
252 | endp |
||
253 | |||
254 | align 4 |
||
255 | proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword |
||
769 | Rus | 256 | push ebx |
164 | serge | 257 | xor eax, eax |
258 | xor ebx, ebx |
||
259 | mov ah, byte [bus] |
||
672 | hidnplayr | 260 | mov al, 8 |
164 | serge | 261 | mov bh, byte [devfn] |
262 | mov bl, byte [reg] |
||
672 | hidnplayr | 263 | mov ecx, [val] |
264 | call pci_write_reg |
||
769 | Rus | 265 | pop ebx |
164 | serge | 266 | ret |
267 | endp |
||
268 | |||
557 | serge | 269 | align 4 |
270 | proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword |
||
769 | Rus | 271 | push ebx |
557 | serge | 272 | xor eax, eax |
273 | xor ebx, ebx |
||
274 | mov ah, byte [bus] |
||
672 | hidnplayr | 275 | mov al, 9 |
557 | serge | 276 | mov bh, byte [devfn] |
277 | mov bl, byte [reg] |
||
672 | hidnplayr | 278 | mov ecx, [val] |
279 | call pci_write_reg |
||
769 | Rus | 280 | pop ebx |
557 | serge | 281 | ret |
282 | endp |
||
283 | |||
672 | hidnplayr | 284 | align 4 |
285 | proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword |
||
769 | Rus | 286 | push ebx |
672 | hidnplayr | 287 | xor eax, eax |
288 | xor ebx, ebx |
||
289 | mov ah, byte [bus] |
||
290 | mov al, 10 |
||
291 | mov bh, byte [devfn] |
||
292 | mov bl, byte [reg] |
||
293 | mov ecx, [val] |
||
294 | call pci_write_reg |
||
769 | Rus | 295 | pop ebx |
672 | hidnplayr | 296 | ret |
297 | endp |
||
164 | serge | 298 | |
672 | hidnplayr | 299 | handle equ IOCTL.handle |
300 | io_code equ IOCTL.io_code |
||
301 | input equ IOCTL.input |
||
302 | inp_size equ IOCTL.inp_size |
||
303 | output equ IOCTL.output |
||
304 | out_size equ IOCTL.out_size |
||
164 | serge | 305 | |
672 | hidnplayr | 306 | |
164 | serge | 307 | align 4 |
308 | proc srv_handler stdcall, ioctl:dword |
||
672 | hidnplayr | 309 | mov esi, [ioctl] |
310 | test esi, esi |
||
311 | jz .err |
||
164 | serge | 312 | |
672 | hidnplayr | 313 | mov edi, [esi+handle] |
314 | cmp [edi+SRV.magic], ' SRV' |
||
164 | serge | 315 | jne .fail |
316 | |||
672 | hidnplayr | 317 | cmp [edi+SRV.size], SRV_SIZE |
164 | serge | 318 | jne .fail |
319 | |||
672 | hidnplayr | 320 | stdcall [edi+SRV.srv_proc], esi |
321 | ret |
||
164 | serge | 322 | .fail: |
672 | hidnplayr | 323 | xor eax, eax |
324 | not eax |
||
325 | mov [esi+output], eax |
||
326 | mov [esi+out_size], 4 |
||
327 | ret |
||
164 | serge | 328 | .err: |
672 | hidnplayr | 329 | xor eax, eax |
330 | not eax |
||
331 | ret |
||
164 | serge | 332 | endp |
333 | |||
377 | serge | 334 | ; param |
335 | ; ebx= io_control |
||
336 | ; |
||
337 | ; retval |
||
338 | ; eax= error code |
||
339 | |||
164 | serge | 340 | align 4 |
377 | serge | 341 | srv_handlerEx: |
672 | hidnplayr | 342 | cmp ebx, OS_BASE |
343 | jae .fail |
||
164 | serge | 344 | |
672 | hidnplayr | 345 | mov eax, [ebx+handle] |
346 | cmp [eax+SRV.magic], ' SRV' |
||
164 | serge | 347 | jne .fail |
348 | |||
672 | hidnplayr | 349 | cmp [eax+SRV.size], SRV_SIZE |
164 | serge | 350 | jne .fail |
351 | |||
672 | hidnplayr | 352 | stdcall [eax+SRV.srv_proc], ebx |
353 | ret |
||
164 | serge | 354 | .fail: |
672 | hidnplayr | 355 | or eax, -1 |
356 | ret |
||
164 | serge | 357 | |
358 | restore handle |
||
359 | restore io_code |
||
360 | restore input |
||
361 | restore inp_size |
||
362 | restore output |
||
363 | restore out_size |
||
364 | |||
365 | align 4 |
||
366 | proc get_service stdcall, sz_name:dword |
||
672 | hidnplayr | 367 | mov eax, [sz_name] |
368 | test eax, eax |
||
369 | jnz @F |
||
370 | ret |
||
164 | serge | 371 | @@: |
672 | hidnplayr | 372 | mov edx, [srv.fd] |
188 | serge | 373 | @@: |
672 | hidnplayr | 374 | cmp edx, srv.fd-SRV_FD_OFFSET |
375 | je .not_load |
||
278 | serge | 376 | |
672 | hidnplayr | 377 | stdcall strncmp, edx, [sz_name], 16 |
378 | test eax, eax |
||
379 | je .ok |
||
164 | serge | 380 | |
672 | hidnplayr | 381 | mov edx, [edx+SRV.fd] |
382 | jmp @B |
||
164 | serge | 383 | .not_load: |
672 | hidnplayr | 384 | pop ebp |
385 | jmp load_driver |
||
164 | serge | 386 | .ok: |
672 | hidnplayr | 387 | mov eax, edx |
388 | ret |
||
164 | serge | 389 | endp |
390 | |||
391 | align 4 |
||
740 | serge | 392 | proc reg_service stdcall, name:dword, handler:dword |
164 | serge | 393 | |
769 | Rus | 394 | xor eax, eax |
164 | serge | 395 | |
769 | Rus | 396 | cmp [name], eax |
397 | je .fail |
||
740 | serge | 398 | |
769 | Rus | 399 | cmp [handler], eax |
400 | je .fail |
||
740 | serge | 401 | |
769 | Rus | 402 | push ebx |
672 | hidnplayr | 403 | mov eax, SRV_SIZE |
404 | call malloc ;call alloc_service |
||
769 | Rus | 405 | pop ebx |
164 | serge | 406 | test eax, eax |
407 | jz .fail |
||
408 | |||
769 | Rus | 409 | push ebx |
410 | push esi |
||
411 | push edi |
||
164 | serge | 412 | mov edi, eax |
769 | Rus | 413 | mov esi, [name] |
672 | hidnplayr | 414 | mov ecx, 16/4 |
415 | rep movsd |
||
769 | Rus | 416 | pop edi |
417 | pop esi |
||
164 | serge | 418 | |
672 | hidnplayr | 419 | mov [eax+SRV.magic], ' SRV' |
420 | mov [eax+SRV.size], SRV_SIZE |
||
278 | serge | 421 | |
672 | hidnplayr | 422 | mov ebx, srv.fd-SRV_FD_OFFSET |
423 | mov edx, [ebx+SRV.fd] |
||
424 | mov [eax+SRV.fd], edx |
||
425 | mov [eax+SRV.bk], ebx |
||
426 | mov [ebx+SRV.fd], eax |
||
427 | mov [edx+SRV.bk], eax |
||
278 | serge | 428 | |
769 | Rus | 429 | mov ecx, [handler] |
672 | hidnplayr | 430 | mov [eax+SRV.srv_proc], ecx |
769 | Rus | 431 | pop ebx |
432 | ret |
||
164 | serge | 433 | .fail: |
434 | xor eax, eax |
||
769 | Rus | 435 | ret |
740 | serge | 436 | endp |
164 | serge | 437 | |
438 | align 4 |
||
439 | proc get_proc stdcall, exp:dword, sz_name:dword |
||
440 | |||
672 | hidnplayr | 441 | mov edx, [exp] |
164 | serge | 442 | .next: |
672 | hidnplayr | 443 | mov eax, [edx] |
444 | test eax, eax |
||
445 | jz .end |
||
164 | serge | 446 | |
672 | hidnplayr | 447 | push edx |
448 | stdcall strncmp, eax, [sz_name], 16 |
||
449 | pop edx |
||
450 | test eax, eax |
||
451 | jz .ok |
||
164 | serge | 452 | |
672 | hidnplayr | 453 | add edx,8 |
454 | jmp .next |
||
164 | serge | 455 | .ok: |
672 | hidnplayr | 456 | mov eax, [edx+4] |
164 | serge | 457 | .end: |
672 | hidnplayr | 458 | ret |
164 | serge | 459 | endp |
460 | |||
461 | align 4 |
||
462 | proc get_coff_sym stdcall, pSym:dword,count:dword, sz_sym:dword |
||
463 | |||
464 | @@: |
||
465 | stdcall strncmp, [pSym], [sz_sym], 8 |
||
466 | test eax,eax |
||
467 | jz .ok |
||
468 | add [pSym], 18 |
||
469 | dec [count] |
||
470 | jnz @b |
||
471 | xor eax, eax |
||
472 | ret |
||
473 | .ok: |
||
474 | mov ebx, [pSym] |
||
475 | mov eax, [ebx+8] |
||
476 | ret |
||
477 | endp |
||
478 | |||
479 | align 4 |
||
188 | serge | 480 | proc get_curr_task |
672 | hidnplayr | 481 | mov eax,[CURRENT_TASK] |
482 | shl eax, 8 |
||
483 | ret |
||
188 | serge | 484 | endp |
164 | serge | 485 | |
188 | serge | 486 | align 4 |
487 | proc get_fileinfo stdcall, file_name:dword, info:dword |
||
672 | hidnplayr | 488 | locals |
489 | cmd dd ? |
||
490 | offset dd ? |
||
491 | dd ? |
||
492 | count dd ? |
||
493 | buff dd ? |
||
494 | db ? |
||
495 | name dd ? |
||
496 | endl |
||
164 | serge | 497 | |
672 | hidnplayr | 498 | xor eax, eax |
499 | mov ebx, [file_name] |
||
500 | mov ecx, [info] |
||
164 | serge | 501 | |
672 | hidnplayr | 502 | mov [cmd], 5 |
503 | mov [offset], eax |
||
504 | mov [offset+4], eax |
||
505 | mov [count], eax |
||
506 | mov [buff], ecx |
||
507 | mov byte [buff+4], al |
||
508 | mov [name], ebx |
||
164 | serge | 509 | |
672 | hidnplayr | 510 | mov eax, 70 |
511 | lea ebx, [cmd] |
||
512 | int 0x40 |
||
513 | ret |
||
188 | serge | 514 | endp |
164 | serge | 515 | |
188 | serge | 516 | align 4 |
517 | proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\ |
||
672 | hidnplayr | 518 | bytes:dword |
519 | locals |
||
520 | cmd dd ? |
||
521 | offset dd ? |
||
522 | dd ? |
||
523 | count dd ? |
||
524 | buff dd ? |
||
525 | db ? |
||
526 | name dd ? |
||
527 | endl |
||
164 | serge | 528 | |
672 | hidnplayr | 529 | xor eax, eax |
530 | mov ebx, [file_name] |
||
531 | mov ecx, [off] |
||
532 | mov edx, [bytes] |
||
533 | mov esi, [buffer] |
||
164 | serge | 534 | |
672 | hidnplayr | 535 | mov [cmd], eax |
536 | mov [offset], ecx |
||
537 | mov [offset+4], eax |
||
538 | mov [count], edx |
||
539 | mov [buff], esi |
||
540 | mov byte [buff+4], al |
||
541 | mov [name], ebx |
||
188 | serge | 542 | |
672 | hidnplayr | 543 | pushad |
544 | push eax |
||
545 | lea eax, [cmd] |
||
546 | call file_system_lfn |
||
547 | pop eax |
||
548 | popad |
||
549 | ret |
||
188 | serge | 550 | endp |
551 | |||
363 | serge | 552 | ; description |
553 | ; allocate kernel memory and loads the specified file |
||
554 | ; |
||
555 | ; param |
||
556 | ; file_name= full path to file |
||
557 | ; |
||
558 | ; retval |
||
559 | ; eax= file image in kernel memory |
||
560 | ; ebx= size of file |
||
561 | ; |
||
562 | ; warging |
||
563 | ; You mast call kernel_free() to delete each file |
||
564 | ; loaded by the load_file() function |
||
565 | |||
188 | serge | 566 | align 4 |
567 | proc load_file stdcall, file_name:dword |
||
672 | hidnplayr | 568 | locals |
569 | attr dd ? |
||
570 | flags dd ? |
||
571 | cr_time dd ? |
||
572 | cr_date dd ? |
||
573 | acc_time dd ? |
||
574 | acc_date dd ? |
||
575 | mod_time dd ? |
||
576 | mod_date dd ? |
||
577 | file_size dd ? |
||
188 | serge | 578 | |
672 | hidnplayr | 579 | file dd ? |
580 | file2 dd ? |
||
581 | endl |
||
188 | serge | 582 | |
672 | hidnplayr | 583 | push esi |
584 | push edi |
||
662 | serge | 585 | |
672 | hidnplayr | 586 | lea eax, [attr] |
587 | stdcall get_fileinfo, [file_name], eax |
||
588 | test eax, eax |
||
589 | jnz .fail |
||
164 | serge | 590 | |
672 | hidnplayr | 591 | mov eax, [file_size] |
592 | cmp eax, 1024*1024*16 |
||
593 | ja .fail |
||
206 | serge | 594 | |
672 | hidnplayr | 595 | stdcall kernel_alloc, [file_size] |
596 | mov [file], eax |
||
164 | serge | 597 | |
672 | hidnplayr | 598 | stdcall read_file, [file_name], eax, dword 0, [file_size] |
599 | cmp ebx, [file_size] |
||
600 | jne .cleanup |
||
211 | serge | 601 | |
672 | hidnplayr | 602 | mov eax, [file] |
603 | cmp dword [eax], 0x4B43504B |
||
604 | jne .exit |
||
605 | mov ebx, [eax+4] |
||
606 | mov [file_size], ebx |
||
607 | stdcall kernel_alloc, ebx |
||
211 | serge | 608 | |
672 | hidnplayr | 609 | test eax, eax |
610 | jz .cleanup |
||
211 | serge | 611 | |
672 | hidnplayr | 612 | mov [file2], eax |
613 | stdcall unpack, [file], eax |
||
614 | stdcall kernel_free, [file] |
||
615 | mov eax, [file2] |
||
616 | mov ebx, [file_size] |
||
211 | serge | 617 | .exit: |
672 | hidnplayr | 618 | push eax |
619 | lea edi, [eax+ebx] ;cleanup remain space |
||
620 | mov ecx, 4096 ;from file end |
||
621 | and ebx, 4095 |
||
622 | jz @f |
||
623 | sub ecx, ebx |
||
624 | xor eax, eax |
||
625 | cld |
||
626 | rep stosb |
||
521 | diamond | 627 | @@: |
672 | hidnplayr | 628 | mov ebx, [file_size] |
629 | pop eax |
||
630 | pop edi |
||
631 | pop esi |
||
632 | ret |
||
188 | serge | 633 | .cleanup: |
672 | hidnplayr | 634 | stdcall kernel_free, [file] |
188 | serge | 635 | .fail: |
672 | hidnplayr | 636 | xor eax, eax |
637 | xor ebx, ebx |
||
638 | pop edi |
||
639 | pop esi |
||
640 | ret |
||
188 | serge | 641 | endp |
164 | serge | 642 | |
188 | serge | 643 | align 4 |
644 | proc get_proc_ex stdcall, proc_name:dword, imports:dword |
||
645 | |||
646 | .look_up: |
||
672 | hidnplayr | 647 | mov edx, [imports] |
648 | test edx, edx |
||
649 | jz .end |
||
650 | mov edx, [edx] |
||
651 | test edx, edx |
||
652 | jz .end |
||
188 | serge | 653 | .next: |
672 | hidnplayr | 654 | mov eax, [edx] |
655 | test eax, eax |
||
656 | jz .next_table |
||
164 | serge | 657 | |
672 | hidnplayr | 658 | push edx |
659 | stdcall strncmp, eax, [proc_name], 16 |
||
660 | pop edx |
||
661 | test eax, eax |
||
662 | jz .ok |
||
164 | serge | 663 | |
672 | hidnplayr | 664 | add edx,8 |
665 | jmp .next |
||
188 | serge | 666 | .next_table: |
672 | hidnplayr | 667 | add [imports], 4 |
668 | jmp .look_up |
||
188 | serge | 669 | .ok: |
672 | hidnplayr | 670 | mov eax, [edx+4] |
671 | ret |
||
188 | serge | 672 | .end: |
672 | hidnplayr | 673 | xor eax, eax |
674 | ret |
||
188 | serge | 675 | endp |
164 | serge | 676 | |
188 | serge | 677 | align 4 |
678 | proc fix_coff_symbols stdcall, sec:dword, symbols:dword,\ |
||
672 | hidnplayr | 679 | sym_count:dword, strings:dword, imports:dword |
680 | locals |
||
681 | retval dd ? |
||
682 | endl |
||
164 | serge | 683 | |
672 | hidnplayr | 684 | mov edi, [symbols] |
685 | mov [retval], 1 |
||
188 | serge | 686 | .fix: |
672 | hidnplayr | 687 | movzx ebx, [edi+CSYM.SectionNumber] |
688 | test ebx, ebx |
||
689 | jnz .internal |
||
690 | mov eax, dword [edi+CSYM.Name] |
||
691 | test eax, eax |
||
692 | jnz @F |
||
164 | serge | 693 | |
672 | hidnplayr | 694 | mov edi, [edi+4] |
695 | add edi, [strings] |
||
188 | serge | 696 | @@: |
672 | hidnplayr | 697 | push edi |
698 | stdcall get_proc_ex, edi,[imports] |
||
699 | pop edi |
||
164 | serge | 700 | |
672 | hidnplayr | 701 | xor ebx, ebx |
702 | test eax, eax |
||
703 | jnz @F |
||
164 | serge | 704 | |
672 | hidnplayr | 705 | mov esi, msg_unresolved |
706 | call sys_msg_board_str |
||
707 | mov esi, edi |
||
708 | call sys_msg_board_str |
||
709 | mov esi, msg_CR |
||
710 | call sys_msg_board_str |
||
164 | serge | 711 | |
672 | hidnplayr | 712 | mov [retval],0 |
188 | serge | 713 | @@: |
672 | hidnplayr | 714 | mov edi, [symbols] |
715 | mov [edi+CSYM.Value], eax |
||
716 | jmp .next |
||
188 | serge | 717 | .internal: |
672 | hidnplayr | 718 | cmp bx, -1 |
719 | je .next |
||
720 | cmp bx, -2 |
||
721 | je .next |
||
541 | serge | 722 | |
672 | hidnplayr | 723 | dec ebx |
724 | shl ebx, 3 |
||
725 | lea ebx, [ebx+ebx*4] |
||
726 | add ebx, [sec] |
||
188 | serge | 727 | |
672 | hidnplayr | 728 | mov eax, [ebx+CFS.VirtualAddress] |
729 | add [edi+CSYM.Value], eax |
||
188 | serge | 730 | .next: |
672 | hidnplayr | 731 | add edi, CSYM_SIZE |
732 | mov [symbols], edi |
||
733 | dec [sym_count] |
||
734 | jnz .fix |
||
735 | mov eax, [retval] |
||
736 | ret |
||
164 | serge | 737 | endp |
738 | |||
739 | align 4 |
||
188 | serge | 740 | proc fix_coff_relocs stdcall, coff:dword, sec:dword, sym:dword |
164 | serge | 741 | locals |
672 | hidnplayr | 742 | n_sec dd ? |
164 | serge | 743 | endl |
744 | |||
672 | hidnplayr | 745 | mov eax, [coff] |
746 | movzx ebx, [eax+CFH.nSections] |
||
747 | mov [n_sec], ebx |
||
188 | serge | 748 | .fix_sec: |
672 | hidnplayr | 749 | mov esi, [sec] |
164 | serge | 750 | mov edi, [esi+CFS.PtrReloc] |
672 | hidnplayr | 751 | add edi, [coff] |
164 | serge | 752 | |
672 | hidnplayr | 753 | movzx ecx, [esi+CFS.NumReloc] |
754 | test ecx, ecx |
||
755 | jz .next |
||
188 | serge | 756 | .next_reloc: |
164 | serge | 757 | mov ebx, [edi+CRELOC.SymIndex] |
758 | add ebx,ebx |
||
759 | lea ebx,[ebx+ebx*8] |
||
672 | hidnplayr | 760 | add ebx, [sym] |
164 | serge | 761 | |
672 | hidnplayr | 762 | mov edx, [ebx+CSYM.Value] |
164 | serge | 763 | |
672 | hidnplayr | 764 | cmp [edi+CRELOC.Type], 6 |
765 | je .dir_32 |
||
164 | serge | 766 | |
672 | hidnplayr | 767 | cmp [edi+CRELOC.Type], 20 |
768 | jne .next_reloc |
||
188 | serge | 769 | .rel_32: |
164 | serge | 770 | mov eax, [edi+CRELOC.VirtualAddress] |
672 | hidnplayr | 771 | add eax, [esi+CFS.VirtualAddress] |
772 | sub edx, eax |
||
773 | sub edx, 4 |
||
774 | jmp .fix |
||
188 | serge | 775 | .dir_32: |
776 | mov eax, [edi+CRELOC.VirtualAddress] |
||
672 | hidnplayr | 777 | add eax, [esi+CFS.VirtualAddress] |
188 | serge | 778 | .fix: |
672 | hidnplayr | 779 | add [eax], edx |
780 | add edi, 10 |
||
781 | dec ecx |
||
782 | jnz .next_reloc |
||
188 | serge | 783 | .next: |
672 | hidnplayr | 784 | add [sec], COFF_SECTION_SIZE |
785 | dec [n_sec] |
||
786 | jnz .fix_sec |
||
164 | serge | 787 | .exit: |
788 | ret |
||
789 | endp |
||
790 | |||
188 | serge | 791 | align 4 |
346 | diamond | 792 | proc load_driver stdcall, driver_name:dword |
672 | hidnplayr | 793 | locals |
794 | coff dd ? |
||
795 | sym dd ? |
||
796 | strings dd ? |
||
797 | img_size dd ? |
||
798 | img_base dd ? |
||
799 | start dd ? |
||
188 | serge | 800 | |
672 | hidnplayr | 801 | exports dd ? ;fake exports table |
802 | dd ? |
||
803 | file_name rb 13+16+4+1 ; '/sys/drivers/ |
||
804 | endl |
||
188 | serge | 805 | |
672 | hidnplayr | 806 | lea edx, [file_name] |
807 | mov dword [edx], '/sys' |
||
808 | mov dword [edx+4], '/dri' |
||
809 | mov dword [edx+8], 'vers' |
||
810 | mov byte [edx+12], '/' |
||
811 | mov esi, [driver_name] |
||
812 | lea edi, [edx+13] |
||
813 | mov ecx, 16 |
||
346 | diamond | 814 | @@: |
672 | hidnplayr | 815 | lodsb |
816 | test al, al |
||
817 | jz @f |
||
818 | stosb |
||
819 | loop @b |
||
346 | diamond | 820 | @@: |
672 | hidnplayr | 821 | mov dword [edi], '.obj' |
822 | mov byte [edi+4], 0 |
||
823 | stdcall load_file, edx |
||
214 | serge | 824 | |
672 | hidnplayr | 825 | test eax, eax |
826 | jz .exit |
||
188 | serge | 827 | |
672 | hidnplayr | 828 | mov [coff], eax |
188 | serge | 829 | |
672 | hidnplayr | 830 | movzx ecx, [eax+CFH.nSections] |
831 | xor ebx, ebx |
||
188 | serge | 832 | |
672 | hidnplayr | 833 | lea edx, [eax+20] |
188 | serge | 834 | @@: |
672 | hidnplayr | 835 | add ebx, [edx+CFS.SizeOfRawData] |
836 | add ebx, 15 |
||
837 | and ebx, not 15 |
||
838 | add edx, COFF_SECTION_SIZE |
||
839 | dec ecx |
||
840 | jnz @B |
||
841 | mov [img_size], ebx |
||
188 | serge | 842 | |
672 | hidnplayr | 843 | stdcall kernel_alloc, ebx |
844 | test eax, eax |
||
845 | jz .fail |
||
846 | mov [img_base], eax |
||
188 | serge | 847 | |
672 | hidnplayr | 848 | mov edi, eax |
849 | xor eax, eax |
||
850 | mov ecx, [img_size] |
||
851 | add ecx, 4095 |
||
852 | and ecx, not 4095 |
||
853 | shr ecx, 2 |
||
854 | cld |
||
855 | rep stosd |
||
188 | serge | 856 | |
672 | hidnplayr | 857 | mov edx, [coff] |
858 | movzx ebx, [edx+CFH.nSections] |
||
859 | mov edi, [img_base] |
||
860 | lea eax, [edx+20] |
||
188 | serge | 861 | @@: |
672 | hidnplayr | 862 | mov [eax+CFS.VirtualAddress], edi |
863 | mov esi, [eax+CFS.PtrRawData] |
||
864 | test esi, esi |
||
865 | jnz .copy |
||
866 | add edi, [eax+CFS.SizeOfRawData] |
||
867 | jmp .next |
||
188 | serge | 868 | .copy: |
672 | hidnplayr | 869 | add esi, edx |
870 | mov ecx, [eax+CFS.SizeOfRawData] |
||
871 | cld |
||
872 | rep movsb |
||
188 | serge | 873 | .next: |
672 | hidnplayr | 874 | add edi, 15 |
875 | and edi, not 15 |
||
876 | add eax, COFF_SECTION_SIZE |
||
877 | dec ebx |
||
878 | jnz @B |
||
188 | serge | 879 | |
672 | hidnplayr | 880 | mov ebx, [edx+CFH.pSymTable] |
881 | add ebx, edx |
||
882 | mov [sym], ebx |
||
883 | mov ecx, [edx+CFH.nSymbols] |
||
884 | add ecx,ecx |
||
885 | lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE |
||
886 | add ecx, [sym] |
||
887 | mov [strings], ecx |
||
188 | serge | 888 | |
672 | hidnplayr | 889 | lea ebx, [exports] |
890 | mov dword [ebx], kernel_export |
||
891 | mov dword [ebx+4], 0 |
||
892 | lea eax, [edx+20] |
||
188 | serge | 893 | |
672 | hidnplayr | 894 | stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\ |
895 | [strings], ebx |
||
896 | test eax, eax |
||
897 | jz .link_fail |
||
188 | serge | 898 | |
672 | hidnplayr | 899 | mov ebx, [coff] |
900 | add ebx, 20 |
||
901 | stdcall fix_coff_relocs, [coff], ebx, [sym] |
||
188 | serge | 902 | |
672 | hidnplayr | 903 | mov ebx, [coff] |
904 | stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szVersion |
||
905 | test eax, eax |
||
906 | jz .link_fail |
||
227 | serge | 907 | |
672 | hidnplayr | 908 | mov eax, [eax] |
909 | shr eax, 16 |
||
910 | cmp eax, DRV_COMPAT |
||
911 | jb .ver_fail |
||
227 | serge | 912 | |
672 | hidnplayr | 913 | cmp eax, DRV_CURRENT |
914 | ja .ver_fail |
||
227 | serge | 915 | |
672 | hidnplayr | 916 | mov ebx, [coff] |
917 | stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART |
||
918 | mov [start], eax |
||
188 | serge | 919 | |
672 | hidnplayr | 920 | stdcall kernel_free, [coff] |
188 | serge | 921 | |
672 | hidnplayr | 922 | mov ebx, [start] |
923 | stdcall ebx, DRV_ENTRY |
||
924 | test eax, eax |
||
925 | jnz .ok |
||
188 | serge | 926 | |
672 | hidnplayr | 927 | stdcall kernel_free, [img_base] |
928 | xor eax, eax |
||
929 | ret |
||
188 | serge | 930 | .ok: |
672 | hidnplayr | 931 | mov ebx, [img_base] |
932 | mov [eax+SRV.base], ebx |
||
933 | mov ecx, [start] |
||
934 | mov [eax+SRV.entry], ecx |
||
935 | ret |
||
227 | serge | 936 | |
937 | .ver_fail: |
||
672 | hidnplayr | 938 | mov esi, msg_CR |
939 | call sys_msg_board_str |
||
940 | mov esi, [driver_name] |
||
941 | call sys_msg_board_str |
||
942 | mov esi, msg_CR |
||
943 | call sys_msg_board_str |
||
944 | mov esi, msg_version |
||
945 | call sys_msg_board_str |
||
946 | mov esi, msg_www |
||
947 | call sys_msg_board_str |
||
948 | jmp .cleanup |
||
227 | serge | 949 | |
950 | .link_fail: |
||
672 | hidnplayr | 951 | mov esi, msg_module |
952 | call sys_msg_board_str |
||
953 | mov esi, [driver_name] |
||
954 | call sys_msg_board_str |
||
955 | mov esi, msg_CR |
||
956 | call sys_msg_board_str |
||
227 | serge | 957 | .cleanup: |
672 | hidnplayr | 958 | stdcall kernel_free,[img_base] |
188 | serge | 959 | .fail: |
672 | hidnplayr | 960 | stdcall kernel_free, [coff] |
227 | serge | 961 | .exit: |
672 | hidnplayr | 962 | xor eax, eax |
963 | ret |
||
164 | serge | 964 | endp |
965 | |||
198 | serge | 966 | align 4 |
967 | proc load_library stdcall, file_name:dword |
||
672 | hidnplayr | 968 | locals |
969 | coff dd ? |
||
970 | sym dd ? |
||
971 | strings dd ? |
||
972 | img_size dd ? |
||
973 | img_base dd ? |
||
974 | exports dd ? |
||
975 | endl |
||
198 | serge | 976 | |
672 | hidnplayr | 977 | cli |
198 | serge | 978 | |
672 | hidnplayr | 979 | stdcall load_file, [file_name] |
980 | test eax, eax |
||
981 | jz .fail |
||
198 | serge | 982 | |
672 | hidnplayr | 983 | mov [coff], eax |
984 | movzx ecx, [eax+CFH.nSections] |
||
985 | xor ebx, ebx |
||
198 | serge | 986 | |
672 | hidnplayr | 987 | lea edx, [eax+20] |
198 | serge | 988 | @@: |
672 | hidnplayr | 989 | add ebx, [edx+CFS.SizeOfRawData] |
990 | add ebx, 15 |
||
991 | and ebx, not 15 |
||
992 | add edx, COFF_SECTION_SIZE |
||
993 | dec ecx |
||
994 | jnz @B |
||
995 | mov [img_size], ebx |
||
198 | serge | 996 | |
672 | hidnplayr | 997 | call init_heap |
998 | stdcall user_alloc, [img_size] |
||
198 | serge | 999 | |
672 | hidnplayr | 1000 | test eax, eax |
1001 | jz .fail |
||
1002 | mov [img_base], eax |
||
198 | serge | 1003 | |
672 | hidnplayr | 1004 | mov edx, [coff] |
1005 | movzx ebx, [edx+CFH.nSections] |
||
1006 | mov edi, [img_base] |
||
1007 | lea eax, [edx+20] |
||
198 | serge | 1008 | @@: |
672 | hidnplayr | 1009 | mov [eax+CFS.VirtualAddress], edi |
1010 | mov esi, [eax+CFS.PtrRawData] |
||
1011 | test esi, esi |
||
1012 | jnz .copy |
||
1013 | add edi, [eax+CFS.SizeOfRawData] |
||
1014 | jmp .next |
||
198 | serge | 1015 | .copy: |
672 | hidnplayr | 1016 | add esi, edx |
465 | serge | 1017 | ; add edi, new_app_base |
672 | hidnplayr | 1018 | mov ecx, [eax+CFS.SizeOfRawData] |
1019 | cld |
||
1020 | rep movsb |
||
198 | serge | 1021 | .next: |
672 | hidnplayr | 1022 | add edi, 15 ;-new_app_base |
1023 | and edi, -16 |
||
1024 | add eax, COFF_SECTION_SIZE |
||
1025 | dec ebx |
||
1026 | jnz @B |
||
198 | serge | 1027 | |
672 | hidnplayr | 1028 | mov ebx, [edx+CFH.pSymTable] |
1029 | add ebx, edx |
||
1030 | mov [sym], ebx |
||
1031 | mov ecx, [edx+CFH.nSymbols] |
||
1032 | add ecx,ecx |
||
1033 | lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE |
||
1034 | add ecx, [sym] |
||
1035 | mov [strings], ecx |
||
198 | serge | 1036 | |
672 | hidnplayr | 1037 | lea eax, [edx+20] |
198 | serge | 1038 | |
672 | hidnplayr | 1039 | stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\ |
1040 | [strings], dword 0 |
||
1041 | test eax, eax |
||
1042 | jnz @F |
||
198 | serge | 1043 | |
1044 | @@: |
||
672 | hidnplayr | 1045 | mov edx, [coff] |
1046 | movzx ebx, [edx+CFH.nSections] |
||
1047 | mov edi, new_app_base |
||
1048 | lea eax, [edx+20] |
||
198 | serge | 1049 | @@: |
672 | hidnplayr | 1050 | add [eax+CFS.VirtualAddress], edi ;patch user space offset |
1051 | add eax, COFF_SECTION_SIZE |
||
1052 | dec ebx |
||
1053 | jnz @B |
||
198 | serge | 1054 | |
672 | hidnplayr | 1055 | add edx, 20 |
1056 | stdcall fix_coff_relocs, [coff], edx, [sym] |
||
198 | serge | 1057 | |
672 | hidnplayr | 1058 | mov ebx, [coff] |
1059 | stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szEXPORTS |
||
1060 | mov [exports], eax |
||
198 | serge | 1061 | |
672 | hidnplayr | 1062 | stdcall kernel_free, [coff] |
1063 | mov eax, [exports] |
||
1064 | ret |
||
198 | serge | 1065 | .fail: |
672 | hidnplayr | 1066 | xor eax, eax |
1067 | ret |
||
198 | serge | 1068 | endp |
1069 | |||
214 | serge | 1070 | align 4 |
1071 | proc stop_all_services |
||
278 | serge | 1072 | |
672 | hidnplayr | 1073 | mov edx, [srv.fd] |
214 | serge | 1074 | .next: |
672 | hidnplayr | 1075 | cmp edx, srv.fd-SRV_FD_OFFSET |
1076 | je .done |
||
1077 | cmp [edx+SRV.magic], ' SRV' |
||
1078 | jne .next |
||
1079 | cmp [edx+SRV.size], SRV_SIZE |
||
1080 | jne .next |
||
732 | serge | 1081 | |
769 | Rus | 1082 | mov ebx, [edx+SRV.entry] |
672 | hidnplayr | 1083 | mov edx, [edx+SRV.fd] |
769 | Rus | 1084 | test ebx, ebx |
1085 | jz .next |
||
732 | serge | 1086 | |
769 | Rus | 1087 | push edx |
672 | hidnplayr | 1088 | stdcall ebx, dword -1 |
1089 | pop edx |
||
1090 | jmp .next |
||
278 | serge | 1091 | .done: |
672 | hidnplayr | 1092 | ret |
214 | serge | 1093 | endp |
198 | serge | 1094 | |
281 | serge | 1095 | ; param |
291 | serge | 1096 | ; eax= size |
1097 | ; ebx= pid |
||
214 | serge | 1098 | |
281 | serge | 1099 | align 4 |
1100 | create_kernel_object: |
||
1101 | |||
672 | hidnplayr | 1102 | push ebx |
1103 | call malloc |
||
1104 | pop ebx |
||
1105 | test eax, eax |
||
1106 | jz .fail |
||
281 | serge | 1107 | |
672 | hidnplayr | 1108 | mov ecx,[current_slot] |
1109 | add ecx, APP_OBJ_OFFSET |
||
281 | serge | 1110 | |
672 | hidnplayr | 1111 | pushfd |
1112 | cli |
||
1113 | mov edx, [ecx+APPOBJ.fd] |
||
1114 | mov [eax+APPOBJ.fd], edx |
||
1115 | mov [eax+APPOBJ.bk], ecx |
||
1116 | mov [eax+APPOBJ.pid], ebx |
||
281 | serge | 1117 | |
672 | hidnplayr | 1118 | mov [ecx+APPOBJ.fd], eax |
1119 | mov [edx+APPOBJ.bk], eax |
||
1120 | popfd |
||
281 | serge | 1121 | .fail: |
672 | hidnplayr | 1122 | ret |
281 | serge | 1123 | |
1124 | ; param |
||
1125 | ; eax= object |
||
1126 | |||
1127 | align 4 |
||
1128 | destroy_kernel_object: |
||
1129 | |||
672 | hidnplayr | 1130 | pushfd |
1131 | cli |
||
1132 | mov ebx, [eax+APPOBJ.fd] |
||
1133 | mov ecx, [eax+APPOBJ.bk] |
||
1134 | mov [ebx+APPOBJ.bk], ecx |
||
1135 | mov [ecx+APPOBJ.fd], ebx |
||
1136 | popfd |
||
281 | serge | 1137 | |
672 | hidnplayr | 1138 | xor edx, edx ;clear common header |
1139 | mov [eax], edx |
||
1140 | mov [eax+4], edx |
||
1141 | mov [eax+8], edx |
||
1142 | mov [eax+12], edx |
||
1143 | mov [eax+16], edx |
||
281 | serge | 1144 | |
672 | hidnplayr | 1145 | call free ;release object memory |
1146 | ret |
||
281 | serge | 1147 | |
1148 | |||
164 | serge | 1149 | |
465 | serge | 1150 | if 0 |
164 | serge | 1151 | |
465 | serge | 1152 | irq: |
188 | serge | 1153 | |
465 | serge | 1154 | .irq0: |
672 | hidnplayr | 1155 | pusfd |
1156 | pushad |
||
1157 | push IRQ_0 |
||
1158 | jmp .master |
||
465 | serge | 1159 | .irq_1: |
672 | hidnplayr | 1160 | pusfd |
1161 | pushad |
||
1162 | push IRQ_1 |
||
1163 | jmp .master |
||
465 | serge | 1164 | |
1165 | .master: |
||
672 | hidnplayr | 1166 | mov ax, app_data |
1167 | mov ds, eax |
||
1168 | mov es, eax |
||
1169 | mov ebx, [esp+4] ;IRQ_xx |
||
1170 | mov eax, [irq_handlers+ebx+4] |
||
1171 | call intr_handler |
||
1172 | mov ecx, [esp+4] |
||
1173 | cmp [irq_actids+ecx*4], 0 |
||
1174 | je @F |
||
1175 | in al, 0x21 |
||
1176 | bts eax, ecx |
||
1177 | out 0x21, al |
||
1178 | mov al, 0x20 |
||
1179 | out 0x20, al |
||
1180 | jmp .restart |
||
465 | serge | 1181 | |
1182 | .slave: |
||
672 | hidnplayr | 1183 | mov ax, app_data |
1184 | mov ds, eax |
||
1185 | mov es, eax |
||
1186 | mov ebx, [esp+4] ;IRQ_xx |
||
1187 | mov eax, [irq_handlers+ebx+4] |
||
1188 | call intr_handler |
||
1189 | mov ecx, [esp+4] |
||
1190 | sub ecx, 8 |
||
1191 | cmp [irq_actids+ecx*4], 0 |
||
1192 | je @F |
||
1193 | in al, 0xA1 |
||
1194 | bts eax, ecx |
||
1195 | out 0xA1, al |
||
1196 | mov al, 0x20 |
||
1197 | out 0xA0, al |
||
1198 | out 0x20, al |
||
465 | serge | 1199 | .restart: |
672 | hidnplayr | 1200 | mov ebx, [next_slot] |
1201 | test ebx, ebx |
||
1202 | jz @F |
||
1203 | mov [next_task],0 |
||
1204 | mov esi, [prev_slot] |
||
1205 | call do_change_task |
||
1206 | add esp, 4 |
||
1207 | iretd |
||
465 | serge | 1208 | |
1209 | end if |
||
1210 |