Rev 2112 | Rev 2167 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
431 | serge | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
709 | diamond | 3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
431 | serge | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;; ;; |
||
7 | ;; MenuetOS process management, protected ring3 ;; |
||
8 | ;; ;; |
||
9 | ;; Distributed under GPL. See file COPYING for details. ;; |
||
10 | ;; Copyright 2003 Ville Turjanmaa ;; |
||
11 | ;; ;; |
||
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1 | ha | 13 | |
593 | mikedld | 14 | $Revision: 2118 $ |
15 | |||
16 | |||
1056 | Galkov | 17 | align 4 ;3A08 |
1 | ha | 18 | build_interrupt_table: |
1056 | Galkov | 19 | mov edi, idts |
20 | mov esi, sys_int |
||
21 | mov ecx, 0x40 |
||
22 | mov eax, (10001110b shl 24) + os_code |
||
23 | @@: movsw ;low word of code-entry |
||
24 | stosd ;interrupt gate type : os_code selector |
||
25 | movsw ;high word of code-entry |
||
26 | loop @b |
||
27 | movsd ;copy low dword of trap gate for int 0x40 |
||
28 | movsd ;copy high dword of trap gate for int 0x40 |
||
29 | lidt [esi] |
||
30 | ret |
||
1 | ha | 31 | |
1056 | Galkov | 32 | iglobal |
33 | align 4 |
||
34 | sys_int: |
||
35 | ;exception handlers addresses (for interrupt gate construction) |
||
1076 | Galkov | 36 | dd e0,e1,e2,e3,e4,e5,e6,except_7 ; SEE: core/fpu.inc |
1056 | Galkov | 37 | dd e8,e9,e10,e11,e12,e13,page_fault_exc,e15 |
38 | dd e16, e17,e18, e19 |
||
39 | times 12 dd unknown_interrupt ;int_20..int_31 |
||
164 | serge | 40 | |
1056 | Galkov | 41 | ;interrupt handlers addresses (for interrupt gate construction) |
2112 | serge | 42 | ; 0x20 .. 0x2F - IRQ handlers |
1056 | Galkov | 43 | dd irq0, irq_serv.irq_1, irq_serv.irq_2 |
44 | dd irq_serv.irq_3, irq_serv.irq_4 |
||
1992 | clevermous | 45 | dd irq_serv.irq_5, irq_serv.irq_6, irq_serv.irq_7 |
1056 | Galkov | 46 | dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 |
1989 | clevermous | 47 | dd irq_serv.irq_11, irq_serv.irq_12, irqD, irq_serv.irq_14, irq_serv.irq_15 |
1 | ha | 48 | |
2112 | serge | 49 | |
50 | times 32 - IRQ_RESERVED dd unknown_interrupt |
||
1056 | Galkov | 51 | ;int_0x40 gate trap (for directly copied) |
52 | dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16 |
||
656 | mikedld | 53 | |
1076 | Galkov | 54 | idtreg: ; data for LIDT instruction (!!! must be immediately below sys_int data) |
1056 | Galkov | 55 | dw 2*($-sys_int-4)-1 |
56 | dd idts ;0x8000B100 |
||
57 | dw 0 ;ïðîñòî âûðàâíèâàíèå |
||
656 | mikedld | 58 | |
1056 | Galkov | 59 | msg_fault_sel dd msg_exc_8,msg_exc_u,msg_exc_a,msg_exc_b |
60 | dd msg_exc_c,msg_exc_d,msg_exc_e |
||
164 | serge | 61 | |
1056 | Galkov | 62 | msg_exc_8 db "Double fault", 0 |
63 | msg_exc_u db "Undefined Exception", 0 |
||
64 | msg_exc_a db "Invalid TSS", 0 |
||
65 | msg_exc_b db "Segment not present", 0 |
||
66 | msg_exc_c db "Stack fault", 0 |
||
67 | msg_exc_d db "General protection fault", 0 |
||
68 | msg_exc_e db "Page fault", 0 |
||
1 | ha | 69 | |
1056 | Galkov | 70 | msg_sel_ker db "kernel", 0 |
71 | msg_sel_app db "application", 0 |
||
1 | ha | 72 | |
73 | endg |
||
74 | |||
1056 | Galkov | 75 | macro save_ring3_context { |
76 | pushad |
||
40 | halyavin | 77 | } |
1056 | Galkov | 78 | macro restore_ring3_context { |
79 | popad |
||
40 | halyavin | 80 | } |
1056 | Galkov | 81 | macro exc_wo_code [num] { |
8 | poddubny | 82 | e#num : |
1056 | Galkov | 83 | save_ring3_context |
84 | mov bl, num |
||
85 | jmp exc_c |
||
86 | } exc_wo_code 0,1,2,3,4,5,6,15,16,19 |
||
1 | ha | 87 | |
1056 | Galkov | 88 | macro exc_w_code [num] { |
22 | poddubny | 89 | e#num : |
1056 | Galkov | 90 | add esp, 4 |
91 | save_ring3_context |
||
92 | mov bl, num |
||
93 | jmp exc_c |
||
94 | } exc_w_code 8,9,10,11,12,13,17,18 |
||
22 | poddubny | 95 | |
96 | |||
1056 | Galkov | 97 | uglobal |
98 | pf_err_code dd ? |
||
99 | endg |
||
1 | ha | 100 | |
1086 | Galkov | 101 | page_fault_exc: ; äóðàêîóñòî÷èâîñòü: ñåëåêòîðû èñïîð÷åíû... |
102 | pop [ss:pf_err_code]; äåéñòâèòåëüíî äî ñëåäóþùåãî #PF |
||
1056 | Galkov | 103 | save_ring3_context |
104 | mov bl,14 |
||
1086 | Galkov | 105 | |
106 | exc_c: ; èñêëþ÷åíèÿ (âñå, êðîìå 7-ãî - #NM) |
||
1056 | Galkov | 107 | ; Ôðýéì ñòåêà ïðè èñêëþ÷åíèè/ïðåðûâàíèè èç 3-ãî êîëüöà + pushad (ò.å., èìåííî çäåñü) |
108 | reg_ss equ esp+0x30 |
||
109 | reg_esp3 equ esp+0x2C |
||
110 | reg_eflags equ esp+0x28 |
||
111 | reg_cs3 equ esp+0x24 |
||
112 | reg_eip equ esp+0x20 |
||
113 | ; ýòî ôðýéì îò pushad |
||
114 | reg_eax equ esp+0x1C |
||
115 | reg_ecx equ esp+0x18 |
||
116 | reg_edx equ esp+0x14 |
||
117 | reg_ebx equ esp+0x10 |
||
118 | reg_esp0 equ esp+0x0C |
||
119 | reg_ebp equ esp+0x08 |
||
120 | reg_esi equ esp+0x04 |
||
121 | reg_edi equ esp+0x00 |
||
122 | |||
2118 | serge | 123 | Mov ds,ax,app_data ; çàãðóçèì ïðàâèëüíûå çíà÷åíè |
1056 | Galkov | 124 | mov es,ax ; â ñåãìåíòíûå ðåãèñòðû |
125 | cld ; è ïðèâîäèì DF ê ñòàíäàðòó |
||
1074 | Galkov | 126 | movzx ebx,bl |
709 | diamond | 127 | ; redirect to V86 manager? (EFLAGS & 0x20000) != 0? |
1056 | Galkov | 128 | test byte[reg_eflags+2],2 |
129 | jnz v86_exc_c |
||
130 | cmp bl,14 ; #PF |
||
1074 | Galkov | 131 | jne @f |
1076 | Galkov | 132 | call page_fault_handler ; SEE: core/memory.inc |
1074 | Galkov | 133 | @@: mov esi, [current_slot] |
134 | btr [esi+APPDATA.except_mask], ebx |
||
135 | jnc @f |
||
136 | mov eax,[esi+APPDATA.exc_handler] |
||
137 | test eax, eax |
||
1056 | Galkov | 138 | jnz IRetToUserHook |
1074 | Galkov | 139 | @@: cli |
1056 | Galkov | 140 | mov eax, [esi+APPDATA.debugger_slot] |
141 | test eax, eax |
||
142 | jnz .debug |
||
143 | sti |
||
40 | halyavin | 144 | ; not debuggee => say error and terminate |
1056 | Galkov | 145 | call show_error_parameters ;; only ONE using, inline ??? |
146 | ;mov edx, [TASK_BASE] |
||
147 | mov [edx + TASKDATA.state], byte 4 ; terminate |
||
1076 | Galkov | 148 | jmp change_task ; stack - here it does not matter at all, SEE: core/shed.inc |
40 | halyavin | 149 | .debug: |
150 | ; we are debugged process, notify debugger and suspend ourself |
||
151 | ; eax=debugger PID |
||
1076 | Galkov | 152 | mov ecx,1 ; debug_message code=other_exception |
1056 | Galkov | 153 | cmp bl,1 ; #DB |
1076 | Galkov | 154 | jne .notify ; notify debugger and suspend ourself |
155 | mov ebx, dr6 ; debug_message data=DR6_image |
||
156 | xor edx, edx |
||
157 | mov dr6, edx |
||
158 | mov edx, dr7 |
||
159 | mov cl, not 8 |
||
160 | .l1: shl dl,2 |
||
161 | jc @f |
||
162 | and bl, cl |
||
163 | @@: sar cl,1 |
||
164 | jc .l1 |
||
165 | mov cl, 3 ; debug_message code=debug_exception |
||
166 | .notify: |
||
167 | push ebx ; debug_message data |
||
168 | mov ebx, [TASK_BASE] |
||
169 | push [ebx+TASKDATA.pid] ; PID |
||
170 | push ecx ; debug_message code ((here: ecx==1/3)) |
||
171 | mov cl, 12 ; debug_message size |
||
172 | call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc |
||
173 | add esp,12 |
||
174 | mov edx, [TASK_BASE] |
||
175 | mov byte [edx+TASKDATA.state], 1 ; suspended |
||
176 | call change_task ; SEE: core/shed.inc |
||
177 | restore_ring3_context |
||
178 | iretd |
||
1 | ha | 179 | |
1056 | Galkov | 180 | IRetToUserHook: |
181 | xchg eax, [reg_eip] |
||
1074 | Galkov | 182 | sub dword[reg_esp3], 8 |
1056 | Galkov | 183 | mov edi, [reg_esp3] |
184 | stosd |
||
1074 | Galkov | 185 | mov [edi], ebx |
1056 | Galkov | 186 | restore_ring3_context |
2112 | serge | 187 | ; simply return control to interrupted process |
1056 | Galkov | 188 | unknown_interrupt: |
189 | iretd |
||
1 | ha | 190 | |
658 | Ghost | 191 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
2100 | serge | 192 | ; bl - error vector |
1 | ha | 193 | show_error_parameters: |
1948 | clevermous | 194 | cmp bl, 0x06 |
195 | jnz .no_ud |
||
196 | push ebx |
||
197 | mov ebx, ud_user_message |
||
198 | mov ebp, notifyapp |
||
199 | call fs_execute_from_sysdir_param |
||
200 | pop ebx |
||
201 | .no_ud: |
||
1056 | Galkov | 202 | mov edx,[TASK_BASE] ;not scratched below |
203 | DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid] |
||
204 | cmp bl, 0x08 |
||
205 | jb .l0 |
||
206 | cmp bl, 0x0e |
||
207 | jbe .l1 |
||
208 | .l0: mov bl, 0x09 |
||
1074 | Galkov | 209 | .l1: mov eax,[msg_fault_sel+ebx*4 - 0x08*4] |
1056 | Galkov | 210 | DEBUGF 1, "K : %s\n", eax |
211 | mov eax, [reg_cs3+4] |
||
212 | mov edi, msg_sel_app |
||
213 | mov ebx, [reg_esp3+4] |
||
214 | cmp eax, app_code |
||
215 | je @f |
||
216 | mov edi, msg_sel_ker |
||
217 | mov ebx, [reg_esp0+4] |
||
218 | @@: DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4] |
||
219 | DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [reg_edx+4], [reg_esi+4], [reg_edi+4] |
||
220 | DEBUGF 1, "K : EBP : %x EIP : %x ESP : %x\n", [reg_ebp+4], [reg_eip+4], ebx |
||
221 | DEBUGF 1, "K : Flags : %x CS : %x (%s)\n", [reg_eflags+4], eax, edi |
||
222 | ret |
||
658 | Ghost | 223 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
164 | serge | 224 | |
1056 | Galkov | 225 | restore reg_ss |
226 | restore reg_esp3 |
||
227 | restore reg_eflags |
||
228 | restore reg_cs |
||
229 | restore reg_eip |
||
230 | restore reg_eax |
||
231 | restore reg_ecx |
||
232 | restore reg_edx |
||
233 | restore reg_ebx |
||
234 | restore reg_esp0 |
||
235 | restore reg_ebp |
||
236 | restore reg_esi |
||
237 | restore reg_edi |
||
16 | poddubny | 238 | |
1 | ha | 239 | |
2100 | serge | 240 | align 4 |
1 | ha | 241 | set_application_table_status: |
1056 | Galkov | 242 | push eax |
1 | ha | 243 | |
1056 | Galkov | 244 | mov eax,[CURRENT_TASK] |
245 | shl eax, 5 |
||
246 | add eax,CURRENT_TASK+TASKDATA.pid |
||
247 | mov eax,[eax] |
||
1 | ha | 248 | |
1056 | Galkov | 249 | mov [application_table_status],eax |
1 | ha | 250 | |
1056 | Galkov | 251 | pop eax |
1 | ha | 252 | |
1056 | Galkov | 253 | ret |
1 | ha | 254 | |
2100 | serge | 255 | align 4 |
1 | ha | 256 | clear_application_table_status: |
1056 | Galkov | 257 | push eax |
1 | ha | 258 | |
1056 | Galkov | 259 | mov eax,[CURRENT_TASK] |
260 | shl eax, 5 |
||
261 | add eax,CURRENT_TASK+TASKDATA.pid |
||
262 | mov eax,[eax] |
||
1 | ha | 263 | |
1056 | Galkov | 264 | cmp eax,[application_table_status] |
265 | jne apptsl1 |
||
1306 | Lrz | 266 | xor eax,eax |
267 | mov [application_table_status],eax |
||
1 | ha | 268 | apptsl1: |
269 | |||
1056 | Galkov | 270 | pop eax |
1 | ha | 271 | |
1056 | Galkov | 272 | ret |
1 | ha | 273 | |
1306 | Lrz | 274 | ; * eax = 64 - íîìåð ôóíêöèè |
275 | ; * ebx = 1 - åäèíñòâåííàÿ ïîäôóíêöèÿ |
||
276 | ; * ecx = íîâûé ðàçìåð ïàìÿòè |
||
277 | ;Âîçâðàùàåìîå çíà÷åíèå: |
||
278 | ; * eax = 0 - óñïåøíî |
||
279 | ; * eax = 1 - íåäîñòàòî÷íî ïàìÿòè |
||
280 | |||
2100 | serge | 281 | align 4 |
1 | ha | 282 | sys_resize_app_memory: |
1306 | Lrz | 283 | ; ebx = 1 - resize |
284 | ; ecx = new amount of memory |
||
1 | ha | 285 | |
1306 | Lrz | 286 | ; cmp eax,1 |
287 | dec ebx |
||
288 | jnz .no_application_mem_resize |
||
1307 | Lrz | 289 | stdcall new_mem_resize, ecx |
1306 | Lrz | 290 | mov [esp+32], eax |
164 | serge | 291 | .no_application_mem_resize: |
1056 | Galkov | 292 | ret |
1 | ha | 293 | |
294 | iglobal |
||
1056 | Galkov | 295 | ; process_terminating db 'K : Process - terminating',13,10,0 |
296 | ; process_terminated db 'K : Process - done',13,10,0 |
||
297 | msg_obj_destroy db 'K : destroy app object',13,10,0 |
||
1 | ha | 298 | endg |
299 | |||
329 | serge | 300 | ; param |
301 | ; esi= slot |
||
1 | ha | 302 | |
2100 | serge | 303 | align 4 |
1 | ha | 304 | terminate: ; terminate application |
305 | |||
1056 | Galkov | 306 | .slot equ esp ;locals |
329 | serge | 307 | |
1056 | Galkov | 308 | push esi ;save .slot |
334 | serge | 309 | |
1056 | Galkov | 310 | shl esi, 8 |
311 | cmp [SLOT_BASE+esi+APPDATA.dir_table], 0 |
||
312 | jne @F |
||
313 | pop esi |
||
314 | shl esi, 5 |
||
315 | mov [CURRENT_TASK+esi+TASKDATA.state], 9 |
||
316 | ret |
||
334 | serge | 317 | @@: |
1056 | Galkov | 318 | ;mov esi,process_terminating |
319 | ;call sys_msg_board_str |
||
40 | halyavin | 320 | @@: |
1056 | Galkov | 321 | cli |
322 | cmp [application_table_status],0 |
||
323 | je term9 |
||
324 | sti |
||
325 | call change_task |
||
326 | jmp @b |
||
329 | serge | 327 | term9: |
1056 | Galkov | 328 | call set_application_table_status |
1 | ha | 329 | |
709 | diamond | 330 | ; if the process is in V86 mode... |
1056 | Galkov | 331 | mov eax, [.slot] |
332 | shl eax, 8 |
||
333 | mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack] |
||
334 | add esi, RING0_STACK_SIZE |
||
335 | cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi |
||
336 | jz .nov86 |
||
709 | diamond | 337 | ; ...it has page directory for V86 mode |
1056 | Galkov | 338 | mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0] |
339 | mov ecx, [esi+4] |
||
340 | mov [eax+SLOT_BASE+APPDATA.dir_table], ecx |
||
709 | diamond | 341 | ; ...and I/O permission map for V86 mode |
1056 | Galkov | 342 | mov ecx, [esi+12] |
343 | mov [eax+SLOT_BASE+APPDATA.io_map], ecx |
||
344 | mov ecx, [esi+8] |
||
345 | mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx |
||
709 | diamond | 346 | .nov86: |
347 | |||
1056 | Galkov | 348 | mov esi, [.slot] |
349 | shl esi,8 |
||
350 | add esi, SLOT_BASE+APP_OBJ_OFFSET |
||
329 | serge | 351 | @@: |
1056 | Galkov | 352 | mov eax, [esi+APPOBJ.fd] |
353 | test eax, eax |
||
354 | jz @F |
||
334 | serge | 355 | |
1056 | Galkov | 356 | cmp eax, esi |
357 | je @F |
||
164 | serge | 358 | |
1056 | Galkov | 359 | push esi |
360 | call [eax+APPOBJ.destroy] |
||
361 | DEBUGF 1,"%s",msg_obj_destroy |
||
362 | pop esi |
||
363 | jmp @B |
||
329 | serge | 364 | @@: |
1311 | diamond | 365 | |
1056 | Galkov | 366 | mov eax, [.slot] |
367 | shl eax, 8 |
||
1311 | diamond | 368 | stdcall destroy_app_space, [SLOT_BASE+eax+APPDATA.dir_table], [SLOT_BASE+eax+APPDATA.dlls_list_ptr] |
1 | ha | 369 | |
1056 | Galkov | 370 | mov esi, [.slot] |
371 | cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
||
372 | jne @F |
||
164 | serge | 373 | |
1056 | Galkov | 374 | mov [fpu_owner],1 |
375 | mov eax, [256+SLOT_BASE+APPDATA.fpu_state] |
||
376 | clts |
||
377 | bt [cpu_caps], CAPS_SSE |
||
378 | jnc .no_SSE |
||
379 | fxrstor [eax] |
||
380 | jmp @F |
||
203 | serge | 381 | .no_SSE: |
1056 | Galkov | 382 | fnclex |
383 | frstor [eax] |
||
357 | serge | 384 | @@: |
203 | serge | 385 | |
1056 | Galkov | 386 | mov [KEY_COUNT],byte 0 ; empty keyboard buffer |
387 | mov [BTN_COUNT],byte 0 ; empty button buffer |
||
1 | ha | 388 | |
389 | |||
92 | diamond | 390 | ; remove defined hotkeys |
1056 | Galkov | 391 | mov eax, hotkey_list |
92 | diamond | 392 | .loop: |
1056 | Galkov | 393 | cmp [eax+8], esi |
394 | jnz .cont |
||
395 | mov ecx, [eax] |
||
396 | jecxz @f |
||
397 | push dword [eax+12] |
||
398 | pop dword [ecx+12] |
||
92 | diamond | 399 | @@: |
1056 | Galkov | 400 | mov ecx, [eax+12] |
401 | push dword [eax] |
||
402 | pop dword [ecx] |
||
403 | xor ecx, ecx |
||
404 | mov [eax], ecx |
||
405 | mov [eax+4], ecx |
||
406 | mov [eax+8], ecx |
||
407 | mov [eax+12], ecx |
||
92 | diamond | 408 | .cont: |
1056 | Galkov | 409 | add eax, 16 |
410 | cmp eax, hotkey_list+256*16 |
||
411 | jb .loop |
||
92 | diamond | 412 | ; remove hotkeys in buffer |
1056 | Galkov | 413 | mov eax, hotkey_buffer |
92 | diamond | 414 | .loop2: |
1056 | Galkov | 415 | cmp [eax], esi |
416 | jnz .cont2 |
||
417 | and dword [eax+4], 0 |
||
418 | and dword [eax], 0 |
||
92 | diamond | 419 | .cont2: |
1056 | Galkov | 420 | add eax, 8 |
421 | cmp eax, hotkey_buffer+120*8 |
||
422 | jb .loop2 |
||
92 | diamond | 423 | |
1056 | Galkov | 424 | mov ecx,esi ; remove buttons |
1 | ha | 425 | bnewba2: |
381 | serge | 426 | mov edi,[BTN_ADDR] |
1 | ha | 427 | mov eax,edi |
428 | cld |
||
429 | movzx ebx,word [edi] |
||
430 | inc bx |
||
431 | bnewba: |
||
432 | dec bx |
||
1056 | Galkov | 433 | jz bnmba |
1 | ha | 434 | add eax,0x10 |
435 | cmp cx,[eax] |
||
436 | jnz bnewba |
||
437 | pusha |
||
438 | mov ecx,ebx |
||
439 | inc ecx |
||
440 | shl ecx,4 |
||
441 | mov ebx,eax |
||
442 | add eax,0x10 |
||
443 | call memmove |
||
444 | dec dword [edi] |
||
445 | popa |
||
446 | jmp bnewba2 |
||
447 | bnmba: |
||
448 | |||
449 | pusha ; save window coordinates for window restoring |
||
450 | cld |
||
451 | shl esi,5 |
||
452 | add esi,window_data |
||
114 | mikedld | 453 | mov eax,[esi+WDATA.box.left] |
1362 | mikedld | 454 | mov [draw_limits.left],eax |
114 | mikedld | 455 | add eax,[esi+WDATA.box.width] |
1362 | mikedld | 456 | mov [draw_limits.right],eax |
114 | mikedld | 457 | mov eax,[esi+WDATA.box.top] |
1362 | mikedld | 458 | mov [draw_limits.top],eax |
114 | mikedld | 459 | add eax,[esi+WDATA.box.height] |
1362 | mikedld | 460 | mov [draw_limits.bottom],eax |
1 | ha | 461 | |
142 | diamond | 462 | xor eax, eax |
463 | mov [esi+WDATA.box.left],eax |
||
464 | mov [esi+WDATA.box.width],eax |
||
114 | mikedld | 465 | mov [esi+WDATA.box.top],eax |
142 | diamond | 466 | mov [esi+WDATA.box.height],eax |
115 | poddubny | 467 | mov [esi+WDATA.cl_workarea],eax |
468 | mov [esi+WDATA.cl_titlebar],eax |
||
469 | mov [esi+WDATA.cl_frames],eax |
||
470 | mov dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn |
||
102 | poddubny | 471 | lea edi, [esi-window_data+draw_data] |
1 | ha | 472 | mov ecx,32/4 |
473 | rep stosd |
||
474 | popa |
||
475 | |||
40 | halyavin | 476 | ; debuggee test |
477 | pushad |
||
478 | mov edi, esi |
||
479 | shl edi, 5 |
||
380 | serge | 480 | mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] |
40 | halyavin | 481 | test eax, eax |
1056 | Galkov | 482 | jz .nodebug |
40 | halyavin | 483 | push 8 |
484 | pop ecx |
||
1056 | Galkov | 485 | push dword [CURRENT_TASK+edi+TASKDATA.pid] ; PID |
40 | halyavin | 486 | push 2 |
487 | call debugger_notify |
||
488 | pop ecx |
||
489 | pop ecx |
||
490 | .nodebug: |
||
491 | popad |
||
492 | |||
1056 | Galkov | 493 | mov ebx, [.slot] |
494 | shl ebx, 8 |
||
495 | push ebx |
||
496 | mov ebx,[SLOT_BASE+ebx+APPDATA.pl0_stack] |
||
1 | ha | 497 | |
1056 | Galkov | 498 | stdcall kernel_free, ebx |
1 | ha | 499 | |
1056 | Galkov | 500 | pop ebx |
501 | mov ebx,[SLOT_BASE+ebx+APPDATA.cur_dir] |
||
502 | stdcall kernel_free, ebx |
||
521 | diamond | 503 | |
1056 | Galkov | 504 | mov edi, [.slot] |
505 | shl edi,8 |
||
506 | add edi,SLOT_BASE |
||
465 | serge | 507 | |
1056 | Galkov | 508 | mov eax, [edi+APPDATA.io_map] |
1310 | diamond | 509 | cmp eax, [SLOT_BASE+256+APPDATA.io_map] |
1056 | Galkov | 510 | je @F |
511 | call free_page |
||
465 | serge | 512 | @@: |
1056 | Galkov | 513 | mov eax, [edi+APPDATA.io_map+4] |
1310 | diamond | 514 | cmp eax, [SLOT_BASE+256+APPDATA.io_map+4] |
1056 | Galkov | 515 | je @F |
516 | call free_page |
||
465 | serge | 517 | @@: |
1056 | Galkov | 518 | mov eax, 0x20202020 |
519 | stosd |
||
520 | stosd |
||
521 | stosd |
||
522 | mov ecx,244/4 |
||
523 | xor eax, eax |
||
524 | rep stosd |
||
1 | ha | 525 | |
102 | poddubny | 526 | ; activate window |
1056 | Galkov | 527 | movzx eax, word [WIN_STACK + esi*2] |
528 | cmp eax, [TASK_COUNT] |
||
529 | jne .dont_activate |
||
530 | pushad |
||
102 | poddubny | 531 | .check_next_window: |
1056 | Galkov | 532 | dec eax |
533 | cmp eax, 1 |
||
534 | jbe .nothing_to_activate |
||
535 | lea esi, [WIN_POS+eax*2] |
||
536 | movzx edi, word [esi] ; edi = process |
||
537 | shl edi, 5 |
||
538 | cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots |
||
539 | je .check_next_window |
||
540 | add edi, window_data |
||
154 | diamond | 541 | ; \begin{diamond}[19.09.2006] |
542 | ; skip minimized windows |
||
1056 | Galkov | 543 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
544 | jnz .check_next_window |
||
154 | diamond | 545 | ; \end{diamond} |
1056 | Galkov | 546 | call waredraw |
102 | poddubny | 547 | .nothing_to_activate: |
1056 | Galkov | 548 | popad |
102 | poddubny | 549 | .dont_activate: |
550 | |||
1056 | Galkov | 551 | push esi ; remove hd1 & cd & flp reservation |
552 | shl esi, 5 |
||
553 | mov esi, [esi+CURRENT_TASK+TASKDATA.pid] |
||
554 | cmp [hd1_status], esi |
||
555 | jnz @f |
||
556 | call free_hd_channel |
||
1306 | Lrz | 557 | and [hd1_status], 0 |
92 | diamond | 558 | @@: |
1056 | Galkov | 559 | cmp [cd_status], esi |
560 | jnz @f |
||
561 | call free_cd_channel |
||
1306 | Lrz | 562 | and [cd_status], 0 |
92 | diamond | 563 | @@: |
1056 | Galkov | 564 | cmp [flp_status], esi |
565 | jnz @f |
||
1306 | Lrz | 566 | and [flp_status], 0 |
92 | diamond | 567 | @@: |
1056 | Galkov | 568 | pop esi |
569 | cmp [bgrlockpid], esi |
||
570 | jnz @f |
||
571 | and [bgrlockpid], 0 |
||
1306 | Lrz | 572 | and [bgrlock], 0 |
546 | diamond | 573 | @@: |
1 | ha | 574 | |
1056 | Galkov | 575 | pusha ; remove all port reservations |
1 | ha | 576 | mov edx,esi |
115 | poddubny | 577 | shl edx, 5 |
379 | serge | 578 | add edx,CURRENT_TASK |
115 | poddubny | 579 | mov edx,[edx+TASKDATA.pid] |
1 | ha | 580 | |
581 | rmpr0: |
||
582 | |||
381 | serge | 583 | mov esi,[RESERVED_PORTS] |
1 | ha | 584 | |
1306 | Lrz | 585 | test esi,esi |
586 | jz rmpr9 |
||
1 | ha | 587 | |
588 | rmpr3: |
||
589 | |||
590 | mov edi,esi |
||
591 | shl edi,4 |
||
381 | serge | 592 | add edi,RESERVED_PORTS |
1 | ha | 593 | |
594 | cmp edx,[edi] |
||
1056 | Galkov | 595 | je rmpr4 |
1 | ha | 596 | |
597 | dec esi |
||
598 | jnz rmpr3 |
||
599 | |||
600 | jmp rmpr9 |
||
601 | |||
602 | rmpr4: |
||
603 | |||
604 | mov ecx,256 |
||
605 | sub ecx,esi |
||
606 | shl ecx,4 |
||
607 | |||
608 | mov esi,edi |
||
609 | add esi,16 |
||
610 | cld |
||
611 | rep movsb |
||
612 | |||
381 | serge | 613 | dec dword [RESERVED_PORTS] |
1 | ha | 614 | |
615 | jmp rmpr0 |
||
616 | |||
617 | rmpr9: |
||
618 | |||
619 | popa |
||
1056 | Galkov | 620 | mov edi,esi ; do not run this process slot |
6 | poddubny | 621 | shl edi, 5 |
379 | serge | 622 | mov [edi+CURRENT_TASK + TASKDATA.state],byte 9 |
40 | halyavin | 623 | ; debugger test - terminate all debuggees |
624 | mov eax, 2 |
||
380 | serge | 625 | mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot |
40 | halyavin | 626 | .xd0: |
379 | serge | 627 | cmp eax, [TASK_COUNT] |
1056 | Galkov | 628 | ja .xd1 |
40 | halyavin | 629 | cmp dword [ecx], esi |
630 | jnz @f |
||
631 | and dword [ecx], 0 |
||
632 | pushad |
||
684 | diamond | 633 | xchg eax, ecx |
634 | mov ebx, 2 |
||
40 | halyavin | 635 | call sys_system |
636 | popad |
||
637 | @@: |
||
638 | inc eax |
||
639 | add ecx, 0x100 |
||
640 | jmp .xd0 |
||
641 | .xd1: |
||
1 | ha | 642 | ; call systest |
643 | sti ; .. and life goes on |
||
644 | |||
1362 | mikedld | 645 | mov eax, [draw_limits.left] |
646 | mov ebx, [draw_limits.top] |
||
647 | mov ecx, [draw_limits.right] |
||
648 | mov edx, [draw_limits.bottom] |
||
1 | ha | 649 | call calculatescreen |
650 | xor eax, eax |
||
651 | xor esi, esi |
||
652 | call redrawscreen |
||
653 | |||
381 | serge | 654 | mov [MOUSE_BACKGROUND],byte 0 ; no mouse background |
655 | mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse |
||
1 | ha | 656 | |
1306 | Lrz | 657 | and [application_table_status],0 |
506 | mikedld | 658 | ;mov esi,process_terminated |
659 | ;call sys_msg_board_str |
||
357 | serge | 660 | add esp, 4 |
1 | ha | 661 | ret |
345 | serge | 662 | restore .slot |
1 | ha | 663 | |
664 | iglobal |
||
2104 | maximYCH | 665 | if lang eq ru |
666 | boot_sched_1 db '‘®§¤ ¨¥ GDT TSS 㪠§ ⥫ï',0 |
||
667 | boot_sched_2 db '‘®§¤ ¨¥ IDT â ¡«¨æë',0 |
||
668 | else |
||
1056 | Galkov | 669 | boot_sched_1 db 'Building gdt tss pointer',0 |
670 | boot_sched_2 db 'Building IDT table',0 |
||
2104 | maximYCH | 671 | end if |
1 | ha | 672 | endg |
673 | |||
674 | |||
675 | build_scheduler: |
||
676 | |||
1056 | Galkov | 677 | mov esi,boot_sched_1 |
678 | call boot_log |
||
465 | serge | 679 | ; call build_process_gdt_tss_pointer |
1 | ha | 680 | |
465 | serge | 681 | ; mov esi,boot_sched_2 |
682 | ; call boot_log |
||
1 | ha | 683 | |
1056 | Galkov | 684 | ret |