Rev 321 | Rev 334 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 321 | Rev 329 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; MenuetOS process management, protected ring3 ;; |
3 | ;; MenuetOS process management, protected ring3 ;; |
4 | ;; ;; |
4 | ;; ;; |
5 | ;; Distributed under GPL. See file COPYING for details. ;; |
5 | ;; Distributed under GPL. See file COPYING for details. ;; |
6 | ;; Copyright 2003 Ville Turjanmaa ;; |
6 | ;; Copyright 2003 Ville Turjanmaa ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
9 | 9 | ||
10 | idtreg: |
10 | idtreg: |
11 | dw 8*0x41-1 |
11 | dw 8*0x41-1 |
12 | dd idts+8 |
12 | dd idts+8 |
13 | ;label idts at 0xB100-8 |
13 | ;label idts at 0xB100-8 |
14 | 14 | ||
15 | build_process_gdt_tss_pointer: |
15 | build_process_gdt_tss_pointer: |
16 | 16 | ||
17 | mov ecx,tss_data |
17 | mov ecx,tss_data |
18 | mov edi,0 |
18 | mov edi,0 |
19 | setgdtl2: |
19 | setgdtl2: |
20 | mov [edi+gdts+ tss0 +0], word tss_step |
20 | mov [edi+gdts+ tss0 +0], word tss_step |
21 | mov [edi+gdts+ tss0 +2], cx |
21 | mov [edi+gdts+ tss0 +2], cx |
22 | mov eax,ecx |
22 | mov eax,ecx |
23 | shr eax,16 |
23 | shr eax,16 |
24 | mov [edi+gdts+ tss0 +4], al |
24 | mov [edi+gdts+ tss0 +4], al |
25 | mov [edi+gdts+ tss0 +7], ah |
25 | mov [edi+gdts+ tss0 +7], ah |
26 | mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b |
26 | mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b |
27 | add ecx,tss_step |
27 | add ecx,tss_step |
28 | add edi,8 |
28 | add edi,8 |
29 | cmp edi,8*(max_processes+5) |
29 | cmp edi,8*(max_processes+5) |
30 | jbe setgdtl2 |
30 | jbe setgdtl2 |
31 | 31 | ||
32 | ret |
32 | ret |
33 | 33 | ||
34 | 34 | ||
35 | build_interrupt_table: |
35 | build_interrupt_table: |
36 | 36 | ||
37 | mov edi, idts+8 |
37 | mov edi, idts+8 |
38 | mov esi, sys_int |
38 | mov esi, sys_int |
39 | mov ecx, 0x40 |
39 | mov ecx, 0x40 |
40 | @@: |
40 | @@: |
41 | mov eax, [esi] |
41 | mov eax, [esi] |
42 | mov [edi], ax ; lower part of offset |
42 | mov [edi], ax ; lower part of offset |
43 | mov [edi+2], word os_code ; segment selector |
43 | mov [edi+2], word os_code ; segment selector |
44 | shr eax, 16 |
44 | shr eax, 16 |
45 | mov [edi+4], word 10001110b shl 8 ; interrupt descriptor |
45 | mov [edi+4], word 10001110b shl 8 ; interrupt descriptor |
46 | mov [edi+6], ax |
46 | mov [edi+6], ax |
47 | add esi, 4 |
47 | add esi, 4 |
48 | add edi, 8 |
48 | add edi, 8 |
49 | dec ecx |
49 | dec ecx |
50 | jnz @b |
50 | jnz @b |
51 | 51 | ||
52 | ;mov edi,8*0x40+idts+8 |
52 | ;mov edi,8*0x40+idts+8 |
53 | mov [edi + 0], word (i40 and ((1 shl 16)-1)) |
53 | mov [edi + 0], word (i40 and ((1 shl 16)-1)) |
54 | mov [edi + 2], word os_code |
54 | mov [edi + 2], word os_code |
55 | mov [edi + 4], word 11101110b*256 |
55 | mov [edi + 4], word 11101110b*256 |
56 | mov [edi + 6], word (i40 shr 16) |
56 | mov [edi + 6], word (i40 shr 16) |
57 | 57 | ||
58 | ret |
58 | ret |
59 | 59 | ||
60 | iglobal |
60 | iglobal |
61 | sys_int: |
61 | sys_int: |
62 | dd e0,debug_exc,e2,e3 |
62 | dd e0,debug_exc,e2,e3 |
63 | dd e4,e5,e6,e7 |
63 | dd e4,e5,e6,e7 |
64 | dd e8,e9,e10,e11 |
64 | dd e8,e9,e10,e11 |
65 | dd e12,e13,page_fault_handler,e15 |
65 | dd e12,e13,page_fault_handler,e15 |
66 | 66 | ||
67 | dd except_16, e17,e18, except_19 |
67 | dd except_16, e17,e18, except_19 |
68 | times 12 dd unknown_interrupt |
68 | times 12 dd unknown_interrupt |
69 | 69 | ||
70 | dd irq0 , irq_serv.irq_1, p_irq2 , p_irq3 ;irq_serv.irq_3 |
70 | dd irq0 , irq_serv.irq_1, p_irq2 , p_irq3 ;irq_serv.irq_3 |
71 | dd p_irq4 ,irq_serv.irq_5,p_irq6,irq_serv.irq_7 |
71 | dd p_irq4 ,irq_serv.irq_5,p_irq6,irq_serv.irq_7 |
72 | dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 |
72 | dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 |
73 | dd irq_serv.irq_11,p_irq12,irqD ,p_irq14,p_irq15 |
73 | dd irq_serv.irq_11,p_irq12,irqD ,p_irq14,p_irq15 |
74 | 74 | ||
75 | times 16 dd unknown_interrupt |
75 | times 16 dd unknown_interrupt |
76 | 76 | ||
77 | dd i40 |
77 | dd i40 |
78 | endg |
78 | endg |
79 | 79 | ||
80 | macro save_ring3_context |
80 | macro save_ring3_context |
81 | { |
81 | { |
82 | push ds es |
82 | push ds es |
83 | pushad |
83 | pushad |
84 | } |
84 | } |
85 | macro restore_ring3_context |
85 | macro restore_ring3_context |
86 | { |
86 | { |
87 | popad |
87 | popad |
88 | pop es ds |
88 | pop es ds |
89 | } |
89 | } |
90 | 90 | ||
91 | ; simply return control to interrupted process |
91 | ; simply return control to interrupted process |
92 | unknown_interrupt: |
92 | unknown_interrupt: |
93 | iret |
93 | iret |
94 | 94 | ||
95 | macro exc_wo_code [num] |
95 | macro exc_wo_code [num] |
96 | { |
96 | { |
97 | forward |
97 | forward |
98 | e#num : |
98 | e#num : |
99 | save_ring3_context |
99 | save_ring3_context |
100 | mov bl, num |
100 | mov bl, num |
101 | jmp exc_c |
101 | jmp exc_c |
102 | } |
102 | } |
103 | 103 | ||
104 | macro exc_w_code [num] |
104 | macro exc_w_code [num] |
105 | { |
105 | { |
106 | forward |
106 | forward |
107 | e#num : |
107 | e#num : |
108 | add esp, 4 |
108 | add esp, 4 |
109 | save_ring3_context |
109 | save_ring3_context |
110 | mov bl, num |
110 | mov bl, num |
111 | jmp exc_c |
111 | jmp exc_c |
112 | } |
112 | } |
113 | 113 | ||
114 | exc_wo_code 0, 1, 2, 3, 4, 5, 6, 9, 15, 18 |
114 | exc_wo_code 0, 1, 2, 3, 4, 5, 6, 9, 15, 18 |
115 | exc_w_code 8, 10, 11, 12, 13, 14, 17 |
115 | exc_w_code 8, 10, 11, 12, 13, 14, 17 |
116 | 116 | ||
117 | exc_c: |
117 | exc_c: |
118 | mov ax, os_data |
118 | mov ax, os_data |
119 | mov ds, ax |
119 | mov ds, ax |
120 | mov es, ax |
120 | mov es, ax |
121 | 121 | ||
122 | ; test if debugging |
122 | ; test if debugging |
123 | cli |
123 | cli |
124 | mov eax, [0x3000] |
124 | mov eax, [0x3000] |
125 | shl eax, 8 |
125 | shl eax, 8 |
126 | mov eax, [0x80000+eax+APPDATA.debugger_slot] |
126 | mov eax, [0x80000+eax+APPDATA.debugger_slot] |
127 | test eax, eax |
127 | test eax, eax |
128 | jnz .debug |
128 | jnz .debug |
129 | sti |
129 | sti |
130 | ; not debuggee => say error and terminate |
130 | ; not debuggee => say error and terminate |
131 | add esp, 28h |
131 | add esp, 28h |
132 | movzx eax, bl |
132 | movzx eax, bl |
133 | mov [error_interrupt], eax |
133 | mov [error_interrupt], eax |
134 | call show_error_parameters |
134 | call show_error_parameters |
135 | 135 | ||
136 | mov edx, [0x3010] |
136 | mov edx, [0x3010] |
137 | mov [edx + TASKDATA.state], byte 4 |
137 | mov [edx + TASKDATA.state], byte 4 |
138 | 138 | ||
139 | jmp change_task |
139 | jmp change_task |
140 | 140 | ||
141 | .debug: |
141 | .debug: |
142 | ; we are debugged process, notify debugger and suspend ourself |
142 | ; we are debugged process, notify debugger and suspend ourself |
143 | ; eax=debugger PID |
143 | ; eax=debugger PID |
144 | cld |
144 | cld |
145 | movzx ecx, bl |
145 | movzx ecx, bl |
146 | push ecx |
146 | push ecx |
147 | mov ecx, [0x3010] |
147 | mov ecx, [0x3010] |
148 | push dword [ecx+TASKDATA.pid] ; PID of current process |
148 | push dword [ecx+TASKDATA.pid] ; PID of current process |
149 | push 12 |
149 | push 12 |
150 | pop ecx |
150 | pop ecx |
151 | push 1 ; 1=exception |
151 | push 1 ; 1=exception |
152 | call debugger_notify |
152 | call debugger_notify |
153 | pop ecx |
153 | pop ecx |
154 | pop ecx |
154 | pop ecx |
155 | pop ecx |
155 | pop ecx |
156 | mov edx, [0x3010] |
156 | mov edx, [0x3010] |
157 | mov byte [edx+TASKDATA.state], 1 ; suspended |
157 | mov byte [edx+TASKDATA.state], 1 ; suspended |
158 | call change_task |
158 | call change_task |
159 | restore_ring3_context |
159 | restore_ring3_context |
160 | iretd |
160 | iretd |
161 | 161 | ||
162 | writehex: |
162 | writehex: |
163 | pusha |
163 | pusha |
164 | 164 | ||
165 | mov edi, [write_error_to] |
165 | mov edi, [write_error_to] |
166 | mov esi, 8 |
166 | mov esi, 8 |
167 | @@: |
167 | @@: |
168 | mov ecx, eax |
168 | mov ecx, eax |
169 | and ecx, 0xf |
169 | and ecx, 0xf |
170 | 170 | ||
171 | mov cl,[ecx+hexletters] |
171 | mov cl,[ecx+hexletters] |
172 | mov [edi],cl |
172 | mov [edi],cl |
173 | dec edi |
173 | dec edi |
174 | 174 | ||
175 | shr eax,4 |
175 | shr eax,4 |
176 | dec esi |
176 | dec esi |
177 | jnz @b |
177 | jnz @b |
178 | 178 | ||
179 | popa |
179 | popa |
180 | ret |
180 | ret |
181 | 181 | ||
182 | iglobal |
182 | iglobal |
183 | hexletters db '0123456789ABCDEF' |
183 | hexletters db '0123456789ABCDEF' |
184 | 184 | ||
185 | error_interrupt dd -1 |
185 | error_interrupt dd -1 |
186 | 186 | ||
187 | process_error db 'K : Process - forced terminate INT: 00000000',13,10,0 |
187 | process_error db 'K : Process - forced terminate INT: 00000000',13,10,0 |
188 | process_pid db 'K : Process - forced terminate PID: 00000000',13,10,0 |
188 | process_pid db 'K : Process - forced terminate PID: 00000000',13,10,0 |
189 | process_eip db 'K : Process - forced terminate EIP: 00000000',13,10,0 |
189 | process_eip db 'K : Process - forced terminate EIP: 00000000',13,10,0 |
190 | system_error db 'K : Kernel error',13,10,0 |
190 | system_error db 'K : Kernel error',13,10,0 |
191 | endg |
191 | endg |
192 | 192 | ||
193 | uglobal |
193 | uglobal |
194 | write_error_to dd 0x0 |
194 | write_error_to dd 0x0 |
195 | endg |
195 | endg |
196 | 196 | ||
197 | show_error_parameters: |
197 | show_error_parameters: |
198 | 198 | ||
199 | mov [write_error_to],process_pid+43 |
199 | mov [write_error_to],process_pid+43 |
200 | mov eax,[0x3000] |
200 | mov eax,[0x3000] |
201 | shl eax, 5 |
201 | shl eax, 5 |
202 | mov eax,[0x3000+TASKDATA.pid+eax] |
202 | mov eax,[0x3000+TASKDATA.pid+eax] |
203 | call writehex |
203 | call writehex |
204 | 204 | ||
205 | mov [write_error_to],process_error+43 |
205 | mov [write_error_to],process_error+43 |
206 | mov eax,[error_interrupt] |
206 | mov eax,[error_interrupt] |
207 | call writehex |
207 | call writehex |
208 | 208 | ||
209 | cmp dword [esp+4+4], os_code ; CS |
209 | cmp dword [esp+4+4], os_code ; CS |
210 | jnz @f |
210 | jnz @f |
211 | mov esi,system_error |
211 | mov esi,system_error |
212 | call sys_msg_board_str |
212 | call sys_msg_board_str |
213 | @@: |
213 | @@: |
214 | mov eax, [esp+4] ; EIP |
214 | mov eax, [esp+4] ; EIP |
215 | 215 | ||
216 | mov [write_error_to],process_eip+43 |
216 | mov [write_error_to],process_eip+43 |
217 | call writehex |
217 | call writehex |
218 | 218 | ||
219 | mov esi,process_error |
219 | mov esi,process_error |
220 | call sys_msg_board_str |
220 | call sys_msg_board_str |
221 | 221 | ||
222 | mov esi,process_pid |
222 | mov esi,process_pid |
223 | call sys_msg_board_str |
223 | call sys_msg_board_str |
224 | 224 | ||
225 | mov esi,process_eip |
225 | mov esi,process_eip |
226 | call sys_msg_board_str |
226 | call sys_msg_board_str |
227 | 227 | ||
228 | ret |
228 | ret |
229 | 229 | ||
230 | 230 | ||
231 | 231 | ||
232 | ; irq1 -> hid/keyboard.inc |
232 | ; irq1 -> hid/keyboard.inc |
233 | 233 | ||
234 | 234 | ||
235 | macro irqh [num] |
235 | macro irqh [num] |
236 | { |
236 | { |
237 | forward |
237 | forward |
238 | p_irq#num : |
238 | p_irq#num : |
239 | save_ring3_context |
239 | save_ring3_context |
240 | mov edi, num |
240 | mov edi, num |
241 | jmp irq_c |
241 | jmp irq_c |
242 | } |
242 | } |
243 | 243 | ||
244 | irqh 2,5,7,8,9,10,11 |
244 | irqh 2,5,7,8,9,10,11 |
245 | 245 | ||
246 | irq_c: |
246 | irq_c: |
247 | mov ax, os_data |
247 | mov ax, os_data |
248 | mov ds, ax |
248 | mov ds, ax |
249 | mov es, ax |
249 | mov es, ax |
250 | call irqhandler |
250 | call irqhandler |
251 | restore_ring3_context |
251 | restore_ring3_context |
252 | iret |
252 | iret |
253 | 253 | ||
254 | p_irq6: |
254 | p_irq6: |
255 | save_ring3_context |
255 | save_ring3_context |
256 | mov ax, os_data |
256 | mov ax, os_data |
257 | mov ds, ax |
257 | mov ds, ax |
258 | mov es, ax |
258 | mov es, ax |
259 | call fdc_irq |
259 | call fdc_irq |
260 | call ready_for_next_irq |
260 | call ready_for_next_irq |
261 | restore_ring3_context |
261 | restore_ring3_context |
262 | iret |
262 | iret |
263 | 263 | ||
264 | p_irq3: |
264 | p_irq3: |
265 | save_ring3_context |
265 | save_ring3_context |
266 | mov ax, os_data |
266 | mov ax, os_data |
267 | mov ds, ax |
267 | mov ds, ax |
268 | mov es, ax |
268 | mov es, ax |
269 | cmp [com2_mouse_detected],0 |
269 | cmp [com2_mouse_detected],0 |
270 | je old_irq3_handler |
270 | je old_irq3_handler |
271 | call check_mouse_data_com2 |
271 | call check_mouse_data_com2 |
272 | jmp p_irq3_1 |
272 | jmp p_irq3_1 |
273 | old_irq3_handler: |
273 | old_irq3_handler: |
274 | mov edi,3 |
274 | mov edi,3 |
275 | call irqhandler |
275 | call irqhandler |
276 | p_irq3_1: |
276 | p_irq3_1: |
277 | restore_ring3_context |
277 | restore_ring3_context |
278 | iret |
278 | iret |
279 | 279 | ||
280 | p_irq4: |
280 | p_irq4: |
281 | save_ring3_context |
281 | save_ring3_context |
282 | mov ax, os_data |
282 | mov ax, os_data |
283 | mov ds, ax |
283 | mov ds, ax |
284 | mov es, ax |
284 | mov es, ax |
285 | cmp [com1_mouse_detected],0 |
285 | cmp [com1_mouse_detected],0 |
286 | je old_irq4_handler |
286 | je old_irq4_handler |
287 | call check_mouse_data_com1 |
287 | call check_mouse_data_com1 |
288 | jmp p_irq4_1 |
288 | jmp p_irq4_1 |
289 | old_irq4_handler: |
289 | old_irq4_handler: |
290 | mov edi,4 |
290 | mov edi,4 |
291 | call irqhandler |
291 | call irqhandler |
292 | p_irq4_1: |
292 | p_irq4_1: |
293 | restore_ring3_context |
293 | restore_ring3_context |
294 | iret |
294 | iret |
295 | 295 | ||
296 | p_irq12: |
296 | p_irq12: |
297 | save_ring3_context |
297 | save_ring3_context |
298 | mov ax, os_data |
298 | mov ax, os_data |
299 | mov ds, ax |
299 | mov ds, ax |
300 | mov es, ax |
300 | mov es, ax |
301 | call check_mouse_data_ps2 |
301 | call check_mouse_data_ps2 |
302 | restore_ring3_context |
302 | restore_ring3_context |
303 | iret |
303 | iret |
304 | 304 | ||
305 | p_irq14: |
305 | p_irq14: |
306 | save_ring3_context |
306 | save_ring3_context |
307 | mov ax, os_data |
307 | mov ax, os_data |
308 | mov ds, ax |
308 | mov ds, ax |
309 | mov es, ax |
309 | mov es, ax |
310 | call [irq14_func] |
310 | call [irq14_func] |
311 | call ready_for_next_irq_1 |
311 | call ready_for_next_irq_1 |
312 | restore_ring3_context |
312 | restore_ring3_context |
313 | iret |
313 | iret |
314 | p_irq15: |
314 | p_irq15: |
315 | save_ring3_context |
315 | save_ring3_context |
316 | mov ax, os_data |
316 | mov ax, os_data |
317 | mov ds, ax |
317 | mov ds, ax |
318 | mov es, ax |
318 | mov es, ax |
319 | call [irq15_func] |
319 | call [irq15_func] |
320 | call ready_for_next_irq_1 |
320 | call ready_for_next_irq_1 |
321 | restore_ring3_context |
321 | restore_ring3_context |
322 | iret |
322 | iret |
323 | 323 | ||
324 | ready_for_next_irq: |
324 | ready_for_next_irq: |
325 | mov [check_idle_semaphore],5 |
325 | mov [check_idle_semaphore],5 |
326 | mov al, 0x20 |
326 | mov al, 0x20 |
327 | out 0x20, al |
327 | out 0x20, al |
328 | ret |
328 | ret |
329 | 329 | ||
330 | ready_for_next_irq_1: |
330 | ready_for_next_irq_1: |
331 | mov [check_idle_semaphore],5 |
331 | mov [check_idle_semaphore],5 |
332 | mov al, 0x20 |
332 | mov al, 0x20 |
333 | out 0xa0,al |
333 | out 0xa0,al |
334 | out 0x20, al |
334 | out 0x20, al |
335 | ret |
335 | ret |
336 | 336 | ||
337 | irqD: |
337 | irqD: |
338 | save_ring3_context |
338 | save_ring3_context |
339 | mov ax, os_data |
339 | mov ax, os_data |
340 | mov ds, ax |
340 | mov ds, ax |
341 | mov es, ax |
341 | mov es, ax |
342 | 342 | ||
343 | mov dx,0xf0 |
343 | mov dx,0xf0 |
344 | mov al,0 |
344 | mov al,0 |
345 | out dx,al |
345 | out dx,al |
346 | 346 | ||
347 | mov dx,0xa0 |
347 | mov dx,0xa0 |
348 | mov al,0x20 |
348 | mov al,0x20 |
349 | out dx,al |
349 | out dx,al |
350 | mov dx,0x20 |
350 | mov dx,0x20 |
351 | out dx,al |
351 | out dx,al |
352 | 352 | ||
353 | restore_ring3_context |
353 | restore_ring3_context |
354 | 354 | ||
355 | iret |
355 | iret |
356 | 356 | ||
357 | 357 | ||
358 | irqhandler: |
358 | irqhandler: |
359 | 359 | ||
360 | push edi |
360 | push edi |
361 | 361 | ||
362 | mov esi,edi ; 1 |
362 | mov esi,edi ; 1 |
363 | shl esi,6 ; 1 |
363 | shl esi,6 ; 1 |
364 | add esi,irq00read ; 1 |
364 | add esi,irq00read ; 1 |
365 | shl edi,12 ; 1 |
365 | shl edi,12 ; 1 |
366 | add edi,0x2E0000 |
366 | add edi,0x2E0000 |
367 | mov ecx,16 |
367 | mov ecx,16 |
368 | 368 | ||
369 | mov [check_idle_semaphore],5 |
369 | mov [check_idle_semaphore],5 |
370 | 370 | ||
371 | irqnewread: |
371 | irqnewread: |
372 | dec ecx |
372 | dec ecx |
373 | js irqover |
373 | js irqover |
374 | 374 | ||
375 | mov dx,[esi] ; 2+ |
375 | mov dx,[esi] ; 2+ |
376 | 376 | ||
377 | cmp dx,0 ; 1 |
377 | cmp dx,0 ; 1 |
378 | jz irqover |
378 | jz irqover |
379 | cmp [esi+3],byte 1 ; 2 ; byte read |
379 | cmp [esi+3],byte 1 ; 2 ; byte read |
380 | jne noirqbyte ; 4-11 |
380 | jne noirqbyte ; 4-11 |
381 | 381 | ||
382 | in al,dx |
382 | in al,dx |
383 | 383 | ||
384 | mov edx,[edi] |
384 | mov edx,[edi] |
385 | cmp edx,4000 |
385 | cmp edx,4000 |
386 | je irqfull |
386 | je irqfull |
387 | mov ebx,edi |
387 | mov ebx,edi |
388 | add ebx,0x10 |
388 | add ebx,0x10 |
389 | add ebx,edx |
389 | add ebx,edx |
390 | mov [ebx],al |
390 | mov [ebx],al |
391 | inc edx |
391 | inc edx |
392 | mov [edi],edx |
392 | mov [edi],edx |
393 | 393 | ||
394 | add esi,4 |
394 | add esi,4 |
395 | jmp irqnewread |
395 | jmp irqnewread |
396 | 396 | ||
397 | noirqbyte: |
397 | noirqbyte: |
398 | 398 | ||
399 | 399 | ||
400 | cmp [esi+3],byte 2 ; word read |
400 | cmp [esi+3],byte 2 ; word read |
401 | jne noirqword |
401 | jne noirqword |
402 | 402 | ||
403 | in ax,dx |
403 | in ax,dx |
404 | 404 | ||
405 | mov edx,[edi] |
405 | mov edx,[edi] |
406 | cmp edx,4000 |
406 | cmp edx,4000 |
407 | je irqfull |
407 | je irqfull |
408 | mov ebx,edi |
408 | mov ebx,edi |
409 | add ebx,0x10 |
409 | add ebx,0x10 |
410 | add ebx,edx |
410 | add ebx,edx |
411 | mov [ebx],ax |
411 | mov [ebx],ax |
412 | add edx,2 |
412 | add edx,2 |
413 | mov [edi],edx |
413 | mov [edi],edx |
414 | add esi,4 |
414 | add esi,4 |
415 | jmp irqnewread |
415 | jmp irqnewread |
416 | 416 | ||
417 | noirqword: |
417 | noirqword: |
418 | irqfull: |
418 | irqfull: |
419 | irqover: |
419 | irqover: |
420 | 420 | ||
421 | mov al,0x20 ; ready for next irq |
421 | mov al,0x20 ; ready for next irq |
422 | out 0x20,al |
422 | out 0x20,al |
423 | 423 | ||
424 | pop ebx |
424 | pop ebx |
425 | cmp ebx,7 |
425 | cmp ebx,7 |
426 | jbe noa0 |
426 | jbe noa0 |
427 | out 0xa0,al |
427 | out 0xa0,al |
428 | noa0: |
428 | noa0: |
429 | 429 | ||
430 | ret |
430 | ret |
431 | 431 | ||
432 | 432 | ||
433 | 433 | ||
434 | set_application_table_status: |
434 | set_application_table_status: |
435 | push eax |
435 | push eax |
436 | 436 | ||
437 | mov eax,[0x3000] |
437 | mov eax,[0x3000] |
438 | shl eax, 5 |
438 | shl eax, 5 |
439 | add eax,0x3000+TASKDATA.pid |
439 | add eax,0x3000+TASKDATA.pid |
440 | mov eax,[eax] |
440 | mov eax,[eax] |
441 | 441 | ||
442 | mov [application_table_status],eax |
442 | mov [application_table_status],eax |
443 | 443 | ||
444 | pop eax |
444 | pop eax |
445 | 445 | ||
446 | ret |
446 | ret |
447 | 447 | ||
448 | 448 | ||
449 | clear_application_table_status: |
449 | clear_application_table_status: |
450 | push eax |
450 | push eax |
451 | 451 | ||
452 | mov eax,[0x3000] |
452 | mov eax,[0x3000] |
453 | shl eax, 5 |
453 | shl eax, 5 |
454 | add eax,0x3000+TASKDATA.pid |
454 | add eax,0x3000+TASKDATA.pid |
455 | mov eax,[eax] |
455 | mov eax,[eax] |
456 | 456 | ||
457 | cmp eax,[application_table_status] |
457 | cmp eax,[application_table_status] |
458 | jne apptsl1 |
458 | jne apptsl1 |
459 | mov [application_table_status],0 |
459 | mov [application_table_status],0 |
460 | apptsl1: |
460 | apptsl1: |
461 | 461 | ||
462 | pop eax |
462 | pop eax |
463 | 463 | ||
464 | ret |
464 | ret |
465 | 465 | ||
466 | 466 | ||
467 | 467 | ||
468 | sys_resize_app_memory: |
468 | sys_resize_app_memory: |
469 | ; eax = 1 - resize |
469 | ; eax = 1 - resize |
470 | ; ebx = new amount of memory |
470 | ; ebx = new amount of memory |
471 | 471 | ||
472 | cmp eax,1 |
472 | cmp eax,1 |
473 | jne .no_application_mem_resize |
473 | jne .no_application_mem_resize |
474 | 474 | ||
475 | stdcall new_mem_resize, ebx |
475 | stdcall new_mem_resize, ebx |
476 | mov [esp+36], eax |
476 | mov [esp+36], eax |
477 | ret |
477 | ret |
478 | 478 | ||
479 | .no_application_mem_resize: |
479 | .no_application_mem_resize: |
480 | ret |
480 | ret |
481 | 481 | ||
482 | if 0 |
482 | if 0 |
483 | get_app_params: |
483 | get_app_params: |
484 | 484 | ||
485 | push eax |
485 | push eax |
486 | 486 | ||
487 | cmp [0x90000+6],word '00' |
487 | cmp [0x90000+6],word '00' |
488 | jne no_00_header |
488 | jne no_00_header |
489 | 489 | ||
490 | mov eax,[0x90000+12] |
490 | mov eax,[0x90000+12] |
491 | mov [app_start],eax |
491 | mov [app_start],eax |
492 | mov eax,[0x90000+16] |
492 | mov eax,[0x90000+16] |
493 | mov [app_i_end],eax |
493 | mov [app_i_end],eax |
494 | mov eax,[0x90000+20] |
494 | mov eax,[0x90000+20] |
495 | mov [app_mem],eax |
495 | mov [app_mem],eax |
496 | ; \begin{diamond}[20.08.2006] |
496 | ; \begin{diamond}[20.08.2006] |
497 | ; sanity check (functions 19,58 load app_i_end bytes and that must |
497 | ; sanity check (functions 19,58 load app_i_end bytes and that must |
498 | ; fit in allocated memory to prevent kernel faults) |
498 | ; fit in allocated memory to prevent kernel faults) |
499 | cmp eax,[app_i_end] |
499 | cmp eax,[app_i_end] |
500 | jb no_01_header |
500 | jb no_01_header |
501 | ; \end{diamond}[20.08.2006] |
501 | ; \end{diamond}[20.08.2006] |
502 | shr eax,1 |
502 | shr eax,1 |
503 | sub eax,0x10 |
503 | sub eax,0x10 |
504 | mov [app_esp],eax |
504 | mov [app_esp],eax |
505 | mov eax,[0x90000+24] |
505 | mov eax,[0x90000+24] |
506 | mov [app_i_param],eax |
506 | mov [app_i_param],eax |
507 | mov [app_i_icon],dword 0 |
507 | mov [app_i_icon],dword 0 |
508 | 508 | ||
509 | pop eax |
509 | pop eax |
510 | clc |
510 | clc |
511 | ret |
511 | ret |
512 | 512 | ||
513 | no_00_header: |
513 | no_00_header: |
514 | 514 | ||
515 | 515 | ||
516 | cmp [0x90000+6],word '01' |
516 | cmp [0x90000+6],word '01' |
517 | jne no_01_header |
517 | jne no_01_header |
518 | 518 | ||
519 | mov eax,[0x90000+12] |
519 | mov eax,[0x90000+12] |
520 | mov [app_start],eax |
520 | mov [app_start],eax |
521 | mov eax,[0x90000+16] |
521 | mov eax,[0x90000+16] |
522 | mov [app_i_end],eax |
522 | mov [app_i_end],eax |
523 | mov eax,[0x90000+20] |
523 | mov eax,[0x90000+20] |
524 | mov [app_mem],eax |
524 | mov [app_mem],eax |
525 | ; \begin{diamond}[20.08.2006] |
525 | ; \begin{diamond}[20.08.2006] |
526 | cmp eax,[app_i_end] |
526 | cmp eax,[app_i_end] |
527 | jb no_01_header |
527 | jb no_01_header |
528 | ; \end{diamond}[20.08.2006] |
528 | ; \end{diamond}[20.08.2006] |
529 | mov eax,[0x90000+24] |
529 | mov eax,[0x90000+24] |
530 | mov [app_esp],eax |
530 | mov [app_esp],eax |
531 | mov eax,[0x90000+28] |
531 | mov eax,[0x90000+28] |
532 | mov [app_i_param],eax |
532 | mov [app_i_param],eax |
533 | mov eax,[0x90000+32] |
533 | mov eax,[0x90000+32] |
534 | mov [app_i_icon],eax |
534 | mov [app_i_icon],eax |
535 | 535 | ||
536 | pop eax |
536 | pop eax |
537 | clc |
537 | clc |
538 | ret |
538 | ret |
539 | 539 | ||
540 | no_01_header: |
540 | no_01_header: |
541 | 541 | ||
542 | pop eax |
542 | pop eax |
543 | stc |
543 | stc |
544 | ret |
544 | ret |
- | 545 | ||
- | 546 | uglobal |
|
- | 547 | new_process_place dd 0x0 |
|
- | 548 | app_start dd 0x0 |
|
- | 549 | app_i_end dd 0x0 |
|
- | 550 | app_mem dd 0x0 |
|
- | 551 | app_esp dd 0x0 |
|
- | 552 | app_i_param dd 0x0 |
|
- | 553 | app_i_icon dd 0x0 |
|
545 | 554 | app_mem_pos dd 0x0 |
|
- | 555 | endg |
|
546 | end if |
- | |
547 | - | ||
548 | - | ||
549 | ;uglobal |
- | |
550 | ; new_process_place dd 0x0 |
- | |
551 | ; app_start dd 0x0 |
- | |
552 | ; app_i_end dd 0x0 |
- | |
553 | ; app_mem dd 0x0 |
- | |
554 | ; app_esp dd 0x0 |
- | |
555 | ; app_i_param dd 0x0 |
- | |
556 | ; app_i_icon dd 0x0 |
556 | |
557 | ; app_mem_pos dd 0x0 |
557 | end if |
558 | ;endg |
558 | |
559 | 559 | ||
560 | sys_threads: |
560 | sys_threads: |
561 | 561 | ||
562 | ; eax=1 create thread |
562 | ; eax=1 create thread |
563 | ; |
563 | ; |
564 | ; ebx=thread start |
564 | ; ebx=thread start |
565 | ; ecx=thread stack value |
565 | ; ecx=thread stack value |
566 | ; |
566 | ; |
567 | ; on return : eax = pid |
567 | ; on return : eax = pid |
568 | jmp new_sys_threads |
568 | jmp new_sys_threads |
569 | 569 | ||
570 | iglobal |
570 | iglobal |
571 | process_terminating db 'K : Process - terminating',13,10,0 |
571 | process_terminating db 'K : Process - terminating',13,10,0 |
572 | process_terminated db 'K : Process - done',13,10,0 |
572 | process_terminated db 'K : Process - done',13,10,0 |
- | 573 | msg_obj_destroy db 'K : destroy app object',13,10,0 |
|
573 | endg |
574 | endg |
- | 575 | ||
- | 576 | ; param |
|
574 | 577 | ; esi= slot |
|
- | 578 | ||
- | 579 | terminate: ; terminate application |
|
- | 580 | ||
575 | 581 | .slot equ esp ;locals |
|
576 | terminate: ; terminate application |
582 | |
577 | push esi |
583 | push esi ;save .slot |
578 | mov esi,process_terminating |
- | |
579 | call sys_msg_board_str |
- | |
580 | pop esi |
584 | mov esi,process_terminating |
581 | 585 | call sys_msg_board_str |
|
582 | @@: |
586 | @@: |
583 | cli |
587 | cli |
584 | cmp [application_table_status],0 |
588 | cmp [application_table_status],0 |
585 | je term9 |
589 | je term9 |
586 | sti |
590 | sti |
587 | call change_task |
591 | call change_task |
588 | jmp @b |
592 | jmp @b |
589 | term9: |
593 | term9: |
590 | - | ||
591 | call set_application_table_status |
594 | call set_application_table_status |
- | 595 | ||
- | 596 | mov esi, [.slot] |
|
- | 597 | shl esi,8 |
|
- | 598 | add esi, PROC_BASE+APP_OBJ_OFFSET |
|
- | 599 | @@: |
|
592 | 600 | mov eax, [esi+APPOBJ.fd] |
|
- | 601 | cmp eax, esi |
|
593 | mov eax,esi |
602 | je @F |
- | 603 | ||
- | 604 | push esi |
|
- | 605 | call [eax+APPOBJ.destroy] |
|
- | 606 | mov esi, msg_obj_destroy |
|
- | 607 | call sys_msg_board_str |
|
- | 608 | pop esi |
|
- | 609 | jmp @B |
|
594 | 610 | @@: |
|
595 | pushad |
611 | mov eax, [.slot] |
596 | shl eax,8 |
612 | shl eax, 8 |
597 | mov eax,[PROC_BASE+eax+0xB8] |
- | |
- | 613 | mov eax,[PROC_BASE+eax+APPDATA.dir_table] |
|
- | 614 | stdcall destroy_app_space, eax |
|
598 | stdcall destroy_app_space, eax |
615 | |
599 | popad |
616 | ;; mov esi, [.slot] |
600 | 617 | pop esi ;restore stack |
|
601 | cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
618 | cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
602 | jne fpu_ok_1 |
619 | jne fpu_ok_1 |
603 | 620 | ||
604 | mov [fpu_owner],1 |
621 | mov [fpu_owner],1 |
605 | mov eax, [256+PROC_BASE+0x10] |
622 | mov eax, [256+PROC_BASE+APPDATA.fpu_state] |
606 | bt [cpu_caps], CAPS_SSE |
623 | bt [cpu_caps], CAPS_SSE |
- | 624 | clts |
|
607 | jnc .no_SSE |
625 | jnc .no_SSE |
608 | fxrstor [eax] |
626 | fxrstor [eax] |
609 | jmp fpu_ok_1 |
627 | jmp fpu_ok_1 |
610 | .no_SSE: |
628 | .no_SSE: |
611 | fnclex |
629 | fnclex |
612 | frstor [eax] |
630 | frstor [eax] |
613 | fpu_ok_1: |
631 | fpu_ok_1: |
614 | 632 | ||
615 | mov [0xf400],byte 0 ; empty keyboard buffer |
633 | mov [0xf400],byte 0 ; empty keyboard buffer |
616 | mov [0xf500],byte 0 ; empty button buffer |
634 | mov [0xf500],byte 0 ; empty button buffer |
617 | 635 | ||
618 | 636 | ||
619 | ; remove defined hotkeys |
637 | ; remove defined hotkeys |
620 | mov eax, hotkey_list |
638 | mov eax, hotkey_list |
621 | .loop: |
639 | .loop: |
622 | cmp [eax+8], esi |
640 | cmp [eax+8], esi |
623 | jnz .cont |
641 | jnz .cont |
624 | mov ecx, [eax] |
642 | mov ecx, [eax] |
625 | jecxz @f |
643 | jecxz @f |
626 | push dword [eax+12] |
644 | push dword [eax+12] |
627 | pop dword [ecx+12] |
645 | pop dword [ecx+12] |
628 | @@: |
646 | @@: |
629 | mov ecx, [eax+12] |
647 | mov ecx, [eax+12] |
630 | push dword [eax] |
648 | push dword [eax] |
631 | pop dword [ecx] |
649 | pop dword [ecx] |
632 | xor ecx, ecx |
650 | xor ecx, ecx |
633 | mov [eax], ecx |
651 | mov [eax], ecx |
634 | mov [eax+4], ecx |
652 | mov [eax+4], ecx |
635 | mov [eax+8], ecx |
653 | mov [eax+8], ecx |
636 | mov [eax+12], ecx |
654 | mov [eax+12], ecx |
637 | .cont: |
655 | .cont: |
638 | add eax, 16 |
656 | add eax, 16 |
639 | cmp eax, hotkey_list+256*16 |
657 | cmp eax, hotkey_list+256*16 |
640 | jb .loop |
658 | jb .loop |
641 | ; remove hotkeys in buffer |
659 | ; remove hotkeys in buffer |
642 | mov eax, hotkey_buffer |
660 | mov eax, hotkey_buffer |
643 | .loop2: |
661 | .loop2: |
644 | cmp [eax], esi |
662 | cmp [eax], esi |
645 | jnz .cont2 |
663 | jnz .cont2 |
646 | and dword [eax+4], 0 |
664 | and dword [eax+4], 0 |
647 | and dword [eax], 0 |
665 | and dword [eax], 0 |
648 | .cont2: |
666 | .cont2: |
649 | add eax, 8 |
667 | add eax, 8 |
650 | cmp eax, hotkey_buffer+120*8 |
668 | cmp eax, hotkey_buffer+120*8 |
651 | jb .loop2 |
669 | jb .loop2 |
652 | 670 | ||
653 | mov ecx,esi ; remove buttons |
671 | mov ecx,esi ; remove buttons |
654 | bnewba2: |
672 | bnewba2: |
655 | mov edi,[0xfe88] |
673 | mov edi,[0xfe88] |
656 | mov eax,edi |
674 | mov eax,edi |
657 | cld |
675 | cld |
658 | movzx ebx,word [edi] |
676 | movzx ebx,word [edi] |
659 | inc bx |
677 | inc bx |
660 | bnewba: |
678 | bnewba: |
661 | dec bx |
679 | dec bx |
662 | jz bnmba |
680 | jz bnmba |
663 | add eax,0x10 |
681 | add eax,0x10 |
664 | cmp cx,[eax] |
682 | cmp cx,[eax] |
665 | jnz bnewba |
683 | jnz bnewba |
666 | pusha |
684 | pusha |
667 | mov ecx,ebx |
685 | mov ecx,ebx |
668 | inc ecx |
686 | inc ecx |
669 | shl ecx,4 |
687 | shl ecx,4 |
670 | mov ebx,eax |
688 | mov ebx,eax |
671 | add eax,0x10 |
689 | add eax,0x10 |
672 | call memmove |
690 | call memmove |
673 | dec dword [edi] |
691 | dec dword [edi] |
674 | popa |
692 | popa |
675 | jmp bnewba2 |
693 | jmp bnewba2 |
676 | bnmba: |
694 | bnmba: |
677 | 695 | ||
678 | pusha ; save window coordinates for window restoring |
696 | pusha ; save window coordinates for window restoring |
679 | cld |
697 | cld |
680 | shl esi,5 |
698 | shl esi,5 |
681 | add esi,window_data |
699 | add esi,window_data |
682 | mov eax,[esi+WDATA.box.left] |
700 | mov eax,[esi+WDATA.box.left] |
683 | mov [dlx],eax |
701 | mov [dlx],eax |
684 | add eax,[esi+WDATA.box.width] |
702 | add eax,[esi+WDATA.box.width] |
685 | mov [dlxe],eax |
703 | mov [dlxe],eax |
686 | mov eax,[esi+WDATA.box.top] |
704 | mov eax,[esi+WDATA.box.top] |
687 | mov [dly],eax |
705 | mov [dly],eax |
688 | add eax,[esi+WDATA.box.height] |
706 | add eax,[esi+WDATA.box.height] |
689 | mov [dlye],eax |
707 | mov [dlye],eax |
690 | 708 | ||
691 | xor eax, eax |
709 | xor eax, eax |
692 | mov [esi+WDATA.box.left],eax |
710 | mov [esi+WDATA.box.left],eax |
693 | mov [esi+WDATA.box.width],eax |
711 | mov [esi+WDATA.box.width],eax |
694 | mov [esi+WDATA.box.top],eax |
712 | mov [esi+WDATA.box.top],eax |
695 | mov [esi+WDATA.box.height],eax |
713 | mov [esi+WDATA.box.height],eax |
696 | mov [esi+WDATA.cl_workarea],eax |
714 | mov [esi+WDATA.cl_workarea],eax |
697 | mov [esi+WDATA.cl_titlebar],eax |
715 | mov [esi+WDATA.cl_titlebar],eax |
698 | mov [esi+WDATA.cl_frames],eax |
716 | mov [esi+WDATA.cl_frames],eax |
699 | mov dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn |
717 | mov dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn |
700 | lea edi, [esi-window_data+draw_data] |
718 | lea edi, [esi-window_data+draw_data] |
701 | mov ecx,32/4 |
719 | mov ecx,32/4 |
702 | rep stosd |
720 | rep stosd |
703 | popa |
721 | popa |
704 | 722 | ||
705 | ; debuggee test |
723 | ; debuggee test |
706 | pushad |
724 | pushad |
707 | mov edi, esi |
725 | mov edi, esi |
708 | shl edi, 5 |
726 | shl edi, 5 |
709 | mov eax, [0x80000+edi*8+APPDATA.debugger_slot] |
727 | mov eax, [0x80000+edi*8+APPDATA.debugger_slot] |
710 | test eax, eax |
728 | test eax, eax |
711 | jz .nodebug |
729 | jz .nodebug |
712 | push 8 |
730 | push 8 |
713 | pop ecx |
731 | pop ecx |
714 | push dword [0x3000+edi+TASKDATA.pid] ; PID |
732 | push dword [0x3000+edi+TASKDATA.pid] ; PID |
715 | push 2 |
733 | push 2 |
716 | call debugger_notify |
734 | call debugger_notify |
717 | pop ecx |
735 | pop ecx |
718 | pop ecx |
736 | pop ecx |
719 | .nodebug: |
737 | .nodebug: |
720 | popad |
738 | popad |
721 | 739 | ||
722 | pusha ; at 0x80000+ |
740 | pusha ; at 0x80000+ |
723 | mov edi,esi |
741 | mov edi,esi |
724 | shl edi,8 |
742 | shl edi,8 |
725 | add edi,0x80000 |
743 | add edi,0x80000 |
726 | mov ecx,256/4 |
744 | mov ecx,256/4 |
727 | xor eax, eax |
745 | xor eax, eax |
728 | rep stosd |
746 | rep stosd |
729 | popa |
747 | popa |
730 | 748 | ||
731 | pusha ; name to spaces |
749 | pusha ; name to spaces |
732 | mov edi,esi |
750 | mov edi,esi |
733 | shl edi,8 |
751 | shl edi,8 |
734 | add edi,0x80000+APPDATA.app_name |
752 | add edi,0x80000+APPDATA.app_name |
735 | mov ecx,11 |
753 | mov ecx,11 |
736 | mov eax,' ' |
754 | mov eax,' ' |
737 | rep stosb |
755 | rep stosb |
738 | popa |
756 | popa |
739 | 757 | ||
740 | 758 | ||
741 | ; activate window |
759 | ; activate window |
742 | movzx eax, word [0xC000 + esi*2] |
760 | movzx eax, word [0xC000 + esi*2] |
743 | cmp eax, [0x3004] |
761 | cmp eax, [0x3004] |
744 | jne .dont_activate |
762 | jne .dont_activate |
745 | pushad |
763 | pushad |
746 | .check_next_window: |
764 | .check_next_window: |
747 | dec eax |
765 | dec eax |
748 | cmp eax, 1 |
766 | cmp eax, 1 |
749 | jbe .nothing_to_activate |
767 | jbe .nothing_to_activate |
750 | lea esi, [0xc400+eax*2] |
768 | lea esi, [0xc400+eax*2] |
751 | movzx edi, word [esi] ; edi = process |
769 | movzx edi, word [esi] ; edi = process |
752 | shl edi, 5 |
770 | shl edi, 5 |
753 | cmp [0x3000 + edi + TASKDATA.state], byte 9 ; skip dead slots |
771 | cmp [0x3000 + edi + TASKDATA.state], byte 9 ; skip dead slots |
754 | je .check_next_window |
772 | je .check_next_window |
755 | add edi, window_data |
773 | add edi, window_data |
756 | ; \begin{diamond}[19.09.2006] |
774 | ; \begin{diamond}[19.09.2006] |
757 | ; skip minimized windows |
775 | ; skip minimized windows |
758 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
776 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
759 | jnz .check_next_window |
777 | jnz .check_next_window |
760 | ; \end{diamond} |
778 | ; \end{diamond} |
761 | call waredraw |
779 | call waredraw |
762 | .nothing_to_activate: |
780 | .nothing_to_activate: |
763 | popad |
781 | popad |
764 | .dont_activate: |
782 | .dont_activate: |
765 | 783 | ||
766 | push esi ; remove hd1 & cd & flp reservation |
784 | push esi ; remove hd1 & cd & flp reservation |
767 | shl esi, 5 |
785 | shl esi, 5 |
768 | mov esi, [esi+0x3000+TASKDATA.pid] |
786 | mov esi, [esi+0x3000+TASKDATA.pid] |
769 | cmp [hd1_status], esi |
787 | cmp [hd1_status], esi |
770 | jnz @f |
788 | jnz @f |
771 | call free_hd_channel |
789 | call free_hd_channel |
772 | mov [hd1_status], 0 |
790 | mov [hd1_status], 0 |
773 | @@: |
791 | @@: |
774 | cmp [cd_status], esi |
792 | cmp [cd_status], esi |
775 | jnz @f |
793 | jnz @f |
776 | call free_cd_channel |
794 | call free_cd_channel |
777 | mov [cd_status], 0 |
795 | mov [cd_status], 0 |
778 | @@: |
796 | @@: |
779 | cmp [flp_status], esi |
797 | cmp [flp_status], esi |
780 | jnz @f |
798 | jnz @f |
781 | mov [flp_status], 0 |
799 | mov [flp_status], 0 |
782 | @@: |
800 | @@: |
783 | pop esi |
801 | pop esi |
784 | 802 | ||
785 | pusha ; remove all irq reservations |
803 | pusha ; remove all irq reservations |
786 | mov eax,esi |
804 | mov eax,esi |
787 | shl eax, 5 |
805 | shl eax, 5 |
788 | mov eax,[eax+0x3000+TASKDATA.pid] |
806 | mov eax,[eax+0x3000+TASKDATA.pid] |
789 | mov edi,irq_owner |
807 | mov edi,irq_owner |
790 | mov ecx,16 |
808 | mov ecx,16 |
791 | newirqfree: |
809 | newirqfree: |
792 | scasd |
810 | scasd |
793 | jne nofreeirq |
811 | jne nofreeirq |
794 | mov [edi-4],dword 0 |
812 | mov [edi-4],dword 0 |
795 | nofreeirq: |
813 | nofreeirq: |
796 | loop newirqfree |
814 | loop newirqfree |
797 | popa |
815 | popa |
798 | 816 | ||
799 | 817 | ||
800 | pusha ; remove all port reservations |
818 | pusha ; remove all port reservations |
801 | mov edx,esi |
819 | mov edx,esi |
802 | shl edx, 5 |
820 | shl edx, 5 |
803 | add edx,0x3000 |
821 | add edx,0x3000 |
804 | mov edx,[edx+TASKDATA.pid] |
822 | mov edx,[edx+TASKDATA.pid] |
805 | 823 | ||
806 | rmpr0: |
824 | rmpr0: |
807 | 825 | ||
808 | mov esi,[0x2d0000] |
826 | mov esi,[0x2d0000] |
809 | 827 | ||
810 | cmp esi,0 |
828 | cmp esi,0 |
811 | je rmpr9 |
829 | je rmpr9 |
812 | 830 | ||
813 | rmpr3: |
831 | rmpr3: |
814 | 832 | ||
815 | mov edi,esi |
833 | mov edi,esi |
816 | shl edi,4 |
834 | shl edi,4 |
817 | add edi,0x2d0000 |
835 | add edi,0x2d0000 |
818 | 836 | ||
819 | cmp edx,[edi] |
837 | cmp edx,[edi] |
820 | je rmpr4 |
838 | je rmpr4 |
821 | 839 | ||
822 | dec esi |
840 | dec esi |
823 | jnz rmpr3 |
841 | jnz rmpr3 |
824 | 842 | ||
825 | jmp rmpr9 |
843 | jmp rmpr9 |
826 | 844 | ||
827 | rmpr4: |
845 | rmpr4: |
828 | 846 | ||
829 | mov ecx,256 |
847 | mov ecx,256 |
830 | sub ecx,esi |
848 | sub ecx,esi |
831 | shl ecx,4 |
849 | shl ecx,4 |
832 | 850 | ||
833 | mov esi,edi |
851 | mov esi,edi |
834 | add esi,16 |
852 | add esi,16 |
835 | cld |
853 | cld |
836 | rep movsb |
854 | rep movsb |
837 | 855 | ||
838 | dec dword [0x2d0000] |
856 | dec dword [0x2d0000] |
839 | 857 | ||
840 | jmp rmpr0 |
858 | jmp rmpr0 |
841 | 859 | ||
842 | rmpr9: |
860 | rmpr9: |
843 | 861 | ||
844 | popa |
862 | popa |
845 | mov edi,esi ; do not run this process slot |
863 | mov edi,esi ; do not run this process slot |
846 | shl edi, 5 |
864 | shl edi, 5 |
847 | mov [edi+0x3000 + TASKDATA.state],byte 9 |
865 | mov [edi+0x3000 + TASKDATA.state],byte 9 |
848 | ; debugger test - terminate all debuggees |
866 | ; debugger test - terminate all debuggees |
849 | mov eax, 2 |
867 | mov eax, 2 |
850 | mov ecx, 0x80000+2*0x100+APPDATA.debugger_slot |
868 | mov ecx, 0x80000+2*0x100+APPDATA.debugger_slot |
851 | .xd0: |
869 | .xd0: |
852 | cmp eax, [0x3004] |
870 | cmp eax, [0x3004] |
853 | ja .xd1 |
871 | ja .xd1 |
854 | cmp dword [ecx], esi |
872 | cmp dword [ecx], esi |
855 | jnz @f |
873 | jnz @f |
856 | and dword [ecx], 0 |
874 | and dword [ecx], 0 |
857 | pushad |
875 | pushad |
858 | xchg eax, ebx |
876 | xchg eax, ebx |
859 | mov eax, 2 |
877 | mov eax, 2 |
860 | call sys_system |
878 | call sys_system |
861 | popad |
879 | popad |
862 | @@: |
880 | @@: |
863 | inc eax |
881 | inc eax |
864 | add ecx, 0x100 |
882 | add ecx, 0x100 |
865 | jmp .xd0 |
883 | jmp .xd0 |
866 | .xd1: |
884 | .xd1: |
867 | ; call systest |
885 | ; call systest |
868 | sti ; .. and life goes on |
886 | sti ; .. and life goes on |
869 | 887 | ||
870 | mov eax, [dlx] |
888 | mov eax, [dlx] |
871 | mov ebx, [dly] |
889 | mov ebx, [dly] |
872 | mov ecx, [dlxe] |
890 | mov ecx, [dlxe] |
873 | mov edx, [dlye] |
891 | mov edx, [dlye] |
874 | call calculatescreen |
892 | call calculatescreen |
875 | xor eax, eax |
893 | xor eax, eax |
876 | xor esi, esi |
894 | xor esi, esi |
877 | call redrawscreen |
895 | call redrawscreen |
878 | 896 | ||
879 | mov [0xfff4],byte 0 ; no mouse background |
897 | mov [0xfff4],byte 0 ; no mouse background |
880 | mov [0xfff5],byte 0 ; draw mouse |
898 | mov [0xfff5],byte 0 ; draw mouse |
881 | 899 | ||
882 | mov [application_table_status],0 |
900 | mov [application_table_status],0 |
883 | mov esi,process_terminated |
901 | mov esi,process_terminated |
884 | call sys_msg_board_str |
902 | call sys_msg_board_str |
885 | - | ||
886 | ret |
903 | ret |
887 | 904 | ||
888 | iglobal |
905 | iglobal |
889 | boot_sched_1 db 'Building gdt tss pointer',0 |
906 | boot_sched_1 db 'Building gdt tss pointer',0 |
890 | boot_sched_2 db 'Building IDT table',0 |
907 | boot_sched_2 db 'Building IDT table',0 |
891 | endg |
908 | endg |
892 | 909 | ||
893 | 910 | ||
894 | build_scheduler: |
911 | build_scheduler: |
895 | 912 | ||
896 | mov esi,boot_sched_1 |
913 | mov esi,boot_sched_1 |
897 | call boot_log |
914 | call boot_log |
898 | call build_process_gdt_tss_pointer |
915 | call build_process_gdt_tss_pointer |
899 | 916 | ||
900 | mov esi,boot_sched_2 |
917 | mov esi,boot_sched_2 |
901 | call boot_log |
918 | call boot_log |
902 | call build_interrupt_table |
919 | call build_interrupt_table |
903 | 920 | ||
904 | ret |
921 | ret |