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