#include <Uefi.h>
#include <Guid/MemoryAttributesTable.h>
#include <IndustryStandard/VirtualMemory.h>
Go to the source code of this file.
Data Structures | |
struct | OC_MEMORY_TYPE_DESC |
struct | OC_VMEM_CONTEXT_ |
Macros | |
#define | PREV_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) |
#define | LAST_DESCRIPTOR_ADDR(Desc) |
#define | AREA_WITHIN_DESCRIPTOR(Desc, Area, AreaSize) |
#define | OC_DEFAULT_VMEM_PAGE_COUNT 0x200 |
#define | OC_DEFAULT_MEMORY_MAP_SIZE (EFI_PAGE_SIZE*3) |
#define | OC_MEMORY_TYPE_DESC_COUNT 16 |
Typedefs | |
typedef BOOLEAN(* | CHECK_ALLOCATION_RANGE) (IN EFI_PHYSICAL_ADDRESS Address, IN UINTN Size) |
typedef VOID(* | OC_MEMORY_FILTER) (IN VOID *Context OPTIONAL, IN UINTN MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize) |
typedef struct OC_VMEM_CONTEXT_ | OC_VMEM_CONTEXT |
Functions | |
EFI_STATUS | LegacyRegionLock (IN UINT32 LegacyAddress, IN UINT32 LegacyLength) |
EFI_STATUS | LegacyRegionUnlock (IN UINT32 LegacyAddress, IN UINT32 LegacyLength) |
EFI_MEMORY_DESCRIPTOR * | OcGetCurrentMemoryMap (OUT UINTN *MemoryMapSize, OUT UINTN *DescriptorSize, OUT UINTN *MapKey OPTIONAL, OUT UINT32 *DescriptorVersion OPTIONAL, OUT UINTN *OriginalMemoryMapSize OPTIONAL, IN BOOLEAN IncludeSplitSpace) |
EFI_STATUS | OcGetCurrentMemoryMapAlloc (OUT UINTN *MemoryMapSize, OUT EFI_MEMORY_DESCRIPTOR **MemoryMap, OUT UINTN *MapKey, OUT UINTN *DescriptorSize, OUT UINT32 *DescriptorVersion, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL, IN OUT EFI_PHYSICAL_ADDRESS *TopMemory OPTIONAL) |
VOID | OcSortMemoryMap (IN UINTN MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize) |
EFI_STATUS | OcShrinkMemoryMap (IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize) |
EFI_STATUS | OcDeduplicateDescriptors (IN OUT UINT32 *EntryCount, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize) |
EFI_STATUS | OcAllocatePagesFromTop (IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, IN OUT EFI_PHYSICAL_ADDRESS *Memory, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL, IN EFI_ALLOCATE_PAGES AllocatePages OPTIONAL, IN CHECK_ALLOCATION_RANGE CheckRange OPTIONAL) |
UINT64 | OcCountRuntimePages (IN UINTN MemoryMapSize, IN EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize, OUT UINTN *DescriptorCount OPTIONAL) |
UINTN | OcCountFreePages (OUT UINTN *LowerMemory OPTIONAL) |
VOID | OcPrintMemoryAttributesTable (VOID) |
VOID | OcPrintMemoryMap (IN UINTN MemoryMapSize, IN EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize) |
EFI_STATUS | OcUpdateDescriptors (IN UINTN MemoryMapSize, IN EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize, IN EFI_PHYSICAL_ADDRESS Address, IN EFI_MEMORY_TYPE Type, IN UINT64 SetAttributes, IN UINT64 DropAttributes) |
EFI_MEMORY_ATTRIBUTES_TABLE * | OcGetMemoryAttributes (OUT EFI_MEMORY_DESCRIPTOR **MemoryAttributesEntry OPTIONAL) |
EFI_STATUS | OcRebuildAttributes (IN EFI_PHYSICAL_ADDRESS Address, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL) |
UINTN | OcCountSplitDescriptors (VOID) |
EFI_STATUS | OcSplitMemoryMapByAttributes (IN UINTN MaxMemoryMapSize, IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize) |
BOOLEAN | OcIsPatSupported (VOID) |
CHAR8 * | OcGetMtrrTypeString (UINT8 MtrrType) |
CHAR8 * | OcGetPatTypeString (UINT8 PatType) |
PAGE_MAP_AND_DIRECTORY_POINTER * | OcGetCurrentPageTable (OUT UINTN *Flags OPTIONAL) |
EFI_STATUS | OcGetPhysicalAddress (IN PAGE_MAP_AND_DIRECTORY_POINTER *PageTable OPTIONAL, IN EFI_VIRTUAL_ADDRESS VirtualAddr, OUT EFI_PHYSICAL_ADDRESS *PhysicalAddr) |
EFI_STATUS | OcGetSetPageTableInfoForAddress (IN PAGE_MAP_AND_DIRECTORY_POINTER *PageTable OPTIONAL, IN EFI_VIRTUAL_ADDRESS VirtualAddr, OUT EFI_PHYSICAL_ADDRESS *PhysicalAddr OPTIONAL, OUT UINT8 *Level OPTIONAL, OUT UINT64 *Bits OPTIONAL, IN OUT PAT_INDEX *PatIndex OPTIONAL, IN BOOLEAN SetPat) |
EFI_STATUS | OcSetPatIndexForAddressRange (IN PAGE_MAP_AND_DIRECTORY_POINTER *PageTable OPTIONAL, IN EFI_VIRTUAL_ADDRESS VirtualAddr, IN UINT64 Length, IN PAT_INDEX *PatIndex) |
EFI_STATUS | OcDescToMemoryType (IN CHAR8 *MemoryTypeDesc, OUT EFI_MEMORY_TYPE *MemoryType) |
EFI_STATUS | OcModifyMtrrRange (IN EFI_PHYSICAL_ADDRESS Address, IN UINT8 MtrrType, OUT UINT64 *Length OPTIONAL) |
EFI_STATUS | VmAllocateMemoryPool (OUT OC_VMEM_CONTEXT *Context, IN UINTN NumPages, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL) |
VOID * | VmAllocatePages (IN OUT OC_VMEM_CONTEXT *Context, IN UINTN NumPages) |
EFI_STATUS | VmMapVirtualPage (IN OUT OC_VMEM_CONTEXT *Context, IN OUT PAGE_MAP_AND_DIRECTORY_POINTER *PageTable OPTIONAL, IN EFI_VIRTUAL_ADDRESS VirtualAddr, IN EFI_PHYSICAL_ADDRESS PhysicalAddr) |
EFI_STATUS | VmMapVirtualPages (IN OUT OC_VMEM_CONTEXT *Context, IN OUT PAGE_MAP_AND_DIRECTORY_POINTER *PageTable OPTIONAL, IN EFI_VIRTUAL_ADDRESS VirtualAddr, IN UINT64 NumPages, IN EFI_PHYSICAL_ADDRESS PhysicalAddr) |
VOID | VmFlushCaches (VOID) |
BOOLEAN | UmmInitialized (VOID) |
VOID | UmmSetHeap (IN VOID *Heap, IN UINT32 Size) |
VOID * | UmmMalloc (IN UINT32 Size) |
BOOLEAN | UmmFree (IN VOID *Ptr) |
Copyright (C) 2019, vit9696. All rights reserved.
All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Definition in file OcMemoryLib.h.
#define AREA_WITHIN_DESCRIPTOR | ( | Desc, | |
Area, | |||
AreaSize ) |
Check if area is within the specified descriptor. It is assumed that the descriptor contains pages and AreaSize is not 0.
Definition at line 39 of file OcMemoryLib.h.
#define LAST_DESCRIPTOR_ADDR | ( | Desc | ) |
Get last descriptor address. It is assumed that the descriptor contains pages.
Definition at line 32 of file OcMemoryLib.h.
#define OC_DEFAULT_MEMORY_MAP_SIZE (EFI_PAGE_SIZE*3) |
Reasonable default memory map size used when allocations are problematic. Note, that MacPro5,1 is known to have 8880 memory map.
Definition at line 51 of file OcMemoryLib.h.
#define OC_DEFAULT_VMEM_PAGE_COUNT 0x200 |
Reasonable default virtual memory page pool size (2 MB).
Definition at line 45 of file OcMemoryLib.h.
#define OC_MEMORY_TYPE_DESC_COUNT 16 |
Definition at line 53 of file OcMemoryLib.h.
#define PREV_MEMORY_DESCRIPTOR | ( | MemoryDescriptor, | |
Size ) |
Reverse equivalent of NEXT_MEMORY_DESCRIPTOR.
Definition at line 25 of file OcMemoryLib.h.
typedef BOOLEAN(* CHECK_ALLOCATION_RANGE) (IN EFI_PHYSICAL_ADDRESS Address, IN UINTN Size) |
Check range allocation compatibility callback.
[in] | Address | Starting address. |
[in] | Size | Size of memory range. |
TRUE | when suitable for allocation. |
Definition at line 193 of file OcMemoryLib.h.
typedef VOID(* OC_MEMORY_FILTER) (IN VOID *Context OPTIONAL, IN UINTN MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize) |
Filter memory map entries.
[in] | Context | Parameterised filter data. |
[in,out] | MemoryMapSize | Memory map size in bytes. |
[in,out] | MemoryMap | Memory map to filter. |
[in] | DescriptorSize | Memory map descriptor size in bytes. |
Definition at line 208 of file OcMemoryLib.h.
typedef struct OC_VMEM_CONTEXT_ OC_VMEM_CONTEXT |
Virtual memory context
EFI_STATUS LegacyRegionLock | ( | IN UINT32 | LegacyAddress, |
IN UINT32 | LegacyLength ) |
Lock the legacy region specified to enable modification.
[in] | LegacyAddress | The address of the region to lock. |
[in] | LegacyLength | The size of the region to lock. |
EFI_SUCCESS | The region was locked successfully. |
Definition at line 43 of file LegacyRegionLock.c.
EFI_STATUS LegacyRegionUnlock | ( | IN UINT32 | LegacyAddress, |
IN UINT32 | LegacyLength ) |
Unlock the legacy region specified to enable modification.
[in] | LegacyAddress | The address of the region to unlock. |
[in] | LegacyLength | The size of the region to unlock. |
EFI_SUCCESS | The region was unlocked successfully. |
Definition at line 43 of file LegacyRegionUnLock.c.
EFI_STATUS OcAllocatePagesFromTop | ( | IN EFI_MEMORY_TYPE | MemoryType, |
IN UINTN | Pages, | ||
IN OUT EFI_PHYSICAL_ADDRESS * | Memory, | ||
IN EFI_GET_MEMORY_MAP GetMemoryMap | OPTIONAL, | ||
IN EFI_ALLOCATE_PAGES AllocatePages | OPTIONAL, | ||
IN CHECK_ALLOCATION_RANGE CheckRange | OPTIONAL ) |
Allocate pages from the top of physical memory up to address specified in Memory. Unlike AllocateMaxAddress, this method guarantees to choose top most address.
[in] | MemoryType | Allocated memory type. |
[in] | Pages | Amount of pages to allocate. |
[in,out] | Memory | Top address for input, allocated address for output. |
[in] | GetMemoryMap | Custom GetMemoryMap implementation to use, optional. |
[in] | AllocatePages | Custom AllocatePages implementation to use, optional. |
[in] | CheckRange | Handler allowing to not allocate select ranges, optional. |
EFI_SUCCESS | on successful allocation. |
Definition at line 27 of file MemoryAlloc.c.
UINTN OcCountFreePages | ( | OUT UINTN *LowerMemory | OPTIONAL | ) |
Calculate number of free pages in the memory map.
[out] | LowerMemory | Number of free pages below 4 GB, optional. |
Number | of free pages. |
Definition at line 148 of file MemoryAlloc.c.
UINT64 OcCountRuntimePages | ( | IN UINTN | MemoryMapSize, |
IN EFI_MEMORY_DESCRIPTOR * | MemoryMap, | ||
IN UINTN | DescriptorSize, | ||
OUT UINTN *DescriptorCount | OPTIONAL ) |
Calculate number of runtime pages in the memory map.
[in] | MemoryMapSize | Memory map size in bytes. |
[in] | MemoryMap | Memory map to inspect. |
[in] | DescriptorSize | Memory map descriptor size in bytes. |
[out] | DescriptorCount | Number of relevant descriptors, optional. |
Number | of runtime pages. |
Definition at line 111 of file MemoryAlloc.c.
UINTN OcCountSplitDescriptors | ( | VOID | ) |
Count upper bound of split runtime descriptors.
amount | of runtime descriptors. |
Definition at line 541 of file MemoryAttributes.c.
EFI_STATUS OcDeduplicateDescriptors | ( | IN OUT UINT32 * | EntryCount, |
IN OUT EFI_MEMORY_DESCRIPTOR * | MemoryMap, | ||
IN UINTN | DescriptorSize ) |
Deduplicate memory descriptors. Requires sorted entry list.
[in,out] | EntryCount | Memory map size in entries, updated on shrink. |
[in,out] | MemoryMap | Memory map to shrink. |
[in] | DescriptorSize | Memory map descriptor size in bytes. |
EFI_SUCCESS | on success. |
EFI_NOT_FOUND | when cannot join anything. |
Definition at line 438 of file MemoryMap.c.
EFI_STATUS OcDescToMemoryType | ( | IN CHAR8 * | MemoryTypeDesc, |
OUT EFI_MEMORY_TYPE * | MemoryType ) |
Return EFI memory type for given type description
[in] | MemoryTypeDesc | Memory type string representation. |
[out] | MemoryType | EFI memory type to return. |
EFI_NOT_FOUND | on unsuccessful lookup. |
EFI_INVALID_PARAMETER | on wrong passed agruments. |
EFI_SUCCESS | on successful lookup. |
Definition at line 90 of file MemoryMap.c.
EFI_MEMORY_DESCRIPTOR * OcGetCurrentMemoryMap | ( | OUT UINTN * | MemoryMapSize, |
OUT UINTN * | DescriptorSize, | ||
OUT UINTN *MapKey | OPTIONAL, | ||
OUT UINT32 *DescriptorVersion | OPTIONAL, | ||
OUT UINTN *OriginalMemoryMapSize | OPTIONAL, | ||
IN BOOLEAN | IncludeSplitSpace ) |
Get current memory map allocated on pool with reserved entries.
[out] | MemoryMapSize | Resulting memory map size in bytes. |
[out] | DescriptorSize | Resulting memory map descriptor size in bytes. |
[out] | MapKey | Memory map key, optional. |
[out] | DescriptorVersion | Memory map descriptor version, optional. |
[out] | OriginalMemoryMapSize | Actual pool allocation memory, optional. |
[out] | IncludeSplitSpace | Allocate memory to permit splitting memory map. |
current | memory map or NULL. |
Definition at line 116 of file MemoryMap.c.
EFI_STATUS OcGetCurrentMemoryMapAlloc | ( | OUT UINTN * | MemoryMapSize, |
OUT EFI_MEMORY_DESCRIPTOR ** | MemoryMap, | ||
OUT UINTN * | MapKey, | ||
OUT UINTN * | DescriptorSize, | ||
OUT UINT32 * | DescriptorVersion, | ||
IN EFI_GET_MEMORY_MAP GetMemoryMap | OPTIONAL, | ||
IN OUT EFI_PHYSICAL_ADDRESS *TopMemory | OPTIONAL ) |
Get current memory map of custom allocation.
[out] | MemoryMapSize | Resulting memory map size in bytes. |
[out] | MemoryMap | Resulting memory map. |
[out] | MapKey | Memory map key. |
[out] | DescriptorSize | Resulting memory map descriptor size in bytes. |
[out] | DescriptorVersion | Memory map descriptor version. |
[in] | GetMemoryMap | Custom GetMemoryMap implementation to use, optional. |
[in,out] | TopMemory | Base top address for OcAllocatePagesFromTop allocation, number of pages after return. |
EFI_SUCCESS | on success. |
Definition at line 201 of file MemoryMap.c.
PAGE_MAP_AND_DIRECTORY_POINTER * OcGetCurrentPageTable | ( | OUT UINTN *Flags | OPTIONAL | ) |
Return pointer to PML4 table in PageTable and PWT and PCD flags in Flags.
[out] | Flags | Current page table PWT and PCT flags. |
Current | page table address. |
Definition at line 97 of file VirtualMemory.c.
EFI_MEMORY_ATTRIBUTES_TABLE * OcGetMemoryAttributes | ( | OUT EFI_MEMORY_DESCRIPTOR **MemoryAttributesEntry | OPTIONAL | ) |
Obtain memory attributes table.
[out] | MemoryAttributesEntry | memory descriptor pointer, optional. |
pointer | to memory attributes table. |
NULL | if memory attributes table is unsupported. |
Definition at line 409 of file MemoryAttributes.c.
CHAR8 * OcGetMtrrTypeString | ( | UINT8 | MtrrType | ) |
Return short string representation of MTRR cache type, as used in Intel tables.
[in] | MtrrType | MTRR type. |
String | representation. |
Definition at line 58 of file VirtualMemory.c.
CHAR8 * OcGetPatTypeString | ( | UINT8 | PatType | ) |
Return short string representation of PAT cache type, as used in Intel tables.
[in] | PatType | PAT type. |
String | representation. |
Definition at line 70 of file VirtualMemory.c.
EFI_STATUS OcGetPhysicalAddress | ( | IN PAGE_MAP_AND_DIRECTORY_POINTER *PageTable | OPTIONAL, |
IN EFI_VIRTUAL_ADDRESS | VirtualAddr, | ||
OUT EFI_PHYSICAL_ADDRESS * | PhysicalAddr ) |
Return physical address for given virtual address.
[in] | PageTable | Page table to use for solving. |
[in] | VirtualAddr | Virtual address to look up. |
[out] | PhysicalAddr | Physical address to return. |
EFI_SUCCESS | on successful lookup. |
Definition at line 146 of file VirtualMemory.c.
EFI_STATUS OcGetSetPageTableInfoForAddress | ( | IN PAGE_MAP_AND_DIRECTORY_POINTER *PageTable | OPTIONAL, |
IN EFI_VIRTUAL_ADDRESS | VirtualAddr, | ||
OUT EFI_PHYSICAL_ADDRESS *PhysicalAddr | OPTIONAL, | ||
OUT UINT8 *Level | OPTIONAL, | ||
OUT UINT64 *Bits | OPTIONAL, | ||
IN OUT PAT_INDEX *PatIndex | OPTIONAL, | ||
IN BOOLEAN | SetPat ) |
Get page table info for a given virtual address. Includes option to get or set Page Attribute Table (PAT) index for caching type.
[in] | PageTable | Page table to use for solving, and modify iff SetPat==TRUE. |
[in] | VirtualAddr | Virtual address to look up. |
[out] | PhysicalAddr | Physical address to return. |
[out] | Level | Page table mapping level, 1, 2 or 4 for 1Gb, 2Mb or 4kb. |
[out] | Bits | Page table mapping flag bits. |
[in,out] | PatIndex | PAT index to get or set. |
[in] | SetPat | If TRUE then set PatIndex if present, else get. |
EFI_SUCCESS | on success. |
Definition at line 221 of file VirtualMemory.c.
BOOLEAN OcIsPatSupported | ( | VOID | ) |
Checks if PAT is supported.
TRUE | PAT is supported. |
FALSE | PAT is not supported. |
Definition at line 82 of file VirtualMemory.c.
EFI_STATUS OcModifyMtrrRange | ( | IN EFI_PHYSICAL_ADDRESS | Address, |
IN UINT8 | MtrrType, | ||
OUT UINT64 *Length | OPTIONAL ) |
Attempt to set entire MTRR range which starts with address to new MTRR cache type. Use with caution - attempting to change cache-type on the fly of any region used for code or data is likely to hang. Works successfully to uncache GOP (i.e. WC->UC), producing visibly slower results, on newer firmware where GOP range is set to WC in the first place.
[in] | Address | Start of range. |
[in] | MtrrType | MTRR cache type to assign. |
[out] | Length | Length of range converted or attempted to be converted, when non-zero. |
EFI_SUCCESS | if cache type is set and system is still running. |
EFI_UNSUPPORTED | if MTRR is unsupported. |
error | - other error from methods called. |
Definition at line 410 of file VirtualMemory.c.
VOID OcPrintMemoryAttributesTable | ( | VOID | ) |
Print memory attributes table if present.
Definition at line 96 of file MemoryDebug.c.
VOID OcPrintMemoryMap | ( | IN UINTN | MemoryMapSize, |
IN EFI_MEMORY_DESCRIPTOR * | MemoryMap, | ||
IN UINTN | DescriptorSize ) |
Print memory map.
[in] | MemoryMapSize | Memory map size in bytes. |
[in] | MemoryMap | Memory map to print. |
[in] | DescriptorSize | Memory map descriptor size in bytes. |
Definition at line 144 of file MemoryDebug.c.
EFI_STATUS OcRebuildAttributes | ( | IN EFI_PHYSICAL_ADDRESS | Address, |
IN EFI_GET_MEMORY_MAP GetMemoryMap | OPTIONAL ) |
Refresh memory attributes entry containing the specified address.
[in] | Address | Address contained in the updated entry. |
[in] | GetMemoryMap |
EFI_SUCCESS | on success. |
EFI_NOT_FOUND | no entry contains the specified address. |
EFI_UNSUPPORTED | memory attributes are not supported by the platform. |
Definition at line 431 of file MemoryAttributes.c.
EFI_STATUS OcSetPatIndexForAddressRange | ( | IN PAGE_MAP_AND_DIRECTORY_POINTER *PageTable | OPTIONAL, |
IN EFI_VIRTUAL_ADDRESS | VirtualAddr, | ||
IN UINT64 | Length, | ||
IN PAT_INDEX * | PatIndex ) |
Set Page Attribute Table (PAT) index for an address range. Assumes UEFI identity mapping between physical and virtual addresses.
[in] | PageTable | Page table to use and modify. |
[in] | VirtualAddr | Address range start. |
[in] | Length | Address range length. |
[in] | PatIndex | PAT index to set. |
EFI_SUCCESS | on success. |
EFI_INVALID_PARAMETER | on invalid memory range. |
error | - other error from called methods. |
Definition at line 164 of file VirtualMemory.c.
EFI_STATUS OcShrinkMemoryMap | ( | IN OUT UINTN * | MemoryMapSize, |
IN OUT EFI_MEMORY_DESCRIPTOR * | MemoryMap, | ||
IN UINTN | DescriptorSize ) |
Shrink memory map by joining non-runtime records. Requires sorted memory map.
[in,out] | MemoryMapSize | Memory map size in bytes, updated on shrink. |
[in,out] | MemoryMap | Memory map to shrink. |
[in] | DescriptorSize | Memory map descriptor size in bytes. |
EFI_SUCCESS | on success. |
EFI_NOT_FOUND | when cannot join anything. |
Definition at line 333 of file MemoryMap.c.
VOID OcSortMemoryMap | ( | IN UINTN | MemoryMapSize, |
IN OUT EFI_MEMORY_DESCRIPTOR * | MemoryMap, | ||
IN UINTN | DescriptorSize ) |
Sort memory map entries based upon PhysicalStart, from low to high.
MemoryMapSize | Size, in bytes, of the MemoryMap buffer. |
MemoryMap | A pointer to the buffer in which firmware places the current memory map. |
DescriptorSize | Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR. |
Definition at line 302 of file MemoryMap.c.
EFI_STATUS OcSplitMemoryMapByAttributes | ( | IN UINTN | MaxMemoryMapSize, |
IN OUT UINTN * | MemoryMapSize, | ||
IN OUT EFI_MEMORY_DESCRIPTOR * | MemoryMap, | ||
IN UINTN | DescriptorSize ) |
Split memory map by memory attributes if available. Requires sorted memory map!
[in] | MaxMemoryMapSize | Upper memory map size bound for growth. |
[in,out] | MemoryMapSize | Current memory map size, updated on return. |
[in,out] | MemoryMap | Memory map to split. |
[in] | DescriptorSize | Memory map descriptor size. |
Note, the function is guaranteed to return valid memory map, though not necessarily split.
EFI_SUCCESS | on success. |
EFI_UNSUPPORTED | memory attributes are not supported by the platform. |
EFI_OUT_OF_RESOURCES | new memory map did not fit. |
Definition at line 573 of file MemoryAttributes.c.
EFI_STATUS OcUpdateDescriptors | ( | IN UINTN | MemoryMapSize, |
IN EFI_MEMORY_DESCRIPTOR * | MemoryMap, | ||
IN UINTN | DescriptorSize, | ||
IN EFI_PHYSICAL_ADDRESS | Address, | ||
IN EFI_MEMORY_TYPE | Type, | ||
IN UINT64 | SetAttributes, | ||
IN UINT64 | DropAttributes ) |
Refresh memory descriptor containing the specified address.
[in] | MemoryMapSize | Memory map size in bytes. |
[in] | MemoryMap | Memory map to refresh. |
[in] | DescriptorSize | Memory map descriptor size in bytes. |
[in] | Address | Address contained in the updated entry. |
[in] | Type | Memory type to assign to the entry. |
[in] | SetAttributes | Attributes to set. |
[in] | DropAttributes | Attributes to remove. |
EFI_SUCCESS | on success. |
EFI_NOT_FOUND | no entry contains the specified address. |
EFI_UNSUPPORTED | memory attributes are not supported by the platform. |
Definition at line 505 of file MemoryMap.c.
BOOLEAN UmmFree | ( | IN VOID * | Ptr | ) |
Perform free of allocated memory. Accepts NULL pointer and checks whether memory belongs to itself.
[in] | Ptr | Memory to free. |
TRUE | on success |
BOOLEAN UmmInitialized | ( | VOID | ) |
Check whether built-in allocator is initialized.
TRUE | on success. |
Definition at line 276 of file UmmMalloc.c.
VOID * UmmMalloc | ( | IN UINT32 | Size | ) |
Perform allocation from built-in allocator.
[in] | Size | Allocation size. |
allocated | memory on success. |
VOID UmmSetHeap | ( | IN VOID * | Heap, |
IN UINT32 | Size ) |
Initialize built-in allocator.
[in] | Heap | Memory pool used for allocations. |
[in] | Size | Memory pool size. |
EFI_STATUS VmAllocateMemoryPool | ( | OUT OC_VMEM_CONTEXT * | Context, |
IN UINTN | NumPages, | ||
IN EFI_GET_MEMORY_MAP GetMemoryMap | OPTIONAL ) |
Allocate EfiBootServicesData virtual memory pool from boot services in the end of BASE_4GB of RAM. Should be called while boot services are still usable.
[out] | Context | Virtual memory pool context. |
[in] | NumPages | Number of pages to be allocated in the pool. |
[in] | GetMemoryMap | Custom GetMemoryMap implementation to use, optional. |
EFI_SUCCESS | on successful allocation. |
Definition at line 441 of file VirtualMemory.c.
VOID * VmAllocatePages | ( | IN OUT OC_VMEM_CONTEXT * | Context, |
IN UINTN | NumPages ) |
Allocate pages for e.g. vm page maps.
[in,out] | Context | Virtual memory pool context. |
[in] | NumPages | Number of pages to allocate. |
allocated | pages or NULL. |
Definition at line 469 of file VirtualMemory.c.
VOID VmFlushCaches | ( | VOID | ) |
Flushes TLB caches.
Definition at line 726 of file VirtualMemory.c.
EFI_STATUS VmMapVirtualPage | ( | IN OUT OC_VMEM_CONTEXT * | Context, |
IN OUT PAGE_MAP_AND_DIRECTORY_POINTER *PageTable | OPTIONAL, | ||
IN EFI_VIRTUAL_ADDRESS | VirtualAddr, | ||
IN EFI_PHYSICAL_ADDRESS | PhysicalAddr ) |
Map (remap) given page at physical address to given virtual address in the specified page table.
[in,out] | Context | Virtual memory pool context. |
[in] | PageTable | Page table to update. |
[in] | VirtualAddr | Virtual memory address to map at. |
[in] | PhysicalAddr | Physical memory address to map from. |
EFI_SUCCESS | on success. |
Definition at line 488 of file VirtualMemory.c.
EFI_STATUS VmMapVirtualPages | ( | IN OUT OC_VMEM_CONTEXT * | Context, |
IN OUT PAGE_MAP_AND_DIRECTORY_POINTER *PageTable | OPTIONAL, | ||
IN EFI_VIRTUAL_ADDRESS | VirtualAddr, | ||
IN UINT64 | NumPages, | ||
IN EFI_PHYSICAL_ADDRESS | PhysicalAddr ) |
Map (remap) a range of 4K pages at physical address to given virtual address in the specified page table.
[in,out] | Context | Virtual memory pool context. |
[in] | PageTable | Page table to update. |
[in] | VirtualAddr | Virtual memory address to map at. |
[in] | NumPages | Number of 4K pages to map. |
[in] | PhysicalAddr | Physical memory address to map from. |
EFI_SUCCESS | on success. |
Definition at line 693 of file VirtualMemory.c.