Rev 1514 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1514 | Rev 2382 | ||
---|---|---|---|
Line 9... | Line 9... | ||
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 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 13... | Line 13... | ||
13 | 13 | ||
Line 14... | Line 14... | ||
14 | $Revision: 1514 $ |
14 | $Revision: 2382 $ |
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 | @@: |
23 | @@: movsw ;low word of code-entry |
24 | movsw ;low word of code-entry |
24 | stosd ;interrupt gate type : os_code selector |
25 | stosd ;interrupt gate type : os_code selector |
25 | movsw ;high word of code-entry |
26 | movsw ;high word of code-entry |
Line 37... | Line 38... | ||
37 | dd e8,e9,e10,e11,e12,e13,page_fault_exc,e15 |
38 | dd e8,e9,e10,e11,e12,e13,page_fault_exc,e15 |
38 | dd e16, e17,e18, e19 |
39 | dd e16, e17,e18, e19 |
39 | times 12 dd unknown_interrupt ;int_20..int_31 |
40 | times 12 dd unknown_interrupt ;int_20..int_31 |
Line 40... | Line 41... | ||
40 | 41 | ||
- | 42 | ;interrupt handlers addresses (for interrupt gate construction) |
|
41 | ;interrupt handlers addresses (for interrupt gate construction) |
43 | ; 0x20 .. 0x2F - IRQ handlers |
42 | dd irq0, irq_serv.irq_1, irq_serv.irq_2 |
- | |
43 | if USE_COM_IRQ |
44 | dd irq0, irq_serv.irq_1, irq_serv.irq_2 |
44 | dd irq_serv.irq_3, irq_serv.irq_4 |
- | |
45 | else |
- | |
46 | dd p_irq3, p_irq4 ;??? íåñòûêîâêà |
- | |
47 | end if |
45 | dd irq_serv.irq_3, irq_serv.irq_4 |
48 | dd irq_serv.irq_5, p_irq6, irq_serv.irq_7 |
46 | dd irq_serv.irq_5, irq_serv.irq_6, irq_serv.irq_7 |
49 | dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 |
47 | dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 |
- | 48 | dd irq_serv.irq_11, irq_serv.irq_12, irqD, irq_serv.irq_14, irq_serv.irq_15 |
|
- | 49 | dd irq_serv.irq_16 |
|
- | 50 | dd irq_serv.irq_17 |
|
- | 51 | dd irq_serv.irq_18 |
|
- | 52 | dd irq_serv.irq_19 |
|
- | 53 | dd irq_serv.irq_20 |
|
- | 54 | dd irq_serv.irq_21 |
|
50 | dd irq_serv.irq_11, irq_serv.irq_12, irqD,p_irq14,p_irq15 |
55 | dd irq_serv.irq_22 |
Line -... | Line 56... | ||
- | 56 | dd irq_serv.irq_23 |
|
51 | times 16 dd unknown_interrupt ;int_0x30..int_0x3F |
57 | |
52 | 58 | times 32 - IRQ_RESERVED dd unknown_interrupt |
|
Line 53... | Line 59... | ||
53 | ;int_0x40 gate trap (for directly copied) |
59 | ;int_0x40 gate trap (for directly copied) |
54 | dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16 |
60 | dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16 |
Line 120... | Line 126... | ||
120 | reg_esp0 equ esp+0x0C |
126 | reg_esp0 equ esp+0x0C |
121 | reg_ebp equ esp+0x08 |
127 | reg_ebp equ esp+0x08 |
122 | reg_esi equ esp+0x04 |
128 | reg_esi equ esp+0x04 |
123 | reg_edi equ esp+0x00 |
129 | reg_edi equ esp+0x00 |
Line -... | Line 130... | ||
- | 130 | ||
124 | 131 | mov ax, app_data ;èñêëþ÷åíèå |
|
125 | Mov ds,ax,app_data ; çàãðóçèì ïðàâèëüíûå çíà÷åíèÿ |
132 | mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíèÿ |
126 | mov es,ax ; â ñåãìåíòíûå ðåãèñòðû |
133 | mov es, ax ;â ðåãèñòðû |
127 | cld ; è ïðèâîäèì DF ê ñòàíäàðòó |
134 | cld ; è ïðèâîäèì DF ê ñòàíäàðòó |
128 | movzx ebx,bl |
135 | movzx ebx, bl |
129 | ; redirect to V86 manager? (EFLAGS & 0x20000) != 0? |
136 | ; redirect to V86 manager? (EFLAGS & 0x20000) != 0? |
130 | test byte[reg_eflags+2],2 |
137 | test byte[reg_eflags+2], 2 |
131 | jnz v86_exc_c |
138 | jnz v86_exc_c |
132 | cmp bl,14 ; #PF |
139 | cmp bl, 14 ; #PF |
133 | jne @f |
140 | jne @f |
- | 141 | call page_fault_handler ; SEE: core/memory.inc |
|
134 | call page_fault_handler ; SEE: core/memory.inc |
142 | @@: |
135 | @@: mov esi, [current_slot] |
143 | mov esi, [current_slot] |
136 | btr [esi+APPDATA.except_mask], ebx |
144 | btr [esi+APPDATA.except_mask], ebx |
137 | jnc @f |
145 | jnc @f |
138 | mov eax,[esi+APPDATA.exc_handler] |
146 | mov eax, [esi+APPDATA.exc_handler] |
139 | test eax, eax |
147 | test eax, eax |
140 | jnz IRetToUserHook |
148 | jnz IRetToUserHook |
- | 149 | @@: |
|
141 | @@: cli |
150 | cli |
142 | mov eax, [esi+APPDATA.debugger_slot] |
151 | mov eax, [esi+APPDATA.debugger_slot] |
143 | test eax, eax |
152 | test eax, eax |
144 | jnz .debug |
153 | jnz .debug |
145 | sti |
154 | sti |
Line 157... | Line 166... | ||
157 | mov ebx, dr6 ; debug_message data=DR6_image |
166 | mov ebx, dr6 ; debug_message data=DR6_image |
158 | xor edx, edx |
167 | xor edx, edx |
159 | mov dr6, edx |
168 | mov dr6, edx |
160 | mov edx, dr7 |
169 | mov edx, dr7 |
161 | mov cl, not 8 |
170 | mov cl, not 8 |
- | 171 | .l1: |
|
162 | .l1: shl dl,2 |
172 | shl dl, 2 |
163 | jc @f |
173 | jc @f |
164 | and bl, cl |
174 | and bl, cl |
- | 175 | @@: |
|
165 | @@: sar cl,1 |
176 | sar cl, 1 |
166 | jc .l1 |
177 | jc .l1 |
167 | mov cl, 3 ; debug_message code=debug_exception |
178 | mov cl, 3 ; debug_message code=debug_exception |
168 | .notify: |
179 | .notify: |
169 | push ebx ; debug_message data |
180 | push ebx ; debug_message data |
170 | mov ebx, [TASK_BASE] |
181 | mov ebx, [TASK_BASE] |
Line 184... | Line 195... | ||
184 | sub dword[reg_esp3], 8 |
195 | sub dword[reg_esp3], 8 |
185 | mov edi, [reg_esp3] |
196 | mov edi, [reg_esp3] |
186 | stosd |
197 | stosd |
187 | mov [edi], ebx |
198 | mov [edi], ebx |
188 | restore_ring3_context |
199 | restore_ring3_context |
- | 200 | ; simply return control to interrupted process |
|
189 | unknown_interrupt: |
201 | unknown_interrupt: |
190 | iretd |
202 | iretd |
Line 191... | Line 203... | ||
191 | 203 | ||
- | 204 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
|
192 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
205 | ; bl - error vector |
- | 206 | show_error_parameters: |
|
- | 207 | cmp bl, 0x06 |
|
- | 208 | jnz .no_ud |
|
- | 209 | push ebx |
|
- | 210 | mov ebx, ud_user_message |
|
- | 211 | mov ebp, notifyapp |
|
- | 212 | call fs_execute_from_sysdir_param |
|
- | 213 | pop ebx |
|
193 | show_error_parameters: |
214 | .no_ud: |
194 | mov edx,[TASK_BASE] ;not scratched below |
215 | mov edx, [TASK_BASE];not scratched below |
195 | DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid] |
216 | DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid] |
196 | cmp bl, 0x08 |
217 | cmp bl, 0x08 |
197 | jb .l0 |
218 | jb .l0 |
198 | cmp bl, 0x0e |
219 | cmp bl, 0x0e |
- | 220 | jbe .l1 |
|
199 | jbe .l1 |
221 | .l0: |
- | 222 | mov bl, 0x09 |
|
200 | .l0: mov bl, 0x09 |
223 | .l1: |
201 | .l1: mov eax,[msg_fault_sel+ebx*4 - 0x08*4] |
224 | mov eax, [msg_fault_sel+ebx*4 - 0x08*4] |
202 | DEBUGF 1, "K : %s\n", eax |
225 | DEBUGF 1, "K : %s\n", eax |
203 | mov eax, [reg_cs3+4] |
226 | mov eax, [reg_cs3+4] |
204 | mov edi, msg_sel_app |
227 | mov edi, msg_sel_app |
205 | mov ebx, [reg_esp3+4] |
228 | mov ebx, [reg_esp3+4] |
206 | cmp eax, app_code |
229 | cmp eax, app_code |
207 | je @f |
230 | je @f |
208 | mov edi, msg_sel_ker |
231 | mov edi, msg_sel_ker |
- | 232 | mov ebx, [reg_esp0+4] |
|
209 | mov ebx, [reg_esp0+4] |
233 | @@: |
210 | @@: DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4] |
234 | 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] |
235 | 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 |
236 | 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 |
237 | DEBUGF 1, "K : Flags : %x CS : %x (%s)\n", [reg_eflags+4], eax, edi |
214 | ret |
238 | ret |
Line 226... | Line 250... | ||
226 | restore reg_esp0 |
250 | restore reg_esp0 |
227 | restore reg_ebp |
251 | restore reg_ebp |
228 | restore reg_esi |
252 | restore reg_esi |
229 | restore reg_edi |
253 | restore reg_edi |
Line 230... | Line -... | ||
230 | - | ||
231 | ; irq1 -> hid/keyboard.inc |
- | |
232 | macro irqh [num] { |
- | |
233 | p_irq#num : |
- | |
234 | mov edi, num |
- | |
235 | jmp irqhandler |
- | |
236 | } |
- | |
237 | - | ||
238 | - | ||
239 | - | ||
240 | p_irq6: |
- | |
241 | save_ring3_context |
- | |
242 | mov ax, app_data ;os_data |
- | |
243 | mov ds, ax |
- | |
244 | mov es, ax |
- | |
245 | mov edi, 6 |
- | |
246 | cmp [v86_irqhooks+edi*8], 0 |
- | |
247 | jnz v86_irq2 |
- | |
248 | call fdc_irq |
- | |
249 | call ready_for_next_irq |
- | |
250 | restore_ring3_context |
- | |
251 | iret |
- | |
252 | - | ||
253 | - | ||
254 | p_irq14: |
- | |
255 | save_ring3_context |
- | |
256 | mov ax, app_data ;os_data |
- | |
257 | mov ds, ax |
- | |
258 | mov es, ax |
- | |
259 | mov edi, 14 |
- | |
260 | cmp [v86_irqhooks+edi*8], 0 |
- | |
261 | jnz v86_irq2 |
- | |
262 | ; mov byte [BOOT_VAR + 0x48E], 0xFF |
- | |
263 | call [irq14_func] |
- | |
264 | call ready_for_next_irq_1 |
- | |
265 | restore_ring3_context |
- | |
266 | iret |
- | |
267 | p_irq15: |
- | |
268 | save_ring3_context |
- | |
269 | mov ax, app_data ;os_data |
- | |
270 | mov ds, ax |
- | |
271 | mov es, ax |
- | |
272 | mov edi, 15 |
- | |
273 | cmp [v86_irqhooks+edi*8], 0 |
- | |
274 | jnz v86_irq2 |
- | |
275 | ; mov byte [BOOT_VAR + 0x48E], 0xFF |
- | |
276 | call [irq15_func] |
- | |
277 | call ready_for_next_irq_1 |
- | |
278 | restore_ring3_context |
- | |
279 | iret |
- | |
280 | - | ||
281 | ready_for_next_irq: |
- | |
282 | mov eax,5 |
- | |
283 | mov [check_idle_semaphore],eax |
- | |
284 | ; mov al, 0x20 |
- | |
285 | add eax,(0x20-0x5) |
- | |
286 | - | ||
287 | out 0x20, al |
- | |
288 | ret |
- | |
289 | ;destroy eax |
- | |
290 | ready_for_next_irq_1: |
- | |
291 | mov eax,5 |
- | |
292 | mov [check_idle_semaphore],eax |
- | |
293 | ; mov al, 0x20 |
- | |
294 | add eax,(0x20-0x5) |
- | |
295 | out 0xa0,al |
- | |
296 | out 0x20, al |
- | |
297 | ret |
- | |
298 | - | ||
299 | irqD: |
- | |
300 | push eax |
- | |
301 | xor eax,eax |
- | |
302 | out 0xf0,al |
- | |
303 | mov al,0x20 |
- | |
304 | out 0xa0,al |
- | |
305 | out 0x20,al |
- | |
306 | pop eax |
- | |
307 | iret |
- | |
308 | - | ||
309 | - | ||
310 | irqh 2,3,4,5,7,8,9,10,11 |
- | |
311 | - | ||
312 | irqhandler: |
- | |
313 | - | ||
314 | mov esi,edi ; 1 |
- | |
315 | shl esi,6 ; 1 |
- | |
316 | add esi,irq00read ; 1 |
- | |
317 | shl edi,12 ; 1 |
- | |
318 | add edi,IRQ_SAVE |
- | |
319 | mov ecx,16 |
- | |
320 | - | ||
321 | irqnewread: |
- | |
322 | dec ecx |
- | |
323 | js irqover |
- | |
324 | - | ||
325 | movzx edx, word [esi] ; 2+ |
- | |
326 | - | ||
327 | test edx, edx ; 1 |
- | |
328 | jz irqover |
- | |
329 | - | ||
330 | - | ||
331 | mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size |
- | |
332 | mov eax, 4000 ; + 0x4 dword - data begin offset |
- | |
333 | cmp ebx, eax |
- | |
334 | je irqfull |
- | |
335 | add ebx, [edi + 0x4] ; add data size to data begin offset |
- | |
336 | cmp ebx, eax ; if end of buffer, begin cycle again |
- | |
337 | jb @f |
- | |
338 | - | ||
339 | xor ebx, ebx |
- | |
340 | - | ||
341 | @@: |
- | |
342 | add ebx, edi |
- | |
343 | movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word |
- | |
344 | dec eax |
- | |
345 | jz irqbyte |
- | |
346 | dec eax |
- | |
347 | jnz noirqword |
- | |
348 | - | ||
349 | in ax,dx |
- | |
350 | cmp ebx, 3999 ; check for address odd in the end of buffer |
- | |
351 | jne .odd |
- | |
352 | mov [ebx + 0x10], ax |
- | |
353 | jmp .add_size |
- | |
354 | .odd: |
- | |
355 | mov [ebx + 0x10], al ; I could make mistake here :) |
- | |
356 | mov [edi + 0x10], ah |
- | |
357 | .add_size: |
- | |
358 | add dword [edi], 2 |
- | |
359 | jmp nextport |
- | |
360 | - | ||
361 | - | ||
362 | irqbyte: |
- | |
363 | in al,dx |
- | |
364 | mov [ebx + 0x10],al |
- | |
365 | inc dword [edi] |
- | |
366 | nextport: |
- | |
367 | add esi,4 |
- | |
368 | jmp irqnewread |
- | |
369 | - | ||
370 | - | ||
371 | noirqword: |
- | |
372 | irqfull: |
- | |
373 | irqover: |
- | |
374 | - | ||
375 | ret |
- | |
376 | - | ||
Line -... | Line 254... | ||
- | 254 | ||
377 | 255 | ||
378 | 256 | align 4 |
|
Line 379... | Line 257... | ||
379 | set_application_table_status: |
257 | set_application_table_status: |
380 | push eax |
258 | push eax |
Line 388... | Line 266... | ||
388 | 266 | ||
Line 389... | Line 267... | ||
389 | pop eax |
267 | pop eax |
Line 390... | Line 268... | ||
390 | 268 | ||
391 | ret |
269 | ret |
392 | 270 | ||
Line 393... | Line 271... | ||
393 | 271 | align 4 |
|
394 | clear_application_table_status: |
272 | clear_application_table_status: |
Line 414... | Line 292... | ||
414 | ; * ecx = íîâûé ðàçìåð ïàìÿòè |
292 | ; * ecx = íîâûé ðàçìåð ïàìÿòè |
415 | ;Âîçâðàùàåìîå çíà÷åíèå: |
293 | ;Âîçâðàùàåìîå çíà÷åíèå: |
416 | ; * eax = 0 - óñïåøíî |
294 | ; * eax = 0 - óñïåøíî |
417 | ; * eax = 1 - íåäîñòàòî÷íî ïàìÿòè |
295 | ; * eax = 1 - íåäîñòàòî÷íî ïàìÿòè |
Line -... | Line 296... | ||
- | 296 | ||
418 | 297 | align 4 |
|
419 | sys_resize_app_memory: |
298 | sys_resize_app_memory: |
420 | ; ebx = 1 - resize |
299 | ; ebx = 1 - resize |
Line 421... | Line 300... | ||
421 | ; ecx = new amount of memory |
300 | ; ecx = new amount of memory |
Line 435... | Line 314... | ||
435 | endg |
314 | endg |
Line 436... | Line 315... | ||
436 | 315 | ||
437 | ; param |
316 | ; param |
Line -... | Line 317... | ||
- | 317 | ; esi= slot |
|
438 | ; esi= slot |
318 | |
Line 439... | Line 319... | ||
439 | 319 | align 4 |
|
Line 440... | Line 320... | ||
440 | terminate: ; terminate application |
320 | terminate: ; terminate application |
Line 706... | Line 586... | ||
706 | jnz @f |
586 | jnz @f |
707 | and [bgrlockpid], 0 |
587 | and [bgrlockpid], 0 |
708 | and [bgrlock], 0 |
588 | and [bgrlock], 0 |
709 | @@: |
589 | @@: |
Line 710... | Line -... | ||
710 | - | ||
711 | pusha ; remove all irq reservations |
- | |
712 | mov eax,esi |
- | |
713 | shl eax, 5 |
- | |
714 | mov eax,[eax+CURRENT_TASK+TASKDATA.pid] |
- | |
715 | mov edi,irq_owner |
- | |
716 | xor ebx, ebx |
- | |
717 | xor edx, edx |
- | |
718 | newirqfree: |
- | |
719 | cmp [edi + 4 * ebx], eax |
- | |
720 | jne nofreeirq |
- | |
721 | mov [edi + 4 * ebx], edx ; remove irq reservation |
- | |
722 | mov [irq_tab + 4 * ebx], edx ; remove irq handler |
- | |
723 | mov [irq_rights + 4 * ebx], edx ; set access rights to full access |
- | |
724 | nofreeirq: |
- | |
725 | inc ebx |
- | |
726 | cmp ebx, 16 |
- | |
727 | jb newirqfree |
- | |
728 | popa |
- | |
729 | 590 | ||
730 | pusha ; remove all port reservations |
591 | pusha ; remove all port reservations |
731 | mov edx,esi |
592 | mov edx, esi |
732 | shl edx, 5 |
593 | shl edx, 5 |
733 | add edx,CURRENT_TASK |
594 | add edx, CURRENT_TASK |
Line 810... | Line 671... | ||
810 | mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse |
671 | mov [DONT_DRAW_MOUSE], byte 0; draw mouse |
Line 811... | Line 672... | ||
811 | 672 | ||
812 | and [application_table_status],0 |
673 | and [application_table_status], 0 |
813 | ;mov esi,process_terminated |
674 | ;mov esi,process_terminated |
814 | ;call sys_msg_board_str |
- | |
815 | - | ||
816 | mov eax, [.slot] |
- | |
817 | call SOCKET_process_end |
- | |
818 | 675 | ;call sys_msg_board_str |
|
819 | add esp, 4 |
676 | add esp, 4 |
820 | ret |
677 | ret |
Line 821... | Line 678... | ||
821 | restore .slot |
678 | restore .slot |
- | 679 | ||
- | 680 | iglobal |
|
- | 681 | if lang eq ru |
|
- | 682 | boot_sched_1 db '®§¤ ¨¥ GDT TSS 㪠§ ⥫ï',0 |
|
822 | 683 | boot_sched_2 db '®§¤ ¨¥ IDT â ¡«¨æë',0 |
|
823 | iglobal |
684 | else |
- | 685 | boot_sched_1 db 'Building gdt tss pointer',0 |
|
824 | boot_sched_1 db 'Building gdt tss pointer',0 |
686 | boot_sched_2 db 'Building IDT table',0 |
Line 825... | Line 687... | ||
825 | boot_sched_2 db 'Building IDT table',0 |
687 | end if |