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