Rev 887 | Rev 889 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 887 | Rev 888 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 887 $ |
8 | $Revision: 888 $ |
Line 9... | Line 9... | ||
9 | 9 | ||
Line 198... | Line 198... | ||
198 | mov ebx,[slot_base] |
198 | mov ebx,[slot_base] |
199 | mov [ebx+APPDATA.dir_table],eax |
199 | mov [ebx+APPDATA.dir_table],eax |
200 | mov eax,[hdr_mem] |
200 | mov eax,[hdr_mem] |
201 | mov [ebx+APPDATA.mem_size],eax |
201 | mov [ebx+APPDATA.mem_size],eax |
Line 202... | Line -... | ||
202 | - | ||
203 | if GREEDY_KERNEL |
- | |
204 | else |
202 | |
205 | mov ecx, [hdr_mem] |
203 | mov ecx, [hdr_mem] |
206 | mov edi, [file_size] |
204 | mov edi, [file_size] |
207 | add edi, 4095 |
205 | add edi, 4095 |
208 | and edi, not 4095 |
206 | and edi, not 4095 |
Line 211... | Line 209... | ||
211 | 209 | ||
212 | xor eax, eax |
210 | xor eax, eax |
213 | cld |
211 | cld |
214 | rep stosb |
212 | rep stosb |
215 | @@: |
213 | @@: |
216 | end if |
- | |
217 | 214 | mov ecx, [file_base] |
|
Line 218... | Line -... | ||
218 | ; release only virtual space, not phisical memory |
- | |
219 | 215 | call @mem_free@4 |
|
220 | stdcall free_kernel_space, [file_base] ; |
216 | |
221 | lea eax, [hdr_cmdline] |
217 | lea eax, [hdr_cmdline] |
222 | lea ebx, [cmdline] |
218 | lea ebx, [cmdline] |
Line 373... | Line 369... | ||
373 | 369 | ||
374 | mov [img_size], ecx |
370 | mov [img_size], ecx |
375 | shr ecx, 12 |
371 | shr ecx, 12 |
Line 376... | Line -... | ||
376 | mov [img_pages], ecx |
- | |
377 | - | ||
378 | ; if GREEDY_KERNEL |
- | |
379 | ; lea eax, [ecx+ebx+2] ;only image size |
- | |
380 | ; else |
- | |
381 | ; lea eax, [eax+ebx+2] ;all requested memory |
- | |
382 | ; end if |
- | |
383 | ; cmp eax, [pg_data.pages_free] |
- | |
384 | ; ja .fail |
372 | mov [img_pages], ecx |
385 | 373 | ||
386 | call _alloc_page |
374 | call _alloc_page |
387 | test eax, eax |
375 | test eax, eax |
Line 432... | Line 420... | ||
432 | mov ecx, [app_tabs] |
420 | mov ecx, [app_tabs] |
433 | shl ecx, 10 |
421 | shl ecx, 10 |
434 | xor eax, eax |
422 | xor eax, eax |
435 | rep stosd |
423 | rep stosd |
Line 436... | Line -... | ||
436 | - | ||
437 | mov ecx, [img_pages] |
- | |
438 | mov ebx, PG_UW |
- | |
439 | mov esi, [img_base] |
- | |
440 | shr esi, 10 |
- | |
441 | add esi, page_tabs |
- | |
442 | xor edx, edx |
- | |
443 | mov edi, page_tabs |
- | |
444 | .remap: |
- | |
445 | lodsd |
- | |
446 | or eax, ebx ; force user level r/w access |
- | |
447 | stosd |
- | |
448 | add edx, 0x1000 |
- | |
449 | dec [app_pages] |
- | |
450 | dec ecx |
- | |
451 | jnz .remap |
- | |
452 | 424 | ||
453 | mov ecx, [app_pages] |
425 | mov ecx, [app_pages] |
454 | test ecx, ecx |
- | |
455 | jz .done |
- | |
456 | - | ||
457 | if GREEDY_KERNEL |
- | |
458 | mov eax, 0x02 |
- | |
459 | rep stosd |
- | |
460 | else |
- | |
461 | 426 | xor ebx, ebx |
|
- | 427 | .alloc: |
|
462 | .alloc: |
428 | xor ecx, ecx |
463 | call _alloc_page |
429 | call @core_alloc@4 |
464 | test eax, eax |
430 | test eax, eax |
Line 465... | Line 431... | ||
465 | jz .fail |
431 | jz .fail |
466 | 432 | ||
467 | stdcall map_page,edx,eax,dword PG_UW |
433 | stdcall map_page,ebx,eax,dword PG_UW |
468 | add edx, 0x1000 |
434 | add ebx, 0x1000 |
- | 435 | dec [app_pages] |
|
- | 436 | jnz .alloc |
|
- | 437 | ||
- | 438 | mov ecx, [img_size] ; FIXME remap md |
|
469 | dec [app_pages] |
439 | mov esi, [img_base] |
- | 440 | xor edi, edi |
|
Line 470... | Line 441... | ||
470 | jnz .alloc |
441 | |
471 | end if |
442 | rep movsb |
472 | 443 | ||
473 | .done: |
444 | .done: |
Line 493... | Line 464... | ||
493 | ret |
464 | ret |
Line 494... | Line 465... | ||
494 | 465 | ||
495 | align 4 |
466 | align 4 |
Line -... | Line 467... | ||
- | 467 | proc destroy_page_table stdcall, pg_tab:dword |
|
496 | proc destroy_page_table stdcall, pg_tab:dword |
468 | |
Line 497... | Line 469... | ||
497 | 469 | push ebx |
|
498 | push esi |
470 | push esi |
499 | 471 | ||
500 | mov esi, [pg_tab] |
472 | mov esi, [pg_tab] |
501 | mov ecx, 1024 |
473 | mov ebx, 1024 |
502 | .free: |
474 | .free: |
Line 503... | Line 475... | ||
503 | mov eax, [esi] |
475 | mov ecx, [esi] |
504 | test eax, 1 |
476 | test ecx, 1 |
Line 505... | Line 477... | ||
505 | jz .next |
477 | jz .next |
506 | 478 | ||
507 | test eax, 1 shl 9 |
479 | test ecx, 1 shl 9 |
508 | jnz .next ;skip shared pages |
480 | jnz .next ;skip shared pages |
509 | 481 | ||
510 | call free_page |
482 | call @core_free@4 |
- | 483 | .next: |
|
511 | .next: |
484 | add esi, 4 |
512 | add esi, 4 |
485 | dec ebx |
Line 513... | Line 486... | ||
513 | dec ecx |
486 | jnz .free |
514 | jnz .free |
487 | pop esi |
Line 561... | Line 534... | ||
561 | and eax, not 0xFFF |
534 | and eax, not 0xFFF |
562 | add eax, OS_BASE |
535 | add eax, OS_BASE |
Line 563... | Line 536... | ||
563 | 536 | ||
Line 564... | Line 537... | ||
564 | stdcall destroy_page_table, eax |
537 | stdcall destroy_page_table, eax |
565 | 538 | ||
566 | mov eax, [esi] |
539 | mov ecx, [esi] |
567 | call free_page |
540 | call @core_free@4 |
568 | .next: |
541 | .next: |
569 | add esi, 4 |
542 | add esi, 4 |
Line 570... | Line 543... | ||
570 | dec edi |
543 | dec edi |
571 | jnz .destroy |
544 | jnz .destroy |
572 | 545 | ||
573 | mov eax, [pg_dir] |
546 | mov ecx, [pg_dir] |
574 | call free_page |
547 | call @core_free@4 |
575 | .exit: |
548 | .exit: |
Line 742... | Line 715... | ||
742 | mov ecx, 0x8000 |
715 | mov ecx, 0x8000 |
743 | @@: |
716 | @@: |
744 | mov eax, [slot] |
717 | mov eax, [slot] |
745 | shl eax,8 |
718 | shl eax,8 |
746 | mov ebx, [offset] |
719 | mov ebx, [offset] |
747 | ; add ebx, new_app_base |
- | |
748 | push ecx |
720 | push ecx |
749 | stdcall map_memEx, [proc_mem_map],\ |
721 | stdcall map_memEx, [proc_mem_map],\ |
750 | [SLOT_BASE+eax+0xB8],\ |
722 | [SLOT_BASE+eax+0xB8],\ |
751 | ebx, ecx |
723 | ebx, ecx |
752 | pop ecx |
724 | pop ecx |