Rev 2987 | Rev 3626 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2987 | Rev 3500 | ||
---|---|---|---|
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 | ||
14 | $Revision: 2987 $ |
- | |
Line 15... | Line 14... | ||
15 | 14 | $Revision: 3500 $ |
|
16 | 15 | ||
17 | align 4 ;3A08 |
16 | align 4 ;3A08 |
18 | build_interrupt_table: |
17 | build_interrupt_table: |
Line 73... | Line 72... | ||
73 | msg_exc_b db "Segment not present", 0 |
72 | msg_exc_b db "Segment not present", 0 |
74 | msg_exc_c db "Stack fault", 0 |
73 | msg_exc_c db "Stack fault", 0 |
75 | msg_exc_d db "General protection fault", 0 |
74 | msg_exc_d db "General protection fault", 0 |
76 | msg_exc_e db "Page fault", 0 |
75 | msg_exc_e db "Page fault", 0 |
Line -... | Line 76... | ||
- | 76 | ||
- | 77 | if lang eq sp |
|
- | 78 | include 'core/sys32-sp.inc' |
|
77 | 79 | else |
|
78 | msg_sel_ker db "kernel", 0 |
80 | msg_sel_ker db "kernel", 0 |
- | 81 | msg_sel_app db "application", 0 |
|
Line 79... | Line 82... | ||
79 | msg_sel_app db "application", 0 |
82 | end if |
Line 80... | Line 83... | ||
80 | 83 | ||
81 | endg |
84 | endg |
Line 211... | Line 214... | ||
211 | mov ebp, notifyapp |
214 | mov ebp, notifyapp |
212 | call fs_execute_from_sysdir_param |
215 | call fs_execute_from_sysdir_param |
213 | pop ebx |
216 | pop ebx |
214 | .no_ud: |
217 | .no_ud: |
215 | mov edx, [TASK_BASE];not scratched below |
218 | mov edx, [TASK_BASE];not scratched below |
- | 219 | if lang eq sp |
|
- | 220 | DEBUGF 1, "K : Proceso - terminado forzado PID: %x [%s]\n", [edx+TASKDATA.pid], [current_slot] |
|
- | 221 | else |
|
216 | DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid] |
222 | DEBUGF 1, "K : Process - forced terminate PID: %x [%s]\n", [edx+TASKDATA.pid], [current_slot] |
- | 223 | end if |
|
217 | cmp bl, 0x08 |
224 | cmp bl, 0x08 |
218 | jb .l0 |
225 | jb .l0 |
219 | cmp bl, 0x0e |
226 | cmp bl, 0x0e |
220 | jbe .l1 |
227 | jbe .l1 |
221 | .l0: |
228 | .l0: |
Line 705... | Line 712... | ||
705 | ; call build_process_gdt_tss_pointer |
712 | ; call build_process_gdt_tss_pointer |
Line 706... | Line 713... | ||
706 | 713 | ||
707 | ; mov esi,boot_sched_2 |
714 | ; mov esi,boot_sched_2 |
708 | ; call boot_log |
715 | ; call boot_log |
- | 716 | ; ret |
|
- | 717 | ||
- | 718 | ; Three following procedures are used to guarantee that |
|
- | 719 | ; some part of kernel code will not be terminated from outside |
|
- | 720 | ; while it is running. |
|
- | 721 | ; Note: they do not protect a thread from terminating due to errors inside |
|
- | 722 | ; the thread; accessing a nonexisting memory would still terminate it. |
|
- | 723 | ||
- | 724 | ; First two procedures must be used in pair by thread-to-be-protected |
|
- | 725 | ; to signal the beginning and the end of an important part. |
|
- | 726 | ; It is OK to have nested areas. |
|
- | 727 | ||
- | 728 | ; The last procedure must be used by outside wanna-be-terminators; |
|
- | 729 | ; if it is safe to terminate the given thread immediately, it returns eax=1; |
|
- | 730 | ; otherwise, it returns eax=0 and notifies the target thread that it should |
|
- | 731 | ; terminate itself when leaving a critical area (the last critical area if |
|
- | 732 | ; they are nested). |
|
- | 733 | ||
- | 734 | ; Implementation. Those procedures use one dword in APPDATA for the thread, |
|
- | 735 | ; APPDATA.terminate_protection. |
|
- | 736 | ; * The upper bit is 1 during normal operations and 0 when terminate is requested. |
|
- | 737 | ; * Other bits form a number = depth of critical regions, |
|
- | 738 | ; plus 1 if the upper bit is 1. |
|
- | 739 | ; * When this dword goes to zero, the thread should be destructed, |
|
- | 740 | ; and the procedure in which it happened becomes responsible for destruction. |
|
- | 741 | ||
- | 742 | ; Enter critical area. Called by thread which wants to be protected. |
|
- | 743 | proc protect_from_terminate |
|
- | 744 | mov edx, [current_slot] |
|
- | 745 | ; Atomically increment depth of critical areas and get the old value. |
|
- | 746 | mov eax, 1 |
|
- | 747 | lock xadd [edx+APPDATA.terminate_protection], eax |
|
- | 748 | ; If the old value was zero, somebody has started to terminate us, |
|
- | 749 | ; so we are destructing and cannot do anything protected. |
|
- | 750 | ; Otherwise, return to the caller. |
|
- | 751 | test eax, eax |
|
- | 752 | jz @f |
|
- | 753 | ret |
|
- | 754 | @@: |
|
- | 755 | ; Wait for somebody to finish us. |
|
- | 756 | call change_task |
|
- | 757 | jmp @b |
|
- | 758 | endp |
|
- | 759 | ||
- | 760 | ; Leave critical area. Called by thread which wants to be protected. |
|
- | 761 | proc unprotect_from_terminate |
|
- | 762 | mov edx, [current_slot] |
|
- | 763 | ; Atomically decrement depth of critical areas. |
|
- | 764 | lock dec [edx+APPDATA.terminate_protection] |
|
- | 765 | ; If the result of decrement is zero, somebody has requested termination, |
|
- | 766 | ; but at that moment we were inside a critical area; terminate now. |
|
- | 767 | jz sys_end |
|
- | 768 | ; Otherwise, return to the caller. |
|
- | 769 | ret |
|
- | 770 | endp |
|
- | 771 | ||
- | 772 | ; Request termination of thread identified by edx = SLOT_BASE + slot*256. |
|
- | 773 | ; Called by anyone. |
|
- | 774 | proc request_terminate |
|
- | 775 | xor eax, eax ; set return value |
|
- | 776 | ; Atomically clear the upper bit. If it was already zero, then |
|
- | 777 | ; somebody has requested termination before us, so just exit. |
|
- | 778 | lock btr [edx+APPDATA.terminate_protection], 31 |
|
- | 779 | jnc .unsafe |
|
- | 780 | ; Atomically decrement depth of critical areas. |
|
- | 781 | lock dec [edx+APPDATA.terminate_protection] |
|
- | 782 | ; If the result of decrement is nonzero, the target thread is inside a |
|
- | 783 | ; critical area; leave termination to leaving that area. |
|
- | 784 | jnz .unsafe |
|
- | 785 | ; Otherwise, it is safe to kill the target now and the caller is responsible |
|
- | 786 | ; for this. Return eax=1. |
|
- | 787 | inc eax |
|
- | 788 | .unsafe: |
|
- | 789 | ret |
|
- | 790 | endp |