Rev 2010 | Rev 2130 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2010 | Rev 2106 | ||
---|---|---|---|
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: 2010 $ |
14 | $Revision: 2106 $ |
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 | if USE_COM_IRQ |
- | |
45 | dd irq_serv.irq_3, irq_serv.irq_4 |
44 | dd irq_serv.irq_3, irq_serv.irq_4 |
46 | else |
- | |
47 | dd p_irq3, p_irq4 ;??? íåñòûêîâêà |
- | |
48 | end if |
- | |
49 | 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 |
50 | 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 |
51 | 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 |
52 | ; I don`t known how to use IRQ_RESERVE |
- | |
53 | if IRQ_RESERVE > 16 |
- | |
54 | dd irq_serv.irq_16 |
48 | dd irq_serv.irq_16 |
55 | dd irq_serv.irq_17 |
49 | dd irq_serv.irq_17 |
56 | dd irq_serv.irq_18 |
50 | dd irq_serv.irq_18 |
57 | dd irq_serv.irq_19 |
51 | dd irq_serv.irq_19 |
58 | dd irq_serv.irq_20 |
52 | dd irq_serv.irq_20 |
59 | dd irq_serv.irq_21 |
53 | dd irq_serv.irq_21 |
60 | dd irq_serv.irq_22 |
54 | dd irq_serv.irq_22 |
61 | dd irq_serv.irq_23 |
55 | dd irq_serv.irq_23 |
62 | end if |
- | |
63 | 56 | ||
64 | times 32 - IRQ_RESERVE dd unknown_interrupt |
57 | times 32 - IRQ_RESERVE dd unknown_interrupt |
65 | ;int_0x40 gate trap (for directly copied) |
58 | ;int_0x40 gate trap (for directly copied) |
66 | 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 |
67 | 60 | ||
68 | 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) |
69 | dw 2*($-sys_int-4)-1 |
62 | dw 2*($-sys_int-4)-1 |
70 | dd idts ;0x8000B100 |
63 | dd idts ;0x8000B100 |
71 | dw 0 ;ïðîñòî âûðàâíèâàíèå |
64 | dw 0 ;ïðîñòî âûðàâíèâàíèå |
72 | 65 | ||
73 | 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 |
74 | dd msg_exc_c,msg_exc_d,msg_exc_e |
67 | dd msg_exc_c,msg_exc_d,msg_exc_e |
75 | 68 | ||
76 | msg_exc_8 db "Double fault", 0 |
69 | msg_exc_8 db "Double fault", 0 |
77 | msg_exc_u db "Undefined Exception", 0 |
70 | msg_exc_u db "Undefined Exception", 0 |
78 | msg_exc_a db "Invalid TSS", 0 |
71 | msg_exc_a db "Invalid TSS", 0 |
79 | msg_exc_b db "Segment not present", 0 |
72 | msg_exc_b db "Segment not present", 0 |
80 | msg_exc_c db "Stack fault", 0 |
73 | msg_exc_c db "Stack fault", 0 |
81 | msg_exc_d db "General protection fault", 0 |
74 | msg_exc_d db "General protection fault", 0 |
82 | msg_exc_e db "Page fault", 0 |
75 | msg_exc_e db "Page fault", 0 |
83 | 76 | ||
84 | msg_sel_ker db "kernel", 0 |
77 | msg_sel_ker db "kernel", 0 |
85 | msg_sel_app db "application", 0 |
78 | msg_sel_app db "application", 0 |
86 | 79 | ||
87 | endg |
80 | endg |
88 | 81 | ||
89 | macro save_ring3_context { |
82 | macro save_ring3_context { |
90 | pushad |
83 | pushad |
91 | } |
84 | } |
92 | macro restore_ring3_context { |
85 | macro restore_ring3_context { |
93 | popad |
86 | popad |
94 | } |
87 | } |
95 | macro exc_wo_code [num] { |
88 | macro exc_wo_code [num] { |
96 | e#num : |
89 | e#num : |
97 | save_ring3_context |
90 | save_ring3_context |
98 | mov bl, num |
91 | mov bl, num |
99 | jmp exc_c |
92 | jmp exc_c |
100 | } 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 |
101 | 94 | ||
102 | macro exc_w_code [num] { |
95 | macro exc_w_code [num] { |
103 | e#num : |
96 | e#num : |
104 | add esp, 4 |
97 | add esp, 4 |
105 | save_ring3_context |
98 | save_ring3_context |
106 | mov bl, num |
99 | mov bl, num |
107 | jmp exc_c |
100 | jmp exc_c |
108 | } exc_w_code 8,9,10,11,12,13,17,18 |
101 | } exc_w_code 8,9,10,11,12,13,17,18 |
109 | 102 | ||
110 | 103 | ||
111 | uglobal |
104 | uglobal |
112 | pf_err_code dd ? |
105 | pf_err_code dd ? |
113 | endg |
106 | endg |
114 | 107 | ||
115 | page_fault_exc: ; äóðàêîóñòî÷èâîñòü: ñåëåêòîðû èñïîð÷åíû... |
108 | page_fault_exc: ; äóðàêîóñòî÷èâîñòü: ñåëåêòîðû èñïîð÷åíû... |
116 | pop [ss:pf_err_code]; äåéñòâèòåëüíî äî ñëåäóþùåãî #PF |
109 | pop [ss:pf_err_code]; äåéñòâèòåëüíî äî ñëåäóþùåãî #PF |
117 | save_ring3_context |
110 | save_ring3_context |
118 | mov bl,14 |
111 | mov bl,14 |
119 | 112 | ||
120 | exc_c: ; èñêëþ÷åíèÿ (âñå, êðîìå 7-ãî - #NM) |
113 | exc_c: ; èñêëþ÷åíèÿ (âñå, êðîìå 7-ãî - #NM) |
121 | ; Ôðýéì ñòåêà ïðè èñêëþ÷åíèè/ïðåðûâàíèè èç 3-ãî êîëüöà + pushad (ò.å., èìåííî çäåñü) |
114 | ; Ôðýéì ñòåêà ïðè èñêëþ÷åíèè/ïðåðûâàíèè èç 3-ãî êîëüöà + pushad (ò.å., èìåííî çäåñü) |
122 | reg_ss equ esp+0x30 |
115 | reg_ss equ esp+0x30 |
123 | reg_esp3 equ esp+0x2C |
116 | reg_esp3 equ esp+0x2C |
124 | reg_eflags equ esp+0x28 |
117 | reg_eflags equ esp+0x28 |
125 | reg_cs3 equ esp+0x24 |
118 | reg_cs3 equ esp+0x24 |
126 | reg_eip equ esp+0x20 |
119 | reg_eip equ esp+0x20 |
127 | ; ýòî ôðýéì îò pushad |
120 | ; ýòî ôðýéì îò pushad |
128 | reg_eax equ esp+0x1C |
121 | reg_eax equ esp+0x1C |
129 | reg_ecx equ esp+0x18 |
122 | reg_ecx equ esp+0x18 |
130 | reg_edx equ esp+0x14 |
123 | reg_edx equ esp+0x14 |
131 | reg_ebx equ esp+0x10 |
124 | reg_ebx equ esp+0x10 |
132 | reg_esp0 equ esp+0x0C |
125 | reg_esp0 equ esp+0x0C |
133 | reg_ebp equ esp+0x08 |
126 | reg_ebp equ esp+0x08 |
134 | reg_esi equ esp+0x04 |
127 | reg_esi equ esp+0x04 |
135 | reg_edi equ esp+0x00 |
128 | reg_edi equ esp+0x00 |
136 | 129 | ||
137 | mov ax, app_data ;èñêëþ÷åíèå |
130 | mov ax, app_data ;èñêëþ÷åíèå |
138 | mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíè |
131 | mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíè |
139 | mov es, ax ;â ðåãèñòðû |
132 | mov es, ax ;â ðåãèñòðû |
140 | cld ; è ïðèâîäèì DF ê ñòàíäàðòó |
133 | cld ; è ïðèâîäèì DF ê ñòàíäàðòó |
141 | movzx ebx,bl |
134 | movzx ebx,bl |
142 | ; redirect to V86 manager? (EFLAGS & 0x20000) != 0? |
135 | ; redirect to V86 manager? (EFLAGS & 0x20000) != 0? |
143 | test byte[reg_eflags+2],2 |
136 | test byte[reg_eflags+2],2 |
144 | jnz v86_exc_c |
137 | jnz v86_exc_c |
145 | cmp bl,14 ; #PF |
138 | cmp bl,14 ; #PF |
146 | jne @f |
139 | jne @f |
147 | call page_fault_handler ; SEE: core/memory.inc |
140 | call page_fault_handler ; SEE: core/memory.inc |
148 | @@: mov esi, [current_slot] |
141 | @@: mov esi, [current_slot] |
149 | btr [esi+APPDATA.except_mask], ebx |
142 | btr [esi+APPDATA.except_mask], ebx |
150 | jnc @f |
143 | jnc @f |
151 | mov eax,[esi+APPDATA.exc_handler] |
144 | mov eax,[esi+APPDATA.exc_handler] |
152 | test eax, eax |
145 | test eax, eax |
153 | jnz IRetToUserHook |
146 | jnz IRetToUserHook |
154 | @@: cli |
147 | @@: cli |
155 | mov eax, [esi+APPDATA.debugger_slot] |
148 | mov eax, [esi+APPDATA.debugger_slot] |
156 | test eax, eax |
149 | test eax, eax |
157 | jnz .debug |
150 | jnz .debug |
158 | sti |
151 | sti |
159 | ; not debuggee => say error and terminate |
152 | ; not debuggee => say error and terminate |
160 | call show_error_parameters ;; only ONE using, inline ??? |
153 | call show_error_parameters ;; only ONE using, inline ??? |
161 | ;mov edx, [TASK_BASE] |
154 | ;mov edx, [TASK_BASE] |
162 | mov [edx + TASKDATA.state], byte 4 ; terminate |
155 | mov [edx + TASKDATA.state], byte 4 ; terminate |
163 | 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 |
164 | .debug: |
157 | .debug: |
165 | ; we are debugged process, notify debugger and suspend ourself |
158 | ; we are debugged process, notify debugger and suspend ourself |
166 | ; eax=debugger PID |
159 | ; eax=debugger PID |
167 | mov ecx,1 ; debug_message code=other_exception |
160 | mov ecx,1 ; debug_message code=other_exception |
168 | cmp bl,1 ; #DB |
161 | cmp bl,1 ; #DB |
169 | jne .notify ; notify debugger and suspend ourself |
162 | jne .notify ; notify debugger and suspend ourself |
170 | mov ebx, dr6 ; debug_message data=DR6_image |
163 | mov ebx, dr6 ; debug_message data=DR6_image |
171 | xor edx, edx |
164 | xor edx, edx |
172 | mov dr6, edx |
165 | mov dr6, edx |
173 | mov edx, dr7 |
166 | mov edx, dr7 |
174 | mov cl, not 8 |
167 | mov cl, not 8 |
175 | .l1: shl dl,2 |
168 | .l1: shl dl,2 |
176 | jc @f |
169 | jc @f |
177 | and bl, cl |
170 | and bl, cl |
178 | @@: sar cl,1 |
171 | @@: sar cl,1 |
179 | jc .l1 |
172 | jc .l1 |
180 | mov cl, 3 ; debug_message code=debug_exception |
173 | mov cl, 3 ; debug_message code=debug_exception |
181 | .notify: |
174 | .notify: |
182 | push ebx ; debug_message data |
175 | push ebx ; debug_message data |
183 | mov ebx, [TASK_BASE] |
176 | mov ebx, [TASK_BASE] |
184 | push [ebx+TASKDATA.pid] ; PID |
177 | push [ebx+TASKDATA.pid] ; PID |
185 | push ecx ; debug_message code ((here: ecx==1/3)) |
178 | push ecx ; debug_message code ((here: ecx==1/3)) |
186 | mov cl, 12 ; debug_message size |
179 | mov cl, 12 ; debug_message size |
187 | call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc |
180 | call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc |
188 | add esp,12 |
181 | add esp,12 |
189 | mov edx, [TASK_BASE] |
182 | mov edx, [TASK_BASE] |
190 | mov byte [edx+TASKDATA.state], 1 ; suspended |
183 | mov byte [edx+TASKDATA.state], 1 ; suspended |
191 | call change_task ; SEE: core/shed.inc |
184 | call change_task ; SEE: core/shed.inc |
192 | restore_ring3_context |
185 | restore_ring3_context |
193 | iretd |
186 | iretd |
194 | 187 | ||
195 | IRetToUserHook: |
188 | IRetToUserHook: |
196 | xchg eax, [reg_eip] |
189 | xchg eax, [reg_eip] |
197 | sub dword[reg_esp3], 8 |
190 | sub dword[reg_esp3], 8 |
198 | mov edi, [reg_esp3] |
191 | mov edi, [reg_esp3] |
199 | stosd |
192 | stosd |
200 | mov [edi], ebx |
193 | mov [edi], ebx |
201 | restore_ring3_context |
194 | restore_ring3_context |
202 | ; simply return control to interrupted process |
195 | ; simply return control to interrupted process |
203 | unknown_interrupt: |
196 | unknown_interrupt: |
204 | iretd |
197 | iretd |
205 | 198 | ||
206 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
199 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
207 | ; bl - error vector |
200 | ; bl - error vector |
208 | show_error_parameters: |
201 | show_error_parameters: |
209 | cmp bl, 0x06 |
202 | cmp bl, 0x06 |
210 | jnz .no_ud |
203 | jnz .no_ud |
211 | push ebx |
204 | push ebx |
212 | mov ebx, ud_user_message |
205 | mov ebx, ud_user_message |
213 | mov ebp, notifyapp |
206 | mov ebp, notifyapp |
214 | call fs_execute_from_sysdir_param |
207 | call fs_execute_from_sysdir_param |
215 | pop ebx |
208 | pop ebx |
216 | .no_ud: |
209 | .no_ud: |
217 | mov edx,[TASK_BASE] ;not scratched below |
210 | mov edx,[TASK_BASE] ;not scratched below |
218 | 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] |
219 | cmp bl, 0x08 |
212 | cmp bl, 0x08 |
220 | jb .l0 |
213 | jb .l0 |
221 | cmp bl, 0x0e |
214 | cmp bl, 0x0e |
222 | jbe .l1 |
215 | jbe .l1 |
223 | .l0: mov bl, 0x09 |
216 | .l0: mov bl, 0x09 |
224 | .l1: mov eax,[msg_fault_sel+ebx*4 - 0x08*4] |
217 | .l1: mov eax,[msg_fault_sel+ebx*4 - 0x08*4] |
225 | DEBUGF 1, "K : %s\n", eax |
218 | DEBUGF 1, "K : %s\n", eax |
226 | mov eax, [reg_cs3+4] |
219 | mov eax, [reg_cs3+4] |
227 | mov edi, msg_sel_app |
220 | mov edi, msg_sel_app |
228 | mov ebx, [reg_esp3+4] |
221 | mov ebx, [reg_esp3+4] |
229 | cmp eax, app_code |
222 | cmp eax, app_code |
230 | je @f |
223 | je @f |
231 | mov edi, msg_sel_ker |
224 | mov edi, msg_sel_ker |
232 | mov ebx, [reg_esp0+4] |
225 | mov ebx, [reg_esp0+4] |
233 | @@: 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] |
234 | 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] |
235 | 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 |
236 | 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 |
237 | ret |
230 | ret |
238 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
231 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
239 | 232 | ||
240 | restore reg_ss |
233 | restore reg_ss |
241 | restore reg_esp3 |
234 | restore reg_esp3 |
242 | restore reg_eflags |
235 | restore reg_eflags |
243 | restore reg_cs |
236 | restore reg_cs |
244 | restore reg_eip |
237 | restore reg_eip |
245 | restore reg_eax |
238 | restore reg_eax |
246 | restore reg_ecx |
239 | restore reg_ecx |
247 | restore reg_edx |
240 | restore reg_edx |
248 | restore reg_ebx |
241 | restore reg_ebx |
249 | restore reg_esp0 |
242 | restore reg_esp0 |
250 | restore reg_ebp |
243 | restore reg_ebp |
251 | restore reg_esi |
244 | restore reg_esi |
252 | restore reg_edi |
245 | restore reg_edi |
253 | - | ||
254 | ; IRQ runtime |
- | |
255 | - | ||
256 | ; irq1 -> hid/keyboard.inc |
- | |
257 | macro irqh [num] { |
- | |
258 | p_irq#num : |
- | |
259 | mov edi, num |
- | |
260 | jmp irqhandler |
- | |
261 | } |
- | |
262 | - | ||
263 | irqh 2,3,4,5,7,8,9,10,11 |
- | |
264 | ; I don`t known how to use IRQ_RESERVE |
- | |
265 | if IRQ_RESERVE > 16 |
- | |
266 | irqh 16, 17, 18, 19, 20, 21, 22, 23 |
- | |
267 | end if |
- | |
268 | - | ||
269 | p_irq6: ; FDC |
- | |
270 | save_ring3_context |
- | |
271 | mov ax, app_data ;os_data |
- | |
272 | mov ds, ax |
- | |
273 | mov es, ax |
- | |
274 | mov edi, 6 |
- | |
275 | cmp [v86_irqhooks+edi*8], 0 |
- | |
276 | jnz v86_irq2 |
- | |
277 | call fdc_irq |
- | |
278 | mov [check_idle_semaphore], 5 |
- | |
279 | mov al, 6 |
- | |
280 | call IRQ_EOI |
- | |
281 | restore_ring3_context |
- | |
282 | iret |
- | |
283 | - | ||
284 | irq13: ; Math coprocessor |
- | |
285 | save_ring3_context |
- | |
286 | mov ax, app_data ;os_data |
- | |
287 | mov ds, ax |
- | |
288 | mov es, ax |
- | |
289 | - | ||
290 | mov dx, 0xf0 |
- | |
291 | mov al, 0 |
- | |
292 | out dx, al |
- | |
293 | - | ||
294 | mov al, 13 |
- | |
295 | call IRQ_EOI |
- | |
296 | restore_ring3_context |
- | |
297 | iret |
- | |
298 | - | ||
299 | p_irq14: ; HDD |
- | |
300 | save_ring3_context |
- | |
301 | mov ax, app_data ;os_data |
- | |
302 | mov ds, ax |
- | |
303 | mov es, ax |
- | |
304 | mov edi, 14 |
- | |
305 | cmp [v86_irqhooks+edi*8], 0 |
- | |
306 | jnz v86_irq2 |
- | |
307 | ; mov byte [BOOT_VAR + 0x48E], 0xFF |
- | |
308 | call [irq14_func] |
- | |
309 | mov [check_idle_semaphore], 5 |
- | |
310 | mov al, 14 |
- | |
311 | call IRQ_EOI |
- | |
312 | restore_ring3_context |
- | |
313 | iret |
- | |
314 | - | ||
315 | p_irq15: ; HDD2 |
- | |
316 | save_ring3_context |
- | |
317 | mov ax, app_data ;os_data |
- | |
318 | mov ds, ax |
- | |
319 | mov es, ax |
- | |
320 | mov edi, 15 |
- | |
321 | cmp [v86_irqhooks+edi*8], 0 |
- | |
322 | jnz v86_irq2 |
- | |
323 | ; mov byte [BOOT_VAR + 0x48E], 0xFF |
- | |
324 | call [irq15_func] |
- | |
325 | mov [check_idle_semaphore], 5 |
- | |
326 | mov al, 15 |
- | |
327 | call IRQ_EOI |
- | |
328 | restore_ring3_context |
- | |
329 | iret |
- | |
330 | - | ||
331 | ready_for_next_irq: |
- | |
332 | mov eax,5 |
- | |
333 | mov [check_idle_semaphore],eax |
- | |
334 | ; mov al, 0x20 |
- | |
335 | add eax,(0x20-0x5) |
- | |
336 | - | ||
337 | out 0x20, al |
- | |
338 | ret |
- | |
339 | ;destroy eax |
- | |
340 | ready_for_next_irq_1: |
- | |
341 | mov eax,5 |
- | |
342 | mov [check_idle_semaphore],eax |
- | |
343 | ; mov al, 0x20 |
- | |
344 | add eax,(0x20-0x5) |
- | |
345 | out 0xa0,al |
- | |
346 | out 0x20, al |
- | |
- | 246 | ||
347 | ret |
247 | |
348 | 248 | align 4 |
|
349 | irqD: |
249 | irqD: |
350 | push eax |
250 | push eax |
351 | xor eax,eax |
251 | xor eax,eax |
352 | out 0xf0,al |
252 | out 0xf0,al |
353 | mov al,0x20 |
253 | mov al,0x20 |
354 | out 0xa0,al |
254 | out 0xa0,al |
355 | out 0x20,al |
255 | out 0x20,al |
356 | pop eax |
256 | pop eax |
357 | iret |
257 | iret |
358 | 258 | ||
359 | 259 | ||
360 | align 4 |
260 | align 4 |
361 | - | ||
362 | irqhandler: |
- | |
363 | - | ||
364 | mov esi,edi ; 1 |
- | |
365 | shl esi,6 ; 1 |
- | |
366 | add esi,irq00read ; 1 |
- | |
367 | shl edi,12 ; 1 |
- | |
368 | add edi,IRQ_SAVE |
- | |
369 | mov ecx,16 |
- | |
370 | - | ||
371 | irqnewread: |
- | |
372 | dec ecx |
- | |
373 | js irqover |
- | |
374 | - | ||
375 | movzx edx, word [esi] ; 2+ |
- | |
376 | - | ||
377 | test edx, edx ; 1 |
- | |
378 | jz irqover |
- | |
379 | - | ||
380 | - | ||
381 | mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size |
- | |
382 | mov eax, 4000 ; + 0x4 dword - data begin offset |
- | |
383 | cmp ebx, eax |
- | |
384 | je irqfull |
- | |
385 | add ebx, [edi + 0x4] ; add data size to data begin offset |
- | |
386 | cmp ebx, eax ; if end of buffer, begin cycle again |
- | |
387 | jb @f |
- | |
388 | - | ||
389 | xor ebx, ebx |
- | |
390 | - | ||
391 | @@: |
- | |
392 | add ebx, edi |
- | |
393 | movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word |
- | |
394 | dec eax |
- | |
395 | jz irqbyte |
- | |
396 | dec eax |
- | |
397 | jnz noirqword |
- | |
398 | - | ||
399 | in ax,dx |
- | |
400 | cmp ebx, 3999 ; check for address odd in the end of buffer |
- | |
401 | jne .odd |
- | |
402 | mov [ebx + 0x10], ax |
- | |
403 | jmp .add_size |
- | |
404 | .odd: |
- | |
405 | mov [ebx + 0x10], al ; I could make mistake here :) |
- | |
406 | mov [edi + 0x10], ah |
- | |
407 | .add_size: |
- | |
408 | add dword [edi], 2 |
- | |
409 | jmp nextport |
- | |
410 | - | ||
411 | - | ||
412 | irqbyte: |
- | |
413 | in al,dx |
- | |
414 | mov [ebx + 0x10],al |
- | |
415 | inc dword [edi] |
- | |
416 | nextport: |
- | |
417 | add esi,4 |
- | |
418 | jmp irqnewread |
- | |
419 | - | ||
420 | - | ||
421 | noirqword: |
- | |
422 | irqfull: |
- | |
423 | irqover: |
- | |
424 | - | ||
425 | ret |
- | |
426 | - | ||
427 | - | ||
428 | - | ||
429 | set_application_table_status: |
261 | set_application_table_status: |
430 | push eax |
262 | push eax |
431 | 263 | ||
432 | mov eax,[CURRENT_TASK] |
264 | mov eax,[CURRENT_TASK] |
433 | shl eax, 5 |
265 | shl eax, 5 |
434 | add eax,CURRENT_TASK+TASKDATA.pid |
266 | add eax,CURRENT_TASK+TASKDATA.pid |
435 | mov eax,[eax] |
267 | mov eax,[eax] |
436 | 268 | ||
437 | mov [application_table_status],eax |
269 | mov [application_table_status],eax |
438 | 270 | ||
439 | pop eax |
271 | pop eax |
440 | 272 | ||
441 | ret |
273 | ret |
442 | 274 | ||
443 | 275 | align 4 |
|
444 | clear_application_table_status: |
276 | clear_application_table_status: |
445 | push eax |
277 | push eax |
446 | 278 | ||
447 | mov eax,[CURRENT_TASK] |
279 | mov eax,[CURRENT_TASK] |
448 | shl eax, 5 |
280 | shl eax, 5 |
449 | add eax,CURRENT_TASK+TASKDATA.pid |
281 | add eax,CURRENT_TASK+TASKDATA.pid |
450 | mov eax,[eax] |
282 | mov eax,[eax] |
451 | 283 | ||
452 | cmp eax,[application_table_status] |
284 | cmp eax,[application_table_status] |
453 | jne apptsl1 |
285 | jne apptsl1 |
454 | xor eax,eax |
286 | xor eax,eax |
455 | mov [application_table_status],eax |
287 | mov [application_table_status],eax |
456 | apptsl1: |
288 | apptsl1: |
457 | 289 | ||
458 | pop eax |
290 | pop eax |
459 | 291 | ||
460 | ret |
292 | ret |
461 | 293 | ||
462 | ; * eax = 64 - íîìåð ôóíêöèè |
294 | ; * eax = 64 - íîìåð ôóíêöèè |
463 | ; * ebx = 1 - åäèíñòâåííàÿ ïîäôóíêöèÿ |
295 | ; * ebx = 1 - åäèíñòâåííàÿ ïîäôóíêöèÿ |
464 | ; * ecx = íîâûé ðàçìåð ïàìÿòè |
296 | ; * ecx = íîâûé ðàçìåð ïàìÿòè |
465 | ;Âîçâðàùàåìîå çíà÷åíèå: |
297 | ;Âîçâðàùàåìîå çíà÷åíèå: |
466 | ; * eax = 0 - óñïåøíî |
298 | ; * eax = 0 - óñïåøíî |
467 | ; * eax = 1 - íåäîñòàòî÷íî ïàìÿòè |
299 | ; * eax = 1 - íåäîñòàòî÷íî ïàìÿòè |
- | 300 | ||
468 | 301 | align 4 |
|
469 | sys_resize_app_memory: |
302 | sys_resize_app_memory: |
470 | ; ebx = 1 - resize |
303 | ; ebx = 1 - resize |
471 | ; ecx = new amount of memory |
304 | ; ecx = new amount of memory |
472 | 305 | ||
473 | ; cmp eax,1 |
306 | ; cmp eax,1 |
474 | dec ebx |
307 | dec ebx |
475 | jnz .no_application_mem_resize |
308 | jnz .no_application_mem_resize |
476 | stdcall new_mem_resize, ecx |
309 | stdcall new_mem_resize, ecx |
477 | mov [esp+32], eax |
310 | mov [esp+32], eax |
478 | .no_application_mem_resize: |
311 | .no_application_mem_resize: |
479 | ret |
312 | ret |
480 | 313 | ||
481 | iglobal |
314 | iglobal |
482 | ; process_terminating db 'K : Process - terminating',13,10,0 |
315 | ; process_terminating db 'K : Process - terminating',13,10,0 |
483 | ; process_terminated db 'K : Process - done',13,10,0 |
316 | ; process_terminated db 'K : Process - done',13,10,0 |
484 | msg_obj_destroy db 'K : destroy app object',13,10,0 |
317 | msg_obj_destroy db 'K : destroy app object',13,10,0 |
485 | endg |
318 | endg |
486 | 319 | ||
487 | ; param |
320 | ; param |
488 | ; esi= slot |
321 | ; esi= slot |
- | 322 | ||
489 | 323 | align 4 |
|
490 | terminate: ; terminate application |
324 | terminate: ; terminate application |
491 | 325 | ||
492 | .slot equ esp ;locals |
326 | .slot equ esp ;locals |
493 | 327 | ||
494 | push esi ;save .slot |
328 | push esi ;save .slot |
495 | 329 | ||
496 | shl esi, 8 |
330 | shl esi, 8 |
497 | cmp [SLOT_BASE+esi+APPDATA.dir_table], 0 |
331 | cmp [SLOT_BASE+esi+APPDATA.dir_table], 0 |
498 | jne @F |
332 | jne @F |
499 | pop esi |
333 | pop esi |
500 | shl esi, 5 |
334 | shl esi, 5 |
501 | mov [CURRENT_TASK+esi+TASKDATA.state], 9 |
335 | mov [CURRENT_TASK+esi+TASKDATA.state], 9 |
502 | ret |
336 | ret |
503 | @@: |
337 | @@: |
504 | ;mov esi,process_terminating |
338 | ;mov esi,process_terminating |
505 | ;call sys_msg_board_str |
339 | ;call sys_msg_board_str |
506 | @@: |
340 | @@: |
507 | cli |
341 | cli |
508 | cmp [application_table_status],0 |
342 | cmp [application_table_status],0 |
509 | je term9 |
343 | je term9 |
510 | sti |
344 | sti |
511 | call change_task |
345 | call change_task |
512 | jmp @b |
346 | jmp @b |
513 | term9: |
347 | term9: |
514 | call set_application_table_status |
348 | call set_application_table_status |
515 | 349 | ||
516 | ; if the process is in V86 mode... |
350 | ; if the process is in V86 mode... |
517 | mov eax, [.slot] |
351 | mov eax, [.slot] |
518 | shl eax, 8 |
352 | shl eax, 8 |
519 | mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack] |
353 | mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack] |
520 | add esi, RING0_STACK_SIZE |
354 | add esi, RING0_STACK_SIZE |
521 | cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi |
355 | cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi |
522 | jz .nov86 |
356 | jz .nov86 |
523 | ; ...it has page directory for V86 mode |
357 | ; ...it has page directory for V86 mode |
524 | mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0] |
358 | mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0] |
525 | mov ecx, [esi+4] |
359 | mov ecx, [esi+4] |
526 | mov [eax+SLOT_BASE+APPDATA.dir_table], ecx |
360 | mov [eax+SLOT_BASE+APPDATA.dir_table], ecx |
527 | ; ...and I/O permission map for V86 mode |
361 | ; ...and I/O permission map for V86 mode |
528 | mov ecx, [esi+12] |
362 | mov ecx, [esi+12] |
529 | mov [eax+SLOT_BASE+APPDATA.io_map], ecx |
363 | mov [eax+SLOT_BASE+APPDATA.io_map], ecx |
530 | mov ecx, [esi+8] |
364 | mov ecx, [esi+8] |
531 | mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx |
365 | mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx |
532 | .nov86: |
366 | .nov86: |
533 | 367 | ||
534 | mov esi, [.slot] |
368 | mov esi, [.slot] |
535 | shl esi,8 |
369 | shl esi,8 |
536 | add esi, SLOT_BASE+APP_OBJ_OFFSET |
370 | add esi, SLOT_BASE+APP_OBJ_OFFSET |
537 | @@: |
371 | @@: |
538 | mov eax, [esi+APPOBJ.fd] |
372 | mov eax, [esi+APPOBJ.fd] |
539 | test eax, eax |
373 | test eax, eax |
540 | jz @F |
374 | jz @F |
541 | 375 | ||
542 | cmp eax, esi |
376 | cmp eax, esi |
543 | je @F |
377 | je @F |
544 | 378 | ||
545 | push esi |
379 | push esi |
546 | call [eax+APPOBJ.destroy] |
380 | call [eax+APPOBJ.destroy] |
547 | DEBUGF 1,"%s",msg_obj_destroy |
381 | DEBUGF 1,"%s",msg_obj_destroy |
548 | pop esi |
382 | pop esi |
549 | jmp @B |
383 | jmp @B |
550 | @@: |
384 | @@: |
551 | 385 | ||
552 | mov eax, [.slot] |
386 | mov eax, [.slot] |
553 | shl eax, 8 |
387 | shl eax, 8 |
554 | stdcall destroy_app_space, [SLOT_BASE+eax+APPDATA.dir_table], [SLOT_BASE+eax+APPDATA.dlls_list_ptr] |
388 | stdcall destroy_app_space, [SLOT_BASE+eax+APPDATA.dir_table], [SLOT_BASE+eax+APPDATA.dlls_list_ptr] |
555 | 389 | ||
556 | mov esi, [.slot] |
390 | mov esi, [.slot] |
557 | cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
391 | cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
558 | jne @F |
392 | jne @F |
559 | 393 | ||
560 | mov [fpu_owner],1 |
394 | mov [fpu_owner],1 |
561 | mov eax, [256+SLOT_BASE+APPDATA.fpu_state] |
395 | mov eax, [256+SLOT_BASE+APPDATA.fpu_state] |
562 | clts |
396 | clts |
563 | bt [cpu_caps], CAPS_SSE |
397 | bt [cpu_caps], CAPS_SSE |
564 | jnc .no_SSE |
398 | jnc .no_SSE |
565 | fxrstor [eax] |
399 | fxrstor [eax] |
566 | jmp @F |
400 | jmp @F |
567 | .no_SSE: |
401 | .no_SSE: |
568 | fnclex |
402 | fnclex |
569 | frstor [eax] |
403 | frstor [eax] |
570 | @@: |
404 | @@: |
571 | 405 | ||
572 | mov [KEY_COUNT],byte 0 ; empty keyboard buffer |
406 | mov [KEY_COUNT],byte 0 ; empty keyboard buffer |
573 | mov [BTN_COUNT],byte 0 ; empty button buffer |
407 | mov [BTN_COUNT],byte 0 ; empty button buffer |
574 | 408 | ||
575 | 409 | ||
576 | ; remove defined hotkeys |
410 | ; remove defined hotkeys |
577 | mov eax, hotkey_list |
411 | mov eax, hotkey_list |
578 | .loop: |
412 | .loop: |
579 | cmp [eax+8], esi |
413 | cmp [eax+8], esi |
580 | jnz .cont |
414 | jnz .cont |
581 | mov ecx, [eax] |
415 | mov ecx, [eax] |
582 | jecxz @f |
416 | jecxz @f |
583 | push dword [eax+12] |
417 | push dword [eax+12] |
584 | pop dword [ecx+12] |
418 | pop dword [ecx+12] |
585 | @@: |
419 | @@: |
586 | mov ecx, [eax+12] |
420 | mov ecx, [eax+12] |
587 | push dword [eax] |
421 | push dword [eax] |
588 | pop dword [ecx] |
422 | pop dword [ecx] |
589 | xor ecx, ecx |
423 | xor ecx, ecx |
590 | mov [eax], ecx |
424 | mov [eax], ecx |
591 | mov [eax+4], ecx |
425 | mov [eax+4], ecx |
592 | mov [eax+8], ecx |
426 | mov [eax+8], ecx |
593 | mov [eax+12], ecx |
427 | mov [eax+12], ecx |
594 | .cont: |
428 | .cont: |
595 | add eax, 16 |
429 | add eax, 16 |
596 | cmp eax, hotkey_list+256*16 |
430 | cmp eax, hotkey_list+256*16 |
597 | jb .loop |
431 | jb .loop |
598 | ; remove hotkeys in buffer |
432 | ; remove hotkeys in buffer |
599 | mov eax, hotkey_buffer |
433 | mov eax, hotkey_buffer |
600 | .loop2: |
434 | .loop2: |
601 | cmp [eax], esi |
435 | cmp [eax], esi |
602 | jnz .cont2 |
436 | jnz .cont2 |
603 | and dword [eax+4], 0 |
437 | and dword [eax+4], 0 |
604 | and dword [eax], 0 |
438 | and dword [eax], 0 |
605 | .cont2: |
439 | .cont2: |
606 | add eax, 8 |
440 | add eax, 8 |
607 | cmp eax, hotkey_buffer+120*8 |
441 | cmp eax, hotkey_buffer+120*8 |
608 | jb .loop2 |
442 | jb .loop2 |
609 | 443 | ||
610 | mov ecx,esi ; remove buttons |
444 | mov ecx,esi ; remove buttons |
611 | bnewba2: |
445 | bnewba2: |
612 | mov edi,[BTN_ADDR] |
446 | mov edi,[BTN_ADDR] |
613 | mov eax,edi |
447 | mov eax,edi |
614 | cld |
448 | cld |
615 | movzx ebx,word [edi] |
449 | movzx ebx,word [edi] |
616 | inc bx |
450 | inc bx |
617 | bnewba: |
451 | bnewba: |
618 | dec bx |
452 | dec bx |
619 | jz bnmba |
453 | jz bnmba |
620 | add eax,0x10 |
454 | add eax,0x10 |
621 | cmp cx,[eax] |
455 | cmp cx,[eax] |
622 | jnz bnewba |
456 | jnz bnewba |
623 | pusha |
457 | pusha |
624 | mov ecx,ebx |
458 | mov ecx,ebx |
625 | inc ecx |
459 | inc ecx |
626 | shl ecx,4 |
460 | shl ecx,4 |
627 | mov ebx,eax |
461 | mov ebx,eax |
628 | add eax,0x10 |
462 | add eax,0x10 |
629 | call memmove |
463 | call memmove |
630 | dec dword [edi] |
464 | dec dword [edi] |
631 | popa |
465 | popa |
632 | jmp bnewba2 |
466 | jmp bnewba2 |
633 | bnmba: |
467 | bnmba: |
634 | 468 | ||
635 | pusha ; save window coordinates for window restoring |
469 | pusha ; save window coordinates for window restoring |
636 | cld |
470 | cld |
637 | shl esi,5 |
471 | shl esi,5 |
638 | add esi,window_data |
472 | add esi,window_data |
639 | mov eax,[esi+WDATA.box.left] |
473 | mov eax,[esi+WDATA.box.left] |
640 | mov [draw_limits.left],eax |
474 | mov [draw_limits.left],eax |
641 | add eax,[esi+WDATA.box.width] |
475 | add eax,[esi+WDATA.box.width] |
642 | mov [draw_limits.right],eax |
476 | mov [draw_limits.right],eax |
643 | mov eax,[esi+WDATA.box.top] |
477 | mov eax,[esi+WDATA.box.top] |
644 | mov [draw_limits.top],eax |
478 | mov [draw_limits.top],eax |
645 | add eax,[esi+WDATA.box.height] |
479 | add eax,[esi+WDATA.box.height] |
646 | mov [draw_limits.bottom],eax |
480 | mov [draw_limits.bottom],eax |
647 | 481 | ||
648 | xor eax, eax |
482 | xor eax, eax |
649 | mov [esi+WDATA.box.left],eax |
483 | mov [esi+WDATA.box.left],eax |
650 | mov [esi+WDATA.box.width],eax |
484 | mov [esi+WDATA.box.width],eax |
651 | mov [esi+WDATA.box.top],eax |
485 | mov [esi+WDATA.box.top],eax |
652 | mov [esi+WDATA.box.height],eax |
486 | mov [esi+WDATA.box.height],eax |
653 | mov [esi+WDATA.cl_workarea],eax |
487 | mov [esi+WDATA.cl_workarea],eax |
654 | mov [esi+WDATA.cl_titlebar],eax |
488 | mov [esi+WDATA.cl_titlebar],eax |
655 | mov [esi+WDATA.cl_frames],eax |
489 | mov [esi+WDATA.cl_frames],eax |
656 | mov dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn |
490 | mov dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn |
657 | lea edi, [esi-window_data+draw_data] |
491 | lea edi, [esi-window_data+draw_data] |
658 | mov ecx,32/4 |
492 | mov ecx,32/4 |
659 | rep stosd |
493 | rep stosd |
660 | popa |
494 | popa |
661 | 495 | ||
662 | ; debuggee test |
496 | ; debuggee test |
663 | pushad |
497 | pushad |
664 | mov edi, esi |
498 | mov edi, esi |
665 | shl edi, 5 |
499 | shl edi, 5 |
666 | mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] |
500 | mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] |
667 | test eax, eax |
501 | test eax, eax |
668 | jz .nodebug |
502 | jz .nodebug |
669 | push 8 |
503 | push 8 |
670 | pop ecx |
504 | pop ecx |
671 | push dword [CURRENT_TASK+edi+TASKDATA.pid] ; PID |
505 | push dword [CURRENT_TASK+edi+TASKDATA.pid] ; PID |
672 | push 2 |
506 | push 2 |
673 | call debugger_notify |
507 | call debugger_notify |
674 | pop ecx |
508 | pop ecx |
675 | pop ecx |
509 | pop ecx |
676 | .nodebug: |
510 | .nodebug: |
677 | popad |
511 | popad |
678 | 512 | ||
679 | mov ebx, [.slot] |
513 | mov ebx, [.slot] |
680 | shl ebx, 8 |
514 | shl ebx, 8 |
681 | push ebx |
515 | push ebx |
682 | mov ebx,[SLOT_BASE+ebx+APPDATA.pl0_stack] |
516 | mov ebx,[SLOT_BASE+ebx+APPDATA.pl0_stack] |
683 | 517 | ||
684 | stdcall kernel_free, ebx |
518 | stdcall kernel_free, ebx |
685 | 519 | ||
686 | pop ebx |
520 | pop ebx |
687 | mov ebx,[SLOT_BASE+ebx+APPDATA.cur_dir] |
521 | mov ebx,[SLOT_BASE+ebx+APPDATA.cur_dir] |
688 | stdcall kernel_free, ebx |
522 | stdcall kernel_free, ebx |
689 | 523 | ||
690 | mov edi, [.slot] |
524 | mov edi, [.slot] |
691 | shl edi,8 |
525 | shl edi,8 |
692 | add edi,SLOT_BASE |
526 | add edi,SLOT_BASE |
693 | 527 | ||
694 | mov eax, [edi+APPDATA.io_map] |
528 | mov eax, [edi+APPDATA.io_map] |
695 | cmp eax, [SLOT_BASE+256+APPDATA.io_map] |
529 | cmp eax, [SLOT_BASE+256+APPDATA.io_map] |
696 | je @F |
530 | je @F |
697 | call free_page |
531 | call free_page |
698 | @@: |
532 | @@: |
699 | mov eax, [edi+APPDATA.io_map+4] |
533 | mov eax, [edi+APPDATA.io_map+4] |
700 | cmp eax, [SLOT_BASE+256+APPDATA.io_map+4] |
534 | cmp eax, [SLOT_BASE+256+APPDATA.io_map+4] |
701 | je @F |
535 | je @F |
702 | call free_page |
536 | call free_page |
703 | @@: |
537 | @@: |
704 | mov eax, 0x20202020 |
538 | mov eax, 0x20202020 |
705 | stosd |
539 | stosd |
706 | stosd |
540 | stosd |
707 | stosd |
541 | stosd |
708 | mov ecx,244/4 |
542 | mov ecx,244/4 |
709 | xor eax, eax |
543 | xor eax, eax |
710 | rep stosd |
544 | rep stosd |
711 | 545 | ||
712 | ; activate window |
546 | ; activate window |
713 | movzx eax, word [WIN_STACK + esi*2] |
547 | movzx eax, word [WIN_STACK + esi*2] |
714 | cmp eax, [TASK_COUNT] |
548 | cmp eax, [TASK_COUNT] |
715 | jne .dont_activate |
549 | jne .dont_activate |
716 | pushad |
550 | pushad |
717 | .check_next_window: |
551 | .check_next_window: |
718 | dec eax |
552 | dec eax |
719 | cmp eax, 1 |
553 | cmp eax, 1 |
720 | jbe .nothing_to_activate |
554 | jbe .nothing_to_activate |
721 | lea esi, [WIN_POS+eax*2] |
555 | lea esi, [WIN_POS+eax*2] |
722 | movzx edi, word [esi] ; edi = process |
556 | movzx edi, word [esi] ; edi = process |
723 | shl edi, 5 |
557 | shl edi, 5 |
724 | cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots |
558 | cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots |
725 | je .check_next_window |
559 | je .check_next_window |
726 | add edi, window_data |
560 | add edi, window_data |
727 | ; \begin{diamond}[19.09.2006] |
561 | ; \begin{diamond}[19.09.2006] |
728 | ; skip minimized windows |
562 | ; skip minimized windows |
729 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
563 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
730 | jnz .check_next_window |
564 | jnz .check_next_window |
731 | ; \end{diamond} |
565 | ; \end{diamond} |
732 | call waredraw |
566 | call waredraw |
733 | .nothing_to_activate: |
567 | .nothing_to_activate: |
734 | popad |
568 | popad |
735 | .dont_activate: |
569 | .dont_activate: |
736 | 570 | ||
737 | push esi ; remove hd1 & cd & flp reservation |
571 | push esi ; remove hd1 & cd & flp reservation |
738 | shl esi, 5 |
572 | shl esi, 5 |
739 | mov esi, [esi+CURRENT_TASK+TASKDATA.pid] |
573 | mov esi, [esi+CURRENT_TASK+TASKDATA.pid] |
740 | cmp [hd1_status], esi |
574 | cmp [hd1_status], esi |
741 | jnz @f |
575 | jnz @f |
742 | call free_hd_channel |
576 | call free_hd_channel |
743 | and [hd1_status], 0 |
577 | and [hd1_status], 0 |
744 | @@: |
578 | @@: |
745 | cmp [cd_status], esi |
579 | cmp [cd_status], esi |
746 | jnz @f |
580 | jnz @f |
747 | call free_cd_channel |
581 | call free_cd_channel |
748 | and [cd_status], 0 |
582 | and [cd_status], 0 |
749 | @@: |
583 | @@: |
750 | cmp [flp_status], esi |
584 | cmp [flp_status], esi |
751 | jnz @f |
585 | jnz @f |
752 | and [flp_status], 0 |
586 | and [flp_status], 0 |
753 | @@: |
587 | @@: |
754 | pop esi |
588 | pop esi |
755 | cmp [bgrlockpid], esi |
589 | cmp [bgrlockpid], esi |
756 | jnz @f |
590 | jnz @f |
757 | and [bgrlockpid], 0 |
591 | and [bgrlockpid], 0 |
758 | and [bgrlock], 0 |
592 | and [bgrlock], 0 |
759 | @@: |
593 | @@: |
760 | - | ||
761 | pusha ; remove all irq reservations |
- | |
762 | mov eax,esi |
- | |
763 | shl eax, 5 |
- | |
764 | mov eax,[eax+CURRENT_TASK+TASKDATA.pid] |
- | |
765 | mov edi,irq_owner |
- | |
766 | xor ebx, ebx |
- | |
767 | xor edx, edx |
- | |
768 | newirqfree: |
- | |
769 | cmp [edi + 4 * ebx], eax |
- | |
770 | jne nofreeirq |
- | |
771 | mov [edi + 4 * ebx], edx ; remove irq reservation |
- | |
772 | mov [irq_tab + 4 * ebx], edx ; remove irq handler |
- | |
773 | mov [irq_rights + 4 * ebx], edx ; set access rights to full access |
- | |
774 | nofreeirq: |
- | |
775 | inc ebx |
- | |
776 | cmp ebx, 16 |
- | |
777 | jb newirqfree |
- | |
778 | popa |
- | |
779 | 594 | ||
780 | pusha ; remove all port reservations |
595 | pusha ; remove all port reservations |
781 | mov edx,esi |
596 | mov edx,esi |
782 | shl edx, 5 |
597 | shl edx, 5 |
783 | add edx,CURRENT_TASK |
598 | add edx,CURRENT_TASK |
784 | mov edx,[edx+TASKDATA.pid] |
599 | mov edx,[edx+TASKDATA.pid] |
785 | 600 | ||
786 | rmpr0: |
601 | rmpr0: |
787 | 602 | ||
788 | mov esi,[RESERVED_PORTS] |
603 | mov esi,[RESERVED_PORTS] |
789 | 604 | ||
790 | test esi,esi |
605 | test esi,esi |
791 | jz rmpr9 |
606 | jz rmpr9 |
792 | 607 | ||
793 | rmpr3: |
608 | rmpr3: |
794 | 609 | ||
795 | mov edi,esi |
610 | mov edi,esi |
796 | shl edi,4 |
611 | shl edi,4 |
797 | add edi,RESERVED_PORTS |
612 | add edi,RESERVED_PORTS |
798 | 613 | ||
799 | cmp edx,[edi] |
614 | cmp edx,[edi] |
800 | je rmpr4 |
615 | je rmpr4 |
801 | 616 | ||
802 | dec esi |
617 | dec esi |
803 | jnz rmpr3 |
618 | jnz rmpr3 |
804 | 619 | ||
805 | jmp rmpr9 |
620 | jmp rmpr9 |
806 | 621 | ||
807 | rmpr4: |
622 | rmpr4: |
808 | 623 | ||
809 | mov ecx,256 |
624 | mov ecx,256 |
810 | sub ecx,esi |
625 | sub ecx,esi |
811 | shl ecx,4 |
626 | shl ecx,4 |
812 | 627 | ||
813 | mov esi,edi |
628 | mov esi,edi |
814 | add esi,16 |
629 | add esi,16 |
815 | cld |
630 | cld |
816 | rep movsb |
631 | rep movsb |
817 | 632 | ||
818 | dec dword [RESERVED_PORTS] |
633 | dec dword [RESERVED_PORTS] |
819 | 634 | ||
820 | jmp rmpr0 |
635 | jmp rmpr0 |
821 | 636 | ||
822 | rmpr9: |
637 | rmpr9: |
823 | 638 | ||
824 | popa |
639 | popa |
825 | mov edi,esi ; do not run this process slot |
640 | mov edi,esi ; do not run this process slot |
826 | shl edi, 5 |
641 | shl edi, 5 |
827 | mov [edi+CURRENT_TASK + TASKDATA.state],byte 9 |
642 | mov [edi+CURRENT_TASK + TASKDATA.state],byte 9 |
828 | ; debugger test - terminate all debuggees |
643 | ; debugger test - terminate all debuggees |
829 | mov eax, 2 |
644 | mov eax, 2 |
830 | mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot |
645 | mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot |
831 | .xd0: |
646 | .xd0: |
832 | cmp eax, [TASK_COUNT] |
647 | cmp eax, [TASK_COUNT] |
833 | ja .xd1 |
648 | ja .xd1 |
834 | cmp dword [ecx], esi |
649 | cmp dword [ecx], esi |
835 | jnz @f |
650 | jnz @f |
836 | and dword [ecx], 0 |
651 | and dword [ecx], 0 |
837 | pushad |
652 | pushad |
838 | xchg eax, ecx |
653 | xchg eax, ecx |
839 | mov ebx, 2 |
654 | mov ebx, 2 |
840 | call sys_system |
655 | call sys_system |
841 | popad |
656 | popad |
842 | @@: |
657 | @@: |
843 | inc eax |
658 | inc eax |
844 | add ecx, 0x100 |
659 | add ecx, 0x100 |
845 | jmp .xd0 |
660 | jmp .xd0 |
846 | .xd1: |
661 | .xd1: |
847 | ; call systest |
662 | ; call systest |
848 | sti ; .. and life goes on |
663 | sti ; .. and life goes on |
849 | 664 | ||
850 | mov eax, [draw_limits.left] |
665 | mov eax, [draw_limits.left] |
851 | mov ebx, [draw_limits.top] |
666 | mov ebx, [draw_limits.top] |
852 | mov ecx, [draw_limits.right] |
667 | mov ecx, [draw_limits.right] |
853 | mov edx, [draw_limits.bottom] |
668 | mov edx, [draw_limits.bottom] |
854 | call calculatescreen |
669 | call calculatescreen |
855 | xor eax, eax |
670 | xor eax, eax |
856 | xor esi, esi |
671 | xor esi, esi |
857 | call redrawscreen |
672 | call redrawscreen |
858 | 673 | ||
859 | mov [MOUSE_BACKGROUND],byte 0 ; no mouse background |
674 | mov [MOUSE_BACKGROUND],byte 0 ; no mouse background |
860 | mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse |
675 | mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse |
861 | 676 | ||
862 | and [application_table_status],0 |
677 | and [application_table_status],0 |
863 | ;mov esi,process_terminated |
678 | ;mov esi,process_terminated |
864 | ;call sys_msg_board_str |
679 | ;call sys_msg_board_str |
865 | add esp, 4 |
680 | add esp, 4 |
866 | ret |
681 | ret |
867 | restore .slot |
682 | restore .slot |
868 | 683 | ||
869 | iglobal |
684 | iglobal |
870 | boot_sched_1 db 'Building gdt tss pointer',0 |
685 | boot_sched_1 db 'Building gdt tss pointer',0 |
871 | boot_sched_2 db 'Building IDT table',0 |
686 | boot_sched_2 db 'Building IDT table',0 |
872 | endg |
687 | endg |
873 | 688 | ||
874 | 689 | ||
875 | build_scheduler: |
690 | build_scheduler: |
876 | 691 | ||
877 | mov esi,boot_sched_1 |
692 | mov esi,boot_sched_1 |
878 | call boot_log |
693 | call boot_log |
879 | ; call build_process_gdt_tss_pointer |
694 | ; call build_process_gdt_tss_pointer |
880 | 695 | ||
881 | ; mov esi,boot_sched_2 |
696 | ; mov esi,boot_sched_2 |
882 | ; call boot_log |
697 | ; call boot_log |
883 | 698 | ||
884 | ret |
699 | ret |