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