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