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