MMInternal.h revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
0N/A * MM - Internal header file. 2362N/A * Copyright (C) 2006 InnoTek Systemberatung GmbH 2362N/A * This file is part of VirtualBox Open Source Edition (OSE), as 0N/A * you can redistribute it and/or modify it under the terms of the GNU 0N/A * General Public License as published by the Free Software Foundation, 0N/A * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE 0N/A * distribution. VirtualBox OSE is distributed in the hope that it will 0N/A * be useful, but WITHOUT ANY WARRANTY of any kind. 0N/A * If you received this file as part of a commercial VirtualBox 0N/A * distribution, then only the terms of your commercial VirtualBox 0N/A * license agreement apply instead of the previous paragraph. 0N/A#
error "Not in MM! This is an internal header!" 0N/A/** @defgroup grp_mm_int Internals 0N/A/** @name VM Ring-3 Heap Internals 0N/A/** @def MMR3HEAP_WITH_STATISTICS 0N/A * Enable MMR3Heap statistics. 0N/A/** @def MMR3HEAP_SIZE_ALIGNMENT 0N/A * The allocation size alignment of the MMR3Heap. 0N/A * Heap statistics record. 0N/A * There is one global and one per allocation tag. 0N/A /** Core avl node, key is the tag. */ 0N/A /** Pointer to the heap the memory belongs to. */ 0N/A /** Number of allocation. */ 0N/A /** Number of reallocations. */ 0N/A /** Number of frees. */ 0N/A /** Number of bytes allocated (sum). */ 0N/A /** Number of bytes freed. */ 0N/A /** Number of bytes currently allocated. */ 0N/A/** Pointer to heap statistics record. */ 0N/A * Additional heap block header for relating allocations to the VM. 0N/A /** Pointer to the next record. */ 0N/A /** Pointer to the previous record. */ 0N/A /** Pointer to the heap statistics record. 0N/A * (Where the a PVM can be found.) */ 0N/A /** Size of the allocation (including this header). */ 0N/A/** Pointer to MM heap header. */ 0N/A/** MM Heap structure. */ 0N/A /** Lock protecting the heap. */ 0N/A /** Heap block list head. */ 0N/A /** Heap block list tail. */ 0N/A /** Heap per tag statistics tree. */ 0N/A /** The VM handle. */ 0N/A /** Heap global statistics. */ 0N/A/** Pointer to MM Heap structure. */ 0N/A/** @name Hypervisor Heap Internals 0N/A/** @def MMHYPER_HEAP_FREE_DELAY 0N/A * If defined, it indicates the number of frees that should be delayed. 0N/A/** @def MMHYPER_HEAP_FREE_POISON 0N/A * If defined, it indicates that freed memory should be poisoned 0N/A * Hypervisor heap statistics record. 0N/A * There is one global and one per allocation tag. 0N/A /** Core avl node, key is the tag. 0N/A * @todo The type is wrong! Get your lazy a$$ over and create that offsetted uint32_t version we need here! */ 0N/A /** Aligning the 64-bit fields on a 64-bit line. */ 0N/A /** Indicator for whether these statistics are registered with STAM or not. */ 0N/A /** Number of allocation. */ 0N/A /** Number of frees. */ 0N/A /** Number of bytes allocated (sum). */ 0N/A /** Number of bytes freed (sum). */ 0N/A /** Number of bytes currently allocated. */ 0N/A /** Max number of bytes allocated. */ 0N/A/** Pointer to hypervisor heap statistics record. */ 0N/A * Hypervisor heap chunk. 0N/A /** Previous block in the list of all blocks. 0N/A * This is relative to the start of the heap. */ 0N/A /** Offset to the previous block relative to this one. */ 0N/A /** The statistics record this allocation belongs to (self relative). */ 0N/A /** Offset to the heap block (self relative). */ 0N/A/** Pointer to a hypervisor heap chunk. */ 0N/A * Hypervisor heap chunk. 0N/A /** Offset of the next chunk in the list of free nodes. */ 0N/A /** Offset of the previous chunk in the list of free nodes. */ 0N/A /** Size of the block. */ 0N/A/** Pointer to a free hypervisor heap chunk. */ 0N/A * The hypervisor heap. 0N/A /** The typical magic (MMHYPERHEAP_MAGIC). */ 0N/A /** The heap size. (This structure is not included!) */ 0N/A /** The HC Ring-3 address of the VM. */ 0N/A /** The HC Ring-3 address of the heap. */ 0N/A /** The GC address of the heap. */ 0N/A /** The GC address of the VM. */ 0N/A /** The amount of free memory in the heap. */ 0N/A /** Offset of the first free chunk in the heap. 0N/A * The offset is relative to the start of the heap. */ 0N/A /** Offset of the last free chunk in the heap. 0N/A * The offset is relative to the start of the heap. */ 0N/A /** Offset of the first page aligned block in the heap. 0N/A * The offset is equal to cbHeap initially. */ 0N/A /** Tree of hypervisor heap statistics. */ 0N/A /** Where to insert the next free. */ 0N/A /** Array of delayed frees. Circular. Offsets relative to this structure. */ 0N/A /** The free caller address. */ 0N/A /** The offset of the freed chunk. */ 0N/A /** Padding the structure to a 64-bit aligned size. */ 0N/A/** Pointer to the hypervisor heap. */ 0N/A/** Magic value for MMHYPERHEAP. (C. S. Lewis) */ 0N/A * Hypervisor heap minimum alignment (16 bytes). 0N/A * The aligned size of the the MMHYPERHEAP structure. 0N/A/** @name Hypervisor heap chunk flags. 0N/A * The flags are put in the first bits of the MMHYPERCHUNK::offPrev member. 0N/A * These bits aren't used anyway because of the chunk minimal alignment (16 bytes). 0N/A/** The chunk is free. (The code ASSUMES this is 0!) */ 0N/A/** The chunk is in use. */ 0N/A/** The type mask. */ 0N/A/** Checks if the chunk is free. */ 0N/A/** Checks if the chunk is used. */ 0N/A/** Gets the prev offset without the flags. */ 0N/A/** Sets the prev offset without changing the flags. */ 0N/A/** Clears one or more flags. */ 0N/A/** Sets one or more flags. */ 0N/A/** Checks if one is set. */ 0N/A/** @name Page Pool Internals 0N/A * About the allocation of this structrue. To keep the number of heap blocks, 0N/A * the number of heap calls, and fragmentation low we allocate all the data 0N/A * related to a MMPAGESUBPOOL node in one chunk. That means that after the 0N/A * bitmap (which is of variable size) comes the SUPPAGE records and then 0N/A * follows the lookup tree nodes. 0N/A /** Pointer to next sub pool. */ 0N/A /** Pointer to next sub pool in the free chain. 0N/A * This is NULL if we're not in the free chain or at the end of it. */ 0N/A /** Pointer to array of lock ranges. 0N/A * This is allocated together with the MMPAGESUBPOOL and thus needs no freeing. 0N/A * It follows immediately after the bitmap. 0N/A * The reserved field is a pointer to this structure. 0N/A /** Pointer to the first page. */ 0N/A /** Size of the subpool. */ 0N/A /** Number of free pages. */ 0N/A /** The allocation bitmap. 0N/A * This may extend beyond the end of the defined array size. 0N/A /* ... SUPPAGE aRanges[1]; */ 0N/A/** Pointer to page sub pool. */ 0N/A /** List of subpools. */ 0N/A /** Head of subpools with free pages. */ 0N/A /** AVLPV tree for looking up HC virtual addresses. 0N/A * The tree contains MMLOOKUPVIRTPP records. 0N/A /** Tree for looking up HC physical addresses. 0N/A * The tree contains MMLOOKUPPHYSHC records. 0N/A /** Pointer to the VM this pool belongs. */ 0N/A /** Flag indicating the allocation method. 0N/A * Set: SUPLowAlloc(). 0N/A * Clear: SUPPageAlloc() + SUPPageLock(). */ 0N/A /** Number of subpools. */ 0N/A /** Number of pages in pool. */ 0N/A /** Number of free pages in pool. */ 0N/A /** Number of alloc calls. */ 0N/A /** Number of free calls. */ 0N/A /** Number of to phys conversions. */ 0N/A /** Number of to virtual conversions. */ 0N/A /** Number of real errors. */ 0N/A/** Pointer to page pool. */ 0N/A * Lookup record for HC virtual memory in the page pool. 0N/A /** The key is virtual address. */ 0N/A /** Pointer to subpool if lookup record for a pool. */ 0N/A/** Pointer to virtual memory lookup record. */ 0N/A * Lookup record for HC physical memory. 0N/A /** The key is physical address. */ 0N/A /** Pointer to SUPPAGE record for this physical address. */ 0N/A/** Pointer to physical memory lookup record. */ 0N/A * Type of memory that's locked. 0N/A /** Hypervisor memory (VMM GC). */ 0N/A /** Hypervisor memory to be mapped from HC. */ 0N/A /** Physical VM memory (RAM & MMIO2). */ 0N/A/** Pointer to memory type. */ 0N/A * Converts a SUPPAGE pointer to a MMLOCKEDMEM pointer. 0N/A * @returns Pointer to the MMLOCKEDMEM record the range is associated with. 0N/A * @param pSupPage Pointer to SUPPAGE structure managed by MM. 0N/A * Locked memory record. 0N/A /** Address (host mapping). */ 0N/A /** Type specific data. */ 0N/A /** Data for MM_LOCKED_TYPE_HYPER. */ 0N/A /** Data for MM_LOCKED_TYPE_PHYS. */ 0N/A /** The GC physical address. 0N/A * (Assuming that this is a linear range of GC physical pages.) 0N/A /** Physical Page Array. (Variable length.) 0N/A * The uReserved field contains pointer to the MMLOCKMEM record. 0N/A * Use the macro MM_SUPPAGE_TO_MMLOCKEDMEM() to convert. 0N/A * For MM_LOCKED_TYPE_PHYS the low 12 bits of the pvPhys member 0N/A * are bits (MM_RAM_FLAGS_*) and not part of the physical address. 0N/A/** Pointer to locked memory. */ 0N/A * Hypervisor memory mapping type. 0N/A /** Invalid record. This is used for record which are incomplete. */ 0N/A /** Mapping of locked memory. */ 0N/A /** Mapping of contiguous HC physical memory. */ 0N/A /** Mapping of contiguous GC physical memory. */ 0N/A /** Dynamic mapping area (MMR3HyperReserve). 0N/A * A conversion will require to check what's in the page table for the pages. */ 0N/A * Lookup record for the hypervisor memory area. 0N/A /** Byte offset from the start of this record to the next. 0N/A * If the value is NIL_OFFSET the chain is terminated. */ 0N/A /** Offset into the hypvervisor memory area. */ 0N/A /** Size of this part. */ 0N/A /** Locking type. */ 0N/A /** Type specific data */ 0N/A /** Locked memory. */ 0N/A /** Host context pointer. */ 0N/A /** Pointer to the locked mem record. */ 0N/A /** Contiguous physical memory. */ 0N/A /** Host context pointer. */ 0N/A /** HC physical address corresponding to pvHC. */ 0N/A /** Contiguous guest physical memory. */ 0N/A /** HC physical address corresponding to pvHC. */ 0N/A/** Pointer to a hypervisor memory lookup record. */ 0N/A * Converts a MM pointer into a VM pointer. 0N/A * @returns Pointer to the VM structure the MM is part of. 0N/A * @param pMM Pointer to MM instance data. 0N/A * MM Data (part of VM) 0N/A /** Offset to the VM structure. 0N/A /** Set if PGM has been initialized and we can safely call PGMR3Map(). */ 0N/A /** Lookup list for the Hypervisor Memory Area. 0N/A * The offset is relative to the start of the heap. 0N/A * Use pHyperHeapHC or pHyperHeapGC to calculate the address. 0N/A /** The offset of the next static mapping in the Hypervisor Memory Area. */ 0N/A /** The size of the HMA. 0N/A * Starts at 12MB and will be fixed late in the init process. */ 0N/A /** Guest address of the Hypervisor Memory Area. */ 0N/A /** The hypervisor heap (GC Ptr). */ 0N/A /** The hypervisor heap (HC Ptr). */ 0N/A /** List of memory locks. (HC only) */ 0N/A /** Page pool. (HC only) */ /** Page pool pages in low memory. (HC only) */ /** Pointer to the dummy page. * The dummy page is a paranoia thingy used for instance for pure MMIO RAM ranges * to make sure any bugs will not harm whatever the system stores in the first /** Physical address of the dummy page. */ /** Size of the currently allocated guest RAM. * Mark that this is the actual size, not the end address. */ /** Size of the base RAM in bytes. */ /** Pointer to the base RAM. */ /** Pointer to the MM R3 Heap. */ /** Pointer to MM Data (part of VM). */ * Converts a pool address to a physical address. * The specified allocation type must match with the address. * @returns Physical address. * @returns NIL_RTHCPHYS if not found or eType is not matching. * @param pPool Pointer to the page pool. * @param pv The address to convert. * @thread The Emulation Thread. * Converts a pool physical address to a linear address. * The specified allocation type must match with the address. * @returns Physical address. * @returns NULL if not found or eType is not matching. * @param pPool Pointer to the page pool. * @param HCPhys The address to convert. * @thread The Emulation Thread.