Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmm.h
Go to the documentation of this file.
00001 /* 00002 * FreeLoader 00003 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #pragma once 00021 00022 typedef struct _FREELDR_MEMORY_DESCRIPTOR 00023 { 00024 TYPE_OF_MEMORY MemoryType; 00025 PFN_NUMBER BasePage; 00026 PFN_NUMBER PageCount; 00027 } FREELDR_MEMORY_DESCRIPTOR, *PFREELDR_MEMORY_DESCRIPTOR; 00028 00029 00030 #if defined(__i386__) || defined(_PPC_) || defined(_MIPS_) || defined(_ARM_) 00031 00032 #define MM_PAGE_SIZE 4096 00033 #define MM_PAGE_MASK 0xFFF 00034 #define MM_PAGE_SHIFT 12 00035 #define MM_MAX_PAGE 0xFFFFF 00036 00037 #define MM_SIZE_TO_PAGES(a) \ 00038 ( ((a) >> MM_PAGE_SHIFT) + ((a) & MM_PAGE_MASK ? 1 : 0) ) 00039 00040 #endif // defined __i386__ or _PPC_ or _MIPS_ 00041 00042 #if defined (_AMD64_) 00043 00044 #define MM_PAGE_SIZE 4096 00045 #define MM_PAGE_MASK 0xFFF 00046 #define MM_PAGE_SHIFT 12 00047 // FIXME: freeldr implementation uses ULONG for page numbers 00048 #define MM_MAX_PAGE 0xFFFFFFFFFFFFF 00049 00050 #define MM_SIZE_TO_PAGES(a) \ 00051 ( ((a) >> MM_PAGE_SHIFT) + ((a) & MM_PAGE_MASK ? 1 : 0) ) 00052 00053 #endif 00054 00055 // HEAP and STACK size 00056 #define HEAP_PAGES 0x400 00057 #define STACK_PAGES 0x00 00058 00059 #include <pshpack1.h> 00060 typedef struct 00061 { 00062 TYPE_OF_MEMORY PageAllocated; // Type of allocated memory (LoaderFree if this memory is free) 00063 PFN_NUMBER PageAllocationLength; // Number of pages allocated (or zero if this isn't the first page in the chain) 00064 } PAGE_LOOKUP_TABLE_ITEM, *PPAGE_LOOKUP_TABLE_ITEM; 00065 #include <poppack.h> 00066 00067 // 00068 // Define this to 1 if you want the entire contents 00069 // of the memory allocation bitmap displayed 00070 // when a chunk is allocated or freed 00071 // 00072 #define DUMP_MEM_MAP_ON_VERIFY 0 00073 00074 extern PVOID PageLookupTableAddress; 00075 extern PFN_NUMBER TotalPagesInLookupTable; 00076 extern PFN_NUMBER FreePagesInLookupTable; 00077 extern PFN_NUMBER LastFreePageHint; 00078 00079 #if DBG 00080 PCSTR MmGetSystemMemoryMapTypeString(TYPE_OF_MEMORY Type); 00081 #endif 00082 00083 PFN_NUMBER MmGetPageNumberFromAddress(PVOID Address); // Returns the page number that contains a linear address 00084 PFN_NUMBER MmGetAddressablePageCountIncludingHoles(VOID); // Returns the count of addressable pages from address zero including any memory holes and reserved memory regions 00085 PVOID MmFindLocationForPageLookupTable(PFN_NUMBER TotalPageCount); // Returns the address for a memory chunk big enough to hold the page lookup table (starts search from end of memory) 00086 VOID MmInitPageLookupTable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount); // Inits the page lookup table according to the memory types in the memory map 00087 VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER StartPage, PFN_NUMBER PageCount, TYPE_OF_MEMORY PageAllocated); // Marks the specified pages as allocated or free in the lookup table 00088 VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER StartPage, PFN_NUMBER PageCount, TYPE_OF_MEMORY MemoryType); // Allocates the specified pages in the lookup table 00089 PFN_NUMBER MmCountFreePagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount); // Returns the number of free pages in the lookup table 00090 PFN_NUMBER MmFindAvailablePages(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PFN_NUMBER PagesNeeded, BOOLEAN FromEnd); // Returns the page number of the first available page range from the beginning or end of memory 00091 PFN_NUMBER MmFindAvailablePagesBeforePage(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PFN_NUMBER PagesNeeded, PFN_NUMBER LastPage); // Returns the page number of the first available page range before the specified page 00092 VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, PFN_NUMBER TotalPageCount); // Sets the LastFreePageHint to the last usable page of memory 00093 BOOLEAN MmAreMemoryPagesAvailable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PVOID PageAddress, PFN_NUMBER PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE 00094 VOID MmSetMemoryType(PVOID MemoryAddress, SIZE_T MemorySize, TYPE_OF_MEMORY NewType); // Use with EXTREME caution! 00095 00096 PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(PFN_NUMBER *NoEntries); // Returns a pointer to the memory mapping table and a number of entries in it 00097 00098 00099 //BOOLEAN MmInitializeMemoryManager(ULONG LowMemoryStart, ULONG LowMemoryLength); 00100 BOOLEAN MmInitializeMemoryManager(VOID); 00101 VOID MmInitializeHeap(PVOID PageLookupTable); 00102 PVOID MmAllocateMemory(SIZE_T MemorySize); 00103 PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType); 00104 VOID MmFreeMemory(PVOID MemoryPointer); 00105 PVOID MmAllocateMemoryAtAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType); 00106 PVOID MmAllocateHighestMemoryBelowAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType); 00107 00108 PVOID MmHeapAlloc(SIZE_T MemorySize); 00109 VOID MmHeapFree(PVOID MemoryPointer); 00110 00111 /* Heap */ 00112 extern PVOID FrLdrDefaultHeap; 00113 extern PVOID FrLdrTempHeap; 00114 00115 PVOID 00116 HeapCreate( 00117 SIZE_T MaximumSize, 00118 TYPE_OF_MEMORY MemoryType); 00119 00120 VOID 00121 HeapDestroy( 00122 PVOID HeapHandle); 00123 00124 VOID 00125 HeapRelease( 00126 PVOID HeapHandle); 00127 00128 VOID 00129 HeapCleanupAll(VOID); 00130 00131 PVOID 00132 HeapAllocate( 00133 PVOID HeapHandle, 00134 SIZE_T ByteSize, 00135 ULONG Tag); 00136 00137 VOID 00138 HeapFree( 00139 PVOID HeapHandle, 00140 PVOID Pointer, 00141 ULONG Tag); 00142 Generated on Sun May 27 2012 04:19:14 for ReactOS by
1.7.6.1
|