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