Rev 4430 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4430 | Rev 4432 | ||
---|---|---|---|
Line 563... | Line 563... | ||
563 | HEAP_TOP equ 0x80000000 |
563 | HEAP_TOP equ 0x80000000 |
Line 564... | Line 564... | ||
564 | 564 | ||
565 | align 4 |
565 | align 4 |
Line 566... | Line 566... | ||
566 | proc init_heap |
566 | proc init_heap |
567 | - | ||
568 | mov ebx, [current_slot] |
567 | |
569 | mov ebx, [ebx+APPDATA.process] |
568 | mov ebx, [current_process] |
570 | mov eax, [ebx+PROC.heap_top] |
569 | mov eax, [ebx+PROC.heap_top] |
571 | test eax, eax |
570 | test eax, eax |
572 | jz @F |
571 | jz @F |
Line 600... | Line 599... | ||
600 | 599 | ||
601 | mov ecx, [alloc_size] |
600 | mov ecx, [alloc_size] |
602 | add ecx, (4095+PAGE_SIZE) |
601 | add ecx, (4095+PAGE_SIZE) |
Line 603... | Line 602... | ||
603 | and ecx, not 4095 |
602 | and ecx, not 4095 |
604 | - | ||
605 | mov ebx, [current_slot] |
603 | |
606 | mov ebx, [ebx+APPDATA.process] |
604 | mov ebx, [current_process] |
607 | mov esi, dword [ebx+PROC.heap_base] ; heap_base |
605 | mov esi, dword [ebx+PROC.heap_base] ; heap_base |
608 | mov edi, dword [ebx+PROC.heap_top] ; heap_top |
606 | mov edi, dword [ebx+PROC.heap_top] ; heap_top |
609 | .scan: |
607 | .scan: |
Line 637... | Line 635... | ||
637 | inc ebx |
635 | inc ebx |
638 | dec ecx |
636 | dec ecx |
639 | jnz @B |
637 | jnz @B |
640 | .no: |
638 | .no: |
Line 641... | Line 639... | ||
641 | 639 | ||
642 | mov edx, [current_slot] |
- | |
643 | mov edx, [edx+APPDATA.process] |
- | |
644 | 640 | mov edx, [current_process] |
|
645 | mov ebx, [alloc_size] |
641 | mov ebx, [alloc_size] |
646 | add ebx, 0xFFF |
642 | add ebx, 0xFFF |
647 | and ebx, not 0xFFF |
643 | and ebx, not 0xFFF |
Line 674... | Line 670... | ||
674 | 670 | ||
675 | push ebx |
671 | push ebx |
676 | push esi |
672 | push esi |
Line 677... | Line 673... | ||
677 | push edi |
673 | push edi |
678 | - | ||
Line 679... | Line 674... | ||
679 | mov ebx, [current_slot] |
674 | |
680 | mov ebx, [ebx+APPDATA.process] |
675 | mov ebx, [current_process] |
681 | 676 | ||
682 | mov edx, [address] |
677 | mov edx, [address] |
Line 751... | Line 746... | ||
751 | jz .nothird |
746 | jz .nothird |
752 | or cl, FREE_BLOCK |
747 | or cl, FREE_BLOCK |
753 | mov [page_tabs+ebx*4], ecx |
748 | mov [page_tabs+ebx*4], ecx |
Line 754... | Line 749... | ||
754 | 749 | ||
755 | .nothird: |
750 | .nothird: |
756 | mov edx, [current_slot] |
- | |
757 | mov edx, [edx+APPDATA.process] |
- | |
758 | 751 | mov edx, [current_process] |
|
759 | mov ebx, [alloc_size] |
752 | mov ebx, [alloc_size] |
760 | add ebx, 0xFFF |
753 | add ebx, 0xFFF |
761 | and ebx, not 0xFFF |
754 | and ebx, not 0xFFF |
Line 813... | Line 806... | ||
813 | jnz .release |
806 | jnz .release |
Line 814... | Line 807... | ||
814 | 807 | ||
815 | .released: |
808 | .released: |
Line 816... | Line 809... | ||
816 | push edi |
809 | push edi |
817 | - | ||
818 | mov edx, [current_slot] |
810 | |
819 | mov edx, [edx+APPDATA.process] |
811 | mov edx, [current_process] |
820 | mov esi, dword [edx+PROC.heap_base] |
812 | mov esi, dword [edx+PROC.heap_base] |
821 | mov edi, dword [edx+PROC.heap_top] |
813 | mov edi, dword [edx+PROC.heap_top] |
822 | sub ebx, [edx+PROC.mem_used] |
814 | sub ebx, [edx+PROC.mem_used] |
Line 1002... | Line 994... | ||
1002 | sub ebx, ecx |
994 | sub ebx, ecx |
1003 | cmp ebx, 1 |
995 | cmp ebx, 1 |
1004 | jnz .nofreeall |
996 | jnz .nofreeall |
1005 | mov eax, [page_tabs+ecx*4] |
997 | mov eax, [page_tabs+ecx*4] |
1006 | and eax, not 0xFFF |
998 | and eax, not 0xFFF |
1007 | mov edx, [current_slot] |
999 | mov edx, [current_process] |
1008 | mov edx, [edx+APPDATA.process] |
- | |
1009 | mov ebx, [edx+PROC.mem_used] |
1000 | mov ebx, [edx+PROC.mem_used] |
1010 | sub ebx, eax |
1001 | sub ebx, eax |
1011 | add ebx, 0x1000 |
1002 | add ebx, 0x1000 |
1012 | or al, FREE_BLOCK |
1003 | or al, FREE_BLOCK |
1013 | mov [page_tabs+ecx*4], eax |
1004 | mov [page_tabs+ecx*4], eax |
Line 1024... | Line 1015... | ||
1024 | or ebx, USED_BLOCK |
1015 | or ebx, USED_BLOCK |
1025 | xchg [page_tabs+ecx*4], ebx |
1016 | xchg [page_tabs+ecx*4], ebx |
1026 | shr ebx, 12 |
1017 | shr ebx, 12 |
1027 | sub ebx, edx |
1018 | sub ebx, edx |
1028 | push ebx ecx edx |
1019 | push ebx ecx edx |
1029 | mov edx, [current_slot] |
1020 | mov edx, [current_process] |
1030 | mov edx, [edx+APPDATA.process] |
- | |
1031 | shl ebx, 12 |
1021 | shl ebx, 12 |
1032 | sub ebx, [edx+PROC.mem_used] |
1022 | sub ebx, [edx+PROC.mem_used] |
1033 | neg ebx |
1023 | neg ebx |
1034 | mov [edx+PROC.mem_used], ebx |
1024 | mov [edx+PROC.mem_used], ebx |
1035 | pop edx ecx ebx |
1025 | pop edx ecx ebx |
Line 1039... | Line 1029... | ||
1039 | add ecx, edx |
1029 | add ecx, edx |
1040 | lea edx, [ecx+ebx] |
1030 | lea edx, [ecx+ebx] |
1041 | shl ebx, 12 |
1031 | shl ebx, 12 |
1042 | jz .ret |
1032 | jz .ret |
1043 | push esi |
1033 | push esi |
1044 | mov esi, [current_slot] |
1034 | mov esi, [current_process] |
1045 | mov esi, [esi+APPDATA.process] |
- | |
1046 | mov esi, [esi+PROC.heap_top] |
1035 | mov esi, [esi+PROC.heap_top] |
1047 | shr esi, 12 |
1036 | shr esi, 12 |
1048 | @@: |
1037 | @@: |
1049 | cmp edx, esi |
1038 | cmp edx, esi |
1050 | jae .merge_done |
1039 | jae .merge_done |
Line 1064... | Line 1053... | ||
1064 | .ret: |
1053 | .ret: |
1065 | pop eax edx ecx |
1054 | pop eax edx ecx |
1066 | ret |
1055 | ret |
1067 | .realloc_add: |
1056 | .realloc_add: |
1068 | ; get some additional memory |
1057 | ; get some additional memory |
1069 | mov eax, [current_slot] |
1058 | mov eax, [current_process] |
1070 | mov eax, [eax+APPDATA.process] |
- | |
1071 | mov eax, [eax+PROC.heap_top] |
1059 | mov eax, [eax+PROC.heap_top] |
1072 | shr eax, 12 |
1060 | shr eax, 12 |
1073 | cmp edx, eax |
1061 | cmp edx, eax |
1074 | jae .cant_inplace |
1062 | jae .cant_inplace |
1075 | mov eax, [page_tabs+edx*4] |
1063 | mov eax, [page_tabs+edx*4] |
Line 1098... | Line 1086... | ||
1098 | sub ebx, edx |
1086 | sub ebx, edx |
1099 | mov ecx, ebx |
1087 | mov ecx, ebx |
1100 | cld |
1088 | cld |
1101 | rep stosd |
1089 | rep stosd |
1102 | pop edi |
1090 | pop edi |
1103 | mov edx, [current_slot] |
1091 | mov edx, [current_process] |
1104 | mov edx, [edx+APPDATA.process] |
- | |
1105 | shl ebx, 12 |
1092 | shl ebx, 12 |
1106 | add [edx+PROC.mem_used], ebx |
1093 | add [edx+PROC.mem_used], ebx |
1107 | pop eax edx ecx |
1094 | pop eax edx ecx |
1108 | ret |
1095 | ret |
1109 | .cant_inplace: |
1096 | .cant_inplace: |
1110 | push esi edi |
1097 | push esi edi |
1111 | mov eax, [current_slot] |
1098 | mov eax, [current_process] |
1112 | mov eax, [eax+APPDATA.process] |
- | |
1113 | mov esi, [eax+PROC.heap_base] |
1099 | mov esi, [eax+PROC.heap_base] |
1114 | mov edi, [eax+PROC.heap_top] |
1100 | mov edi, [eax+PROC.heap_top] |
1115 | shr esi, 12 |
1101 | shr esi, 12 |
1116 | shr edi, 12 |
1102 | shr edi, 12 |
1117 | sub ebx, ecx |
1103 | sub ebx, ecx |
Line 1172... | Line 1158... | ||
1172 | dec ebx |
1158 | dec ebx |
1173 | dec edx |
1159 | dec edx |
1174 | jnz @b |
1160 | jnz @b |
1175 | .no: |
1161 | .no: |
1176 | push ebx |
1162 | push ebx |
1177 | mov edx, [current_slot] |
1163 | mov edx, [current_process] |
1178 | mov edx, [eax+APPDATA.process] |
- | |
1179 | shl ebx, 12 |
1164 | shl ebx, 12 |
1180 | add [edx+PROC.mem_used], ebx |
1165 | add [edx+PROC.mem_used], ebx |
1181 | pop ebx |
1166 | pop ebx |
1182 | @@: |
1167 | @@: |
1183 | mov dword [page_tabs+esi*4], 2 |
1168 | mov dword [page_tabs+esi*4], 2 |