Rev 4 | Rev 15 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4 | Rev 6 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | ;; ;; |
2 | ;; ;; |
3 | ;; SYSTEM CALL ENTRY ;; |
3 | ;; SYSTEM CALL ENTRY ;; |
4 | ;; ;; |
4 | ;; ;; |
5 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | uglobal |
6 | uglobal |
7 | task_tss rd 1 |
7 | pushed_regs rd 1 |
8 | endg |
8 | endg |
- | 9 | ||
9 | align 32 |
10 | align 32 |
10 | i40: |
11 | i40: |
11 | pushad |
12 | pushad |
Line 12... | Line 13... | ||
12 | 13 | ||
13 | push ds |
14 | push ds |
14 | mov ax,word os_data |
15 | mov ax,word os_data |
15 | mov ds,ax |
16 | mov ds,ax |
16 | mov es,ax |
17 | mov es,ax |
17 | mov [task_tss],esp |
18 | mov [pushed_regs],esp |
18 | add dword [task_tss],4 |
19 | add dword [pushed_regs],4 |
Line 19... | Line 20... | ||
19 | cli |
20 | cli |
20 | 21 | ||
21 | mov edi,[0x3000] |
22 | mov eax, [0x3000] |
22 | mov eax,edi |
- | |
23 | shl edi, 3 |
- | |
24 | ;clear busy flag in application's TSS |
- | |
25 | mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b |
- | |
26 | - | ||
27 | 23 | mov edi, eax |
|
Line 28... | Line 24... | ||
28 | shl edi,5 |
24 | shl edi, 8 |
29 | mov [edi+0x80000+0xB0],eax ; used i40 handler |
25 | mov [edi+0x80000+0xB0],eax ; used i40 handler |
Line 30... | Line -... | ||
30 | - | ||
31 | ; for syscall trace function |
- | |
32 | call save_registers |
- | |
33 | 26 | ||
34 | ; mov esi, [0x3000] |
- | |
35 | ; imul esi, tss_step |
- | |
- | 27 | ; for syscall trace function |
|
36 | ; add esi, tss_data |
28 | call save_registers |
37 | mov esi,[task_tss] |
29 | |
38 | ; sub esi,0x28 |
30 | mov esi,[pushed_regs] |
39 | ; esi holds address of TSS of interupted program |
31 | |
Line 40... | Line 32... | ||
40 | ; load first 3 registers |
32 | ; load first 3 registers |
41 | mov eax,[esi+28];+l.eax-tss_sceleton] |
33 | mov eax,[esi+28] |
42 | mov ebx,[esi+16];l.ebx-tss_sceleton] |
34 | mov ebx,[esi+16] |
Line 43... | Line 35... | ||
43 | mov ecx,[esi+24];l.ecx-tss_sceleton] |
35 | mov ecx,[esi+24] |
44 | 36 | ||
45 | ; save current registers |
37 | ; save current registers |
46 | ; stack may be modified by a system function to return some value to caller! |
38 | ; stack may be modified by a system function to return some value to caller! |
47 | pushad |
39 | pushad |
48 | 40 | ||
49 | ; load all registers from TSS of the application, in crossed order (why?) |
41 | ; load all registers from TSS of the application, in crossed order (why?) |
Line 50... | Line 42... | ||
50 | mov edi,[esi+28];l.eax-tss_sceleton] |
42 | mov edi,[esi+28] |
51 | mov eax,[esi+16];l.ebx-tss_sceleton] |
43 | mov eax,[esi+16] |
52 | mov ebx,[esi+24];l.ecx-tss_sceleton] |
44 | mov ebx,[esi+24] |
53 | mov ecx,[esi+20];l.edx-tss_sceleton] |
45 | mov ecx,[esi+20] |
Line 64... | Line 56... | ||
64 | cli |
56 | cli |
Line 65... | Line 57... | ||
65 | 57 | ||
66 | ; return saved and probably even changed regs |
58 | ; return saved and probably even changed regs |
Line 67... | Line -... | ||
67 | popad |
- | |
68 | - | ||
69 | ; |
- | |
70 | ;mov esi,[0x3000] |
- | |
71 | ;imul esi,tss_step |
- | |
72 | ;add esi,tss_data |
- | |
73 | ; |
59 | popad |
74 | 60 | ||
75 | ; modify 3 program's registers (in its TSS) |
61 | ; modify 3 program's registers (in its TSS) |
76 | mov [esi+28],eax;[esi+l.eax-tss_sceleton], eax |
62 | mov [esi+28],eax |
Line 77... | Line 63... | ||
77 | mov [esi+16],ebx;[esi+l.ebx-tss_sceleton], ebx |
63 | mov [esi+16],ebx |
78 | mov [esi+24],ecx;[esi+l.ecx-tss_sceleton], ecx |
64 | mov [esi+24],ecx |
79 | 65 | ||
80 | xor eax, eax |
66 | xor eax, eax |
Line 87... | Line 73... | ||
87 | mov es,ax |
73 | mov es,ax |
Line 88... | Line 74... | ||
88 | 74 | ||
89 | popad |
75 | popad |
Line 90... | Line -... | ||
90 | iretd |
- | |
91 | - | ||
92 | jmp i40 |
- | |
93 | - | ||
94 | label reg1 dword at 0x6000 |
- | |
95 | label reg2 dword at 0x6400 |
- | |
96 | label usedi40 byte at 0x6800 |
- | |
97 | - | ||
98 | uglobal |
- | |
99 | schd dd 0x0 |
- | |
100 | endg |
76 | iretd |
101 | 77 | ||
102 | align 4 |
- | |
103 | save_registers: |
- | |
104 | - | ||
105 | mov esi,[0x3000] |
- | |
106 | imul esi,tss_step |
- | |
107 | add esi,tss_data |
- | |
108 | - | ||
109 | mov eax,[esi+l.eax-tss_sceleton] |
- | |
110 | mov ebx,[esi+l.ebx-tss_sceleton] |
- | |
111 | mov ecx,[esi+l.ecx-tss_sceleton] |
- | |
112 | mov edx,[esi+l.edx-tss_sceleton] |
- | |
113 | mov edi,[esi+l.edi-tss_sceleton] |
- | |
114 | mov ebp,[esi+l.ebp-tss_sceleton] |
- | |
115 | - | ||
116 | mov esi,[esi+l.esi-tss_sceleton] |
- | |
117 | 78 | align 4 |
|
118 | push eax ecx esi edi |
79 | save_registers: |
119 | mov esi,[0x3010] |
80 | mov esi, [0x3010] |
120 | mov eax,[esi+0x4] |
81 | mov eax, [esi+0x4] ; load PID |
121 | mov esi,esp |
82 | mov esi, [pushed_regs] |
122 | inc [save_syscall_count] |
83 | inc [save_syscall_count] |
123 | mov edi,[save_syscall_count] |
84 | mov edi,[save_syscall_count] |
124 | and edi,0xF |
85 | and edi,0xF |
125 | shl edi,6 |
86 | shl edi,6 |
126 | add edi,save_syscall_data+32 |
87 | add edi,save_syscall_data+32 |
127 | mov [edi-32],eax |
88 | mov [edi-32],eax |
128 | mov ecx,32 / 4 |
89 | mov ecx,32 / 4 |
129 | cld |
- | |
130 | rep movsd |
90 | cld |
Line 131... | Line 91... | ||
131 | pop edi esi ecx eax |
91 | rep movsd |
132 | ret |
92 | ret |
133 | 93 |