Rev 2434 | Rev 2987 | 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: 2465 $ |
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 |
||
92 | diamond | 428 | ; remove hotkeys in buffer |
1056 | Galkov | 429 | mov eax, hotkey_buffer |
92 | diamond | 430 | .loop2: |
1056 | Galkov | 431 | cmp [eax], esi |
432 | jnz .cont2 |
||
433 | and dword [eax+4], 0 |
||
434 | and dword [eax], 0 |
||
92 | diamond | 435 | .cont2: |
1056 | Galkov | 436 | add eax, 8 |
437 | cmp eax, hotkey_buffer+120*8 |
||
438 | jb .loop2 |
||
92 | diamond | 439 | |
2434 | Serge | 440 | mov ecx, esi ; remove buttons |
1 | ha | 441 | bnewba2: |
2434 | Serge | 442 | mov edi, [BTN_ADDR] |
443 | mov eax, edi |
||
444 | cld |
||
445 | movzx ebx, word [edi] |
||
446 | inc bx |
||
1 | ha | 447 | bnewba: |
2434 | Serge | 448 | dec bx |
449 | jz bnmba |
||
450 | add eax, 0x10 |
||
451 | cmp cx, [eax] |
||
452 | jnz bnewba |
||
453 | pusha |
||
454 | mov ecx, ebx |
||
455 | inc ecx |
||
456 | shl ecx, 4 |
||
457 | mov ebx, eax |
||
458 | add eax, 0x10 |
||
459 | call memmove |
||
460 | dec dword [edi] |
||
461 | popa |
||
462 | jmp bnewba2 |
||
1 | ha | 463 | bnmba: |
464 | |||
2434 | Serge | 465 | pusha ; save window coordinates for window restoring |
466 | cld |
||
467 | shl esi, 5 |
||
468 | add esi, window_data |
||
469 | mov eax, [esi+WDATA.box.left] |
||
470 | mov [draw_limits.left], eax |
||
471 | add eax, [esi+WDATA.box.width] |
||
472 | mov [draw_limits.right], eax |
||
473 | mov eax, [esi+WDATA.box.top] |
||
474 | mov [draw_limits.top], eax |
||
475 | add eax, [esi+WDATA.box.height] |
||
476 | mov [draw_limits.bottom], eax |
||
1 | ha | 477 | |
2434 | Serge | 478 | xor eax, eax |
479 | mov [esi+WDATA.box.left], eax |
||
480 | mov [esi+WDATA.box.width], eax |
||
481 | mov [esi+WDATA.box.top], eax |
||
482 | mov [esi+WDATA.box.height], eax |
||
483 | mov [esi+WDATA.cl_workarea], eax |
||
484 | mov [esi+WDATA.cl_titlebar], eax |
||
485 | mov [esi+WDATA.cl_frames], eax |
||
486 | mov dword [esi+WDATA.reserved], eax; clear all flags: wstate, redraw, wdrawn |
||
487 | lea edi, [esi-window_data+draw_data] |
||
488 | mov ecx, 32/4 |
||
489 | rep stosd |
||
490 | popa |
||
1 | ha | 491 | |
40 | halyavin | 492 | ; debuggee test |
2434 | Serge | 493 | pushad |
494 | mov edi, esi |
||
495 | shl edi, 5 |
||
496 | mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] |
||
497 | test eax, eax |
||
498 | jz .nodebug |
||
499 | push 8 |
||
500 | pop ecx |
||
501 | push dword [CURRENT_TASK+edi+TASKDATA.pid]; PID |
||
502 | push 2 |
||
503 | call debugger_notify |
||
504 | pop ecx |
||
505 | pop ecx |
||
40 | halyavin | 506 | .nodebug: |
2434 | Serge | 507 | popad |
40 | halyavin | 508 | |
2434 | Serge | 509 | mov ebx, [.slot] |
510 | shl ebx, 8 |
||
511 | push ebx |
||
512 | mov ebx, [SLOT_BASE+ebx+APPDATA.pl0_stack] |
||
1 | ha | 513 | |
2434 | Serge | 514 | stdcall kernel_free, ebx |
1 | ha | 515 | |
2434 | Serge | 516 | pop ebx |
517 | mov ebx, [SLOT_BASE+ebx+APPDATA.cur_dir] |
||
518 | stdcall kernel_free, ebx |
||
521 | diamond | 519 | |
2434 | Serge | 520 | mov edi, [.slot] |
521 | shl edi, 8 |
||
522 | add edi, SLOT_BASE |
||
465 | serge | 523 | |
2434 | Serge | 524 | mov eax, [edi+APPDATA.io_map] |
525 | cmp eax, [SLOT_BASE+256+APPDATA.io_map] |
||
526 | je @F |
||
527 | call free_page |
||
465 | serge | 528 | @@: |
2434 | Serge | 529 | mov eax, [edi+APPDATA.io_map+4] |
530 | cmp eax, [SLOT_BASE+256+APPDATA.io_map+4] |
||
531 | je @F |
||
532 | call free_page |
||
465 | serge | 533 | @@: |
2434 | Serge | 534 | mov eax, 0x20202020 |
535 | stosd |
||
536 | stosd |
||
537 | stosd |
||
538 | mov ecx, 244/4 |
||
539 | xor eax, eax |
||
540 | rep stosd |
||
1 | ha | 541 | |
102 | poddubny | 542 | ; activate window |
2434 | Serge | 543 | movzx eax, word [WIN_STACK + esi*2] |
544 | cmp eax, [TASK_COUNT] |
||
545 | jne .dont_activate |
||
1056 | Galkov | 546 | pushad |
102 | poddubny | 547 | .check_next_window: |
2434 | Serge | 548 | dec eax |
549 | cmp eax, 1 |
||
550 | jbe .nothing_to_activate |
||
551 | lea esi, [WIN_POS+eax*2] |
||
552 | movzx edi, word [esi] ; edi = process |
||
553 | shl edi, 5 |
||
554 | cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots |
||
555 | je .check_next_window |
||
556 | add edi, window_data |
||
154 | diamond | 557 | ; \begin{diamond}[19.09.2006] |
558 | ; skip minimized windows |
||
2434 | Serge | 559 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
560 | jnz .check_next_window |
||
154 | diamond | 561 | ; \end{diamond} |
2434 | Serge | 562 | call waredraw |
102 | poddubny | 563 | .nothing_to_activate: |
1056 | Galkov | 564 | popad |
102 | poddubny | 565 | .dont_activate: |
566 | |||
1056 | Galkov | 567 | push esi ; remove hd1 & cd & flp reservation |
568 | shl esi, 5 |
||
569 | mov esi, [esi+CURRENT_TASK+TASKDATA.pid] |
||
570 | cmp [hd1_status], esi |
||
571 | jnz @f |
||
572 | call free_hd_channel |
||
1306 | Lrz | 573 | and [hd1_status], 0 |
92 | diamond | 574 | @@: |
1056 | Galkov | 575 | cmp [cd_status], esi |
576 | jnz @f |
||
577 | call free_cd_channel |
||
1306 | Lrz | 578 | and [cd_status], 0 |
92 | diamond | 579 | @@: |
1056 | Galkov | 580 | cmp [flp_status], esi |
581 | jnz @f |
||
1306 | Lrz | 582 | and [flp_status], 0 |
92 | diamond | 583 | @@: |
1056 | Galkov | 584 | pop esi |
585 | cmp [bgrlockpid], esi |
||
586 | jnz @f |
||
587 | and [bgrlockpid], 0 |
||
1306 | Lrz | 588 | and [bgrlock], 0 |
546 | diamond | 589 | @@: |
1 | ha | 590 | |
2434 | Serge | 591 | pusha ; remove all port reservations |
592 | mov edx, esi |
||
593 | shl edx, 5 |
||
594 | add edx, CURRENT_TASK |
||
595 | mov edx, [edx+TASKDATA.pid] |
||
1 | ha | 596 | |
597 | rmpr0: |
||
598 | |||
2434 | Serge | 599 | mov esi, [RESERVED_PORTS] |
1 | ha | 600 | |
2434 | Serge | 601 | test esi, esi |
602 | jz rmpr9 |
||
1 | ha | 603 | |
604 | rmpr3: |
||
605 | |||
2434 | Serge | 606 | mov edi, esi |
607 | shl edi, 4 |
||
608 | add edi, RESERVED_PORTS |
||
1 | ha | 609 | |
2434 | Serge | 610 | cmp edx, [edi] |
611 | je rmpr4 |
||
1 | ha | 612 | |
2434 | Serge | 613 | dec esi |
614 | jnz rmpr3 |
||
1 | ha | 615 | |
2434 | Serge | 616 | jmp rmpr9 |
1 | ha | 617 | |
618 | rmpr4: |
||
619 | |||
2434 | Serge | 620 | mov ecx, 256 |
621 | sub ecx, esi |
||
622 | shl ecx, 4 |
||
1 | ha | 623 | |
2434 | Serge | 624 | mov esi, edi |
625 | add esi, 16 |
||
626 | cld |
||
627 | rep movsb |
||
1 | ha | 628 | |
2434 | Serge | 629 | dec dword [RESERVED_PORTS] |
1 | ha | 630 | |
2434 | Serge | 631 | jmp rmpr0 |
1 | ha | 632 | |
633 | rmpr9: |
||
634 | |||
2434 | Serge | 635 | popa |
636 | mov edi, esi ; do not run this process slot |
||
637 | shl edi, 5 |
||
638 | mov [edi+CURRENT_TASK + TASKDATA.state], byte 9 |
||
40 | halyavin | 639 | ; debugger test - terminate all debuggees |
2434 | Serge | 640 | mov eax, 2 |
641 | mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot |
||
40 | halyavin | 642 | .xd0: |
2434 | Serge | 643 | cmp eax, [TASK_COUNT] |
644 | ja .xd1 |
||
645 | cmp dword [ecx], esi |
||
646 | jnz @f |
||
647 | and dword [ecx], 0 |
||
648 | pushad |
||
649 | xchg eax, ecx |
||
650 | mov ebx, 2 |
||
651 | call sys_system |
||
652 | popad |
||
40 | halyavin | 653 | @@: |
2434 | Serge | 654 | inc eax |
655 | add ecx, 0x100 |
||
656 | jmp .xd0 |
||
40 | halyavin | 657 | .xd1: |
1 | ha | 658 | ; call systest |
2434 | Serge | 659 | sti ; .. and life goes on |
1 | ha | 660 | |
2434 | Serge | 661 | mov eax, [draw_limits.left] |
662 | mov ebx, [draw_limits.top] |
||
663 | mov ecx, [draw_limits.right] |
||
664 | mov edx, [draw_limits.bottom] |
||
665 | call calculatescreen |
||
666 | xor eax, eax |
||
667 | xor esi, esi |
||
668 | call redrawscreen |
||
1 | ha | 669 | |
2434 | Serge | 670 | mov [MOUSE_BACKGROUND], byte 0; no mouse background |
671 | mov [DONT_DRAW_MOUSE], byte 0; draw mouse |
||
1 | ha | 672 | |
2434 | Serge | 673 | and [application_table_status], 0 |
506 | mikedld | 674 | ;mov esi,process_terminated |
675 | ;call sys_msg_board_str |
||
2434 | Serge | 676 | add esp, 4 |
677 | ret |
||
345 | serge | 678 | restore .slot |
1 | ha | 679 | |
680 | iglobal |
||
2130 | serge | 681 | if lang eq ru |
682 | boot_sched_1 db '‘®§¤ ЁҐ GDT TSS гЄ § ⥫п',0 |
||
683 | boot_sched_2 db '‘®§¤ ЁҐ IDT в Ў«Ёжл',0 |
||
684 | else |
||
1056 | Galkov | 685 | boot_sched_1 db 'Building gdt tss pointer',0 |
686 | boot_sched_2 db 'Building IDT table',0 |
||
2130 | serge | 687 | end if |
1 | ha | 688 | endg |
689 | |||
690 | |||
691 | build_scheduler: |
||
692 | |||
2434 | Serge | 693 | mov esi, boot_sched_1 |
694 | call boot_log |
||
465 | serge | 695 | ; call build_process_gdt_tss_pointer |
1 | ha | 696 | |
465 | serge | 697 | ; mov esi,boot_sched_2 |
698 | ; call boot_log |
||
1 | ha | 699 | |
1056 | Galkov | 700 | ret |