Rev 129 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 129 | Rev 133 | ||
---|---|---|---|
Line 136... | Line 136... | ||
136 | jnz .cleanfailed |
136 | jnz .cleanfailed |
137 | cmp [0x90004],word 'ET' |
137 | cmp [0x90004],word 'ET' |
138 | jnz .cleanfailed |
138 | jnz .cleanfailed |
Line 139... | Line 139... | ||
139 | 139 | ||
140 | call get_app_params ;parse header fields |
- | |
141 | test esi, esi |
140 | call get_app_params ;parse header fields |
Line 142... | Line 141... | ||
142 | jz .cleanfailed |
141 | jc .cleanfailed |
143 | 142 | ||
144 | mov eax,[new_process_place] |
143 | mov eax,[new_process_place] |
145 | inc ecx ; -0x1E = no memory |
144 | inc ecx ; -0x1E = no memory |
Line 175... | Line 174... | ||
175 | and eax,not (4096-1) |
174 | and eax,not (4096-1) |
176 | call MEM_Get_Linear_Address |
175 | call MEM_Get_Linear_Address |
177 | mov edx,eax ;read file block to current page |
176 | mov edx,eax ;read file block to current page |
178 | mov eax,[esp+4] ;restore pointer to file name |
177 | mov eax,[esp+4] ;restore pointer to file name |
179 | mov ecx,8 ;number of blocks read |
178 | mov ecx,8 ;number of blocks read |
- | 179 | mov ebp,edx ;save buffer address for .endofimage |
|
180 | push ebx |
180 | push ebx |
181 | mov edi,[esp+16] |
181 | mov edi,[esp+16] |
182 | ; cli |
182 | ; cli |
183 | call floppy_fileread |
183 | call floppy_fileread |
184 | ;ebx=file size |
184 | ;ebx=file size |
185 | ; sti |
185 | ; sti |
186 | pop ecx |
186 | pop ecx |
- | 187 | add ecx,8 |
|
- | 188 | test eax,eax |
|
- | 189 | jnz .endloop1 ;check io errors |
|
- | 190 | mov eax,[app_i_end] |
|
- | 191 | add eax,511 |
|
- | 192 | shr eax,9 |
|
- | 193 | cmp ecx,eax |
|
- | 194 | jg .endofimage ;we have loaded whole program |
|
- | 195 | add ebx,511 |
|
187 | shr ebx,9 |
196 | shr ebx,9 |
188 | cmp ecx,ebx |
197 | cmp ecx,ebx |
189 | jg .endloop1 ;if end of file? |
198 | jg .endloop1 ;if end of file? |
190 | mov ebx,ecx |
199 | mov ebx,ecx |
191 | test eax,eax |
- | |
192 | jnz .endloop1 ;check io errors |
- | |
193 | pop edx |
200 | pop edx |
194 | add ebx,8 ;go to next page |
- | |
195 | add edx,4 |
201 | add edx,4 |
196 | jmp .loop1 |
202 | jmp .loop1 |
Line -... | Line 203... | ||
- | 203 | ||
- | 204 | .endofimage: ;set to zero memory at end of page |
|
- | 205 | mov ecx,[app_i_end] |
|
- | 206 | and ecx,4096-1 |
|
- | 207 | jz .endloop1 |
|
- | 208 | lea edi,[ebp+ecx] |
|
- | 209 | neg ecx |
|
- | 210 | add ecx,4096 |
|
- | 211 | xor eax,eax |
|
- | 212 | cld |
|
197 | 213 | rep stosb |
|
198 | .endloop1: |
214 | .endloop1: |
199 | add esp,8+4 ;pop linear address of page table entry and pointer to file name |
215 | add esp,8+4 ;pop linear address of page table entry and pointer to file name |
200 | call new_start_application_fl.add_app_parameters |
216 | call new_start_application_fl.add_app_parameters |
201 | mov [esp+28],eax |
217 | mov [esp+28],eax |
Line 301... | Line 317... | ||
301 | jnz .cleanfailed |
317 | jnz .cleanfailed |
302 | cmp [0x90004],word 'ET' |
318 | cmp [0x90004],word 'ET' |
303 | jnz .cleanfailed |
319 | jnz .cleanfailed |
Line 304... | Line 320... | ||
304 | 320 | ||
305 | call get_app_params ;parse header fields |
- | |
306 | test esi,esi |
321 | call get_app_params ;parse header fields |
Line 307... | Line 322... | ||
307 | jz .cleanfailed |
322 | jc .cleanfailed |
308 | 323 | ||
309 | mov eax,[new_process_place] |
324 | mov eax,[new_process_place] |
310 | inc ecx ; -0x1E = no memory |
325 | inc ecx ; -0x1E = no memory |
Line 340... | Line 355... | ||
340 | and eax,not (4096-1) |
355 | and eax,not (4096-1) |
341 | call MEM_Get_Linear_Address |
356 | call MEM_Get_Linear_Address |
342 | mov edx,eax ;read file block to current page |
357 | mov edx,eax ;read file block to current page |
343 | mov eax,[esp+4] ;restore pointer to file name |
358 | mov eax,[esp+4] ;restore pointer to file name |
344 | mov ecx,8 ;number of blocks read |
359 | mov ecx,8 ;number of blocks read |
- | 360 | mov ebp,edx ;save buffer address for .endofimage |
|
345 | push ebx |
361 | push ebx |
346 | cli |
362 | cli |
347 | call fileread |
363 | call fileread |
348 | ;ebx=file size |
364 | ;ebx=file size |
349 | call safe_sti |
365 | call safe_sti |
350 | pop ecx |
366 | pop ecx |
- | 367 | add ecx,8 |
|
- | 368 | test eax,eax |
|
- | 369 | jnz .endloop1 ;check io errors |
|
- | 370 | mov eax,[app_i_end] |
|
- | 371 | add eax,511 |
|
- | 372 | shr eax,9 |
|
- | 373 | cmp ecx,eax |
|
- | 374 | jg .endofimage ;we have loaded whole program |
|
- | 375 | add ebx,511 |
|
351 | shr ebx,9 |
376 | shr ebx,9 |
352 | cmp ecx,ebx |
377 | cmp ecx,ebx |
353 | jg .endloop1 ;if end of file? |
378 | jg .endloop1 ;if end of file? |
354 | mov ebx,ecx |
379 | mov ebx,ecx |
355 | test eax,eax |
- | |
356 | jnz .endloop1 ;check io errors |
- | |
357 | pop edx |
380 | pop edx |
358 | add ebx,8 ;go to next page |
- | |
359 | add edx,4 |
381 | add edx,4 |
360 | jmp .loop1 |
382 | jmp .loop1 |
Line -... | Line 383... | ||
- | 383 | ||
- | 384 | .endofimage: ;set to zero memory at end of page |
|
- | 385 | mov ecx,[app_i_end] |
|
- | 386 | and ecx,4096-1 |
|
- | 387 | jz .endloop1 |
|
- | 388 | lea edi,[ebp+ecx] |
|
- | 389 | neg ecx |
|
- | 390 | add ecx,4096 |
|
- | 391 | xor eax,eax |
|
- | 392 | cld |
|
361 | 393 | rep stosb |
|
362 | .endloop1: |
394 | .endloop1: |
363 | add esp,8 ;pop linear address of page table entry and pointer to file name |
395 | add esp,8 ;pop linear address of page table entry and pointer to file name |
364 | call .add_app_parameters |
396 | call .add_app_parameters |
365 | mov [esp+28],eax |
397 | mov [esp+28],eax |
Line 1265... | Line 1297... | ||
1265 | mov ecx,512/4 |
1297 | mov ecx,512/4 |
1266 | cld |
1298 | cld |
1267 | rep movsd ;copy first block to 0x90000 address for get_app_params function |
1299 | rep movsd ;copy first block to 0x90000 address for get_app_params function |
1268 | call get_app_params |
1300 | call get_app_params |
1269 | mov ecx, -0x1F ; not Menuet/Kolibri executable |
1301 | mov ecx, -0x1F ; not Menuet/Kolibri executable |
1270 | test esi,esi |
- | |
1271 | jz .cleanfailed |
1302 | jc .cleanfailed |
Line 1272... | Line 1303... | ||
1272 | 1303 | ||
1273 | mov eax,[new_process_place] |
1304 | mov eax,[new_process_place] |
1274 | inc ecx ; -0x1E = no memory |
1305 | inc ecx ; -0x1E = no memory |
1275 | call create_app_cr3_table ;create page directory |
1306 | call create_app_cr3_table ;create page directory |
Line 1500... | Line 1531... | ||
1500 | jnz .cleanfailed |
1531 | jnz .cleanfailed |
1501 | cmp word [0x90004], 'ET' |
1532 | cmp word [0x90004], 'ET' |
1502 | jnz .cleanfailed |
1533 | jnz .cleanfailed |
1503 | call get_app_params |
1534 | call get_app_params |
1504 | mov ecx, -0x1F |
1535 | mov ecx, -0x1F |
- | 1536 | jc .cleanfailed |
|
- | 1537 | ; sanity check - because we will load all file, |
|
- | 1538 | ; file size must be not greater than memory size |
|
1505 | test esi, esi |
1539 | mov eax, [esp+8+36] |
- | 1540 | cmp [app_mem], eax |
|
1506 | jz .cleanfailed |
1541 | jb .cleanfailed |
Line 1507... | Line 1542... | ||
1507 | 1542 | ||
1508 | mov eax, [new_process_place] |
1543 | mov eax, [new_process_place] |
1509 | inc ecx ; -0x1E = no memory |
1544 | inc ecx ; -0x1E = no memory |
1510 | call create_app_cr3_table |
1545 | call create_app_cr3_table |