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