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