Rev 203 | Rev 221 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 203 | Rev 214 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; MenuetOS process management, protected ring3 ;; |
3 | ;; MenuetOS process management, protected ring3 ;; |
4 | ;; ;; |
4 | ;; ;; |
5 | ;; Distributed under GPL. See file COPYING for details. ;; |
5 | ;; Distributed under GPL. See file COPYING for details. ;; |
6 | ;; Copyright 2003 Ville Turjanmaa ;; |
6 | ;; Copyright 2003 Ville Turjanmaa ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
9 | 9 | ||
10 | idtreg: |
10 | idtreg: |
11 | dw 8*0x41-1 |
11 | dw 8*0x41-1 |
12 | dd idts+8 |
12 | dd idts+8 |
13 | ;label idts at 0xB100-8 |
13 | ;label idts at 0xB100-8 |
14 | 14 | ||
15 | 15 | ||
16 | uglobal |
16 | uglobal |
17 | tss_sceleton: |
17 | tss_sceleton: |
18 | l.back dw 0,0 |
18 | l.back dw 0,0 |
19 | l.esp0 dd 0 |
19 | l.esp0 dd 0 |
20 | l.ss0 dw 0,0 |
20 | l.ss0 dw 0,0 |
21 | l.esp1 dd 0 |
21 | l.esp1 dd 0 |
22 | l.ss1 dw 0,0 |
22 | l.ss1 dw 0,0 |
23 | l.esp2 dd 0 |
23 | l.esp2 dd 0 |
24 | l.ss2 dw 0,0 |
24 | l.ss2 dw 0,0 |
25 | l.cr3 dd 0 |
25 | l.cr3 dd 0 |
26 | l.eip dd 0 |
26 | l.eip dd 0 |
27 | l.eflags dd 0 |
27 | l.eflags dd 0 |
28 | l.eax dd 0 |
28 | l.eax dd 0 |
29 | l.ecx dd 0 |
29 | l.ecx dd 0 |
30 | l.edx dd 0 |
30 | l.edx dd 0 |
31 | l.ebx dd 0 |
31 | l.ebx dd 0 |
32 | l.esp dd 0 |
32 | l.esp dd 0 |
33 | l.ebp dd 0 |
33 | l.ebp dd 0 |
34 | l.esi dd 0 |
34 | l.esi dd 0 |
35 | l.edi dd 0 |
35 | l.edi dd 0 |
36 | l.es dw 0,0 |
36 | l.es dw 0,0 |
37 | l.cs dw 0,0 |
37 | l.cs dw 0,0 |
38 | l.ss dw 0,0 |
38 | l.ss dw 0,0 |
39 | l.ds dw 0,0 |
39 | l.ds dw 0,0 |
40 | l.fs dw 0,0 |
40 | l.fs dw 0,0 |
41 | l.gs dw 0,0 |
41 | l.gs dw 0,0 |
42 | l.ldt dw 0,0 |
42 | l.ldt dw 0,0 |
43 | l.trap dw 0 |
43 | l.trap dw 0 |
44 | l.io dw 0 |
44 | l.io dw 0 |
45 | endg |
45 | endg |
46 | 46 | ||
47 | 47 | ||
48 | build_process_gdt_tss_pointer: |
48 | build_process_gdt_tss_pointer: |
49 | 49 | ||
50 | mov ecx,tss_data |
50 | mov ecx,tss_data |
51 | mov edi,0 |
51 | mov edi,0 |
52 | setgdtl2: |
52 | setgdtl2: |
53 | mov [edi+gdts+ tss0 +0], word tss_step |
53 | mov [edi+gdts+ tss0 +0], word tss_step |
54 | mov [edi+gdts+ tss0 +2], cx |
54 | mov [edi+gdts+ tss0 +2], cx |
55 | mov eax,ecx |
55 | mov eax,ecx |
56 | shr eax,16 |
56 | shr eax,16 |
57 | mov [edi+gdts+ tss0 +4], al |
57 | mov [edi+gdts+ tss0 +4], al |
58 | mov [edi+gdts+ tss0 +7], ah |
58 | mov [edi+gdts+ tss0 +7], ah |
59 | mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b |
59 | mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b |
60 | add ecx,tss_step |
60 | add ecx,tss_step |
61 | add edi,8 |
61 | add edi,8 |
62 | cmp edi,8*(max_processes+5) |
62 | cmp edi,8*(max_processes+5) |
63 | jbe setgdtl2 |
63 | jbe setgdtl2 |
64 | 64 | ||
65 | ret |
65 | ret |
66 | 66 | ||
67 | 67 | ||
68 | build_interrupt_table: |
68 | build_interrupt_table: |
69 | 69 | ||
70 | mov edi, idts+8 |
70 | mov edi, idts+8 |
71 | mov esi, sys_int |
71 | mov esi, sys_int |
72 | mov ecx, 0x40 |
72 | mov ecx, 0x40 |
73 | @@: |
73 | @@: |
74 | mov eax, [esi] |
74 | mov eax, [esi] |
75 | mov [edi], ax ; lower part of offset |
75 | mov [edi], ax ; lower part of offset |
76 | mov [edi+2], word os_code ; segment selector |
76 | mov [edi+2], word os_code ; segment selector |
77 | shr eax, 16 |
77 | shr eax, 16 |
78 | mov [edi+4], word 10001110b shl 8 ; interrupt descriptor |
78 | mov [edi+4], word 10001110b shl 8 ; interrupt descriptor |
79 | mov [edi+6], ax |
79 | mov [edi+6], ax |
80 | add esi, 4 |
80 | add esi, 4 |
81 | add edi, 8 |
81 | add edi, 8 |
82 | dec ecx |
82 | dec ecx |
83 | jnz @b |
83 | jnz @b |
84 | 84 | ||
85 | ;mov edi,8*0x40+idts+8 |
85 | ;mov edi,8*0x40+idts+8 |
86 | mov [edi + 0], word (i40 and ((1 shl 16)-1)) |
86 | mov [edi + 0], word (i40 and ((1 shl 16)-1)) |
87 | mov [edi + 2], word os_code |
87 | mov [edi + 2], word os_code |
88 | mov [edi + 4], word 11101110b*256 |
88 | mov [edi + 4], word 11101110b*256 |
89 | mov [edi + 6], word (i40 shr 16) |
89 | mov [edi + 6], word (i40 shr 16) |
90 | 90 | ||
91 | ret |
91 | ret |
92 | 92 | ||
93 | iglobal |
93 | iglobal |
94 | sys_int: |
94 | sys_int: |
95 | dd e0,debug_exc,e2,e3 |
95 | dd e0,debug_exc,e2,e3 |
96 | dd e4,e5,e6,e7 |
96 | dd e4,e5,e6,e7 |
97 | dd e8,e9,e10,e11 |
97 | dd e8,e9,e10,e11 |
98 | dd e12,e13,page_fault_handler,e15 |
98 | dd e12,e13,page_fault_handler,e15 |
99 | 99 | ||
100 | dd except_16, e17,e18, except_19 |
100 | dd except_16, e17,e18, except_19 |
101 | times 12 dd unknown_interrupt |
101 | times 12 dd unknown_interrupt |
102 | 102 | ||
103 | dd irq0 , irq_serv.irq_1, p_irq2 ,irq_serv.irq_3 |
103 | dd irq0 , irq_serv.irq_1, p_irq2 ,irq_serv.irq_3 |
104 | dd p_irq4 ,irq_serv.irq_5,p_irq6,irq_serv.irq_7 |
104 | dd p_irq4 ,irq_serv.irq_5,p_irq6,irq_serv.irq_7 |
105 | dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 |
105 | dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 |
106 | dd irq_serv.irq_11,p_irq12,irqD ,p_irq14,p_irq15 |
106 | dd irq_serv.irq_11,p_irq12,irqD ,p_irq14,p_irq15 |
107 | 107 | ||
108 | times 16 dd unknown_interrupt |
108 | times 16 dd unknown_interrupt |
109 | 109 | ||
110 | dd i40 |
110 | dd i40 |
111 | endg |
111 | endg |
112 | 112 | ||
113 | macro save_ring3_context |
113 | macro save_ring3_context |
114 | { |
114 | { |
115 | push ds es |
115 | push ds es |
116 | pushad |
116 | pushad |
117 | } |
117 | } |
118 | macro restore_ring3_context |
118 | macro restore_ring3_context |
119 | { |
119 | { |
120 | popad |
120 | popad |
121 | pop es ds |
121 | pop es ds |
122 | } |
122 | } |
123 | 123 | ||
124 | ; simply return control to interrupted process |
124 | ; simply return control to interrupted process |
125 | unknown_interrupt: |
125 | unknown_interrupt: |
126 | iret |
126 | iret |
127 | 127 | ||
128 | macro exc_wo_code [num] |
128 | macro exc_wo_code [num] |
129 | { |
129 | { |
130 | forward |
130 | forward |
131 | e#num : |
131 | e#num : |
132 | save_ring3_context |
132 | save_ring3_context |
133 | mov bl, num |
133 | mov bl, num |
134 | jmp exc_c |
134 | jmp exc_c |
135 | } |
135 | } |
136 | 136 | ||
137 | macro exc_w_code [num] |
137 | macro exc_w_code [num] |
138 | { |
138 | { |
139 | forward |
139 | forward |
140 | e#num : |
140 | e#num : |
141 | add esp, 4 |
141 | add esp, 4 |
142 | save_ring3_context |
142 | save_ring3_context |
143 | mov bl, num |
143 | mov bl, num |
144 | jmp exc_c |
144 | jmp exc_c |
145 | } |
145 | } |
146 | 146 | ||
147 | exc_wo_code 0, 1, 2, 3, 4, 5, 6, 9, 15, 18 |
147 | exc_wo_code 0, 1, 2, 3, 4, 5, 6, 9, 15, 18 |
148 | exc_w_code 8, 10, 11, 12, 13, 14, 17 |
148 | exc_w_code 8, 10, 11, 12, 13, 14, 17 |
149 | 149 | ||
150 | exc_c: |
150 | exc_c: |
151 | mov ax, os_data |
151 | mov ax, os_data |
152 | mov ds, ax |
152 | mov ds, ax |
153 | mov es, ax |
153 | mov es, ax |
154 | 154 | ||
155 | ; test if debugging |
155 | ; test if debugging |
156 | cli |
156 | cli |
157 | mov eax, [0x3000] |
157 | mov eax, [0x3000] |
158 | shl eax, 8 |
158 | shl eax, 8 |
159 | mov eax, [0x80000+eax+APPDATA.debugger_slot] |
159 | mov eax, [0x80000+eax+APPDATA.debugger_slot] |
160 | test eax, eax |
160 | test eax, eax |
161 | jnz .debug |
161 | jnz .debug |
162 | sti |
162 | sti |
163 | ; not debuggee => say error and terminate |
163 | ; not debuggee => say error and terminate |
164 | add esp, 28h |
164 | add esp, 28h |
165 | movzx eax, bl |
165 | movzx eax, bl |
166 | mov [error_interrupt], eax |
166 | mov [error_interrupt], eax |
167 | call show_error_parameters |
167 | call show_error_parameters |
168 | 168 | ||
169 | mov edx, [0x3010] |
169 | mov edx, [0x3010] |
170 | mov [edx + TASKDATA.state], byte 4 |
170 | mov [edx + TASKDATA.state], byte 4 |
171 | 171 | ||
172 | jmp change_task |
172 | jmp change_task |
173 | 173 | ||
174 | .debug: |
174 | .debug: |
175 | ; we are debugged process, notify debugger and suspend ourself |
175 | ; we are debugged process, notify debugger and suspend ourself |
176 | ; eax=debugger PID |
176 | ; eax=debugger PID |
177 | cld |
177 | cld |
178 | movzx ecx, bl |
178 | movzx ecx, bl |
179 | push ecx |
179 | push ecx |
180 | mov ecx, [0x3010] |
180 | mov ecx, [0x3010] |
181 | push dword [ecx+TASKDATA.pid] ; PID of current process |
181 | push dword [ecx+TASKDATA.pid] ; PID of current process |
182 | push 12 |
182 | push 12 |
183 | pop ecx |
183 | pop ecx |
184 | push 1 ; 1=exception |
184 | push 1 ; 1=exception |
185 | call debugger_notify |
185 | call debugger_notify |
186 | pop ecx |
186 | pop ecx |
187 | pop ecx |
187 | pop ecx |
188 | pop ecx |
188 | pop ecx |
189 | mov edx, [0x3010] |
189 | mov edx, [0x3010] |
190 | mov byte [edx+TASKDATA.state], 1 ; suspended |
190 | mov byte [edx+TASKDATA.state], 1 ; suspended |
191 | call change_task |
191 | call change_task |
192 | restore_ring3_context |
192 | restore_ring3_context |
193 | iretd |
193 | iretd |
194 | - | ||
195 | ;;;;;;;;;;;;;;;;;;;;;;; |
- | |
196 | ;; FPU ERROR HANDLER ;; |
- | |
197 | ;;;;;;;;;;;;;;;;;;;;;;; |
- | |
198 | - | ||
199 | align 4 |
- | |
200 | e7: |
- | |
201 | save_ring3_context |
- | |
202 | clts |
- | |
203 | mov ax, os_data |
- | |
204 | mov ds, ax |
- | |
205 | mov es, ax |
- | |
206 | - | ||
207 | mov ebx, [fpu_owner] |
- | |
208 | cmp ebx, [CURRENT_TASK] |
- | |
209 | je .exit |
- | |
210 | - | ||
211 | shl ebx, 8 |
- | |
212 | mov eax, [ebx+PROC_BASE+APPDATA.fpu_state] |
- | |
213 | bt [cpu_caps], CAPS_FXSR |
- | |
214 | jnc .no_SSE |
- | |
215 | - | ||
216 | fxsave [eax] |
- | |
217 | mov ebx, [CURRENT_TASK] |
- | |
218 | mov [fpu_owner], ebx |
- | |
219 | shl ebx, 8 |
- | |
220 | cmp dword [ebx+PROC_BASE+APPDATA.fpu_init], 0 |
- | |
221 | je .init |
- | |
222 | mov eax, [ebx+PROC_BASE+APPDATA.fpu_state] |
- | |
223 | fxrstor [eax] |
- | |
224 | restore_ring3_context |
- | |
225 | iret |
- | |
226 | - | ||
227 | .no_SSE: |
- | |
228 | fnsave [eax] |
- | |
229 | mov ebx, [CURRENT_TASK] |
- | |
230 | mov [fpu_owner], ebx |
- | |
231 | shl ebx, 8 |
- | |
232 | cmp dword [ebx+PROC_BASE+APPDATA.fpu_init], 0 |
- | |
233 | je .ready |
- | |
234 | - | ||
235 | mov eax, [ebx+PROC_BASE+APPDATA.fpu_state] |
- | |
236 | frstor [eax] |
- | |
237 | restore_ring3_context |
- | |
238 | iret |
- | |
239 | .init: |
- | |
240 | fninit ; ¬ ÂÂ¥ Âã¦Âë Â¥¬ áª¨à ®¢ ÂÂë¥ ¨áª«îç¥Â¨ï |
- | |
241 | .ready: |
- | |
242 | mov dword [ebx+PROC_BASE+APPDATA.fpu_init], 1 |
- | |
243 | .exit: |
- | |
244 | restore_ring3_context |
- | |
245 | iret |
- | |
246 | - | ||
247 | iglobal |
- | |
248 | fpu_owner dd 1 |
- | |
249 | endg |
- | |
250 | - | ||
251 | 194 | ||
252 | writehex: |
195 | writehex: |
253 | pusha |
196 | pusha |
254 | 197 | ||
255 | mov edi, [write_error_to] |
198 | mov edi, [write_error_to] |
256 | mov esi, 8 |
199 | mov esi, 8 |
257 | @@: |
200 | @@: |
258 | mov ecx, eax |
201 | mov ecx, eax |
259 | and ecx, 0xf |
202 | and ecx, 0xf |
260 | 203 | ||
261 | mov cl,[ecx+hexletters] |
204 | mov cl,[ecx+hexletters] |
262 | mov [edi],cl |
205 | mov [edi],cl |
263 | dec edi |
206 | dec edi |
264 | 207 | ||
265 | shr eax,4 |
208 | shr eax,4 |
266 | dec esi |
209 | dec esi |
267 | jnz @b |
210 | jnz @b |
268 | 211 | ||
269 | popa |
212 | popa |
270 | ret |
213 | ret |
271 | 214 | ||
272 | iglobal |
215 | iglobal |
273 | hexletters db '0123456789ABCDEF' |
216 | hexletters db '0123456789ABCDEF' |
274 | 217 | ||
275 | error_interrupt dd -1 |
218 | error_interrupt dd -1 |
276 | 219 | ||
277 | process_error db 'K : Process - forced terminate INT: 00000000',13,10,0 |
220 | process_error db 'K : Process - forced terminate INT: 00000000',13,10,0 |
278 | process_pid db 'K : Process - forced terminate PID: 00000000',13,10,0 |
221 | process_pid db 'K : Process - forced terminate PID: 00000000',13,10,0 |
279 | process_eip db 'K : Process - forced terminate EIP: 00000000',13,10,0 |
222 | process_eip db 'K : Process - forced terminate EIP: 00000000',13,10,0 |
280 | system_error db 'K : Kernel error',13,10,0 |
223 | system_error db 'K : Kernel error',13,10,0 |
281 | endg |
224 | endg |
282 | 225 | ||
283 | uglobal |
226 | uglobal |
284 | write_error_to dd 0x0 |
227 | write_error_to dd 0x0 |
285 | endg |
228 | endg |
286 | 229 | ||
287 | show_error_parameters: |
230 | show_error_parameters: |
288 | 231 | ||
289 | mov [write_error_to],process_pid+43 |
232 | mov [write_error_to],process_pid+43 |
290 | mov eax,[0x3000] |
233 | mov eax,[0x3000] |
291 | shl eax, 5 |
234 | shl eax, 5 |
292 | mov eax,[0x3000+TASKDATA.pid+eax] |
235 | mov eax,[0x3000+TASKDATA.pid+eax] |
293 | call writehex |
236 | call writehex |
294 | 237 | ||
295 | mov [write_error_to],process_error+43 |
238 | mov [write_error_to],process_error+43 |
296 | mov eax,[error_interrupt] |
239 | mov eax,[error_interrupt] |
297 | call writehex |
240 | call writehex |
298 | 241 | ||
299 | cmp dword [esp+4+4], os_code ; CS |
242 | cmp dword [esp+4+4], os_code ; CS |
300 | jnz @f |
243 | jnz @f |
301 | mov esi,system_error |
244 | mov esi,system_error |
302 | call sys_msg_board_str |
245 | call sys_msg_board_str |
303 | @@: |
246 | @@: |
304 | mov eax, [esp+4] ; EIP |
247 | mov eax, [esp+4] ; EIP |
305 | 248 | ||
306 | mov [write_error_to],process_eip+43 |
249 | mov [write_error_to],process_eip+43 |
307 | call writehex |
250 | call writehex |
308 | 251 | ||
309 | mov esi,process_error |
252 | mov esi,process_error |
310 | call sys_msg_board_str |
253 | call sys_msg_board_str |
311 | 254 | ||
312 | mov esi,process_pid |
255 | mov esi,process_pid |
313 | call sys_msg_board_str |
256 | call sys_msg_board_str |
314 | 257 | ||
315 | mov esi,process_eip |
258 | mov esi,process_eip |
316 | call sys_msg_board_str |
259 | call sys_msg_board_str |
317 | 260 | ||
318 | ret |
261 | ret |
319 | 262 | ||
320 | 263 | ||
321 | 264 | ||
322 | ; irq1 -> hid/keyboard.inc |
265 | ; irq1 -> hid/keyboard.inc |
323 | 266 | ||
324 | 267 | ||
325 | macro irqh [num] |
268 | macro irqh [num] |
326 | { |
269 | { |
327 | forward |
270 | forward |
328 | p_irq#num : |
271 | p_irq#num : |
329 | save_ring3_context |
272 | save_ring3_context |
330 | mov edi, num |
273 | mov edi, num |
331 | jmp irq_c |
274 | jmp irq_c |
332 | } |
275 | } |
333 | 276 | ||
334 | irqh 2,5,7,8,9,10,11 |
277 | irqh 2,5,7,8,9,10,11 |
335 | 278 | ||
336 | irq_c: |
279 | irq_c: |
337 | mov ax, os_data |
280 | mov ax, os_data |
338 | mov ds, ax |
281 | mov ds, ax |
339 | mov es, ax |
282 | mov es, ax |
340 | call irqhandler |
283 | call irqhandler |
341 | restore_ring3_context |
284 | restore_ring3_context |
342 | iret |
285 | iret |
343 | 286 | ||
344 | p_irq6: |
287 | p_irq6: |
345 | save_ring3_context |
288 | save_ring3_context |
346 | mov ax, os_data |
289 | mov ax, os_data |
347 | mov ds, ax |
290 | mov ds, ax |
348 | mov es, ax |
291 | mov es, ax |
349 | call fdc_irq |
292 | call fdc_irq |
350 | call ready_for_next_irq |
293 | call ready_for_next_irq |
351 | restore_ring3_context |
294 | restore_ring3_context |
352 | iret |
295 | iret |
353 | 296 | ||
354 | p_irq3: |
297 | p_irq3: |
355 | save_ring3_context |
298 | save_ring3_context |
356 | mov ax, os_data |
299 | mov ax, os_data |
357 | mov ds, ax |
300 | mov ds, ax |
358 | mov es, ax |
301 | mov es, ax |
359 | cmp [com2_mouse_detected],0 |
302 | cmp [com2_mouse_detected],0 |
360 | je old_irq3_handler |
303 | je old_irq3_handler |
361 | call check_mouse_data_com2 |
304 | call check_mouse_data_com2 |
362 | jmp p_irq3_1 |
305 | jmp p_irq3_1 |
363 | old_irq3_handler: |
306 | old_irq3_handler: |
364 | mov edi,3 |
307 | mov edi,3 |
365 | call irqhandler |
308 | call irqhandler |
366 | p_irq3_1: |
309 | p_irq3_1: |
367 | restore_ring3_context |
310 | restore_ring3_context |
368 | iret |
311 | iret |
369 | 312 | ||
370 | p_irq4: |
313 | p_irq4: |
371 | save_ring3_context |
314 | save_ring3_context |
372 | mov ax, os_data |
315 | mov ax, os_data |
373 | mov ds, ax |
316 | mov ds, ax |
374 | mov es, ax |
317 | mov es, ax |
375 | cmp [com1_mouse_detected],0 |
318 | cmp [com1_mouse_detected],0 |
376 | je old_irq4_handler |
319 | je old_irq4_handler |
377 | call check_mouse_data_com1 |
320 | call check_mouse_data_com1 |
378 | jmp p_irq4_1 |
321 | jmp p_irq4_1 |
379 | old_irq4_handler: |
322 | old_irq4_handler: |
380 | mov edi,4 |
323 | mov edi,4 |
381 | call irqhandler |
324 | call irqhandler |
382 | p_irq4_1: |
325 | p_irq4_1: |
383 | restore_ring3_context |
326 | restore_ring3_context |
384 | iret |
327 | iret |
385 | 328 | ||
386 | p_irq12: |
329 | p_irq12: |
387 | save_ring3_context |
330 | save_ring3_context |
388 | mov ax, os_data |
331 | mov ax, os_data |
389 | mov ds, ax |
332 | mov ds, ax |
390 | mov es, ax |
333 | mov es, ax |
391 | call check_mouse_data_ps2 |
334 | call check_mouse_data_ps2 |
392 | restore_ring3_context |
335 | restore_ring3_context |
393 | iret |
336 | iret |
394 | 337 | ||
395 | p_irq14: |
338 | p_irq14: |
396 | save_ring3_context |
339 | save_ring3_context |
397 | mov ax, os_data |
340 | mov ax, os_data |
398 | mov ds, ax |
341 | mov ds, ax |
399 | mov es, ax |
342 | mov es, ax |
400 | call [irq14_func] |
343 | call [irq14_func] |
401 | call ready_for_next_irq_1 |
344 | call ready_for_next_irq_1 |
402 | restore_ring3_context |
345 | restore_ring3_context |
403 | iret |
346 | iret |
404 | p_irq15: |
347 | p_irq15: |
405 | save_ring3_context |
348 | save_ring3_context |
406 | mov ax, os_data |
349 | mov ax, os_data |
407 | mov ds, ax |
350 | mov ds, ax |
408 | mov es, ax |
351 | mov es, ax |
409 | call [irq15_func] |
352 | call [irq15_func] |
410 | call ready_for_next_irq_1 |
353 | call ready_for_next_irq_1 |
411 | restore_ring3_context |
354 | restore_ring3_context |
412 | iret |
355 | iret |
413 | 356 | ||
414 | ready_for_next_irq: |
357 | ready_for_next_irq: |
415 | mov [check_idle_semaphore],5 |
358 | mov [check_idle_semaphore],5 |
416 | mov al, 0x20 |
359 | mov al, 0x20 |
417 | out 0x20, al |
360 | out 0x20, al |
418 | ret |
361 | ret |
419 | 362 | ||
420 | ready_for_next_irq_1: |
363 | ready_for_next_irq_1: |
421 | mov [check_idle_semaphore],5 |
364 | mov [check_idle_semaphore],5 |
422 | mov al, 0x20 |
365 | mov al, 0x20 |
423 | out 0xa0,al |
366 | out 0xa0,al |
424 | out 0x20, al |
367 | out 0x20, al |
425 | ret |
368 | ret |
426 | 369 | ||
427 | irqD: |
370 | irqD: |
428 | save_ring3_context |
371 | save_ring3_context |
429 | mov ax, os_data |
372 | mov ax, os_data |
430 | mov ds, ax |
373 | mov ds, ax |
431 | mov es, ax |
374 | mov es, ax |
432 | 375 | ||
433 | mov dx,0xf0 |
376 | mov dx,0xf0 |
434 | mov al,0 |
377 | mov al,0 |
435 | out dx,al |
378 | out dx,al |
436 | 379 | ||
437 | mov dx,0xa0 |
380 | mov dx,0xa0 |
438 | mov al,0x20 |
381 | mov al,0x20 |
439 | out dx,al |
382 | out dx,al |
440 | mov dx,0x20 |
383 | mov dx,0x20 |
441 | out dx,al |
384 | out dx,al |
442 | 385 | ||
443 | restore_ring3_context |
386 | restore_ring3_context |
444 | 387 | ||
445 | iret |
388 | iret |
446 | 389 | ||
447 | 390 | ||
448 | irqhandler: |
391 | irqhandler: |
449 | 392 | ||
450 | push edi |
393 | push edi |
451 | 394 | ||
452 | mov esi,edi ; 1 |
395 | mov esi,edi ; 1 |
453 | shl esi,6 ; 1 |
396 | shl esi,6 ; 1 |
454 | add esi,irq00read ; 1 |
397 | add esi,irq00read ; 1 |
455 | shl edi,12 ; 1 |
398 | shl edi,12 ; 1 |
456 | add edi,0x2E0000 |
399 | add edi,0x2E0000 |
457 | mov ecx,16 |
400 | mov ecx,16 |
458 | 401 | ||
459 | mov [check_idle_semaphore],5 |
402 | mov [check_idle_semaphore],5 |
460 | 403 | ||
461 | irqnewread: |
404 | irqnewread: |
462 | dec ecx |
405 | dec ecx |
463 | js irqover |
406 | js irqover |
464 | 407 | ||
465 | mov dx,[esi] ; 2+ |
408 | mov dx,[esi] ; 2+ |
466 | 409 | ||
467 | cmp dx,0 ; 1 |
410 | cmp dx,0 ; 1 |
468 | jz irqover |
411 | jz irqover |
469 | cmp [esi+3],byte 1 ; 2 ; byte read |
412 | cmp [esi+3],byte 1 ; 2 ; byte read |
470 | jne noirqbyte ; 4-11 |
413 | jne noirqbyte ; 4-11 |
471 | 414 | ||
472 | in al,dx |
415 | in al,dx |
473 | 416 | ||
474 | mov edx,[edi] |
417 | mov edx,[edi] |
475 | cmp edx,4000 |
418 | cmp edx,4000 |
476 | je irqfull |
419 | je irqfull |
477 | mov ebx,edi |
420 | mov ebx,edi |
478 | add ebx,0x10 |
421 | add ebx,0x10 |
479 | add ebx,edx |
422 | add ebx,edx |
480 | mov [ebx],al |
423 | mov [ebx],al |
481 | inc edx |
424 | inc edx |
482 | mov [edi],edx |
425 | mov [edi],edx |
483 | 426 | ||
484 | add esi,4 |
427 | add esi,4 |
485 | jmp irqnewread |
428 | jmp irqnewread |
486 | 429 | ||
487 | noirqbyte: |
430 | noirqbyte: |
488 | 431 | ||
489 | 432 | ||
490 | cmp [esi+3],byte 2 ; word read |
433 | cmp [esi+3],byte 2 ; word read |
491 | jne noirqword |
434 | jne noirqword |
492 | 435 | ||
493 | in ax,dx |
436 | in ax,dx |
494 | 437 | ||
495 | mov edx,[edi] |
438 | mov edx,[edi] |
496 | cmp edx,4000 |
439 | cmp edx,4000 |
497 | je irqfull |
440 | je irqfull |
498 | mov ebx,edi |
441 | mov ebx,edi |
499 | add ebx,0x10 |
442 | add ebx,0x10 |
500 | add ebx,edx |
443 | add ebx,edx |
501 | mov [ebx],ax |
444 | mov [ebx],ax |
502 | add edx,2 |
445 | add edx,2 |
503 | mov [edi],edx |
446 | mov [edi],edx |
504 | add esi,4 |
447 | add esi,4 |
505 | jmp irqnewread |
448 | jmp irqnewread |
506 | 449 | ||
507 | noirqword: |
450 | noirqword: |
508 | irqfull: |
451 | irqfull: |
509 | irqover: |
452 | irqover: |
510 | 453 | ||
511 | mov al,0x20 ; ready for next irq |
454 | mov al,0x20 ; ready for next irq |
512 | out 0x20,al |
455 | out 0x20,al |
513 | 456 | ||
514 | pop ebx |
457 | pop ebx |
515 | cmp ebx,7 |
458 | cmp ebx,7 |
516 | jbe noa0 |
459 | jbe noa0 |
517 | out 0xa0,al |
460 | out 0xa0,al |
518 | noa0: |
461 | noa0: |
519 | 462 | ||
520 | ret |
463 | ret |
521 | 464 | ||
522 | 465 | ||
523 | 466 | ||
524 | set_application_table_status: |
467 | set_application_table_status: |
525 | push eax |
468 | push eax |
526 | 469 | ||
527 | mov eax,[0x3000] |
470 | mov eax,[0x3000] |
528 | shl eax, 5 |
471 | shl eax, 5 |
529 | add eax,0x3000+TASKDATA.pid |
472 | add eax,0x3000+TASKDATA.pid |
530 | mov eax,[eax] |
473 | mov eax,[eax] |
531 | 474 | ||
532 | mov [application_table_status],eax |
475 | mov [application_table_status],eax |
533 | 476 | ||
534 | pop eax |
477 | pop eax |
535 | 478 | ||
536 | ret |
479 | ret |
537 | 480 | ||
538 | 481 | ||
539 | clear_application_table_status: |
482 | clear_application_table_status: |
540 | push eax |
483 | push eax |
541 | 484 | ||
542 | mov eax,[0x3000] |
485 | mov eax,[0x3000] |
543 | shl eax, 5 |
486 | shl eax, 5 |
544 | add eax,0x3000+TASKDATA.pid |
487 | add eax,0x3000+TASKDATA.pid |
545 | mov eax,[eax] |
488 | mov eax,[eax] |
546 | 489 | ||
547 | cmp eax,[application_table_status] |
490 | cmp eax,[application_table_status] |
548 | jne apptsl1 |
491 | jne apptsl1 |
549 | mov [application_table_status],0 |
492 | mov [application_table_status],0 |
550 | apptsl1: |
493 | apptsl1: |
551 | 494 | ||
552 | pop eax |
495 | pop eax |
553 | 496 | ||
554 | ret |
497 | ret |
555 | 498 | ||
556 | 499 | ||
557 | 500 | ||
558 | sys_resize_app_memory: |
501 | sys_resize_app_memory: |
559 | ; eax = 1 - resize |
502 | ; eax = 1 - resize |
560 | ; ebx = new amount of memory |
503 | ; ebx = new amount of memory |
561 | 504 | ||
562 | cmp eax,1 |
505 | cmp eax,1 |
563 | jne .no_application_mem_resize |
506 | jne .no_application_mem_resize |
564 | 507 | ||
565 | stdcall new_mem_resize, ebx |
508 | stdcall new_mem_resize, ebx |
566 | mov [esp+36], eax |
509 | mov [esp+36], eax |
567 | ret |
510 | ret |
568 | 511 | ||
569 | .no_application_mem_resize: |
512 | .no_application_mem_resize: |
570 | ret |
513 | ret |
571 | 514 | ||
572 | 515 | ||
573 | 516 | ||
574 | get_app_params: |
517 | get_app_params: |
575 | 518 | ||
576 | push eax |
519 | push eax |
577 | 520 | ||
578 | cmp [0x90000+6],word '00' |
521 | cmp [0x90000+6],word '00' |
579 | jne no_00_header |
522 | jne no_00_header |
580 | 523 | ||
581 | mov eax,[0x90000+12] |
524 | mov eax,[0x90000+12] |
582 | mov [app_start],eax |
525 | mov [app_start],eax |
583 | mov eax,[0x90000+16] |
526 | mov eax,[0x90000+16] |
584 | mov [app_i_end],eax |
527 | mov [app_i_end],eax |
585 | mov eax,[0x90000+20] |
528 | mov eax,[0x90000+20] |
586 | mov [app_mem],eax |
529 | mov [app_mem],eax |
587 | ; \begin{diamond}[20.08.2006] |
530 | ; \begin{diamond}[20.08.2006] |
588 | ; sanity check (functions 19,58 load app_i_end bytes and that must |
531 | ; sanity check (functions 19,58 load app_i_end bytes and that must |
589 | ; fit in allocated memory to prevent kernel faults) |
532 | ; fit in allocated memory to prevent kernel faults) |
590 | cmp eax,[app_i_end] |
533 | cmp eax,[app_i_end] |
591 | jb no_01_header |
534 | jb no_01_header |
592 | ; \end{diamond}[20.08.2006] |
535 | ; \end{diamond}[20.08.2006] |
593 | shr eax,1 |
536 | shr eax,1 |
594 | sub eax,0x10 |
537 | sub eax,0x10 |
595 | mov [app_esp],eax |
538 | mov [app_esp],eax |
596 | mov eax,[0x90000+24] |
539 | mov eax,[0x90000+24] |
597 | mov [app_i_param],eax |
540 | mov [app_i_param],eax |
598 | mov [app_i_icon],dword 0 |
541 | mov [app_i_icon],dword 0 |
599 | 542 | ||
600 | pop eax |
543 | pop eax |
601 | clc |
544 | clc |
602 | ret |
545 | ret |
603 | 546 | ||
604 | no_00_header: |
547 | no_00_header: |
605 | 548 | ||
606 | 549 | ||
607 | cmp [0x90000+6],word '01' |
550 | cmp [0x90000+6],word '01' |
608 | jne no_01_header |
551 | jne no_01_header |
609 | 552 | ||
610 | mov eax,[0x90000+12] |
553 | mov eax,[0x90000+12] |
611 | mov [app_start],eax |
554 | mov [app_start],eax |
612 | mov eax,[0x90000+16] |
555 | mov eax,[0x90000+16] |
613 | mov [app_i_end],eax |
556 | mov [app_i_end],eax |
614 | mov eax,[0x90000+20] |
557 | mov eax,[0x90000+20] |
615 | mov [app_mem],eax |
558 | mov [app_mem],eax |
616 | ; \begin{diamond}[20.08.2006] |
559 | ; \begin{diamond}[20.08.2006] |
617 | cmp eax,[app_i_end] |
560 | cmp eax,[app_i_end] |
618 | jb no_01_header |
561 | jb no_01_header |
619 | ; \end{diamond}[20.08.2006] |
562 | ; \end{diamond}[20.08.2006] |
620 | mov eax,[0x90000+24] |
563 | mov eax,[0x90000+24] |
621 | mov [app_esp],eax |
564 | mov [app_esp],eax |
622 | mov eax,[0x90000+28] |
565 | mov eax,[0x90000+28] |
623 | mov [app_i_param],eax |
566 | mov [app_i_param],eax |
624 | mov eax,[0x90000+32] |
567 | mov eax,[0x90000+32] |
625 | mov [app_i_icon],eax |
568 | mov [app_i_icon],eax |
626 | 569 | ||
627 | pop eax |
570 | pop eax |
628 | clc |
571 | clc |
629 | ret |
572 | ret |
630 | 573 | ||
631 | no_01_header: |
574 | no_01_header: |
632 | 575 | ||
633 | pop eax |
576 | pop eax |
634 | stc |
577 | stc |
635 | ret |
578 | ret |
636 | 579 | ||
637 | 580 | ||
638 | uglobal |
581 | uglobal |
639 | new_process_place dd 0x0 |
582 | new_process_place dd 0x0 |
640 | app_start dd 0x0 |
583 | app_start dd 0x0 |
641 | app_i_end dd 0x0 |
584 | app_i_end dd 0x0 |
642 | app_mem dd 0x0 |
585 | app_mem dd 0x0 |
643 | app_esp dd 0x0 |
586 | app_esp dd 0x0 |
644 | app_i_param dd 0x0 |
587 | app_i_param dd 0x0 |
645 | app_i_icon dd 0x0 |
588 | app_i_icon dd 0x0 |
646 | ; app_mem_pos dd 0x0 |
589 | ; app_mem_pos dd 0x0 |
647 | appl_path dd 0x0 |
590 | appl_path dd 0x0 |
648 | appl_path_size dd 0x0 |
591 | appl_path_size dd 0x0 |
649 | endg |
592 | endg |
650 | 593 | ||
651 | 594 | ||
652 | sys_threads: |
595 | sys_threads: |
653 | 596 | ||
654 | ; eax=1 create thread |
597 | ; eax=1 create thread |
655 | ; |
598 | ; |
656 | ; ebx=thread start |
599 | ; ebx=thread start |
657 | ; ecx=thread stack value |
600 | ; ecx=thread stack value |
658 | ; |
601 | ; |
659 | ; on return : eax = pid |
602 | ; on return : eax = pid |
660 | jmp new_sys_threads |
603 | jmp new_sys_threads |
661 | 604 | ||
662 | iglobal |
605 | iglobal |
663 | process_terminating db 'K : Process - terminating',13,10,0 |
606 | process_terminating db 'K : Process - terminating',13,10,0 |
664 | process_terminated db 'K : Process - done',13,10,0 |
607 | process_terminated db 'K : Process - done',13,10,0 |
665 | endg |
608 | endg |
666 | 609 | ||
667 | 610 | ||
668 | terminate: ; terminate application |
611 | terminate: ; terminate application |
669 | push esi |
612 | push esi |
670 | mov esi,process_terminating |
613 | mov esi,process_terminating |
671 | call sys_msg_board_str |
614 | call sys_msg_board_str |
672 | pop esi |
615 | pop esi |
673 | 616 | ||
674 | @@: |
617 | @@: |
675 | cli |
618 | cli |
676 | cmp [application_table_status],0 |
619 | cmp [application_table_status],0 |
677 | je term9 |
620 | je term9 |
678 | sti |
621 | sti |
679 | call change_task |
622 | call change_task |
680 | jmp @b |
623 | jmp @b |
681 | term9: |
624 | term9: |
682 | 625 | ||
683 | call set_application_table_status |
626 | call set_application_table_status |
684 | 627 | ||
685 | mov eax,esi |
628 | mov eax,esi |
686 | 629 | ||
687 | pushad |
630 | pushad |
688 | shl eax,8 |
631 | shl eax,8 |
689 | mov eax,[PROC_BASE+eax+0xB8] |
632 | mov eax,[PROC_BASE+eax+0xB8] |
690 | stdcall destroy_app_space, eax |
633 | stdcall destroy_app_space, eax |
691 | popad |
634 | popad |
692 | 635 | ||
693 | cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
636 | cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
694 | jne fpu_ok_1 |
637 | jne fpu_ok_1 |
695 | 638 | ||
696 | mov [fpu_owner],1 |
639 | mov [fpu_owner],1 |
697 | mov eax, [256+PROC_BASE+0x10] |
640 | mov eax, [256+PROC_BASE+0x10] |
698 | bt [cpu_caps], CAPS_FXSR |
641 | bt [cpu_caps], CAPS_FXSR |
699 | jnc .no_SSE |
642 | jnc .no_SSE |
700 | fxrstor [eax] |
643 | fxrstor [eax] |
701 | jmp fpu_ok_1 |
644 | jmp fpu_ok_1 |
702 | .no_SSE: |
645 | .no_SSE: |
703 | fnclex |
646 | fnclex |
704 | frstor [eax] |
647 | frstor [eax] |
705 | fpu_ok_1: |
648 | fpu_ok_1: |
706 | 649 | ||
707 | mov [0xf400],byte 0 ; empty keyboard buffer |
650 | mov [0xf400],byte 0 ; empty keyboard buffer |
708 | mov [0xf500],byte 0 ; empty button buffer |
651 | mov [0xf500],byte 0 ; empty button buffer |
709 | 652 | ||
710 | 653 | ||
711 | ; remove defined hotkeys |
654 | ; remove defined hotkeys |
712 | mov eax, hotkey_list |
655 | mov eax, hotkey_list |
713 | .loop: |
656 | .loop: |
714 | cmp [eax+8], esi |
657 | cmp [eax+8], esi |
715 | jnz .cont |
658 | jnz .cont |
716 | mov ecx, [eax] |
659 | mov ecx, [eax] |
717 | jecxz @f |
660 | jecxz @f |
718 | push dword [eax+12] |
661 | push dword [eax+12] |
719 | pop dword [ecx+12] |
662 | pop dword [ecx+12] |
720 | @@: |
663 | @@: |
721 | mov ecx, [eax+12] |
664 | mov ecx, [eax+12] |
722 | push dword [eax] |
665 | push dword [eax] |
723 | pop dword [ecx] |
666 | pop dword [ecx] |
724 | xor ecx, ecx |
667 | xor ecx, ecx |
725 | mov [eax], ecx |
668 | mov [eax], ecx |
726 | mov [eax+4], ecx |
669 | mov [eax+4], ecx |
727 | mov [eax+8], ecx |
670 | mov [eax+8], ecx |
728 | mov [eax+12], ecx |
671 | mov [eax+12], ecx |
729 | .cont: |
672 | .cont: |
730 | add eax, 16 |
673 | add eax, 16 |
731 | cmp eax, hotkey_list+256*16 |
674 | cmp eax, hotkey_list+256*16 |
732 | jb .loop |
675 | jb .loop |
733 | ; remove hotkeys in buffer |
676 | ; remove hotkeys in buffer |
734 | mov eax, hotkey_buffer |
677 | mov eax, hotkey_buffer |
735 | .loop2: |
678 | .loop2: |
736 | cmp [eax], esi |
679 | cmp [eax], esi |
737 | jnz .cont2 |
680 | jnz .cont2 |
738 | and dword [eax+4], 0 |
681 | and dword [eax+4], 0 |
739 | and dword [eax], 0 |
682 | and dword [eax], 0 |
740 | .cont2: |
683 | .cont2: |
741 | add eax, 8 |
684 | add eax, 8 |
742 | cmp eax, hotkey_buffer+120*8 |
685 | cmp eax, hotkey_buffer+120*8 |
743 | jb .loop2 |
686 | jb .loop2 |
744 | 687 | ||
745 | mov ecx,esi ; remove buttons |
688 | mov ecx,esi ; remove buttons |
746 | bnewba2: |
689 | bnewba2: |
747 | mov edi,[0xfe88] |
690 | mov edi,[0xfe88] |
748 | mov eax,edi |
691 | mov eax,edi |
749 | cld |
692 | cld |
750 | movzx ebx,word [edi] |
693 | movzx ebx,word [edi] |
751 | inc bx |
694 | inc bx |
752 | bnewba: |
695 | bnewba: |
753 | dec bx |
696 | dec bx |
754 | jz bnmba |
697 | jz bnmba |
755 | add eax,0x10 |
698 | add eax,0x10 |
756 | cmp cx,[eax] |
699 | cmp cx,[eax] |
757 | jnz bnewba |
700 | jnz bnewba |
758 | pusha |
701 | pusha |
759 | mov ecx,ebx |
702 | mov ecx,ebx |
760 | inc ecx |
703 | inc ecx |
761 | shl ecx,4 |
704 | shl ecx,4 |
762 | mov ebx,eax |
705 | mov ebx,eax |
763 | add eax,0x10 |
706 | add eax,0x10 |
764 | call memmove |
707 | call memmove |
765 | dec dword [edi] |
708 | dec dword [edi] |
766 | popa |
709 | popa |
767 | jmp bnewba2 |
710 | jmp bnewba2 |
768 | bnmba: |
711 | bnmba: |
769 | 712 | ||
770 | pusha ; save window coordinates for window restoring |
713 | pusha ; save window coordinates for window restoring |
771 | cld |
714 | cld |
772 | shl esi,5 |
715 | shl esi,5 |
773 | add esi,window_data |
716 | add esi,window_data |
774 | mov eax,[esi+WDATA.box.left] |
717 | mov eax,[esi+WDATA.box.left] |
775 | mov [dlx],eax |
718 | mov [dlx],eax |
776 | add eax,[esi+WDATA.box.width] |
719 | add eax,[esi+WDATA.box.width] |
777 | mov [dlxe],eax |
720 | mov [dlxe],eax |
778 | mov eax,[esi+WDATA.box.top] |
721 | mov eax,[esi+WDATA.box.top] |
779 | mov [dly],eax |
722 | mov [dly],eax |
780 | add eax,[esi+WDATA.box.height] |
723 | add eax,[esi+WDATA.box.height] |
781 | mov [dlye],eax |
724 | mov [dlye],eax |
782 | 725 | ||
783 | xor eax, eax |
726 | xor eax, eax |
784 | mov [esi+WDATA.box.left],eax |
727 | mov [esi+WDATA.box.left],eax |
785 | mov [esi+WDATA.box.width],eax |
728 | mov [esi+WDATA.box.width],eax |
786 | mov [esi+WDATA.box.top],eax |
729 | mov [esi+WDATA.box.top],eax |
787 | mov [esi+WDATA.box.height],eax |
730 | mov [esi+WDATA.box.height],eax |
788 | mov [esi+WDATA.cl_workarea],eax |
731 | mov [esi+WDATA.cl_workarea],eax |
789 | mov [esi+WDATA.cl_titlebar],eax |
732 | mov [esi+WDATA.cl_titlebar],eax |
790 | mov [esi+WDATA.cl_frames],eax |
733 | mov [esi+WDATA.cl_frames],eax |
791 | mov dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn |
734 | mov dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn |
792 | lea edi, [esi-window_data+draw_data] |
735 | lea edi, [esi-window_data+draw_data] |
793 | mov ecx,32/4 |
736 | mov ecx,32/4 |
794 | rep stosd |
737 | rep stosd |
795 | popa |
738 | popa |
796 | 739 | ||
797 | ; debuggee test |
740 | ; debuggee test |
798 | pushad |
741 | pushad |
799 | mov edi, esi |
742 | mov edi, esi |
800 | shl edi, 5 |
743 | shl edi, 5 |
801 | mov eax, [0x80000+edi*8+APPDATA.debugger_slot] |
744 | mov eax, [0x80000+edi*8+APPDATA.debugger_slot] |
802 | test eax, eax |
745 | test eax, eax |
803 | jz .nodebug |
746 | jz .nodebug |
804 | push 8 |
747 | push 8 |
805 | pop ecx |
748 | pop ecx |
806 | push dword [0x3000+edi+TASKDATA.pid] ; PID |
749 | push dword [0x3000+edi+TASKDATA.pid] ; PID |
807 | push 2 |
750 | push 2 |
808 | call debugger_notify |
751 | call debugger_notify |
809 | pop ecx |
752 | pop ecx |
810 | pop ecx |
753 | pop ecx |
811 | .nodebug: |
754 | .nodebug: |
812 | popad |
755 | popad |
813 | 756 | ||
814 | pusha ; at 0x80000+ |
757 | pusha ; at 0x80000+ |
815 | mov edi,esi |
758 | mov edi,esi |
816 | shl edi,8 |
759 | shl edi,8 |
817 | add edi,0x80000 |
760 | add edi,0x80000 |
818 | mov ecx,256/4 |
761 | mov ecx,256/4 |
819 | xor eax, eax |
762 | xor eax, eax |
820 | rep stosd |
763 | rep stosd |
821 | popa |
764 | popa |
822 | 765 | ||
823 | pusha ; name to spaces |
766 | pusha ; name to spaces |
824 | mov edi,esi |
767 | mov edi,esi |
825 | shl edi,8 |
768 | shl edi,8 |
826 | add edi,0x80000+APPDATA.app_name |
769 | add edi,0x80000+APPDATA.app_name |
827 | mov ecx,11 |
770 | mov ecx,11 |
828 | mov eax,' ' |
771 | mov eax,' ' |
829 | rep stosb |
772 | rep stosb |
830 | popa |
773 | popa |
831 | 774 | ||
832 | 775 | ||
833 | ; activate window |
776 | ; activate window |
834 | movzx eax, word [0xC000 + esi*2] |
777 | movzx eax, word [0xC000 + esi*2] |
835 | cmp eax, [0x3004] |
778 | cmp eax, [0x3004] |
836 | jne .dont_activate |
779 | jne .dont_activate |
837 | pushad |
780 | pushad |
838 | .check_next_window: |
781 | .check_next_window: |
839 | dec eax |
782 | dec eax |
840 | cmp eax, 1 |
783 | cmp eax, 1 |
841 | jbe .nothing_to_activate |
784 | jbe .nothing_to_activate |
842 | lea esi, [0xc400+eax*2] |
785 | lea esi, [0xc400+eax*2] |
843 | movzx edi, word [esi] ; edi = process |
786 | movzx edi, word [esi] ; edi = process |
844 | shl edi, 5 |
787 | shl edi, 5 |
845 | cmp [0x3000 + edi + TASKDATA.state], byte 9 ; skip dead slots |
788 | cmp [0x3000 + edi + TASKDATA.state], byte 9 ; skip dead slots |
846 | je .check_next_window |
789 | je .check_next_window |
847 | add edi, window_data |
790 | add edi, window_data |
848 | ; \begin{diamond}[19.09.2006] |
791 | ; \begin{diamond}[19.09.2006] |
849 | ; skip minimized windows |
792 | ; skip minimized windows |
850 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
793 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
851 | jnz .check_next_window |
794 | jnz .check_next_window |
852 | ; \end{diamond} |
795 | ; \end{diamond} |
853 | call waredraw |
796 | call waredraw |
854 | .nothing_to_activate: |
797 | .nothing_to_activate: |
855 | popad |
798 | popad |
856 | .dont_activate: |
799 | .dont_activate: |
857 | 800 | ||
858 | push esi ; remove hd1 & cd & flp reservation |
801 | push esi ; remove hd1 & cd & flp reservation |
859 | shl esi, 5 |
802 | shl esi, 5 |
860 | mov esi, [esi+0x3000+TASKDATA.pid] |
803 | mov esi, [esi+0x3000+TASKDATA.pid] |
861 | cmp [hd1_status], esi |
804 | cmp [hd1_status], esi |
862 | jnz @f |
805 | jnz @f |
863 | mov [hd1_status], 0 |
806 | mov [hd1_status], 0 |
864 | @@: |
807 | @@: |
865 | cmp [cd_status], esi |
808 | cmp [cd_status], esi |
866 | jnz @f |
809 | jnz @f |
867 | mov [cd_status], 0 |
810 | mov [cd_status], 0 |
868 | @@: |
811 | @@: |
869 | cmp [flp_status], esi |
812 | cmp [flp_status], esi |
870 | jnz @f |
813 | jnz @f |
871 | mov [flp_status], 0 |
814 | mov [flp_status], 0 |
872 | @@: |
815 | @@: |
873 | pop esi |
816 | pop esi |
874 | 817 | ||
875 | pusha ; remove all irq reservations |
818 | pusha ; remove all irq reservations |
876 | mov eax,esi |
819 | mov eax,esi |
877 | shl eax, 5 |
820 | shl eax, 5 |
878 | mov eax,[eax+0x3000+TASKDATA.pid] |
821 | mov eax,[eax+0x3000+TASKDATA.pid] |
879 | mov edi,irq_owner |
822 | mov edi,irq_owner |
880 | mov ecx,16 |
823 | mov ecx,16 |
881 | newirqfree: |
824 | newirqfree: |
882 | scasd |
825 | scasd |
883 | jne nofreeirq |
826 | jne nofreeirq |
884 | mov [edi-4],dword 0 |
827 | mov [edi-4],dword 0 |
885 | nofreeirq: |
828 | nofreeirq: |
886 | loop newirqfree |
829 | loop newirqfree |
887 | popa |
830 | popa |
888 | 831 | ||
889 | 832 | ||
890 | pusha ; remove all port reservations |
833 | pusha ; remove all port reservations |
891 | mov edx,esi |
834 | mov edx,esi |
892 | shl edx, 5 |
835 | shl edx, 5 |
893 | add edx,0x3000 |
836 | add edx,0x3000 |
894 | mov edx,[edx+TASKDATA.pid] |
837 | mov edx,[edx+TASKDATA.pid] |
895 | 838 | ||
896 | rmpr0: |
839 | rmpr0: |
897 | 840 | ||
898 | mov esi,[0x2d0000] |
841 | mov esi,[0x2d0000] |
899 | 842 | ||
900 | cmp esi,0 |
843 | cmp esi,0 |
901 | je rmpr9 |
844 | je rmpr9 |
902 | 845 | ||
903 | rmpr3: |
846 | rmpr3: |
904 | 847 | ||
905 | mov edi,esi |
848 | mov edi,esi |
906 | shl edi,4 |
849 | shl edi,4 |
907 | add edi,0x2d0000 |
850 | add edi,0x2d0000 |
908 | 851 | ||
909 | cmp edx,[edi] |
852 | cmp edx,[edi] |
910 | je rmpr4 |
853 | je rmpr4 |
911 | 854 | ||
912 | dec esi |
855 | dec esi |
913 | jnz rmpr3 |
856 | jnz rmpr3 |
914 | 857 | ||
915 | jmp rmpr9 |
858 | jmp rmpr9 |
916 | 859 | ||
917 | rmpr4: |
860 | rmpr4: |
918 | 861 | ||
919 | mov ecx,256 |
862 | mov ecx,256 |
920 | sub ecx,esi |
863 | sub ecx,esi |
921 | shl ecx,4 |
864 | shl ecx,4 |
922 | 865 | ||
923 | mov esi,edi |
866 | mov esi,edi |
924 | add esi,16 |
867 | add esi,16 |
925 | cld |
868 | cld |
926 | rep movsb |
869 | rep movsb |
927 | 870 | ||
928 | dec dword [0x2d0000] |
871 | dec dword [0x2d0000] |
929 | 872 | ||
930 | jmp rmpr0 |
873 | jmp rmpr0 |
931 | 874 | ||
932 | rmpr9: |
875 | rmpr9: |
933 | 876 | ||
934 | popa |
877 | popa |
935 | mov edi,esi ; do not run this process slot |
878 | mov edi,esi ; do not run this process slot |
936 | shl edi, 5 |
879 | shl edi, 5 |
937 | mov [edi+0x3000 + TASKDATA.state],byte 9 |
880 | mov [edi+0x3000 + TASKDATA.state],byte 9 |
938 | ; debugger test - terminate all debuggees |
881 | ; debugger test - terminate all debuggees |
939 | mov eax, 2 |
882 | mov eax, 2 |
940 | mov ecx, 0x80000+2*0x100+APPDATA.debugger_slot |
883 | mov ecx, 0x80000+2*0x100+APPDATA.debugger_slot |
941 | .xd0: |
884 | .xd0: |
942 | cmp eax, [0x3004] |
885 | cmp eax, [0x3004] |
943 | ja .xd1 |
886 | ja .xd1 |
944 | cmp dword [ecx], esi |
887 | cmp dword [ecx], esi |
945 | jnz @f |
888 | jnz @f |
946 | and dword [ecx], 0 |
889 | and dword [ecx], 0 |
947 | pushad |
890 | pushad |
948 | xchg eax, ebx |
891 | xchg eax, ebx |
949 | mov eax, 2 |
892 | mov eax, 2 |
950 | call sys_system |
893 | call sys_system |
951 | popad |
894 | popad |
952 | @@: |
895 | @@: |
953 | inc eax |
896 | inc eax |
954 | add ecx, 0x100 |
897 | add ecx, 0x100 |
955 | jmp .xd0 |
898 | jmp .xd0 |
956 | .xd1: |
899 | .xd1: |
957 | ; call systest |
900 | ; call systest |
958 | sti ; .. and life goes on |
901 | sti ; .. and life goes on |
959 | 902 | ||
960 | mov eax, [dlx] |
903 | mov eax, [dlx] |
961 | mov ebx, [dly] |
904 | mov ebx, [dly] |
962 | mov ecx, [dlxe] |
905 | mov ecx, [dlxe] |
963 | mov edx, [dlye] |
906 | mov edx, [dlye] |
964 | call calculatescreen |
907 | call calculatescreen |
965 | xor eax, eax |
908 | xor eax, eax |
966 | xor esi, esi |
909 | xor esi, esi |
967 | call redrawscreen |
910 | call redrawscreen |
968 | 911 | ||
969 | mov [0xfff4],byte 0 ; no mouse background |
912 | mov [0xfff4],byte 0 ; no mouse background |
970 | mov [0xfff5],byte 0 ; draw mouse |
913 | mov [0xfff5],byte 0 ; draw mouse |
971 | 914 | ||
972 | mov [application_table_status],0 |
915 | mov [application_table_status],0 |
973 | mov esi,process_terminated |
916 | mov esi,process_terminated |
974 | call sys_msg_board_str |
917 | call sys_msg_board_str |
975 | 918 | ||
976 | ret |
919 | ret |
977 | 920 | ||
978 | iglobal |
921 | iglobal |
979 | boot_sched_1 db 'Building gdt tss pointer',0 |
922 | boot_sched_1 db 'Building gdt tss pointer',0 |
980 | boot_sched_2 db 'Building IDT table',0 |
923 | boot_sched_2 db 'Building IDT table',0 |
981 | endg |
924 | endg |
982 | 925 | ||
983 | 926 | ||
984 | build_scheduler: |
927 | build_scheduler: |
985 | 928 | ||
986 | mov esi,boot_sched_1 |
929 | mov esi,boot_sched_1 |
987 | call boot_log |
930 | call boot_log |
988 | call build_process_gdt_tss_pointer |
931 | call build_process_gdt_tss_pointer |
989 | 932 | ||
990 | mov esi,boot_sched_2 |
933 | mov esi,boot_sched_2 |
991 | call boot_log |
934 | call boot_log |
992 | call build_interrupt_table |
935 | call build_interrupt_table |
993 | 936 | ||
994 | ret |
937 | ret |