Subversion Repositories Kolibri OS

Rev

Rev 4423 | Rev 5565 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4423 Rev 5201
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: 4423 $
8
$Revision: 5201 $
9
 
9
 
10
 
10
 
Line 127... Line 127...
127
        stosd
127
        stosd
128
        stosd
128
        stosd
129
        loop    @B
129
        loop    @B
Line 130... Line 130...
130
 
130
 
-
 
131
        stdcall alloc_pages, dword 32
-
 
132
 
-
 
133
        or      eax, PG_SW
131
        stdcall alloc_pages, dword 32
134
        mov     ebx, HEAP_BASE
132
        mov     ecx, 32
-
 
133
        mov     edx, eax
-
 
134
        mov     edi, HEAP_BASE
-
 
135
.l1:
-
 
136
        stdcall map_page, edi, edx, PG_SW
135
        mov     ecx, 32
137
        add     edi, 0x1000
-
 
138
        add     edx, 0x1000
-
 
139
        dec     ecx
-
 
Line 140... Line 136...
140
        jnz     .l1
136
        call    commit_pages
141
 
137
 
142
        mov     edi, HEAP_BASE                     ;descriptors
138
        mov     edi, HEAP_BASE                     ;descriptors
Line 478... Line 474...
478
        mov     ebx, eax
474
        mov     ebx, eax
479
        shr     ebx, 12
475
        shr     ebx, 12
480
        mov     [pages_count], ebx
476
        mov     [pages_count], ebx
Line 481... Line 477...
481
 
477
 
-
 
478
        stdcall alloc_kernel_space, eax
-
 
479
        mov     [lin_addr], eax
482
        stdcall alloc_kernel_space, eax
480
        mov     ebx, [pages_count]
483
        test    eax, eax
481
        test    eax, eax
484
        jz      .err
-
 
Line 485... Line -...
485
        mov     [lin_addr], eax
-
 
486
 
482
        jz      .err
487
        mov     ecx, [pages_count]
-
 
Line 488... Line 483...
488
        mov     edx, eax
483
 
489
        mov     ebx, ecx
484
        mov     edx, eax
Line 490... Line 485...
490
 
485
 
491
        shr     ecx, 3
-
 
492
        jz      .next
486
        shr     ebx, 3
493
 
-
 
494
        and     ebx, not 7
487
        jz      .tail
495
        push    ebx
488
 
Line 496... Line 489...
496
        stdcall alloc_pages, ebx
489
        shl     ebx, 3
497
        pop     ecx                  ; yes ecx!!!
490
        stdcall alloc_pages, ebx
498
        and     eax, eax
-
 
499
        jz      .err
-
 
500
 
491
        test    eax, eax
501
        mov     edi, eax
492
        jz      .err
-
 
493
 
502
        mov     edx, [lin_addr]
494
        mov     ecx, ebx
503
@@:
-
 
504
        stdcall map_page, edx, edi, dword PG_SW
495
        or      eax, PG_SW
505
        add     edx, 0x1000
496
        mov     ebx, [lin_addr]
506
        add     edi, 0x1000
497
        call    commit_pages
507
        dec     ecx
498
 
508
        jnz     @B
499
        mov     edx, ebx                    ; this dirty hack
509
.next:
-
 
510
        mov     ecx, [pages_count]
500
.tail:
511
        and     ecx, 7
-
 
512
        jz      .end
501
        mov     ebx, [pages_count]
513
@@:
502
        and     ebx, 7
Line 514... Line 503...
514
        push    ecx
503
        jz      .end
515
        call    alloc_page
504
@@:
516
        pop     ecx
505
        call    alloc_page
517
        test    eax, eax
506
        test    eax, eax
518
        jz      .err
507
        jz      .err
519
 
508
 
520
        stdcall map_page, edx, eax, dword PG_SW
509
        stdcall map_page, edx, eax, dword PG_SW
521
        add     edx, 0x1000
510
        add     edx, 0x1000
Line 567... Line 556...
567
restore block_list
556
restore block_list
568
restore block_base
557
restore block_base
569
restore block_size
558
restore block_size
570
restore block_flags
559
restore block_flags
Line 571... Line 560...
571
 
560
 
Line 572... Line 561...
572
;;;;;;;;;;;;;;      USER     ;;;;;;;;;;;;;;;;;
561
;;;;;;;;;;;;;;      USER HEAP     ;;;;;;;;;;;;;;;;;
Line 573... Line 562...
573
 
562
 
574
HEAP_TOP  equ 0x80000000
563
HEAP_TOP  equ 0x80000000
Line 575... Line 564...
575
 
564
 
576
align 4
565
align 4
577
proc init_heap
566
proc init_heap
578
 
567
 
579
        mov     ebx, [current_slot]
568
        mov     ebx, [current_process]
580
        mov     eax, [ebx+APPDATA.heap_top]
569
        mov     eax, [ebx+PROC.heap_top]
581
        test    eax, eax
570
        test    eax, eax
582
        jz      @F
571
        jz      @F
-
 
572
        sub     eax, [ebx+PROC.heap_base]
-
 
573
        sub     eax, PAGE_SIZE
-
 
574
        ret
583
        sub     eax, [ebx+APPDATA.heap_base]
575
@@:
584
        sub     eax, 4096
576
        lea     ecx, [ebx+PROC.heap_lock]
585
        ret
577
        call    mutex_init
586
@@:
578
 
587
        mov     esi, [ebx+APPDATA.mem_size]
579
        mov     esi, [ebx+PROC.mem_used]
588
        add     esi, 4095
580
        add     esi, 4095
589
        and     esi, not 4095
581
        and     esi, not 4095
Line 590... Line 582...
590
        mov     [ebx+APPDATA.mem_size], esi
582
        mov     [ebx+PROC.mem_used], esi
591
        mov     eax, HEAP_TOP
583
        mov     eax, HEAP_TOP
592
        mov     [ebx+APPDATA.heap_base], esi
584
        mov     [ebx+PROC.heap_base], esi
593
        mov     [ebx+APPDATA.heap_top], eax
585
        mov     [ebx+PROC.heap_top], eax
594
 
586
 
595
        sub     eax, esi
587
        sub     eax, esi
596
        shr     esi, 10
588
        shr     esi, 10
597
        mov     ecx, eax
589
        mov     ecx, eax
Line 606... Line 598...
606
 
598
 
607
        push    ebx
599
        push    ebx
608
        push    esi
600
        push    esi
Line -... Line 601...
-
 
601
        push    edi
-
 
602
 
-
 
603
        mov     ebx, [current_process]
-
 
604
        lea     ecx, [ebx+PROC.heap_lock]
609
        push    edi
605
        call    mutex_lock
610
 
606
 
611
        mov     ecx, [alloc_size]
607
        mov     ecx, [alloc_size]
Line 612... Line -...
612
        add     ecx, (4095+4096)
-
 
613
        and     ecx, not 4095
608
        add     ecx, (4095+PAGE_SIZE)
614
 
609
        and     ecx, not 4095
615
        mov     ebx, [current_slot]
610
 
616
        mov     esi, dword [ebx+APPDATA.heap_base] ; heap_base
611
        mov     esi, dword [ebx+PROC.heap_base] ; heap_base
617
        mov     edi, dword [ebx+APPDATA.heap_top]  ; heap_top
612
        mov     edi, dword [ebx+PROC.heap_top]  ; heap_top
Line 618... Line 613...
618
l_0:
613
.scan:
619
        cmp     esi, edi
614
        cmp     esi, edi
620
        jae     m_exit
615
        jae     .m_exit
621
 
616
 
622
        mov     ebx, esi
617
        mov     ebx, esi
623
        shr     ebx, 12
618
        shr     ebx, 12
624
        mov     eax, [page_tabs+ebx*4]
619
        mov     eax, [page_tabs+ebx*4]
625
        test    al, FREE_BLOCK
620
        test    al, FREE_BLOCK
626
        jz      test_used
621
        jz      .test_used
Line 627... Line 622...
627
        and     eax, 0xFFFFF000
622
        and     eax, 0xFFFFF000
628
        cmp     eax, ecx   ;alloc_size
623
        cmp     eax, ecx   ;alloc_size
629
        jb      m_next
624
        jb      .m_next
Line 646... Line 641...
646
        inc     ebx
641
        inc     ebx
647
        dec     ecx
642
        dec     ecx
648
        jnz     @B
643
        jnz     @B
649
.no:
644
.no:
Line 650... Line 645...
650
 
645
 
651
        mov     edx, [current_slot]
646
        mov     edx, [current_process]
652
        mov     ebx, [alloc_size]
647
        mov     ebx, [alloc_size]
653
        add     ebx, 0xFFF
648
        add     ebx, 0xFFF
-
 
649
        and     ebx, not 0xFFF
-
 
650
        add     [edx+PROC.mem_used], ebx
654
        and     ebx, not 0xFFF
651
 
655
        add     ebx, [edx+APPDATA.mem_size]
652
        lea     ecx, [edx+PROC.heap_lock]
Line 656... Line 653...
656
        call    update_mem_size
653
        call    mutex_unlock
Line 657... Line 654...
657
 
654
 
658
        lea     eax, [esi+4096]
655
        lea     eax, [esi+4096]
659
 
656
 
660
        pop     edi
657
        pop     edi
661
        pop     esi
658
        pop     esi
662
        pop     ebx
659
        pop     ebx
663
        ret
660
        ret
Line 664... Line 661...
664
test_used:
661
.test_used:
665
        test    al, USED_BLOCK
662
        test    al, USED_BLOCK
666
        jz      m_exit
663
        jz      .m_exit
667
 
664
 
668
        and     eax, 0xFFFFF000
665
        and     eax, 0xFFFFF000
-
 
666
.m_next:
-
 
667
        add     esi, eax
-
 
668
        jmp     .scan
-
 
669
.m_exit:
669
m_next:
670
        mov     ecx, [current_process]
670
        add     esi, eax
671
        lea     ecx, [ecx+PROC.heap_lock]
671
        jmp     l_0
672
        call    mutex_unlock
672
m_exit:
673
 
673
        xor     eax, eax
674
        xor     eax, eax
Line 682... Line 683...
682
 
683
 
683
        push    ebx
684
        push    ebx
684
        push    esi
685
        push    esi
Line 685... Line 686...
685
        push    edi
686
        push    edi
-
 
687
 
-
 
688
        mov     ebx, [current_process]
-
 
689
        lea     ecx, [ebx+PROC.heap_lock]
686
 
690
        call    mutex_lock
687
        mov     ebx, [current_slot]
691
 
688
        mov     edx, [address]
692
        mov     edx, [address]
689
        and     edx, not 0xFFF
693
        and     edx, not 0xFFF
690
        mov     [address], edx
694
        mov     [address], edx
691
        sub     edx, 0x1000
695
        sub     edx, 0x1000
692
        jb      .error
696
        jb      .error
693
        mov     esi, [ebx+APPDATA.heap_base]
697
        mov     esi, [ebx+PROC.heap_base]
694
        mov     edi, [ebx+APPDATA.heap_top]
698
        mov     edi, [ebx+PROC.heap_top]
695
        cmp     edx, esi
699
        cmp     edx, esi
696
        jb      .error
700
        jb      .error
697
.scan:
701
.scan:
Line 706... Line 710...
706
        cmp     edx, ecx
710
        cmp     edx, ecx
707
        jb      .found
711
        jb      .found
708
        mov     esi, ecx
712
        mov     esi, ecx
709
        jmp     .scan
713
        jmp     .scan
710
.error:
714
.error:
-
 
715
        mov     ecx, [current_process]
-
 
716
        lea     ecx, [ecx+PROC.heap_lock]
-
 
717
        call    mutex_unlock
-
 
718
 
711
        xor     eax, eax
719
        xor     eax, eax
712
        pop     edi
720
        pop     edi
713
        pop     esi
721
        pop     esi
714
        pop     ebx
722
        pop     ebx
715
        ret
723
        ret
Line 757... Line 765...
757
        jz      .nothird
765
        jz      .nothird
758
        or      cl, FREE_BLOCK
766
        or      cl, FREE_BLOCK
759
        mov     [page_tabs+ebx*4], ecx
767
        mov     [page_tabs+ebx*4], ecx
Line 760... Line 768...
760
 
768
 
761
.nothird:
-
 
762
 
769
.nothird:
763
        mov     edx, [current_slot]
770
        mov     edx, [current_process]
764
        mov     ebx, [alloc_size]
771
        mov     ebx, [alloc_size]
765
        add     ebx, 0xFFF
772
        add     ebx, 0xFFF
-
 
773
        and     ebx, not 0xFFF
-
 
774
        add     [edx+PROC.mem_used], ebx
766
        and     ebx, not 0xFFF
775
 
767
        add     ebx, [edx+APPDATA.mem_size]
776
        lea     ecx, [edx+PROC.heap_lock]
Line 768... Line 777...
768
        call    update_mem_size
777
        call    mutex_unlock
Line 769... Line 778...
769
 
778
 
770
        mov     eax, [address]
779
        mov     eax, [address]
Line 780... Line 789...
780
 
789
 
Line 781... Line 790...
781
        push    esi
790
        push    esi
782
 
791
 
783
        mov     esi, [base]
792
        mov     esi, [base]
Line 784... Line 793...
784
        test    esi, esi
793
        test    esi, esi
Line -... Line 794...
-
 
794
        jz      .fail
-
 
795
 
-
 
796
        push    ebx
-
 
797
 
785
        jz      .exit
798
        mov     ebx, [current_process]
786
 
799
        lea     ecx, [ebx+PROC.heap_lock]
787
        push    ebx
800
        call    mutex_lock
788
 
801
 
789
        xor     ebx, ebx
802
        xor     ebx, ebx
Line 819... Line 832...
819
        jnz     .release
832
        jnz     .release
Line 820... Line 833...
820
 
833
 
821
.released:
834
.released:
Line 822... Line 835...
822
        push    edi
835
        push    edi
-
 
836
 
823
 
837
        mov     edx, [current_process]
824
        mov     edx, [current_slot]
838
        lea     ecx, [edx+PROC.heap_lock]
825
        mov     esi, dword [edx+APPDATA.heap_base]
839
        mov     esi, dword [edx+PROC.heap_base]
826
        mov     edi, dword [edx+APPDATA.heap_top]
840
        mov     edi, dword [edx+PROC.heap_top]
827
        sub     ebx, [edx+APPDATA.mem_size]
841
        sub     ebx, [edx+PROC.mem_used]
828
        neg     ebx
842
        neg     ebx
829
        call    update_mem_size
843
        mov     [edx+PROC.mem_used], ebx
830
        call    user_normalize
-
 
831
        pop     edi
-
 
832
        pop     ebx
-
 
833
        pop     esi
844
        call    user_normalize
-
 
845
        pop     edi
-
 
846
.exit:
834
        ret
847
        call    mutex_unlock
835
.exit:
848
 
-
 
849
        xor     eax, eax
836
        xor     eax, eax
850
        inc     eax
837
        inc     eax
851
        pop     ebx
-
 
852
        pop     esi
838
        pop     esi
853
        ret
-
 
854
 
-
 
855
.cantfree:
-
 
856
        mov     ecx, [current_process]
-
 
857
        lea     ecx, [ecx+PROC.heap_lock]
839
        ret
858
        jmp     .exit
840
.cantfree:
-
 
841
        xor     eax, eax
859
.fail:
842
        pop     ebx
860
        xor     eax, eax
843
        pop     esi
861
        pop     esi
Line 966... Line 984...
966
        push    ebx
984
        push    ebx
967
        call    user_alloc
985
        call    user_alloc
968
        ret
986
        ret
969
@@:
987
@@:
970
        push    ecx edx
988
        push    ecx edx
-
 
989
 
-
 
990
        push    eax
-
 
991
        mov     ecx, [current_process]
-
 
992
        lea     ecx, [ecx+PROC.heap_lock]
-
 
993
        call    mutex_lock
-
 
994
        pop     eax
-
 
995
 
971
        lea     ecx, [eax - 0x1000]
996
        lea     ecx, [eax - 0x1000]
972
        shr     ecx, 12
997
        shr     ecx, 12
973
        mov     edx, [page_tabs+ecx*4]
998
        mov     edx, [page_tabs+ecx*4]
974
        test    dl, USED_BLOCK
999
        test    dl, USED_BLOCK
975
        jnz     @f
1000
        jnz     @f
976
; attempt to realloc invalid pointer
1001
; attempt to realloc invalid pointer
977
.ret0:
1002
.ret0:
-
 
1003
        mov     ecx, [current_process]
-
 
1004
        lea     ecx, [ecx+PROC.heap_lock]
-
 
1005
        call    mutex_unlock
-
 
1006
 
978
        pop     edx ecx
1007
        pop     edx ecx
979
        xor     eax, eax
1008
        xor     eax, eax
980
        ret
1009
        ret
981
@@:
1010
@@:
982
        test    dl, DONT_FREE_BLOCK
1011
        test    dl, DONT_FREE_BLOCK
Line 1007... Line 1036...
1007
        sub     ebx, ecx
1036
        sub     ebx, ecx
1008
        cmp     ebx, 1
1037
        cmp     ebx, 1
1009
        jnz     .nofreeall
1038
        jnz     .nofreeall
1010
        mov     eax, [page_tabs+ecx*4]
1039
        mov     eax, [page_tabs+ecx*4]
1011
        and     eax, not 0xFFF
1040
        and     eax, not 0xFFF
1012
        mov     edx, [current_slot]
1041
        mov     edx, [current_process]
1013
        mov     ebx, [APPDATA.mem_size+edx]
1042
        mov     ebx, [edx+PROC.mem_used]
1014
        sub     ebx, eax
1043
        sub     ebx, eax
1015
        add     ebx, 0x1000
1044
        add     ebx, 0x1000
1016
        or      al, FREE_BLOCK
1045
        or      al, FREE_BLOCK
1017
        mov     [page_tabs+ecx*4], eax
1046
        mov     [page_tabs+ecx*4], eax
1018
        push    esi edi
1047
        push    esi edi
1019
        mov     esi, [APPDATA.heap_base+edx]
1048
        mov     esi, [edx+PROC.heap_base]
1020
        mov     edi, [APPDATA.heap_top+edx]
1049
        mov     edi, [edx+PROC.heap_top]
1021
        call    update_mem_size
1050
        mov     [edx+PROC.mem_used], ebx
1022
        call    user_normalize
1051
        call    user_normalize
1023
        pop     edi esi
1052
        pop     edi esi
1024
        jmp     .ret0   ; all freed
1053
        jmp     .ret0   ; all freed
1025
.nofreeall:
1054
.nofreeall:
1026
        sub     edx, ecx
1055
        sub     edx, ecx
Line 1028... Line 1057...
1028
        or      ebx, USED_BLOCK
1057
        or      ebx, USED_BLOCK
1029
        xchg    [page_tabs+ecx*4], ebx
1058
        xchg    [page_tabs+ecx*4], ebx
1030
        shr     ebx, 12
1059
        shr     ebx, 12
1031
        sub     ebx, edx
1060
        sub     ebx, edx
1032
        push    ebx ecx edx
1061
        push    ebx ecx edx
1033
        mov     edx, [current_slot]
1062
        mov     edx, [current_process]
1034
        shl     ebx, 12
1063
        shl     ebx, 12
1035
        sub     ebx, [APPDATA.mem_size+edx]
1064
        sub     ebx, [edx+PROC.mem_used]
1036
        neg     ebx
1065
        neg     ebx
1037
        call    update_mem_size
1066
        mov     [edx+PROC.mem_used], ebx
1038
        pop     edx ecx ebx
1067
        pop     edx ecx ebx
1039
        lea     eax, [ecx+1]
1068
        lea     eax, [ecx+1]
1040
        shl     eax, 12
1069
        shl     eax, 12
1041
        push    eax
1070
        push    eax
1042
        add     ecx, edx
1071
        add     ecx, edx
1043
        lea     edx, [ecx+ebx]
1072
        lea     edx, [ecx+ebx]
1044
        shl     ebx, 12
1073
        shl     ebx, 12
1045
        jz      .ret
1074
        jz      .ret
1046
        push    esi
1075
        push    esi
1047
        mov     esi, [current_slot]
1076
        mov     esi, [current_process]
1048
        mov     esi, [APPDATA.heap_top+esi]
1077
        mov     esi, [esi+PROC.heap_top]
1049
        shr     esi, 12
1078
        shr     esi, 12
1050
@@:
1079
@@:
1051
        cmp     edx, esi
1080
        cmp     edx, esi
1052
        jae     .merge_done
1081
        jae     .merge_done
1053
        mov     eax, [page_tabs+edx*4]
1082
        mov     eax, [page_tabs+edx*4]
Line 1062... Line 1091...
1062
.merge_done:
1091
.merge_done:
1063
        pop     esi
1092
        pop     esi
1064
        or      ebx, FREE_BLOCK
1093
        or      ebx, FREE_BLOCK
1065
        mov     [page_tabs+ecx*4], ebx
1094
        mov     [page_tabs+ecx*4], ebx
1066
.ret:
1095
.ret:
-
 
1096
        mov     ecx, [current_process]
-
 
1097
        lea     ecx, [ecx+PROC.heap_lock]
-
 
1098
        call    mutex_unlock
1067
        pop     eax edx ecx
1099
        pop     eax edx ecx
1068
        ret
1100
        ret
-
 
1101
 
1069
.realloc_add:
1102
.realloc_add:
1070
; get some additional memory
1103
; get some additional memory
1071
        mov     eax, [current_slot]
1104
        mov     eax, [current_process]
1072
        mov     eax, [APPDATA.heap_top+eax]
1105
        mov     eax, [eax+PROC.heap_top]
1073
        shr     eax, 12
1106
        shr     eax, 12
1074
        cmp     edx, eax
1107
        cmp     edx, eax
1075
        jae     .cant_inplace
1108
        jae     .cant_inplace
1076
        mov     eax, [page_tabs+edx*4]
1109
        mov     eax, [page_tabs+edx*4]
1077
        test    al, FREE_BLOCK
1110
        test    al, FREE_BLOCK
Line 1099... Line 1132...
1099
        sub     ebx, edx
1132
        sub     ebx, edx
1100
        mov     ecx, ebx
1133
        mov     ecx, ebx
1101
        cld
1134
        cld
1102
        rep stosd
1135
        rep stosd
1103
        pop     edi
1136
        pop     edi
1104
        mov     edx, [current_slot]
1137
        mov     edx, [current_process]
1105
        shl     ebx, 12
1138
        shl     ebx, 12
1106
        add     ebx, [APPDATA.mem_size+edx]
1139
        add     [edx+PROC.mem_used], ebx
-
 
1140
 
-
 
1141
        mov     ecx, [current_process]
-
 
1142
        lea     ecx, [ecx+PROC.heap_lock]
1107
        call    update_mem_size
1143
        call    mutex_unlock
1108
        pop     eax edx ecx
1144
        pop     eax edx ecx
1109
        ret
1145
        ret
-
 
1146
 
1110
.cant_inplace:
1147
.cant_inplace:
1111
        push    esi edi
1148
        push    esi edi
1112
        mov     eax, [current_slot]
1149
        mov     eax, [current_process]
1113
        mov     esi, [APPDATA.heap_base+eax]
1150
        mov     esi, [eax+PROC.heap_base]
1114
        mov     edi, [APPDATA.heap_top+eax]
1151
        mov     edi, [eax+PROC.heap_top]
1115
        shr     esi, 12
1152
        shr     esi, 12
1116
        shr     edi, 12
1153
        shr     edi, 12
1117
        sub     ebx, ecx
1154
        sub     ebx, ecx
1118
.find_place:
1155
.find_place:
1119
        cmp     esi, edi
1156
        cmp     esi, edi
Line 1172... Line 1209...
1172
        dec     ebx
1209
        dec     ebx
1173
        dec     edx
1210
        dec     edx
1174
        jnz     @b
1211
        jnz     @b
1175
.no:
1212
.no:
1176
        push    ebx
1213
        push    ebx
1177
        mov     edx, [current_slot]
1214
        mov     edx, [current_process]
1178
        shl     ebx, 12
1215
        shl     ebx, 12
1179
        add     ebx, [APPDATA.mem_size+edx]
1216
        add     [edx+PROC.mem_used], ebx
1180
        call    update_mem_size
-
 
1181
        pop     ebx
1217
        pop     ebx
1182
@@:
1218
@@:
1183
        mov     dword [page_tabs+esi*4], 2
1219
        mov     dword [page_tabs+esi*4], 2
1184
        inc     esi
1220
        inc     esi
1185
        dec     ebx
1221
        dec     ebx
1186
        jnz     @b
1222
        jnz     @b
1187
        pop     eax edi esi edx ecx
-
 
1188
        ret
-
 
Line 1189... Line -...
1189
 
-
 
1190
if 0
-
 
1191
align 4
-
 
1192
proc alloc_dll
-
 
1193
        pushf
-
 
1194
        cli
1223
 
1195
        bsf     eax, [dll_map]
-
 
1196
        jnz     .find
-
 
1197
        popf
-
 
1198
        xor     eax, eax
-
 
1199
        ret
-
 
1200
.find:
-
 
1201
        btr     [dll_map], eax
-
 
1202
        popf
-
 
1203
        shl     eax, 5
-
 
1204
        add     eax, dll_tab
-
 
1205
        ret
-
 
1206
endp
-
 
1207
 
-
 
1208
align 4
-
 
1209
proc alloc_service
-
 
1210
        pushf
-
 
1211
        cli
1224
        mov     ecx, [current_process]
1212
        bsf     eax, [srv_map]
1225
        lea     ecx, [ecx+PROC.heap_lock]
1213
        jnz     .find
-
 
1214
        popf
1226
        call    mutex_unlock
1215
        xor     eax, eax
-
 
1216
        ret
-
 
1217
.find:
-
 
1218
        btr     [srv_map], eax
-
 
1219
        popf
-
 
1220
        shl     eax, 0x02
-
 
1221
        lea     eax, [srv_tab+eax+eax*8] ;srv_tab+eax*36
1227
        pop     eax edi esi edx ecx
1222
        ret
-
 
Line 1223... Line -...
1223
endp
-
 
Line 1224... Line 1228...
1224
 
1228
        ret
Line 1225... Line 1229...
1225
end if
1229
 
1226
 
1230