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