Rev 2467 | Rev 3232 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2467 | Rev 2987 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2012. 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: 2467 $ |
8 | $Revision: 2987 $ |
9 | 9 | ||
Line 440... | Line 440... | ||
440 | endp |
440 | endp |
Line 441... | Line 441... | ||
441 | 441 | ||
442 | align 4 |
442 | align 4 |
Line -... | Line 443... | ||
- | 443 | proc new_mem_resize stdcall, new_size:dword |
|
- | 444 | ||
- | 445 | push ebx |
|
- | 446 | push esi |
|
443 | proc new_mem_resize stdcall, new_size:dword |
447 | push edi |
- | 448 | ||
444 | 449 | mov edx, [current_slot] |
|
Line 445... | Line 450... | ||
445 | mov ecx, pg_data.mutex |
450 | cmp [edx+APPDATA.heap_base], 0 |
446 | call mutex_lock |
451 | jne .exit |
447 | 452 | ||
448 | mov edi, [new_size] |
453 | mov edi, [new_size] |
Line 449... | Line -... | ||
449 | add edi, 4095 |
- | |
450 | and edi, not 4095 |
- | |
451 | mov [new_size], edi |
- | |
452 | - | ||
453 | mov edx, [current_slot] |
454 | add edi, 4095 |
454 | cmp [edx+APPDATA.heap_base], 0 |
455 | and edi, not 4095 |
455 | jne .exit |
456 | mov [new_size], edi |
Line 456... | Line 457... | ||
456 | 457 | ||
457 | mov esi, [edx+APPDATA.mem_size] |
458 | mov esi, [edx+APPDATA.mem_size] |
- | 459 | add esi, 4095 |
|
Line -... | Line 460... | ||
- | 460 | and esi, not 4095 |
|
458 | add esi, 4095 |
461 | |
459 | and esi, not 4095 |
462 | cmp edi, esi |
- | 463 | ja .expand |
|
- | 464 | je .exit |
|
- | 465 | ||
460 | 466 | mov ebx, edi |
|
461 | cmp edi, esi |
467 | shr edi, 12 |
462 | jae .expand |
468 | shr esi, 12 |
463 | 469 | ||
- | 470 | mov ecx, pg_data.mutex |
|
464 | shr edi, 12 |
471 | call mutex_lock |
465 | shr esi, 12 |
- | |
466 | @@: |
- | |
467 | mov eax, [app_page_tabs+edi*4] |
- | |
468 | test eax, 1 |
472 | @@: |
469 | jz .next |
- | |
470 | mov dword [app_page_tabs+edi*4], 2 |
473 | mov eax, [app_page_tabs+edi*4] |
Line 471... | Line 474... | ||
471 | mov ebx, edi |
474 | test eax, 1 |
- | 475 | jz .next |
|
472 | shl ebx, 12 |
476 | |
473 | push eax |
477 | mov dword [app_page_tabs+edi*4], 0 |
474 | invlpg [ebx] |
478 | invlpg [ebx] |
Line 475... | Line -... | ||
475 | pop eax |
- | |
476 | call free_page |
- | |
477 | - | ||
478 | .next: |
- | |
479 | add edi, 1 |
479 | call free_page |
480 | cmp edi, esi |
480 | |
Line -... | Line 481... | ||
- | 481 | .next: |
|
- | 482 | inc edi |
|
- | 483 | add ebx, 0x1000 |
|
- | 484 | cmp edi, esi |
|
- | 485 | jb @B |
|
- | 486 | ||
- | 487 | mov ecx, pg_data.mutex |
|
- | 488 | call mutex_unlock |
|
481 | jb @B |
489 | |
482 | 490 | .update_size: |
|
- | 491 | mov edx, [current_slot] |
|
483 | .update_size: |
492 | mov ebx, [new_size] |
Line -... | Line 493... | ||
- | 493 | call update_mem_size |
|
484 | mov ebx, [new_size] |
494 | .exit: |
- | 495 | pop edi |
|
485 | call update_mem_size |
496 | pop esi |
- | 497 | pop ebx |
|
- | 498 | xor eax, eax |
|
- | 499 | ret |
|
Line 486... | Line 500... | ||
486 | 500 | ||
487 | mov ecx, pg_data.mutex |
501 | .expand: |
488 | call mutex_unlock |
502 | |
489 | 503 | mov ecx, pg_data.mutex |
|
Line 490... | Line 504... | ||
490 | xor eax, eax |
504 | call mutex_lock |
491 | ret |
505 | |
492 | .expand: |
- | |
493 | - | ||
494 | push esi |
- | |
495 | push edi |
506 | xchg esi, edi |
496 | 507 | ||
497 | add edi, 0x3FFFFF |
508 | push esi ;new size |
498 | and edi, not(0x3FFFFF) |
509 | push edi ;old size |
Line 499... | Line 510... | ||
499 | add esi, 0x3FFFFF |
510 | |
Line 500... | Line 511... | ||
500 | and esi, not(0x3FFFFF) |
511 | add edi, 0x3FFFFF |
501 | 512 | and edi, not(0x3FFFFF) |
|
Line 522... | Line 533... | ||
522 | 533 | ||
523 | add edi, 0x00400000 |
534 | add edi, 0x00400000 |
524 | cmp edi, esi |
535 | cmp edi, esi |
525 | jb @B |
536 | jb @B |
526 | .grow: |
- | |
527 | ;//- |
- | |
528 | pop edi |
- | |
529 | push edi |
537 | .grow: |
530 | mov esi, [pg_data.pages_free] |
- | |
531 | sub esi, 1 |
- | |
532 | shr edi, 12 |
- | |
533 | cmp esi, edi |
- | |
534 | jle .out_of_memory |
- | |
535 | ;//- |
- | |
536 | pop edi |
- | |
537 | pop esi |
- | |
538 | @@: |
- | |
539 | call alloc_page |
- | |
540 | test eax, eax |
- | |
541 | jz .exit |
538 | pop edi ;old size |
Line 542... | Line 539... | ||
542 | stdcall map_page, esi, eax, dword PG_UW |
539 | pop ecx ;new size |
543 | 540 | ||
544 | push edi |
541 | shr edi, 10 |
- | 542 | shr ecx, 10 |
|
545 | mov edi, esi |
543 | sub ecx, edi |
- | 544 | shr ecx, 2 ;pages count |
|
546 | xor eax, eax |
545 | mov eax, 2 |
547 | mov ecx, 1024 |
546 | |
548 | cld |
- | |
Line 549... | Line 547... | ||
549 | rep stosd |
547 | add edi, app_page_tabs |
550 | pop edi |
548 | rep stosd |
551 | - | ||
Line 552... | Line 549... | ||
552 | add esi, 0x1000 |
549 | |
553 | cmp esi, edi |
550 | mov ecx, pg_data.mutex |
554 | jb @B |
551 | call mutex_unlock |
555 | - | ||
556 | jmp .update_size |
- | |
557 | ;//- |
- | |
558 | .exit_pop: |
- | |
559 | .out_of_memory: |
- | |
560 | ;//- |
552 | |
561 | pop edi |
553 | jmp .update_size |
Line -... | Line 554... | ||
- | 554 | ||
- | 555 | .exit_fail: |
|
- | 556 | mov ecx, pg_data.mutex |
|
- | 557 | call mutex_unlock |
|
562 | pop esi |
558 | |
563 | .exit: |
559 | add esp, 8 |
564 | mov ecx, pg_data.mutex |
560 | pop edi |
565 | call mutex_unlock |
561 | pop esi |
Line -... | Line 562... | ||
- | 562 | pop ebx |
|
- | 563 | xor eax, eax |
|
566 | 564 | inc eax |
|
567 | xor eax, eax |
565 | ret |
568 | inc eax |
566 | endp |
569 | ret |
567 | |
Line 1251... | Line 1249... | ||
1251 | ret |
1249 | ret |
1252 | .21: |
1250 | .21: |
1253 | cmp ecx, OS_BASE |
1251 | cmp ecx, OS_BASE |
1254 | jae .fail |
1252 | jae .fail |
Line 1255... | Line 1253... | ||
1255 | 1253 | ||
1256 | cmp ebx, OS_BASE |
1254 | cmp edx, OS_BASE |
Line 1257... | Line 1255... | ||
1257 | jae .fail |
1255 | jae .fail |
1258 | 1256 | ||
1259 | mov edi, edx |
1257 | mov edi, edx |
Line 1457... | Line 1455... | ||
1457 | wrmsr |
1455 | wrmsr |
Line 1458... | Line 1456... | ||
1458 | 1456 | ||
1459 | mov ebx, [size] |
1457 | mov ebx, [size] |
1460 | dec ebx |
1458 | dec ebx |
1461 | mov eax, 0xFFFFFFFF |
1459 | mov eax, 0xFFFFFFFF |
1462 | mov edx, 0x00000000 |
1460 | mov edx, 0x0000000F |
1463 | sub eax, ebx |
1461 | sub eax, ebx |
1464 | sbb edx, 0 |
1462 | sbb edx, 0 |
1465 | or eax, 0x800 |
1463 | or eax, 0x800 |
1466 | inc ecx |
1464 | inc ecx |