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