Rev 40 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 40 | Rev 41 | ||
---|---|---|---|
1 | if ~defined newprocess_inc |
1 | if ~defined newprocess_inc |
2 | newprocess_inc_fix: |
2 | newprocess_inc_fix: |
3 | newprocess_inc fix newprocess_inc_fix |
3 | newprocess_inc fix newprocess_inc_fix |
4 | include "mem.inc" |
4 | include "mem.inc" |
5 | include "memmanag.inc" |
5 | include "memmanag.inc" |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 | ;;Working with new types of processes. |
7 | ;;Working with new types of processes. |
8 | ;;Author: Khalyavin Andrey halyavin@land.ru |
8 | ;;Author: Khalyavin Andrey halyavin@land.ru |
9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
10 | iglobal |
10 | iglobal |
11 | new_process_loading db 'K : New Process - loading',13,10,0 |
11 | new_process_loading db 'K : New Process - loading',13,10,0 |
12 | new_process_running db 'K : New Process - done',13,10,0 |
12 | new_process_running db 'K : New Process - done',13,10,0 |
13 | start_not_enough_memory db 'K : New Process - not enough memory',13,10,0 |
13 | start_not_enough_memory db 'K : New Process - not enough memory',13,10,0 |
14 | endg |
14 | endg |
15 | ;----------------------------------------------------------------------------- |
15 | ;----------------------------------------------------------------------------- |
16 | 16 | ||
17 | find_new_process_place: |
17 | find_new_process_place: |
18 | ;input: |
18 | ;input: |
19 | ; none |
19 | ; none |
20 | ;result: |
20 | ;result: |
21 | ; eax=[new_process_place]<>0 - ok |
21 | ; eax=[new_process_place]<>0 - ok |
22 | ; 0 - failed. |
22 | ; 0 - failed. |
23 | ;This function find least empty slot. |
23 | ;This function find least empty slot. |
24 | ;It doesn't increase [0x3004]! |
24 | ;It doesn't increase [0x3004]! |
25 | mov eax,0x3000+second_base_address |
25 | mov eax,0x3000+second_base_address |
26 | push ebx |
26 | push ebx |
27 | mov ebx,[0x3004] |
27 | mov ebx,[0x3004] |
28 | inc ebx |
28 | inc ebx |
29 | shl ebx,5 |
29 | shl ebx,5 |
30 | add ebx,eax ;ebx - address of process information for (last+1) slot |
30 | add ebx,eax ;ebx - address of process information for (last+1) slot |
31 | .newprocessplace: |
31 | .newprocessplace: |
32 | ;eax = address of process information for current slot |
32 | ;eax = address of process information for current slot |
33 | cmp eax,ebx |
33 | cmp eax,ebx |
34 | jz .endnewprocessplace ;empty slot after high boundary |
34 | jz .endnewprocessplace ;empty slot after high boundary |
35 | add eax,0x20 |
35 | add eax,0x20 |
36 | cmp word [eax+0xa],9 ;check process state, 9 means that process slot is empty |
36 | cmp word [eax+0xa],9 ;check process state, 9 means that process slot is empty |
37 | jnz .newprocessplace |
37 | jnz .newprocessplace |
38 | .endnewprocessplace: |
38 | .endnewprocessplace: |
39 | mov ebx,eax |
39 | mov ebx,eax |
40 | sub eax,0x3000+second_base_address |
40 | sub eax,0x3000+second_base_address |
41 | shr eax,5 ;calculate slot index |
41 | shr eax,5 ;calculate slot index |
42 | cmp eax,256 |
42 | cmp eax,256 |
43 | jge .failed ;it should be <256 |
43 | jge .failed ;it should be <256 |
44 | mov word [ebx+0xa],9 ;set process state to 9 (for slot after hight boundary) |
44 | mov word [ebx+0xa],9 ;set process state to 9 (for slot after hight boundary) |
45 | mov [new_process_place],eax ;save process slot |
45 | mov [new_process_place],eax ;save process slot |
46 | pop ebx |
46 | pop ebx |
47 | ret |
47 | ret |
48 | .failed: |
48 | .failed: |
49 | xor eax,eax |
49 | xor eax,eax |
50 | pop ebx |
50 | pop ebx |
51 | ret |
51 | ret |
52 | ;----------------------------------------------------------------------------- |
52 | ;----------------------------------------------------------------------------- |
53 | safe_sti: |
53 | safe_sti: |
54 | cmp byte [0xe000], 1 |
54 | cmp byte [0xe000], 1 |
55 | jne @f |
55 | jne @f |
56 | sti |
56 | sti |
57 | @@:ret |
57 | @@:ret |
58 | 58 | ||
59 | new_start_application_floppy: |
59 | new_start_application_floppy: |
60 | ;input: |
60 | ;input: |
61 | ; eax - pointer to filename |
61 | ; eax - pointer to filename |
62 | ; ebx - parameters to pass |
62 | ; ebx - parameters to pass |
63 | ; edx - flags |
63 | ; edx - flags |
64 | ;result: |
64 | ;result: |
65 | ; eax - pid of new process |
65 | ; eax - pid of new process |
66 | ; or 0 if call fails. |
66 | ; or 0 if call fails. |
67 | mov [appl_path],edi |
67 | mov [appl_path],edi |
68 | pushad |
68 | pushad |
69 | mov esi,new_process_loading |
69 | mov esi,new_process_loading |
70 | call sys_msg_board_str ;write to debug board |
70 | call sys_msg_board_str ;write to debug board |
71 | 71 | ||
72 | ;wait application_table_status mutex |
72 | ;wait application_table_status mutex |
73 | .table_status: |
73 | .table_status: |
74 | cli |
74 | cli |
75 | cmp [application_table_status],0 |
75 | cmp [application_table_status],0 |
76 | jz .stf |
76 | jz .stf |
77 | sti |
77 | sti |
78 | call change_task |
78 | call change_task |
79 | jmp .table_status |
79 | jmp .table_status |
80 | .stf: |
80 | .stf: |
81 | call set_application_table_status |
81 | call set_application_table_status |
82 | ;we can change system tables now |
82 | ;we can change system tables now |
83 | push edi |
83 | push edi |
84 | push ebx |
84 | push ebx |
85 | push eax |
85 | push eax |
86 | call find_new_process_place ;find empty process slot |
86 | call find_new_process_place ;find empty process slot |
87 | sti |
87 | sti |
88 | test eax,eax |
88 | test eax,eax |
89 | jz .failed |
89 | jz .failed |
90 | 90 | ||
91 | mov edi,eax |
91 | mov edi,eax |
92 | shl edi,8 |
92 | shl edi,8 |
93 | add edi,0x80000 |
93 | add edi,0x80000 |
94 | mov ecx,256/4 |
94 | mov ecx,256/4 |
95 | xor eax,eax |
95 | xor eax,eax |
96 | cld |
96 | cld |
97 | rep stosd ;clean extended information about process |
97 | rep stosd ;clean extended information about process |
98 | 98 | ||
99 | ;set new process name |
99 | ;set new process name |
100 | xor eax,eax |
100 | xor eax,eax |
101 | mov [appl_path_size],eax |
101 | mov [appl_path_size],eax |
102 | mov eax,[esp] ;+8] |
102 | mov eax,[esp] ;+8] |
103 | .find_last_byte: |
103 | .find_last_byte: |
104 | cmp byte [eax],0 |
104 | cmp byte [eax],0 |
105 | jz .find_last_byte_end |
105 | jz .find_last_byte_end |
106 | inc eax |
106 | inc eax |
107 | inc [appl_path_size] |
107 | inc [appl_path_size] |
108 | jmp .find_last_byte |
108 | jmp .find_last_byte |
109 | .find_last_byte_end: |
109 | .find_last_byte_end: |
110 | add [appl_path_size],24 |
110 | add [appl_path_size],24 |
111 | sub eax,11 ;last 11 bytes = application name |
111 | sub eax,11 ;last 11 bytes = application name |
112 | ; mov eax,[esp] ;eax - pointer to file name |
112 | ; mov eax,[esp] ;eax - pointer to file name |
113 | mov ebx,[new_process_place] |
113 | mov ebx,[new_process_place] |
114 | shl ebx,8 |
114 | shl ebx,8 |
115 | add ebx,0x80000 |
115 | add ebx,0x80000 |
116 | mov ecx,11 |
116 | mov ecx,11 |
117 | call memmove |
117 | call memmove |
118 | 118 | ||
119 | ;read header of file |
119 | ;read header of file |
120 | mov eax,[esp] |
120 | mov eax,[esp] |
121 | mov ebx,1 ;index of first block |
121 | mov ebx,1 ;index of first block |
122 | mov ecx,2 ;number of blocks |
122 | mov ecx,2 ;number of blocks |
123 | mov edx,0x90000 ;temp area |
123 | mov edx,0x90000 ;temp area |
124 | mov esi,12 ;file name length |
124 | mov esi,12 ;file name length |
125 | mov edi,[esp+8] |
125 | mov edi,[esp+8] |
126 | ; cli |
126 | ; cli |
127 | call floppy_fileread ;read file from FD |
127 | call floppy_fileread ;read file from FD |
128 | ; sti |
128 | ; sti |
129 | cmp eax,0 |
129 | cmp eax,0 |
130 | jne .cleanfailed |
130 | jne .cleanfailed |
131 | ;check MENUET signature |
131 | ;check MENUET signature |
132 | cmp [0x90000],dword 'MENU' |
132 | cmp [0x90000],dword 'MENU' |
133 | jnz .cleanfailed |
133 | jnz .cleanfailed |
134 | cmp [0x90004],word 'ET' |
134 | cmp [0x90004],word 'ET' |
135 | jnz .cleanfailed |
135 | jnz .cleanfailed |
136 | 136 | ||
137 | call get_app_params ;parse header fields |
137 | call get_app_params ;parse header fields |
138 | cmp esi,0 |
138 | cmp esi,0 |
139 | jz .cleanfailed |
139 | jz .cleanfailed |
140 | 140 | ||
141 | mov eax,[new_process_place] |
141 | mov eax,[new_process_place] |
142 | call create_app_cr3_table ;create page directory for new process |
142 | call create_app_cr3_table ;create page directory for new process |
143 | test eax,eax |
143 | test eax,eax |
144 | jz .cleanfailed_mem |
144 | jz .cleanfailed_mem |
145 | 145 | ||
146 | call MEM_Get_Linear_Address ;calculate linear address of it |
146 | call MEM_Get_Linear_Address ;calculate linear address of it |
147 | 147 | ||
148 | mov ebx,std_application_base_address |
148 | mov ebx,std_application_base_address |
149 | mov ecx,[app_mem] |
149 | mov ecx,[app_mem] |
150 | add ecx,4095 |
150 | add ecx,4095 |
151 | shr ecx,12 |
151 | shr ecx,12 |
152 | mov edx,eax |
152 | mov edx,eax |
153 | call mem_alloc_specified_region ;allocate memory for application |
153 | call mem_alloc_specified_region ;allocate memory for application |
154 | test eax,eax |
154 | test eax,eax |
155 | jz .cleanfailed_mem1 |
155 | jz .cleanfailed_mem1 |
156 | 156 | ||
157 | mov eax,[edx+(std_application_base_address shr 20)] |
157 | mov eax,[edx+(std_application_base_address shr 20)] |
158 | and eax,not (4096-1) ;eax - physical address of first (for application memory) page table |
158 | and eax,not (4096-1) ;eax - physical address of first (for application memory) page table |
159 | call MEM_Get_Linear_Address |
159 | call MEM_Get_Linear_Address |
160 | mov edx,eax |
160 | mov edx,eax |
161 | 161 | ||
162 | ;read file |
162 | ;read file |
163 | mov ebx,1 |
163 | mov ebx,1 |
164 | mov esi,12 ;length of file name |
164 | mov esi,12 ;length of file name |
165 | .loop1: |
165 | .loop1: |
166 | ;edx = linear address of current page table entry |
166 | ;edx = linear address of current page table entry |
167 | ;ebx = index of current block in file |
167 | ;ebx = index of current block in file |
168 | push edx |
168 | push edx |
169 | mov eax,[edx] |
169 | mov eax,[edx] |
170 | and eax,not (4096-1) |
170 | and eax,not (4096-1) |
171 | call MEM_Get_Linear_Address |
171 | call MEM_Get_Linear_Address |
172 | mov edx,eax ;read file block to current page |
172 | mov edx,eax ;read file block to current page |
173 | mov eax,[esp+4] ;restore pointer to file name |
173 | mov eax,[esp+4] ;restore pointer to file name |
174 | mov ecx,8 ;number of blocks read |
174 | mov ecx,8 ;number of blocks read |
175 | push ebx |
175 | push ebx |
176 | mov edi,[esp+16] |
176 | mov edi,[esp+16] |
177 | ; cli |
177 | ; cli |
178 | call floppy_fileread |
178 | call floppy_fileread |
179 | ;ebx=file size |
179 | ;ebx=file size |
180 | ; sti |
180 | ; sti |
181 | pop ecx |
181 | pop ecx |
182 | shr ebx,9 |
182 | shr ebx,9 |
183 | cmp ecx,ebx |
183 | cmp ecx,ebx |
184 | jg .endloop1 ;if end of file? |
184 | jg .endloop1 ;if end of file? |
185 | mov ebx,ecx |
185 | mov ebx,ecx |
186 | test eax,eax |
186 | test eax,eax |
187 | jnz .endloop1 ;check io errors |
187 | jnz .endloop1 ;check io errors |
188 | pop edx |
188 | pop edx |
189 | add ebx,8 ;go to next page |
189 | add ebx,8 ;go to next page |
190 | add edx,4 |
190 | add edx,4 |
191 | jmp .loop1 |
191 | jmp .loop1 |
192 | 192 | ||
193 | .endloop1: |
193 | .endloop1: |
194 | add esp,8+4 ;pop linear address of page table entry and pointer to file name |
194 | add esp,8+4 ;pop linear address of page table entry and pointer to file name |
195 | call new_start_application_fl.add_app_parameters |
195 | call new_start_application_fl.add_app_parameters |
196 | mov [esp+28],eax |
196 | mov [esp+28],eax |
197 | popad |
197 | popad |
198 | ret |
198 | ret |
199 | 199 | ||
200 | .cleanfailed_mem1: |
200 | .cleanfailed_mem1: |
201 | ;there is mem for directory entry, but there is no mem for pages |
201 | ;there is mem for directory entry, but there is no mem for pages |
202 | ;so free directory entry |
202 | ;so free directory entry |
203 | mov eax,[new_process_place] |
203 | mov eax,[new_process_place] |
204 | shl eax,8 |
204 | shl eax,8 |
205 | mov eax,[0x80000+eax+0xB8] |
205 | mov eax,[0x80000+eax+0xB8] |
206 | call MEM_Free_Page |
206 | call MEM_Free_Page |
207 | .cleanfailed_mem: |
207 | .cleanfailed_mem: |
208 | ;there is no mem for directory entry, display message. |
208 | ;there is no mem for directory entry, display message. |
209 | mov esi,start_not_enough_memory |
209 | mov esi,start_not_enough_memory |
210 | call sys_msg_board_str |
210 | call sys_msg_board_str |
211 | .cleanfailed: ;clean process name |
211 | .cleanfailed: ;clean process name |
212 | ;can't read file, clean process name. |
212 | ;can't read file, clean process name. |
213 | ;this avoid problems with panel application. |
213 | ;this avoid problems with panel application. |
214 | mov edi,[new_process_place] |
214 | mov edi,[new_process_place] |
215 | shl edi,8 |
215 | shl edi,8 |
216 | add edi,0x80000 |
216 | add edi,0x80000 |
217 | mov ecx,11 |
217 | mov ecx,11 |
218 | mov eax,' ' |
218 | mov eax,' ' |
219 | cld |
219 | cld |
220 | rep stosb |
220 | rep stosb |
221 | .failed: |
221 | .failed: |
222 | ;no more slots |
222 | ;no more slots |
223 | add esp,8+4 |
223 | add esp,8+4 |
224 | mov [application_table_status],0 |
224 | mov [application_table_status],0 |
225 | popad |
225 | popad |
226 | sti |
226 | sti |
227 | mov eax,-1 |
227 | mov eax,-1 |
228 | ret |
228 | ret |
229 | 229 | ||
230 | ;----------------------------------------------------------------------------- |
230 | ;----------------------------------------------------------------------------- |
231 | new_start_application_fl: |
231 | new_start_application_fl: |
232 | ;input: |
232 | ;input: |
233 | ; eax - pointer to filename |
233 | ; eax - pointer to filename |
234 | ; ebx - parameters to pass |
234 | ; ebx - parameters to pass |
235 | ; edx - flags |
235 | ; edx - flags |
236 | ;result: |
236 | ;result: |
237 | ; eax - pid of new process |
237 | ; eax - pid of new process |
238 | ; or 0 if call fails. |
238 | ; or 0 if call fails. |
239 | mov [appl_path],edi |
239 | mov [appl_path],edi |
240 | mov [appl_path_size],36 |
240 | mov [appl_path_size],36 |
241 | pushad |
241 | pushad |
242 | mov esi,new_process_loading |
242 | mov esi,new_process_loading |
243 | call sys_msg_board_str ;write to debug board |
243 | call sys_msg_board_str ;write to debug board |
244 | 244 | ||
245 | ;wait application_table_status mutex |
245 | ;wait application_table_status mutex |
246 | .table_status: |
246 | .table_status: |
247 | cli |
247 | cli |
248 | cmp [application_table_status],0 |
248 | cmp [application_table_status],0 |
249 | jz .stf |
249 | jz .stf |
250 | sti |
250 | sti |
251 | call change_task |
251 | call change_task |
252 | jmp .table_status |
252 | jmp .table_status |
253 | .stf: |
253 | .stf: |
254 | call set_application_table_status |
254 | call set_application_table_status |
255 | ;we can change system tables now |
255 | ;we can change system tables now |
256 | push ebx |
256 | push ebx |
257 | push eax |
257 | push eax |
258 | call find_new_process_place ;find empty process slot |
258 | call find_new_process_place ;find empty process slot |
259 | call safe_sti |
259 | call safe_sti |
260 | test eax,eax |
260 | test eax,eax |
261 | jz .failed |
261 | jz .failed |
262 | 262 | ||
263 | mov edi,eax |
263 | mov edi,eax |
264 | shl edi,8 |
264 | shl edi,8 |
265 | add edi,0x80000 |
265 | add edi,0x80000 |
266 | mov ecx,256/4 |
266 | mov ecx,256/4 |
267 | xor eax,eax |
267 | xor eax,eax |
268 | cld |
268 | cld |
269 | rep stosd ;clean extended information about process |
269 | rep stosd ;clean extended information about process |
270 | 270 | ||
271 | ;set new process name |
271 | ;set new process name |
272 | mov eax,[esp] ;eax - pointer to file name |
272 | mov eax,[esp] ;eax - pointer to file name |
273 | mov ebx,[new_process_place] |
273 | mov ebx,[new_process_place] |
274 | shl ebx,8 |
274 | shl ebx,8 |
275 | add ebx,0x80000 |
275 | add ebx,0x80000 |
276 | mov ecx,11 |
276 | mov ecx,11 |
277 | call memmove |
277 | call memmove |
278 | 278 | ||
279 | ;read header of file |
279 | ;read header of file |
280 | mov ebx,1 ;index of first block |
280 | mov ebx,1 ;index of first block |
281 | mov ecx,2 ;number of blocks |
281 | mov ecx,2 ;number of blocks |
282 | mov edx,0x90000 ;temp area |
282 | mov edx,0x90000 ;temp area |
283 | mov esi,12 ;file name length |
283 | mov esi,12 ;file name length |
284 | cli |
284 | cli |
285 | call fileread ;read file from RD |
285 | call fileread ;read file from RD |
286 | call safe_sti |
286 | call safe_sti |
287 | cmp eax,0 |
287 | cmp eax,0 |
288 | jne .cleanfailed |
288 | jne .cleanfailed |
289 | ;check MENUET signature |
289 | ;check MENUET signature |
290 | cmp [0x90000],dword 'MENU' |
290 | cmp [0x90000],dword 'MENU' |
291 | jnz .cleanfailed |
291 | jnz .cleanfailed |
292 | cmp [0x90004],word 'ET' |
292 | cmp [0x90004],word 'ET' |
293 | jnz .cleanfailed |
293 | jnz .cleanfailed |
294 | 294 | ||
295 | call get_app_params ;parse header fields |
295 | call get_app_params ;parse header fields |
296 | cmp esi,0 |
296 | cmp esi,0 |
297 | jz .cleanfailed |
297 | jz .cleanfailed |
298 | 298 | ||
299 | mov eax,[new_process_place] |
299 | mov eax,[new_process_place] |
300 | call create_app_cr3_table ;create page directory for new process |
300 | call create_app_cr3_table ;create page directory for new process |
301 | test eax,eax |
301 | test eax,eax |
302 | jz .cleanfailed_mem |
302 | jz .cleanfailed_mem |
303 | 303 | ||
304 | call MEM_Get_Linear_Address ;calculate linear address of it |
304 | call MEM_Get_Linear_Address ;calculate linear address of it |
305 | 305 | ||
306 | mov ebx,std_application_base_address |
306 | mov ebx,std_application_base_address |
307 | mov ecx,[app_mem] |
307 | mov ecx,[app_mem] |
308 | add ecx,4095 |
308 | add ecx,4095 |
309 | shr ecx,12 |
309 | shr ecx,12 |
310 | mov edx,eax |
310 | mov edx,eax |
311 | call mem_alloc_specified_region ;allocate memory for application |
311 | call mem_alloc_specified_region ;allocate memory for application |
312 | test eax,eax |
312 | test eax,eax |
313 | jz .cleanfailed_mem1 |
313 | jz .cleanfailed_mem1 |
314 | 314 | ||
315 | mov eax,[edx+(std_application_base_address shr 20)] |
315 | mov eax,[edx+(std_application_base_address shr 20)] |
316 | and eax,not (4096-1) ;eax - physical address of first (for application memory) page table |
316 | and eax,not (4096-1) ;eax - physical address of first (for application memory) page table |
317 | call MEM_Get_Linear_Address |
317 | call MEM_Get_Linear_Address |
318 | mov edx,eax |
318 | mov edx,eax |
319 | 319 | ||
320 | ;read file |
320 | ;read file |
321 | mov ebx,1 |
321 | mov ebx,1 |
322 | mov esi,12 ;length of file name |
322 | mov esi,12 ;length of file name |
323 | .loop1: |
323 | .loop1: |
324 | ;edx = linear address of current page table entry |
324 | ;edx = linear address of current page table entry |
325 | ;ebx = index of current block in file |
325 | ;ebx = index of current block in file |
326 | push edx |
326 | push edx |
327 | mov eax,[edx] |
327 | mov eax,[edx] |
328 | and eax,not (4096-1) |
328 | and eax,not (4096-1) |
329 | call MEM_Get_Linear_Address |
329 | call MEM_Get_Linear_Address |
330 | mov edx,eax ;read file block to current page |
330 | mov edx,eax ;read file block to current page |
331 | mov eax,[esp+4] ;restore pointer to file name |
331 | mov eax,[esp+4] ;restore pointer to file name |
332 | mov ecx,8 ;number of blocks read |
332 | mov ecx,8 ;number of blocks read |
333 | push ebx |
333 | push ebx |
334 | cli |
334 | cli |
335 | call fileread |
335 | call fileread |
336 | ;ebx=file size |
336 | ;ebx=file size |
337 | call safe_sti |
337 | call safe_sti |
338 | pop ecx |
338 | pop ecx |
339 | shr ebx,9 |
339 | shr ebx,9 |
340 | cmp ecx,ebx |
340 | cmp ecx,ebx |
341 | jg .endloop1 ;if end of file? |
341 | jg .endloop1 ;if end of file? |
342 | mov ebx,ecx |
342 | mov ebx,ecx |
343 | test eax,eax |
343 | test eax,eax |
344 | jnz .endloop1 ;check io errors |
344 | jnz .endloop1 ;check io errors |
345 | pop edx |
345 | pop edx |
346 | add ebx,8 ;go to next page |
346 | add ebx,8 ;go to next page |
347 | add edx,4 |
347 | add edx,4 |
348 | jmp .loop1 |
348 | jmp .loop1 |
349 | 349 | ||
350 | .endloop1: |
350 | .endloop1: |
351 | add esp,8 ;pop linear address of page table entry and pointer to file name |
351 | add esp,8 ;pop linear address of page table entry and pointer to file name |
352 | call .add_app_parameters |
352 | call .add_app_parameters |
353 | mov [esp+28],eax |
353 | mov [esp+28],eax |
354 | popad |
354 | popad |
355 | ret |
355 | ret |
356 | 356 | ||
357 | .cleanfailed_mem1: |
357 | .cleanfailed_mem1: |
358 | ;there is mem for directory entry, but there is no mem for pages |
358 | ;there is mem for directory entry, but there is no mem for pages |
359 | ;so free directory entry |
359 | ;so free directory entry |
360 | mov eax,[new_process_place] |
360 | mov eax,[new_process_place] |
361 | shl eax,8 |
361 | shl eax,8 |
362 | mov eax,[0x80000+eax+0xB8] |
362 | mov eax,[0x80000+eax+0xB8] |
363 | call MEM_Free_Page |
363 | call MEM_Free_Page |
364 | .cleanfailed_mem: |
364 | .cleanfailed_mem: |
365 | ;there is no mem for directory entry, display message. |
365 | ;there is no mem for directory entry, display message. |
366 | mov esi,start_not_enough_memory |
366 | mov esi,start_not_enough_memory |
367 | call sys_msg_board_str |
367 | call sys_msg_board_str |
368 | .cleanfailed: ;clean process name |
368 | .cleanfailed: ;clean process name |
369 | ;can't read file, clean process name. |
369 | ;can't read file, clean process name. |
370 | ;this avoid problems with panel application. |
370 | ;this avoid problems with panel application. |
371 | mov edi,[new_process_place] |
371 | mov edi,[new_process_place] |
372 | shl edi,8 |
372 | shl edi,8 |
373 | add edi,0x80000 |
373 | add edi,0x80000 |
374 | mov ecx,11 |
374 | mov ecx,11 |
375 | mov eax,' ' |
375 | mov eax,' ' |
376 | cld |
376 | cld |
377 | rep stosb |
377 | rep stosb |
378 | .failed: |
378 | .failed: |
379 | ;no more slots |
379 | ;no more slots |
380 | add esp,8 |
380 | add esp,8 |
381 | mov [application_table_status],0 |
381 | mov [application_table_status],0 |
382 | popad |
382 | popad |
383 | call safe_sti |
383 | call safe_sti |
384 | mov eax,-1 |
384 | mov eax,-1 |
385 | ret |
385 | ret |
386 | 386 | ||
387 | .add_app_parameters: |
387 | .add_app_parameters: |
388 | ;input: |
388 | ;input: |
389 | ; [esp] - pointer to parameters |
389 | ; [esp] - pointer to parameters |
390 | ; [esp+4]-[esp+36] pushad registers. |
390 | ; [esp+4]-[esp+36] pushad registers. |
391 | ;result |
391 | ;result |
392 | ; eax - pid of new process |
392 | ; eax - pid of new process |
393 | ; or zero if failed |
393 | ; or zero if failed |
394 | cli |
394 | cli |
395 | mov ebx,[new_process_place] |
395 | mov ebx,[new_process_place] |
396 | cmp ebx,[0x3004] |
396 | cmp ebx,[0x3004] |
397 | jle .noinc |
397 | jle .noinc |
398 | inc dword [0x3004] ;update number of processes |
398 | inc dword [0x3004] ;update number of processes |
399 | .noinc: |
399 | .noinc: |
400 | 400 | ||
401 | ; mov ebx,[new_process_place] |
401 | ; mov ebx,[new_process_place] |
402 | ;set 0x8c field of extended information about process |
402 | ;set 0x8c field of extended information about process |
403 | ;(size of application memory) |
403 | ;(size of application memory) |
404 | shl ebx,8 |
404 | shl ebx,8 |
405 | mov eax,[app_mem] |
405 | mov eax,[app_mem] |
406 | mov [second_base_address+0x80000+0x8c+ebx],eax |
406 | mov [second_base_address+0x80000+0x8c+ebx],eax |
407 | ;set 0x10 field of information about process |
407 | ;set 0x10 field of information about process |
408 | ;(application base address) |
408 | ;(application base address) |
409 | ; mov ebx,[new_process_place] |
409 | ; mov ebx,[new_process_place] |
410 | ; shl ebx,5 |
410 | ; shl ebx,5 |
411 | shr ebx,3 |
411 | shr ebx,3 |
412 | mov dword [second_base_address+0x3000+ebx+0x10],std_application_base_address |
412 | mov dword [second_base_address+0x3000+ebx+0x10],std_application_base_address |
413 | 413 | ||
414 | ;add command line parameters |
414 | ;add command line parameters |
415 | .add_command_line: |
415 | .add_command_line: |
416 | mov edx,[app_i_param] |
416 | mov edx,[app_i_param] |
417 | test edx,edx |
417 | test edx,edx |
418 | jz .no_command_line ;application don't need parameters |
418 | jz .no_command_line ;application don't need parameters |
419 | mov eax,[esp+4] |
419 | mov eax,[esp+4] |
420 | test eax,eax |
420 | test eax,eax |
421 | jz .no_command_line ;no parameters specified |
421 | jz .no_command_line ;no parameters specified |
422 | ;calculate parameter length |
422 | ;calculate parameter length |
423 | mov esi,eax |
423 | mov esi,eax |
424 | xor ecx,ecx |
424 | xor ecx,ecx |
425 | .command_line_len: |
425 | .command_line_len: |
426 | cmp byte [esi],0 |
426 | cmp byte [esi],0 |
427 | jz .command_line_len_end |
427 | jz .command_line_len_end |
428 | inc esi |
428 | inc esi |
429 | inc ecx |
429 | inc ecx |
430 | cmp ecx,256 |
430 | cmp ecx,256 |
431 | jl .command_line_len |
431 | jl .command_line_len |
432 | 432 | ||
433 | .command_line_len_end: |
433 | .command_line_len_end: |
434 | ;ecx - parameter length |
434 | ;ecx - parameter length |
435 | ;edx - address of parameters in new process address space |
435 | ;edx - address of parameters in new process address space |
436 | mov ebx,eax ;ebx - address of parameters in our address space |
436 | mov ebx,eax ;ebx - address of parameters in our address space |
437 | mov eax,[new_process_place] |
437 | mov eax,[new_process_place] |
438 | call write_process_memory ;copy parameters to new process address space |
438 | call write_process_memory ;copy parameters to new process address space |
439 | 439 | ||
440 | .no_command_line: |
440 | .no_command_line: |
441 | ;****************************************************************** |
441 | ;****************************************************************** |
442 | mov edx,[app_i_icon] |
442 | mov edx,[app_i_icon] |
443 | test edx,edx |
443 | test edx,edx |
444 | jz .no_command_line_1 ;application don't need path of file |
444 | jz .no_command_line_1 ;application don't need path of file |
445 | mov ebx,[appl_path] |
445 | mov ebx,[appl_path] |
446 | mov ecx,[appl_path_size] |
446 | mov ecx,[appl_path_size] |
447 | mov eax,[new_process_place] |
447 | mov eax,[new_process_place] |
448 | call write_process_memory ;copy path of file to new process address space |
448 | call write_process_memory ;copy path of file to new process address space |
449 | .no_command_line_1: |
449 | .no_command_line_1: |
450 | ;****************************************************************** |
450 | ;****************************************************************** |
451 | mov ebx,[new_process_place] |
451 | mov ebx,[new_process_place] |
452 | mov eax,ebx |
452 | mov eax,ebx |
453 | shl ebx,5 |
453 | shl ebx,5 |
454 | add ebx,0x3000 ;ebx - pointer to information about process |
454 | add ebx,0x3000 ;ebx - pointer to information about process |
455 | mov [ebx+0xe],al ;set window number on screen = process slot |
455 | mov [ebx+0xe],al ;set window number on screen = process slot |
456 | 456 | ||
457 | mov [ebx],dword 1+2+4 ;set default event flags (see 40 function) |
457 | mov [ebx],dword 1+2+4 ;set default event flags (see 40 function) |
458 | 458 | ||
459 | inc dword [process_number] |
459 | inc dword [process_number] |
460 | mov eax,[process_number] |
460 | mov eax,[process_number] |
461 | mov [ebx+4],eax ;set PID |
461 | mov [ebx+4],eax ;set PID |
462 | 462 | ||
463 | mov ecx,ebx |
463 | mov ecx,ebx |
464 | add ecx,draw_data-0x3000 ;ecx - pointer to draw data |
464 | add ecx,draw_data-0x3000 ;ecx - pointer to draw data |
465 | ;set draw data to full screen |
465 | ;set draw data to full screen |
466 | mov [ecx+0],dword 0 |
466 | mov [ecx+0],dword 0 |
467 | mov [ecx+4],dword 0 |
467 | mov [ecx+4],dword 0 |
468 | mov eax,[0xfe00] |
468 | mov eax,[0xfe00] |
469 | mov [ecx+8],eax |
469 | mov [ecx+8],eax |
470 | mov eax,[0xfe04] |
470 | mov eax,[0xfe04] |
471 | mov [ecx+12],eax |
471 | mov [ecx+12],eax |
- | 472 | ;set window state to 'normal' (non-minimized/maximized/rolled-up) state |
|
- | 473 | mov [ecx+WDATA.fl_wstate],WSTATE_NORMAL |
|
472 | ;set cr3 register in TSS of application |
474 | ;set cr3 register in TSS of application |
473 | mov ecx,[new_process_place] |
475 | mov ecx,[new_process_place] |
474 | shl ecx,8 |
476 | shl ecx,8 |
475 | mov eax,[0x800B8+ecx] |
477 | mov eax,[0x800B8+ecx] |
476 | add eax,8+16 ;add flags |
478 | add eax,8+16 ;add flags |
477 | mov [l.cr3],eax |
479 | mov [l.cr3],eax |
478 | 480 | ||
479 | mov eax,[app_start] |
481 | mov eax,[app_start] |
480 | mov [l.eip],eax ;set eip in TSS |
482 | mov [l.eip],eax ;set eip in TSS |
481 | mov eax,[app_esp] |
483 | mov eax,[app_esp] |
482 | mov [l.esp],eax ;set stack in TSS |
484 | mov [l.esp],eax ;set stack in TSS |
483 | 485 | ||
484 | ;gdt |
486 | ;gdt |
485 | ;mov ebx,[new_process_place] |
487 | ;mov ebx,[new_process_place] |
486 | ;shl ebx,3 |
488 | ;shl ebx,3 |
487 | mov ax,app_code ;ax - selector of code segment |
489 | mov ax,app_code ;ax - selector of code segment |
488 | ;add ax,bx |
490 | ;add ax,bx |
489 | mov [l.cs],ax |
491 | mov [l.cs],ax |
490 | mov ax,app_data |
492 | mov ax,app_data |
491 | ;add ax,bx ;ax - selector of data segment |
493 | ;add ax,bx ;ax - selector of data segment |
492 | mov [l.ss],ax |
494 | mov [l.ss],ax |
493 | mov [l.ds],ax |
495 | mov [l.ds],ax |
494 | mov [l.es],ax |
496 | mov [l.es],ax |
495 | mov [l.fs],ax |
497 | mov [l.fs],ax |
496 | mov ax,graph_data ;ax - selector of graphic segment |
498 | mov ax,graph_data ;ax - selector of graphic segment |
497 | mov [l.gs],ax |
499 | mov [l.gs],ax |
498 | mov [l.io],word 128 |
500 | mov [l.io],word 128 |
499 | mov [l.eflags],dword 0x11202 |
501 | mov [l.eflags],dword 0x11202 |
500 | mov [l.ss0],os_data |
502 | mov [l.ss0],os_data |
501 | mov ebx,[new_process_place] |
503 | mov ebx,[new_process_place] |
502 | shl ebx,12 |
504 | shl ebx,12 |
503 | add ebx,sysint_stack_data+4096 |
505 | add ebx,sysint_stack_data+4096 |
504 | mov [l.esp0],ebx |
506 | mov [l.esp0],ebx |
505 | 507 | ||
506 | ;copy tss to it place |
508 | ;copy tss to it place |
507 | mov eax,tss_sceleton |
509 | mov eax,tss_sceleton |
508 | mov ebx,[new_process_place] |
510 | mov ebx,[new_process_place] |
509 | imul ebx,tss_step |
511 | imul ebx,tss_step |
510 | add ebx,tss_data ;ebx - address of application TSS |
512 | add ebx,tss_data ;ebx - address of application TSS |
511 | mov ecx,120 |
513 | mov ecx,120 |
512 | call memmove |
514 | call memmove |
513 | 515 | ||
514 | ;Add IO access table - bit array of permitted ports |
516 | ;Add IO access table - bit array of permitted ports |
515 | or eax,-1 |
517 | or eax,-1 |
516 | mov edi,[new_process_place] |
518 | mov edi,[new_process_place] |
517 | imul edi,tss_step |
519 | imul edi,tss_step |
518 | add edi,tss_data+128 |
520 | add edi,tss_data+128 |
519 | mov ecx,2048 |
521 | mov ecx,2048 |
520 | cld |
522 | cld |
521 | rep stosd ;full access to 2048*8=16384 ports |
523 | rep stosd ;full access to 2048*8=16384 ports |
522 | 524 | ||
523 | mov ecx,ebx ;ecx - address of application TSS |
525 | mov ecx,ebx ;ecx - address of application TSS |
524 | mov edi,[new_process_place] |
526 | mov edi,[new_process_place] |
525 | shl edi,3 |
527 | shl edi,3 |
526 | ;set TSS descriptor |
528 | ;set TSS descriptor |
527 | mov [edi+gdts+tss0+0],word tss_step ;limit (size) |
529 | mov [edi+gdts+tss0+0],word tss_step ;limit (size) |
528 | mov [edi+gdts+tss0+2],cx ;part of offset |
530 | mov [edi+gdts+tss0+2],cx ;part of offset |
529 | mov eax,ecx |
531 | mov eax,ecx |
530 | shr eax,16 |
532 | shr eax,16 |
531 | mov [edi+gdts+tss0+4],al ;part of offset |
533 | mov [edi+gdts+tss0+4],al ;part of offset |
532 | mov [edi+gdts+tss0+7],ah ;part of offset |
534 | mov [edi+gdts+tss0+7],ah ;part of offset |
533 | mov [edi+gdts+tss0+5],word 01010000b*256+11101001b ;system flags |
535 | mov [edi+gdts+tss0+5],word 01010000b*256+11101001b ;system flags |
534 | 536 | ||
535 | 537 | ||
536 | ;flush keyboard and buttons queue |
538 | ;flush keyboard and buttons queue |
537 | mov [0xf400],byte 0 |
539 | mov [0xf400],byte 0 |
538 | mov [0xf500],byte 0 |
540 | mov [0xf500],byte 0 |
539 | 541 | ||
540 | mov edi,[new_process_place] |
542 | mov edi,[new_process_place] |
541 | shl edi,5 |
543 | shl edi,5 |
542 | add edi,window_data |
544 | add edi,window_data |
543 | mov ebx,[new_process_place] |
545 | mov ebx,[new_process_place] |
544 | movzx esi,word [0xC000+ebx*2] |
546 | movzx esi,word [0xC000+ebx*2] |
545 | lea esi,[0xC400+esi*2] |
547 | lea esi,[0xC400+esi*2] |
546 | call windowactivate ;gui initialization |
548 | call windowactivate ;gui initialization |
547 | 549 | ||
548 | mov ebx,[new_process_place] |
550 | mov ebx,[new_process_place] |
549 | shl ebx,5 |
551 | shl ebx,5 |
550 | mov [0x3000+ebx+0xa],byte 0 ;set process state - running |
552 | mov [0x3000+ebx+0xa],byte 0 ;set process state - running |
551 | ; set if debuggee |
553 | ; set if debuggee |
552 | test byte [esp+28], 1 |
554 | test byte [esp+28], 1 |
553 | jz .no_debug |
555 | jz .no_debug |
554 | mov [0x3000+ebx+0xa],byte 1 ;set process state - suspended |
556 | mov [0x3000+ebx+0xa],byte 1 ;set process state - suspended |
555 | mov eax,[0x3000] |
557 | mov eax,[0x3000] |
556 | mov [0x80000+ebx*8+0xac],eax ;set debugger PID - current |
558 | mov [0x80000+ebx*8+0xac],eax ;set debugger PID - current |
557 | .no_debug: |
559 | .no_debug: |
558 | 560 | ||
559 | mov esi,new_process_running |
561 | mov esi,new_process_running |
560 | call sys_msg_board_str ;output information about succefull startup |
562 | call sys_msg_board_str ;output information about succefull startup |
561 | 563 | ||
562 | ; add esp,4 ;pop pointer to parameters |
564 | ; add esp,4 ;pop pointer to parameters |
563 | ; popad |
565 | ; popad |
564 | mov eax,[process_number] ;set result |
566 | mov eax,[process_number] ;set result |
565 | mov [application_table_status],0 ;unlock application_table_status mutex |
567 | mov [application_table_status],0 ;unlock application_table_status mutex |
566 | call safe_sti |
568 | call safe_sti |
567 | ret 4 |
569 | ret 4 |
568 | ;----------------------------------------------------------------------------- |
570 | ;----------------------------------------------------------------------------- |
569 | new_sys_threads: |
571 | new_sys_threads: |
570 | ;eax=1 - create thread |
572 | ;eax=1 - create thread |
571 | ; ebx=thread start |
573 | ; ebx=thread start |
572 | ; ecx=thread stack value |
574 | ; ecx=thread stack value |
573 | ;result: |
575 | ;result: |
574 | ; eax=pid |
576 | ; eax=pid |
575 | xor edx,edx ; flags=0 |
577 | xor edx,edx ; flags=0 |
576 | pushad |
578 | pushad |
577 | 579 | ||
578 | cmp eax,1 |
580 | cmp eax,1 |
579 | jnz .ret ;other subfunctions |
581 | jnz .ret ;other subfunctions |
580 | mov esi,new_process_loading |
582 | mov esi,new_process_loading |
581 | call sys_msg_board_str |
583 | call sys_msg_board_str |
582 | ;lock application_table_status mutex |
584 | ;lock application_table_status mutex |
583 | .table_status: |
585 | .table_status: |
584 | cli |
586 | cli |
585 | cmp [application_table_status],0 |
587 | cmp [application_table_status],0 |
586 | je .stf |
588 | je .stf |
587 | sti |
589 | sti |
588 | call change_task |
590 | call change_task |
589 | jmp .table_status |
591 | jmp .table_status |
590 | .stf: |
592 | .stf: |
591 | call set_application_table_status |
593 | call set_application_table_status |
592 | ;find free process slot |
594 | ;find free process slot |
593 | 595 | ||
594 | call find_new_process_place |
596 | call find_new_process_place |
595 | test eax,eax |
597 | test eax,eax |
596 | jz .failed |
598 | jz .failed |
597 | 599 | ||
598 | ;set parameters for thread |
600 | ;set parameters for thread |
599 | xor eax,eax |
601 | xor eax,eax |
600 | mov [app_i_param],eax |
602 | mov [app_i_param],eax |
601 | mov [app_i_icon],eax |
603 | mov [app_i_icon],eax |
602 | mov [app_start],ebx |
604 | mov [app_start],ebx |
603 | mov [app_esp],ecx |
605 | mov [app_esp],ecx |
604 | 606 | ||
605 | mov esi,[0x3000] |
607 | mov esi,[0x3000] |
606 | shl esi,8 |
608 | shl esi,8 |
607 | add esi,0x80000 |
609 | add esi,0x80000 |
608 | mov ebx,esi ;ebx=esi - pointer to extended information about current thread |
610 | mov ebx,esi ;ebx=esi - pointer to extended information about current thread |
609 | 611 | ||
610 | mov edi,[new_process_place] |
612 | mov edi,[new_process_place] |
611 | shl edi,8 |
613 | shl edi,8 |
612 | add edi,0x80000 |
614 | add edi,0x80000 |
613 | mov edx,edi ;edx=edi - pointer to extended infomation about new thread |
615 | mov edx,edi ;edx=edi - pointer to extended infomation about new thread |
614 | mov ecx,256/4 |
616 | mov ecx,256/4 |
615 | rep stosd ;clean extended information about new thread |
617 | rep stosd ;clean extended information about new thread |
616 | mov edi,edx |
618 | mov edi,edx |
617 | mov ecx,11 |
619 | mov ecx,11 |
618 | rep movsb ;copy process name |
620 | rep movsb ;copy process name |
619 | mov eax,[ebx+0x8c] |
621 | mov eax,[ebx+0x8c] |
620 | mov [app_mem],eax ;set memory size |
622 | mov [app_mem],eax ;set memory size |
621 | mov eax,[ebx+0xb8] |
623 | mov eax,[ebx+0xb8] |
622 | mov [edx+0xb8],eax ;copy page directory |
624 | mov [edx+0xb8],eax ;copy page directory |
623 | ; mov eax,[new_process_place] |
625 | ; mov eax,[new_process_place] |
624 | ; mov ebx,[0x3000] |
626 | ; mov ebx,[0x3000] |
625 | ; call addreference_app_cr3_table |
627 | ; call addreference_app_cr3_table |
626 | 628 | ||
627 | push 0 ;no parameters |
629 | push 0 ;no parameters |
628 | call new_start_application_fl.add_app_parameters ;start thread |
630 | call new_start_application_fl.add_app_parameters ;start thread |
629 | mov [esp+28],eax |
631 | mov [esp+28],eax |
630 | popad |
632 | popad |
631 | ret |
633 | ret |
632 | 634 | ||
633 | .failed: |
635 | .failed: |
634 | sti |
636 | sti |
635 | popad |
637 | popad |
636 | mov eax,-1 |
638 | mov eax,-1 |
637 | ret |
639 | ret |
638 | .ret: |
640 | .ret: |
639 | popad |
641 | popad |
640 | ret |
642 | ret |
641 | ;----------------------------------------------------------------------------- |
643 | ;----------------------------------------------------------------------------- |
642 | new_mem_resize: |
644 | new_mem_resize: |
643 | ;input: |
645 | ;input: |
644 | ; ebx - new size |
646 | ; ebx - new size |
645 | ;result: |
647 | ;result: |
646 | ; [esp+36]:=0 - normal |
648 | ; [esp+36]:=0 - normal |
647 | ; [esp+36]:=1 - error |
649 | ; [esp+36]:=1 - error |
648 | ;This function set new application memory size. |
650 | ;This function set new application memory size. |
649 | mov esi,ebx ;save new size |
651 | mov esi,ebx ;save new size |
650 | add ebx,4095 |
652 | add ebx,4095 |
651 | and ebx,not (4096-1) ;round up size |
653 | and ebx,not (4096-1) ;round up size |
652 | mov ecx,[0x3000] |
654 | mov ecx,[0x3000] |
653 | shl ecx,8 |
655 | shl ecx,8 |
654 | mov edx,[0x8008C+ecx] |
656 | mov edx,[0x8008C+ecx] |
655 | add edx,4095 |
657 | add edx,4095 |
656 | and edx,not (4096-1) ;old size |
658 | and edx,not (4096-1) ;old size |
657 | mov eax,[0x800B8+ecx] |
659 | mov eax,[0x800B8+ecx] |
658 | call MEM_Get_Linear_Address |
660 | call MEM_Get_Linear_Address |
659 | ;eax - linear address of page directory |
661 | ;eax - linear address of page directory |
660 | call MEM_Heap_Lock ;guarantee that two threads willn't |
662 | call MEM_Heap_Lock ;guarantee that two threads willn't |
661 | ;change memory size simultaneously |
663 | ;change memory size simultaneously |
662 | cmp ebx,edx |
664 | cmp ebx,edx |
663 | ; mov esi,ebx ;save new size |
665 | ; mov esi,ebx ;save new size |
664 | jg .expand |
666 | jg .expand |
665 | 667 | ||
666 | .free: |
668 | .free: |
667 | sub edx,ebx |
669 | sub edx,ebx |
668 | jz .unlock ;do nothing |
670 | jz .unlock ;do nothing |
669 | mov ecx,edx |
671 | mov ecx,edx |
670 | shr ecx,12 |
672 | shr ecx,12 |
671 | add ebx,std_application_base_address |
673 | add ebx,std_application_base_address |
672 | call mem_free_specified_region ;free unnecessary pages |
674 | call mem_free_specified_region ;free unnecessary pages |
673 | jmp .unlock |
675 | jmp .unlock |
674 | 676 | ||
675 | .expand: |
677 | .expand: |
676 | sub ebx,edx |
678 | sub ebx,edx |
677 | mov ecx,ebx |
679 | mov ecx,ebx |
678 | shr ecx,12 |
680 | shr ecx,12 |
679 | mov ebx,edx |
681 | mov ebx,edx |
680 | add ebx,std_application_base_address |
682 | add ebx,std_application_base_address |
681 | call mem_alloc_specified_region ;alloc necessary pages |
683 | call mem_alloc_specified_region ;alloc necessary pages |
682 | test eax,eax |
684 | test eax,eax |
683 | jz .failed ;not enough memory |
685 | jz .failed ;not enough memory |
684 | 686 | ||
685 | .unlock: |
687 | .unlock: |
686 | mov ebx,esi |
688 | mov ebx,esi |
687 | mov eax,[0x3000] |
689 | mov eax,[0x3000] |
688 | shl eax,8 |
690 | shl eax,8 |
689 | mov [eax+0x8008c],ebx ;write new memory size |
691 | mov [eax+0x8008c],ebx ;write new memory size |
690 | ;search threads and update |
692 | ;search threads and update |
691 | ;application memory size infomation |
693 | ;application memory size infomation |
692 | mov ecx,[eax+0x800b8] |
694 | mov ecx,[eax+0x800b8] |
693 | mov eax,2 |
695 | mov eax,2 |
694 | 696 | ||
695 | .search_threads: |
697 | .search_threads: |
696 | ;eax = current slot |
698 | ;eax = current slot |
697 | ;ebx = new memory size |
699 | ;ebx = new memory size |
698 | ;ecx = page directory |
700 | ;ecx = page directory |
699 | cmp eax,[0x3004] |
701 | cmp eax,[0x3004] |
700 | jg .search_threads_end |
702 | jg .search_threads_end |
701 | mov edx,eax |
703 | mov edx,eax |
702 | shl edx,5 |
704 | shl edx,5 |
703 | cmp word [0x3000+edx+0xa],9 ;if slot empty? |
705 | cmp word [0x3000+edx+0xa],9 ;if slot empty? |
704 | jz .search_threads_next |
706 | jz .search_threads_next |
705 | shl edx,3 |
707 | shl edx,3 |
706 | cmp [edx+0x800b8],ecx ;if it is our thread? |
708 | cmp [edx+0x800b8],ecx ;if it is our thread? |
707 | jnz .search_threads_next |
709 | jnz .search_threads_next |
708 | mov [edx+0x8008c],ebx ;update memory size |
710 | mov [edx+0x8008c],ebx ;update memory size |
709 | .search_threads_next: |
711 | .search_threads_next: |
710 | inc eax |
712 | inc eax |
711 | jmp .search_threads |
713 | jmp .search_threads |
712 | .search_threads_end: |
714 | .search_threads_end: |
713 | 715 | ||
714 | call MEM_Heap_UnLock |
716 | call MEM_Heap_UnLock |
715 | mov dword [esp+36],0 |
717 | mov dword [esp+36],0 |
716 | ret |
718 | ret |
717 | 719 | ||
718 | .failed: |
720 | .failed: |
719 | call MEM_Heap_UnLock |
721 | call MEM_Heap_UnLock |
720 | mov dword [esp+36],1 |
722 | mov dword [esp+36],1 |
721 | ret |
723 | ret |
722 | ;----------------------------------------------------------------------------- |
724 | ;----------------------------------------------------------------------------- |
723 | pid_to_slot: |
725 | pid_to_slot: |
724 | ;Input: |
726 | ;Input: |
725 | ; eax - pid of process |
727 | ; eax - pid of process |
726 | ;Output: |
728 | ;Output: |
727 | ; eax - slot of process or 0 if process don't exists |
729 | ; eax - slot of process or 0 if process don't exists |
728 | ;Search process by PID. |
730 | ;Search process by PID. |
729 | push ebx |
731 | push ebx |
730 | push ecx |
732 | push ecx |
731 | mov ebx,[0x3004] |
733 | mov ebx,[0x3004] |
732 | shl ebx,5 |
734 | shl ebx,5 |
733 | mov ecx,2*32 |
735 | mov ecx,2*32 |
734 | 736 | ||
735 | .loop: |
737 | .loop: |
736 | ;ecx=offset of current process info entry |
738 | ;ecx=offset of current process info entry |
737 | ;ebx=maximum permitted offset |
739 | ;ebx=maximum permitted offset |
738 | cmp byte [second_base_address+0x3000+ecx+0xa],9 |
740 | cmp byte [second_base_address+0x3000+ecx+0xa],9 |
739 | jz .endloop ;skip empty slots |
741 | jz .endloop ;skip empty slots |
740 | cmp [second_base_address+0x3000+ecx+0x4],eax ;check PID |
742 | cmp [second_base_address+0x3000+ecx+0x4],eax ;check PID |
741 | jz .pid_found |
743 | jz .pid_found |
742 | .endloop: |
744 | .endloop: |
743 | add ecx,32 |
745 | add ecx,32 |
744 | cmp ecx,ebx |
746 | cmp ecx,ebx |
745 | jle .loop |
747 | jle .loop |
746 | 748 | ||
747 | pop ecx |
749 | pop ecx |
748 | pop ebx |
750 | pop ebx |
749 | xor eax,eax |
751 | xor eax,eax |
750 | ret |
752 | ret |
751 | 753 | ||
752 | .pid_found: |
754 | .pid_found: |
753 | shr ecx,5 |
755 | shr ecx,5 |
754 | mov eax,ecx ;convert offset to index of slot |
756 | mov eax,ecx ;convert offset to index of slot |
755 | pop ecx |
757 | pop ecx |
756 | pop ebx |
758 | pop ebx |
757 | ret |
759 | ret |
758 | ;----------------------------------------------------------------------------- |
760 | ;----------------------------------------------------------------------------- |
759 | is_new_process: |
761 | is_new_process: |
760 | ;Input: |
762 | ;Input: |
761 | ; eax - process slot |
763 | ; eax - process slot |
762 | ;Output: |
764 | ;Output: |
763 | ; eax=1 - it is new process |
765 | ; eax=1 - it is new process |
764 | ; eax=0 - it is old process |
766 | ; eax=0 - it is old process |
765 | ; shl eax,5 |
767 | ; shl eax,5 |
766 | ; mov eax,[second_base_address+0x3000+eax+0x10] |
768 | ; mov eax,[second_base_address+0x3000+eax+0x10] |
767 | ; cmp eax,std_application_base_address ;check base address of application |
769 | ; cmp eax,std_application_base_address ;check base address of application |
768 | ; jz .new_process |
770 | ; jz .new_process |
769 | ; xor eax,eax |
771 | ; xor eax,eax |
770 | ; ret |
772 | ; ret |
771 | 773 | ||
772 | ;.new_process: |
774 | ;.new_process: |
773 | mov eax,1 |
775 | mov eax,1 |
774 | ret |
776 | ret |
775 | ;----------------------------------------------------------------------------- |
777 | ;----------------------------------------------------------------------------- |
776 | write_process_memory: |
778 | write_process_memory: |
777 | ;Input: |
779 | ;Input: |
778 | ; eax - process slot |
780 | ; eax - process slot |
779 | ; ebx - buffer address |
781 | ; ebx - buffer address |
780 | ; ecx - buffer size |
782 | ; ecx - buffer size |
781 | ; edx - start address in other process |
783 | ; edx - start address in other process |
782 | ;Output: |
784 | ;Output: |
783 | ; eax - number of bytes written |
785 | ; eax - number of bytes written |
784 | pushad |
786 | pushad |
785 | shl eax,8 |
787 | shl eax,8 |
786 | mov eax,[0x80000+eax+0xB8] |
788 | mov eax,[0x80000+eax+0xB8] |
787 | call MEM_Get_Linear_Address |
789 | call MEM_Get_Linear_Address |
788 | mov ebp,eax |
790 | mov ebp,eax |
789 | ;ebp=linear address of page directory of other process. |
791 | ;ebp=linear address of page directory of other process. |
790 | add edx,std_application_base_address ;convert to linear address |
792 | add edx,std_application_base_address ;convert to linear address |
791 | test ecx,ecx |
793 | test ecx,ecx |
792 | jle .ret |
794 | jle .ret |
793 | 795 | ||
794 | .write_loop: |
796 | .write_loop: |
795 | ;ebx = current buffer address |
797 | ;ebx = current buffer address |
796 | ;ecx>0 = current size |
798 | ;ecx>0 = current size |
797 | ;edx = current address in other process |
799 | ;edx = current address in other process |
798 | ;ebp = linear address of page directory |
800 | ;ebp = linear address of page directory |
799 | 801 | ||
800 | call MEM_Heap_Lock ;cli |
802 | call MEM_Heap_Lock ;cli |
801 | mov esi,edx |
803 | mov esi,edx |
802 | shr esi,22 |
804 | shr esi,22 |
803 | mov eax,[ebp+4*esi] ;find page directory entry |
805 | mov eax,[ebp+4*esi] ;find page directory entry |
804 | and eax,not (4096-1) ;clear flags |
806 | and eax,not (4096-1) ;clear flags |
805 | test eax,eax |
807 | test eax,eax |
806 | jz .page_not_found |
808 | jz .page_not_found |
807 | call MEM_Get_Linear_Address ;calculate linear address of page table |
809 | call MEM_Get_Linear_Address ;calculate linear address of page table |
808 | test eax,eax |
810 | test eax,eax |
809 | jz .page_not_found |
811 | jz .page_not_found |
810 | mov esi,edx |
812 | mov esi,edx |
811 | shr esi,12 |
813 | shr esi,12 |
812 | and esi,1023 |
814 | and esi,1023 |
813 | mov eax,[eax+4*esi] ;find page table entry |
815 | mov eax,[eax+4*esi] ;find page table entry |
814 | and eax,not (4096-1) |
816 | and eax,not (4096-1) |
815 | test eax,eax |
817 | test eax,eax |
816 | jz .page_not_found |
818 | jz .page_not_found |
817 | call MEM_Get_Linear_Address ;calculate linear address of page |
819 | call MEM_Get_Linear_Address ;calculate linear address of page |
818 | test eax,eax |
820 | test eax,eax |
819 | jz .page_not_found |
821 | jz .page_not_found |
820 | mov edi,eax |
822 | mov edi,eax |
821 | call MEM_Add_Reference_Linear;guarantee that page willn't disappear |
823 | call MEM_Add_Reference_Linear;guarantee that page willn't disappear |
822 | call MEM_Heap_UnLock ;sti |
824 | call MEM_Heap_UnLock ;sti |
823 | 825 | ||
824 | mov esi,edx |
826 | mov esi,edx |
825 | and esi,4095 |
827 | and esi,4095 |
826 | add edi,esi ;add offset in page |
828 | add edi,esi ;add offset in page |
827 | ;edi = linear address corresponding edx in other process |
829 | ;edi = linear address corresponding edx in other process |
828 | sub esi,4096 |
830 | sub esi,4096 |
829 | neg esi ;esi - number of remaining bytes in page |
831 | neg esi ;esi - number of remaining bytes in page |
830 | cmp esi,ecx |
832 | cmp esi,ecx |
831 | jl .min_ecx |
833 | jl .min_ecx |
832 | mov esi,ecx |
834 | mov esi,ecx |
833 | .min_ecx: ;esi=min(ecx,esi) - number of bytes to write |
835 | .min_ecx: ;esi=min(ecx,esi) - number of bytes to write |
834 | sub ecx,esi |
836 | sub ecx,esi |
835 | push ecx |
837 | push ecx |
836 | mov ecx,esi ;ecx - number of bytes to write |
838 | mov ecx,esi ;ecx - number of bytes to write |
837 | mov esi,ebx ;esi - source, edi - destination |
839 | mov esi,ebx ;esi - source, edi - destination |
838 | add edx,ecx ;move pointer in address space of other process |
840 | add edx,ecx ;move pointer in address space of other process |
839 | push edi |
841 | push edi |
840 | 842 | ||
841 | ;move ecx bytes |
843 | ;move ecx bytes |
842 | test ecx,3 |
844 | test ecx,3 |
843 | jnz .not_aligned |
845 | jnz .not_aligned |
844 | shr ecx,2 |
846 | shr ecx,2 |
845 | rep movsd |
847 | rep movsd |
846 | jmp .next_iter |
848 | jmp .next_iter |
847 | .not_aligned: |
849 | .not_aligned: |
848 | rep movsb |
850 | rep movsb |
849 | .next_iter: |
851 | .next_iter: |
850 | 852 | ||
851 | pop eax |
853 | pop eax |
852 | and eax,not (4096-1) ;eax - linear address of current page |
854 | and eax,not (4096-1) ;eax - linear address of current page |
853 | call MEM_Free_Page_Linear ;free reference |
855 | call MEM_Free_Page_Linear ;free reference |
854 | mov ebx,esi ;new pointer to buffer - movsb automaticaly advance it. |
856 | mov ebx,esi ;new pointer to buffer - movsb automaticaly advance it. |
855 | pop ecx ;restore number of remaining bytes |
857 | pop ecx ;restore number of remaining bytes |
856 | test ecx,ecx |
858 | test ecx,ecx |
857 | jnz .write_loop |
859 | jnz .write_loop |
858 | .ret: |
860 | .ret: |
859 | popad |
861 | popad |
860 | mov eax,ecx |
862 | mov eax,ecx |
861 | ret |
863 | ret |
862 | 864 | ||
863 | .page_not_found: |
865 | .page_not_found: |
864 | call MEM_Heap_UnLock ;error has appeared in critical region |
866 | call MEM_Heap_UnLock ;error has appeared in critical region |
865 | sub ecx,[esp+24] ;[esp+24]<-->ecx |
867 | sub ecx,[esp+24] ;[esp+24]<-->ecx |
866 | neg ecx ;ecx=number_of_written_bytes |
868 | neg ecx ;ecx=number_of_written_bytes |
867 | mov [esp+28],ecx ;[esp+28]<-->eax |
869 | mov [esp+28],ecx ;[esp+28]<-->eax |
868 | popad |
870 | popad |
869 | ret |
871 | ret |
870 | ;----------------------------------------------------------------------------- |
872 | ;----------------------------------------------------------------------------- |
871 | syscall_test: |
873 | syscall_test: |
872 | ;for testing memory manager from applications. |
874 | ;for testing memory manager from applications. |
873 | mov edx,ecx |
875 | mov edx,ecx |
874 | mov ecx,ebx |
876 | mov ecx,ebx |
875 | call trans_address |
877 | call trans_address |
876 | mov ebx,eax |
878 | mov ebx,eax |
877 | mov eax,[0x3000] |
879 | mov eax,[0x3000] |
878 | call read_process_memory |
880 | call read_process_memory |
879 | ret |
881 | ret |
880 | ;----------------------------------------------------------------------------- |
882 | ;----------------------------------------------------------------------------- |
881 | read_process_memory: |
883 | read_process_memory: |
882 | ;Input: |
884 | ;Input: |
883 | ; eax - process slot |
885 | ; eax - process slot |
884 | ; ebx - buffer address |
886 | ; ebx - buffer address |
885 | ; ecx - buffer size |
887 | ; ecx - buffer size |
886 | ; edx - start address in other process |
888 | ; edx - start address in other process |
887 | ;Output: |
889 | ;Output: |
888 | ; eax - number of bytes read. |
890 | ; eax - number of bytes read. |
889 | pushad |
891 | pushad |
890 | shl eax,8 |
892 | shl eax,8 |
891 | mov eax,[0x80000+eax+0xB8] |
893 | mov eax,[0x80000+eax+0xB8] |
892 | call MEM_Get_Linear_Address |
894 | call MEM_Get_Linear_Address |
893 | mov ebp,eax |
895 | mov ebp,eax |
894 | add edx,std_application_base_address |
896 | add edx,std_application_base_address |
895 | .read_loop: |
897 | .read_loop: |
896 | ;ebx = current buffer address |
898 | ;ebx = current buffer address |
897 | ;ecx>0 = current size |
899 | ;ecx>0 = current size |
898 | ;edx = current address in other process |
900 | ;edx = current address in other process |
899 | ;ebp = linear address of page directory |
901 | ;ebp = linear address of page directory |
900 | 902 | ||
901 | call MEM_Heap_Lock ;cli |
903 | call MEM_Heap_Lock ;cli |
902 | mov esi,edx |
904 | mov esi,edx |
903 | shr esi,22 |
905 | shr esi,22 |
904 | mov eax,[ebp+4*esi] ;find page directory entry |
906 | mov eax,[ebp+4*esi] ;find page directory entry |
905 | and eax,not (4096-1) |
907 | and eax,not (4096-1) |
906 | test eax,eax |
908 | test eax,eax |
907 | jz .page_not_found |
909 | jz .page_not_found |
908 | call MEM_Get_Linear_Address |
910 | call MEM_Get_Linear_Address |
909 | test eax,eax |
911 | test eax,eax |
910 | jz .page_not_found |
912 | jz .page_not_found |
911 | mov esi,edx |
913 | mov esi,edx |
912 | shr esi,12 |
914 | shr esi,12 |
913 | and esi,1023 |
915 | and esi,1023 |
914 | mov eax,[eax+4*esi] ;find page table entry |
916 | mov eax,[eax+4*esi] ;find page table entry |
915 | and eax,not (4096-1) |
917 | and eax,not (4096-1) |
916 | test eax,eax |
918 | test eax,eax |
917 | jz .page_not_found |
919 | jz .page_not_found |
918 | call MEM_Get_Linear_Address ;calculate linear address of page |
920 | call MEM_Get_Linear_Address ;calculate linear address of page |
919 | test eax,eax |
921 | test eax,eax |
920 | jz .page_not_found |
922 | jz .page_not_found |
921 | mov esi,eax |
923 | mov esi,eax |
922 | call MEM_Add_Reference_Linear;guarantee that page willn't disappear |
924 | call MEM_Add_Reference_Linear;guarantee that page willn't disappear |
923 | call MEM_Heap_UnLock ;sti |
925 | call MEM_Heap_UnLock ;sti |
924 | 926 | ||
925 | mov edi,edx |
927 | mov edi,edx |
926 | and edi,4095 |
928 | and edi,4095 |
927 | add esi,edi ;add offset in page |
929 | add esi,edi ;add offset in page |
928 | ;esi = linear address corresponding edx in other process |
930 | ;esi = linear address corresponding edx in other process |
929 | sub edi,4096 |
931 | sub edi,4096 |
930 | neg edi |
932 | neg edi |
931 | 933 | ||
932 | ;edi=min(edi,ecx) - number of bytes to copy |
934 | ;edi=min(edi,ecx) - number of bytes to copy |
933 | cmp edi,ecx |
935 | cmp edi,ecx |
934 | jl .min_ecx |
936 | jl .min_ecx |
935 | mov edi,ecx |
937 | mov edi,ecx |
936 | .min_ecx: |
938 | .min_ecx: |
937 | 939 | ||
938 | sub ecx,edi ;update size of remaining bytes |
940 | sub ecx,edi ;update size of remaining bytes |
939 | add edx,edi ;update current pointer in other address space. |
941 | add edx,edi ;update current pointer in other address space. |
940 | push ecx |
942 | push ecx |
941 | mov ecx,edi ;ecx - number of bytes to read |
943 | mov ecx,edi ;ecx - number of bytes to read |
942 | mov edi,ebx ;esi - source, edi - destination |
944 | mov edi,ebx ;esi - source, edi - destination |
943 | push esi |
945 | push esi |
944 | ;move ecx bytes |
946 | ;move ecx bytes |
945 | test ecx,3 |
947 | test ecx,3 |
946 | jnz .not_aligned |
948 | jnz .not_aligned |
947 | shr ecx,2 |
949 | shr ecx,2 |
948 | rep movsd |
950 | rep movsd |
949 | jmp .next_iter |
951 | jmp .next_iter |
950 | .not_aligned: |
952 | .not_aligned: |
951 | rep movsb |
953 | rep movsb |
952 | .next_iter: |
954 | .next_iter: |
953 | pop eax |
955 | pop eax |
954 | and eax,not (4096-1) ;eax - linear address of current page |
956 | and eax,not (4096-1) ;eax - linear address of current page |
955 | call MEM_Free_Page_Linear ;free reference |
957 | call MEM_Free_Page_Linear ;free reference |
956 | mov ebx,edi ;new pointer to buffer - movsb automaticaly advance it. |
958 | mov ebx,edi ;new pointer to buffer - movsb automaticaly advance it. |
957 | pop ecx ;restore number of remaining bytes |
959 | pop ecx ;restore number of remaining bytes |
958 | test ecx,ecx |
960 | test ecx,ecx |
959 | jnz .read_loop |
961 | jnz .read_loop |
960 | 962 | ||
961 | popad |
963 | popad |
962 | mov eax,ecx |
964 | mov eax,ecx |
963 | ret |
965 | ret |
964 | 966 | ||
965 | .page_not_found: |
967 | .page_not_found: |
966 | call MEM_Heap_UnLock ;error has appeared in critical region |
968 | call MEM_Heap_UnLock ;error has appeared in critical region |
967 | sub ecx,[esp+24] ;[esp+24]<-->ecx |
969 | sub ecx,[esp+24] ;[esp+24]<-->ecx |
968 | neg ecx ;ecx=number_of_read_bytes |
970 | neg ecx ;ecx=number_of_read_bytes |
969 | mov [esp+28],ecx ;[esp+28]<-->eax |
971 | mov [esp+28],ecx ;[esp+28]<-->eax |
970 | popad |
972 | popad |
971 | ret |
973 | ret |
972 | ;----------------------------------------------------------------------------- |
974 | ;----------------------------------------------------------------------------- |
973 | check_region: |
975 | check_region: |
974 | ;input: |
976 | ;input: |
975 | ; ebx - start of buffer |
977 | ; ebx - start of buffer |
976 | ; ecx - size of buffer |
978 | ; ecx - size of buffer |
977 | ;result: |
979 | ;result: |
978 | ; eax = 1 region lays in app memory |
980 | ; eax = 1 region lays in app memory |
979 | ; eax = 0 region don't lays in app memory |
981 | ; eax = 0 region don't lays in app memory |
980 | mov eax,[0x3000] |
982 | mov eax,[0x3000] |
981 | jmp check_process_region |
983 | jmp check_process_region |
982 | ;----------------------------------------------------------------------------- |
984 | ;----------------------------------------------------------------------------- |
983 | check_process_region: |
985 | check_process_region: |
984 | ;input: |
986 | ;input: |
985 | ; eax - slot |
987 | ; eax - slot |
986 | ; ebx - start of buffer |
988 | ; ebx - start of buffer |
987 | ; ecx - size of buffer |
989 | ; ecx - size of buffer |
988 | ;result: |
990 | ;result: |
989 | ; eax = 1 region lays in app memory |
991 | ; eax = 1 region lays in app memory |
990 | ; eax = 0 region don't lays in app memory |
992 | ; eax = 0 region don't lays in app memory |
991 | test ecx,ecx |
993 | test ecx,ecx |
992 | jle .ok |
994 | jle .ok |
993 | shl eax,5 |
995 | shl eax,5 |
994 | cmp word [0x3000+eax+0xa],0 |
996 | cmp word [0x3000+eax+0xa],0 |
995 | jnz .failed |
997 | jnz .failed |
996 | shl eax,3 |
998 | shl eax,3 |
997 | mov eax,[0x80000+eax+0xb8] |
999 | mov eax,[0x80000+eax+0xb8] |
998 | test eax,eax |
1000 | test eax,eax |
999 | jz .failed |
1001 | jz .failed |
1000 | call MEM_Get_Linear_Address |
1002 | call MEM_Get_Linear_Address |
1001 | push ebx |
1003 | push ebx |
1002 | push ecx |
1004 | push ecx |
1003 | push edx |
1005 | push edx |
1004 | mov edx,ebx |
1006 | mov edx,ebx |
1005 | and edx,not (4096-1) |
1007 | and edx,not (4096-1) |
1006 | sub ebx,edx |
1008 | sub ebx,edx |
1007 | add ecx,ebx |
1009 | add ecx,ebx |
1008 | mov ebx,edx |
1010 | mov ebx,edx |
1009 | add ecx,(4096-1) |
1011 | add ecx,(4096-1) |
1010 | and ecx,not (4096-1) |
1012 | and ecx,not (4096-1) |
1011 | .loop: |
1013 | .loop: |
1012 | ;eax - linear address of page directory |
1014 | ;eax - linear address of page directory |
1013 | ;ebx - current page |
1015 | ;ebx - current page |
1014 | ;ecx - current size |
1016 | ;ecx - current size |
1015 | mov edx,ebx |
1017 | mov edx,ebx |
1016 | shr edx,22 |
1018 | shr edx,22 |
1017 | mov edx,[eax+4*edx] |
1019 | mov edx,[eax+4*edx] |
1018 | and edx,not (4096-1) |
1020 | and edx,not (4096-1) |
1019 | test edx,edx |
1021 | test edx,edx |
1020 | jz .failed1 |
1022 | jz .failed1 |
1021 | push eax |
1023 | push eax |
1022 | mov eax,edx |
1024 | mov eax,edx |
1023 | call MEM_Get_Linear_Address |
1025 | call MEM_Get_Linear_Address |
1024 | mov edx,ebx |
1026 | mov edx,ebx |
1025 | shr edx,12 |
1027 | shr edx,12 |
1026 | and edx,(1024-1) |
1028 | and edx,(1024-1) |
1027 | mov eax,[eax+4*edx] |
1029 | mov eax,[eax+4*edx] |
1028 | and eax,not (4096-1) |
1030 | and eax,not (4096-1) |
1029 | test eax,eax |
1031 | test eax,eax |
1030 | pop eax |
1032 | pop eax |
1031 | jz .failed1 |
1033 | jz .failed1 |
1032 | add ebx,4096 |
1034 | add ebx,4096 |
1033 | sub ecx,4096 |
1035 | sub ecx,4096 |
1034 | jg .loop |
1036 | jg .loop |
1035 | pop edx |
1037 | pop edx |
1036 | pop ecx |
1038 | pop ecx |
1037 | pop ebx |
1039 | pop ebx |
1038 | .ok: |
1040 | .ok: |
1039 | mov eax,1 |
1041 | mov eax,1 |
1040 | ret |
1042 | ret |
1041 | 1043 | ||
1042 | .failed1: |
1044 | .failed1: |
1043 | pop edx |
1045 | pop edx |
1044 | pop ecx |
1046 | pop ecx |
1045 | pop ebx |
1047 | pop ebx |
1046 | .failed: |
1048 | .failed: |
1047 | xor eax,eax |
1049 | xor eax,eax |
1048 | ret |
1050 | ret |
1049 | ;----------------------------------------------------------------------------- |
1051 | ;----------------------------------------------------------------------------- |
1050 | new_sys_ipc: |
1052 | new_sys_ipc: |
1051 | ;input: |
1053 | ;input: |
1052 | ; eax=1 - set ipc buffer area |
1054 | ; eax=1 - set ipc buffer area |
1053 | ; ebx=address of buffer |
1055 | ; ebx=address of buffer |
1054 | ; ecx=size of buffer |
1056 | ; ecx=size of buffer |
1055 | ; eax=2 - send message |
1057 | ; eax=2 - send message |
1056 | ; ebx=PID |
1058 | ; ebx=PID |
1057 | ; ecx=address of message |
1059 | ; ecx=address of message |
1058 | ; edx=size of message |
1060 | ; edx=size of message |
1059 | cmp eax,1 |
1061 | cmp eax,1 |
1060 | jnz .no_ipc_def |
1062 | jnz .no_ipc_def |
1061 | ;set ipc buffer area |
1063 | ;set ipc buffer area |
1062 | mov edi,[0x3000] |
1064 | mov edi,[0x3000] |
1063 | shl edi,8 |
1065 | shl edi,8 |
1064 | add edi,0x80000 |
1066 | add edi,0x80000 |
1065 | cli |
1067 | cli |
1066 | mov [edi+0xA0],ebx ;set fields in extended information area |
1068 | mov [edi+0xA0],ebx ;set fields in extended information area |
1067 | mov [edi+0xA4],ecx |
1069 | mov [edi+0xA4],ecx |
1068 | sti |
1070 | sti |
1069 | mov [esp+36],dword 0 ;success |
1071 | mov [esp+36],dword 0 ;success |
1070 | ret |
1072 | ret |
1071 | 1073 | ||
1072 | .no_ipc_def: |
1074 | .no_ipc_def: |
1073 | cmp eax,2 |
1075 | cmp eax,2 |
1074 | jnz .no_ipc_send |
1076 | jnz .no_ipc_send |
1075 | ;send message |
1077 | ;send message |
1076 | cli |
1078 | cli |
1077 | ;obtain slot from PID |
1079 | ;obtain slot from PID |
1078 | mov eax,ebx |
1080 | mov eax,ebx |
1079 | call pid_to_slot |
1081 | call pid_to_slot |
1080 | test eax,eax |
1082 | test eax,eax |
1081 | jz .no_pid |
1083 | jz .no_pid |
1082 | mov ebp,eax |
1084 | mov ebp,eax |
1083 | ;ebp = slot of other process |
1085 | ;ebp = slot of other process |
1084 | shl eax,8 |
1086 | shl eax,8 |
1085 | mov edi,[eax+0x80000+0xa0] ;is ipc area defined? |
1087 | mov edi,[eax+0x80000+0xa0] ;is ipc area defined? |
1086 | test edi,edi |
1088 | test edi,edi |
1087 | jz .no_ipc_area |
1089 | jz .no_ipc_area |
1088 | mov esi,[eax+0x80000+0xa4] ;esi - size of buffer |
1090 | mov esi,[eax+0x80000+0xa4] ;esi - size of buffer |
1089 | push dword -1 ;temp variable for read_process_memory |
1091 | push dword -1 ;temp variable for read_process_memory |
1090 | mov ebx,esp |
1092 | mov ebx,esp |
1091 | push ecx |
1093 | push ecx |
1092 | push edx |
1094 | push edx |
1093 | mov ecx,4 ;read 4 bytes |
1095 | mov ecx,4 ;read 4 bytes |
1094 | mov eax,ebp |
1096 | mov eax,ebp |
1095 | mov edx,edi ;from beginning of buffer. |
1097 | mov edx,edi ;from beginning of buffer. |
1096 | call read_process_memory |
1098 | call read_process_memory |
1097 | mov eax,[esp+8] |
1099 | mov eax,[esp+8] |
1098 | test eax,eax |
1100 | test eax,eax |
1099 | jnz .ipc_blocked ;if dword [buffer]<>0 - ipc blocked now |
1101 | jnz .ipc_blocked ;if dword [buffer]<>0 - ipc blocked now |
1100 | add edx,4 ;move to next 4 bytes |
1102 | add edx,4 ;move to next 4 bytes |
1101 | mov eax,ebp |
1103 | mov eax,ebp |
1102 | call read_process_memory ;read size of occupied space in buffer |
1104 | call read_process_memory ;read size of occupied space in buffer |
1103 | sub esi,8 |
1105 | sub esi,8 |
1104 | sub esi,[esp] |
1106 | sub esi,[esp] |
1105 | sub esi,[esp+8] ;esi=(buffer size)-(occupied size)-(message size)-(header of message size) |
1107 | sub esi,[esp+8] ;esi=(buffer size)-(occupied size)-(message size)-(header of message size) |
1106 | js .buffer_overflow ;esi<0 - not enough memory in buffer |
1108 | js .buffer_overflow ;esi<0 - not enough memory in buffer |
1107 | mov esi,[esp+8] ;previous offset |
1109 | mov esi,[esp+8] ;previous offset |
1108 | add dword [esp+8],8 |
1110 | add dword [esp+8],8 |
1109 | mov edi,[esp] |
1111 | mov edi,[esp] |
1110 | add [esp+8],edi ;add (size of message)+(size of header of message) to [buffer+4] |
1112 | add [esp+8],edi ;add (size of message)+(size of header of message) to [buffer+4] |
1111 | mov eax,ebp |
1113 | mov eax,ebp |
1112 | call write_process_memory |
1114 | call write_process_memory |
1113 | add edx,esi |
1115 | add edx,esi |
1114 | sub edx,4 ;move to beginning of place for our message |
1116 | sub edx,4 ;move to beginning of place for our message |
1115 | mov eax,[second_base_address+0x3010] |
1117 | mov eax,[second_base_address+0x3010] |
1116 | mov eax,[eax+0x4] ;eax - our PID |
1118 | mov eax,[eax+0x4] ;eax - our PID |
1117 | mov [esp+8],eax |
1119 | mov [esp+8],eax |
1118 | mov eax,ebp |
1120 | mov eax,ebp |
1119 | call write_process_memory ;write PID |
1121 | call write_process_memory ;write PID |
1120 | mov ebx,esp ;address of size of message |
1122 | mov ebx,esp ;address of size of message |
1121 | mov eax,ebp |
1123 | mov eax,ebp |
1122 | add edx,4 |
1124 | add edx,4 |
1123 | call write_process_memory ;write size of message |
1125 | call write_process_memory ;write size of message |
1124 | add edx,4 |
1126 | add edx,4 |
1125 | pop ecx ;ecx - size of message |
1127 | pop ecx ;ecx - size of message |
1126 | pop eax |
1128 | pop eax |
1127 | call trans_address |
1129 | call trans_address |
1128 | mov ebx,eax ;ebx - linear address of message |
1130 | mov ebx,eax ;ebx - linear address of message |
1129 | add esp,4 ;pop temporary variable |
1131 | add esp,4 ;pop temporary variable |
1130 | mov eax,ebp |
1132 | mov eax,ebp |
1131 | call write_process_memory ;write message |
1133 | call write_process_memory ;write message |
1132 | sti |
1134 | sti |
1133 | ;awake other process |
1135 | ;awake other process |
1134 | shl ebp,8 |
1136 | shl ebp,8 |
1135 | mov eax,ebp |
1137 | mov eax,ebp |
1136 | or [eax+0x800A8],dword 0x40 |
1138 | or [eax+0x800A8],dword 0x40 |
1137 | 1139 | ||
1138 | cmp dword [check_idle_semaphore],20 |
1140 | cmp dword [check_idle_semaphore],20 |
1139 | jge .ipc_no_cis |
1141 | jge .ipc_no_cis |
1140 | mov dword [check_idle_semaphore],5 |
1142 | mov dword [check_idle_semaphore],5 |
1141 | .ipc_no_cis: |
1143 | .ipc_no_cis: |
1142 | mov dword [esp+36],0 |
1144 | mov dword [esp+36],0 |
1143 | ret |
1145 | ret |
1144 | .no_ipc_send: |
1146 | .no_ipc_send: |
1145 | mov dword [esp+36],-1 |
1147 | mov dword [esp+36],-1 |
1146 | ret |
1148 | ret |
1147 | .no_pid: |
1149 | .no_pid: |
1148 | sti |
1150 | sti |
1149 | mov dword [esp+36],4 |
1151 | mov dword [esp+36],4 |
1150 | ret |
1152 | ret |
1151 | .no_ipc_area: |
1153 | .no_ipc_area: |
1152 | sti |
1154 | sti |
1153 | mov dword [esp+36],1 |
1155 | mov dword [esp+36],1 |
1154 | ret |
1156 | ret |
1155 | .ipc_blocked: |
1157 | .ipc_blocked: |
1156 | sti |
1158 | sti |
1157 | add esp,12 |
1159 | add esp,12 |
1158 | mov dword [esp+36],2 |
1160 | mov dword [esp+36],2 |
1159 | ret |
1161 | ret |
1160 | .buffer_overflow: |
1162 | .buffer_overflow: |
1161 | sti |
1163 | sti |
1162 | add esp,12 |
1164 | add esp,12 |
1163 | mov dword [esp+36],3 |
1165 | mov dword [esp+36],3 |
1164 | ret |
1166 | ret |
1165 | ;----------------------------------------------------------------------------- |
1167 | ;----------------------------------------------------------------------------- |
1166 | trans_address: |
1168 | trans_address: |
1167 | ;Input |
1169 | ;Input |
1168 | ; eax - application address |
1170 | ; eax - application address |
1169 | ;Output |
1171 | ;Output |
1170 | ; eax - linear address for kernel |
1172 | ; eax - linear address for kernel |
1171 | add eax,std_application_base_address |
1173 | add eax,std_application_base_address |
1172 | ret |
1174 | ret |
1173 | ;----------------------------------------------------------------------------- |
1175 | ;----------------------------------------------------------------------------- |
1174 | new_start_application_hd: |
1176 | new_start_application_hd: |
1175 | ;eax - file name (kernel address) |
1177 | ;eax - file name (kernel address) |
1176 | ;ebx - file name length |
1178 | ;ebx - file name length |
1177 | ;ecx - work area (kernel address) |
1179 | ;ecx - work area (kernel address) |
1178 | ;edx - flags |
1180 | ;edx - flags |
1179 | ;ebp - parameters |
1181 | ;ebp - parameters |
1180 | mov [appl_path],edi |
1182 | mov [appl_path],edi |
1181 | pushad |
1183 | pushad |
1182 | 1184 | ||
1183 | mov esi,new_process_loading |
1185 | mov esi,new_process_loading |
1184 | call sys_msg_board_str ;write message to message board |
1186 | call sys_msg_board_str ;write message to message board |
1185 | 1187 | ||
1186 | ;lock application_table_status mutex |
1188 | ;lock application_table_status mutex |
1187 | .table_status: |
1189 | .table_status: |
1188 | cli |
1190 | cli |
1189 | cmp [application_table_status],0 |
1191 | cmp [application_table_status],0 |
1190 | jz .stf |
1192 | jz .stf |
1191 | sti |
1193 | sti |
1192 | call change_task |
1194 | call change_task |
1193 | jmp .table_status |
1195 | jmp .table_status |
1194 | .stf: |
1196 | .stf: |
1195 | call set_application_table_status |
1197 | call set_application_table_status |
1196 | 1198 | ||
1197 | push ebp |
1199 | push ebp |
1198 | push ebx |
1200 | push ebx |
1199 | push eax |
1201 | push eax |
1200 | push ecx |
1202 | push ecx |
1201 | call find_new_process_place ;find new process slot |
1203 | call find_new_process_place ;find new process slot |
1202 | sti |
1204 | sti |
1203 | test eax,eax |
1205 | test eax,eax |
1204 | jz .failed |
1206 | jz .failed |
1205 | 1207 | ||
1206 | ;write application name |
1208 | ;write application name |
1207 | xor eax,eax |
1209 | xor eax,eax |
1208 | mov [appl_path_size],eax |
1210 | mov [appl_path_size],eax |
1209 | mov eax,[esp+4] |
1211 | mov eax,[esp+4] |
1210 | .find_last_byte: |
1212 | .find_last_byte: |
1211 | cmp byte [eax],0 |
1213 | cmp byte [eax],0 |
1212 | jz .find_last_byte_end |
1214 | jz .find_last_byte_end |
1213 | inc eax |
1215 | inc eax |
1214 | inc [appl_path_size] |
1216 | inc [appl_path_size] |
1215 | jmp .find_last_byte |
1217 | jmp .find_last_byte |
1216 | .find_last_byte_end: |
1218 | .find_last_byte_end: |
1217 | add [appl_path_size],24 |
1219 | add [appl_path_size],24 |
1218 | lea esi,[eax-11] ;last 11 bytes = application name |
1220 | lea esi,[eax-11] ;last 11 bytes = application name |
1219 | mov edi,[new_process_place] |
1221 | mov edi,[new_process_place] |
1220 | shl edi,8 |
1222 | shl edi,8 |
1221 | add edi,0x80000 |
1223 | add edi,0x80000 |
1222 | mov ecx,11 |
1224 | mov ecx,11 |
1223 | cld |
1225 | cld |
1224 | rep movsb ;copy name to extended information about process |
1226 | rep movsb ;copy name to extended information about process |
1225 | 1227 | ||
1226 | ;read header |
1228 | ;read header |
1227 | mov eax,[esp+4] ;file name |
1229 | mov eax,[esp+4] ;file name |
1228 | mov esi,[esp] ;work area |
1230 | mov esi,[esp] ;work area |
1229 | mov ecx,1 ;read from first block |
1231 | mov ecx,1 ;read from first block |
1230 | mov edx,1 ;read 1 block |
1232 | mov edx,1 ;read 1 block |
1231 | call read_hd_file |
1233 | call read_hd_file |
1232 | test eax,eax |
1234 | test eax,eax |
1233 | jnz .cleanfailed |
1235 | jnz .cleanfailed |
1234 | 1236 | ||
1235 | mov esi,[esp] |
1237 | mov esi,[esp] |
1236 | ;check menuet signature |
1238 | ;check menuet signature |
1237 | cmp [esi+1024+0],dword 'MENU' ;read_hd_file function write file to +1024 offset |
1239 | cmp [esi+1024+0],dword 'MENU' ;read_hd_file function write file to +1024 offset |
1238 | jnz .cleanfailed |
1240 | jnz .cleanfailed |
1239 | cmp [esi+1024+4],word 'ET' |
1241 | cmp [esi+1024+4],word 'ET' |
1240 | jnz .cleanfailed |
1242 | jnz .cleanfailed |
1241 | add esi,1024 |
1243 | add esi,1024 |
1242 | mov edi,0x90000 |
1244 | mov edi,0x90000 |
1243 | mov ecx,512/4 |
1245 | mov ecx,512/4 |
1244 | cld |
1246 | cld |
1245 | rep movsd ;copy first block to 0x90000 address for get_app_params function |
1247 | rep movsd ;copy first block to 0x90000 address for get_app_params function |
1246 | call get_app_params |
1248 | call get_app_params |
1247 | test esi,esi |
1249 | test esi,esi |
1248 | jz .cleanfailed |
1250 | jz .cleanfailed |
1249 | 1251 | ||
1250 | mov eax,[new_process_place] |
1252 | mov eax,[new_process_place] |
1251 | call create_app_cr3_table ;create page directory |
1253 | call create_app_cr3_table ;create page directory |
1252 | test eax,eax |
1254 | test eax,eax |
1253 | jz .cleanfailed_mem |
1255 | jz .cleanfailed_mem |
1254 | 1256 | ||
1255 | call MEM_Get_Linear_Address |
1257 | call MEM_Get_Linear_Address |
1256 | 1258 | ||
1257 | mov ebx,std_application_base_address |
1259 | mov ebx,std_application_base_address |
1258 | mov ecx,[app_mem] |
1260 | mov ecx,[app_mem] |
1259 | add ecx,4096-1 |
1261 | add ecx,4096-1 |
1260 | shr ecx,12 |
1262 | shr ecx,12 |
1261 | mov edx,eax ;edx - linear address of page directory |
1263 | mov edx,eax ;edx - linear address of page directory |
1262 | call mem_alloc_specified_region ;allocate memory for application |
1264 | call mem_alloc_specified_region ;allocate memory for application |
1263 | test eax,eax |
1265 | test eax,eax |
1264 | jz .cleanfailed_mem1 |
1266 | jz .cleanfailed_mem1 |
1265 | 1267 | ||
1266 | add edx,(std_application_base_address shr 20) |
1268 | add edx,(std_application_base_address shr 20) |
1267 | mov eax,[edx] |
1269 | mov eax,[edx] |
1268 | and eax,not (4096-1) |
1270 | and eax,not (4096-1) |
1269 | call MEM_Get_Linear_Address |
1271 | call MEM_Get_Linear_Address |
1270 | push edx ;save pointer to first page table |
1272 | push edx ;save pointer to first page table |
1271 | mov edx,eax |
1273 | mov edx,eax |
1272 | ;read file |
1274 | ;read file |
1273 | mov ecx,1 |
1275 | mov ecx,1 |
1274 | xor ebp,ebp |
1276 | xor ebp,ebp |
1275 | .loop1: |
1277 | .loop1: |
1276 | ;[esp] - pointer to current page directory entry |
1278 | ;[esp] - pointer to current page directory entry |
1277 | ;edx - pointer to current page table |
1279 | ;edx - pointer to current page table |
1278 | ;ebp - offset in page |
1280 | ;ebp - offset in page |
1279 | ;ecx - current cluster |
1281 | ;ecx - current cluster |
1280 | push edx |
1282 | push edx |
1281 | mov eax,[esp+12] ;file name |
1283 | mov eax,[esp+12] ;file name |
1282 | mov ebx,[esp+16] ;file name length |
1284 | mov ebx,[esp+16] ;file name length |
1283 | mov esi,[esp+8] ;work area |
1285 | mov esi,[esp+8] ;work area |
1284 | mov edx,1 ;number of blocks to read |
1286 | mov edx,1 ;number of blocks to read |
1285 | push ecx |
1287 | push ecx |
1286 | push ebp |
1288 | push ebp |
1287 | cli |
1289 | cli |
1288 | call read_hd_file |
1290 | call read_hd_file |
1289 | sti |
1291 | sti |
1290 | pop ebp |
1292 | pop ebp |
1291 | test eax,eax |
1293 | test eax,eax |
1292 | jnz .endloop1 ;check io errors |
1294 | jnz .endloop1 ;check io errors |
1293 | 1295 | ||
1294 | mov esi,[esp+8+4] ;work area |
1296 | mov esi,[esp+8+4] ;work area |
1295 | add esi,1024 |
1297 | add esi,1024 |
1296 | mov eax,[esp+4] ;current page table |
1298 | mov eax,[esp+4] ;current page table |
1297 | mov eax,[eax] |
1299 | mov eax,[eax] |
1298 | and eax,not (4096-1) |
1300 | and eax,not (4096-1) |
1299 | call MEM_Get_Linear_Address;calculate linear page address |
1301 | call MEM_Get_Linear_Address;calculate linear page address |
1300 | lea edi,[eax+ebp] ;add page offset |
1302 | lea edi,[eax+ebp] ;add page offset |
1301 | mov ecx,512/4 |
1303 | mov ecx,512/4 |
1302 | cld |
1304 | cld |
1303 | rep movsd ;copy data |
1305 | rep movsd ;copy data |
1304 | 1306 | ||
1305 | pop ecx |
1307 | pop ecx |
1306 | inc ecx ;next block |
1308 | inc ecx ;next block |
1307 | mov eax,[app_i_end] ;todo: precalculate ([app_i_end]+4095)/4096 |
1309 | mov eax,[app_i_end] ;todo: precalculate ([app_i_end]+4095)/4096 |
1308 | add eax,512-1 |
1310 | add eax,512-1 |
1309 | shr eax,9 ;calculate application image size |
1311 | shr eax,9 ;calculate application image size |
1310 | cmp ecx,eax |
1312 | cmp ecx,eax |
1311 | jg .endloop11 |
1313 | jg .endloop11 |
1312 | pop edx |
1314 | pop edx |
1313 | add ebp,512 ;new offset |
1315 | add ebp,512 ;new offset |
1314 | test ebp,4096 |
1316 | test ebp,4096 |
1315 | jz .loop1 |
1317 | jz .loop1 |
1316 | xor ebp,ebp |
1318 | xor ebp,ebp |
1317 | add edx,4 ;go to next page |
1319 | add edx,4 ;go to next page |
1318 | test edx,(4096-1) |
1320 | test edx,(4096-1) |
1319 | jnz .loop1 |
1321 | jnz .loop1 |
1320 | add dword [esp],4 ;go to next directory entry |
1322 | add dword [esp],4 ;go to next directory entry |
1321 | mov eax,[esp] |
1323 | mov eax,[esp] |
1322 | mov eax,[eax] |
1324 | mov eax,[eax] |
1323 | and eax,not (4096-1) |
1325 | and eax,not (4096-1) |
1324 | call MEM_Get_Linear_Address |
1326 | call MEM_Get_Linear_Address |
1325 | mov edx,eax |
1327 | mov edx,eax |
1326 | jmp .loop1 |
1328 | jmp .loop1 |
1327 | .endloop1: |
1329 | .endloop1: |
1328 | add esp,4 ;pop ecx |
1330 | add esp,4 ;pop ecx |
1329 | .endloop11: |
1331 | .endloop11: |
1330 | add esp,4+4 ;pop edx, pop edx |
1332 | add esp,4+4 ;pop edx, pop edx |
1331 | 1333 | ||
1332 | ;add_app_parameters |
1334 | ;add_app_parameters |
1333 | add esp,12 ;now pointer to parameters is on the top of the stack |
1335 | add esp,12 ;now pointer to parameters is on the top of the stack |
1334 | call new_start_application_fl.add_app_parameters ;start process |
1336 | call new_start_application_fl.add_app_parameters ;start process |
1335 | mov [esp+28],eax |
1337 | mov [esp+28],eax |
1336 | popad |
1338 | popad |
1337 | ret |
1339 | ret |
1338 | 1340 | ||
1339 | .cleanfailed_mem1: |
1341 | .cleanfailed_mem1: |
1340 | ;there is mem for directory entry, but there is no mem for pages |
1342 | ;there is mem for directory entry, but there is no mem for pages |
1341 | ;so free directory entry |
1343 | ;so free directory entry |
1342 | mov eax,[new_process_place] |
1344 | mov eax,[new_process_place] |
1343 | shl eax,8 |
1345 | shl eax,8 |
1344 | mov eax,[0x80000+eax+0xB8] |
1346 | mov eax,[0x80000+eax+0xB8] |
1345 | call MEM_Free_Page |
1347 | call MEM_Free_Page |
1346 | .cleanfailed_mem: |
1348 | .cleanfailed_mem: |
1347 | ;there is no mem for directory entry, display message. |
1349 | ;there is no mem for directory entry, display message. |
1348 | mov esi,start_not_enough_memory |
1350 | mov esi,start_not_enough_memory |
1349 | call sys_msg_board_str |
1351 | call sys_msg_board_str |
1350 | .cleanfailed: ;clean process name |
1352 | .cleanfailed: ;clean process name |
1351 | ;can't read file, clean process name. |
1353 | ;can't read file, clean process name. |
1352 | ;this avoid problems with panel application. |
1354 | ;this avoid problems with panel application. |
1353 | mov edi,[new_process_place] |
1355 | mov edi,[new_process_place] |
1354 | shl edi,8 |
1356 | shl edi,8 |
1355 | add edi,0x80000 |
1357 | add edi,0x80000 |
1356 | mov ecx,11 |
1358 | mov ecx,11 |
1357 | mov eax,' ' |
1359 | mov eax,' ' |
1358 | cld |
1360 | cld |
1359 | rep stosb |
1361 | rep stosb |
1360 | .failed: |
1362 | .failed: |
1361 | ;no more slots |
1363 | ;no more slots |
1362 | add esp,16 |
1364 | add esp,16 |
1363 | popad |
1365 | popad |
1364 | mov eax,-1 |
1366 | mov eax,-1 |
1365 | mov [application_table_status],0 |
1367 | mov [application_table_status],0 |
1366 | sti |
1368 | sti |
1367 | ret |
1369 | ret |
1368 | end if |
1370 | end if |
1369 | 1371 | ||
1370 | include 'debug.inc'0>>-->-->-->-->256 |
1372 | include 'debug.inc'0>>-->-->-->-->256 |
1371 | >> |
1373 | >> |