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