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