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