|
TianoCore EDK2 master
|
Go to the source code of this file.
Data Structures | |
| struct | MEMORY_MAP |
Macros | |
| #define | TRUNCATE_TO_PAGES(a) ((a) >> EFI_PAGE_SHIFT) |
| #define | MEMORY_MAP_SIGNATURE SIGNATURE_32('m','m','a','p') |
| #define | MAX_MAP_DEPTH 6 |
Variables | |
| LIST_ENTRY | mSmmMemoryMap = INITIALIZE_LIST_HEAD_VARIABLE (mSmmMemoryMap) |
| LIST_ENTRY | gMemoryMap = INITIALIZE_LIST_HEAD_VARIABLE (gMemoryMap) |
| UINTN | mMapDepth = 0 |
| MEMORY_MAP | mMapStack [MAX_MAP_DEPTH] |
| UINTN | mFreeMapStack = 0 |
| LIST_ENTRY | mFreeMemoryMapEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemoryMapEntryList) |
SMM Memory page management functions.
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Page.c.
| #define MEMORY_MAP_SIGNATURE SIGNATURE_32('m','m','a','p') |
| MEMORY_MAP * AllocateMemoryMapEntry | ( | VOID | ) |
Internal function. Deque a descriptor entry from the mFreeMemoryMapEntryList. If the list is emtry, then allocate a new page to refuel the list. Please Note this algorithm to allocate the memory map descriptor has a property that the memory allocated for memory entries always grows, and will never really be freed.
| VOID ConvertSmmMemoryMapEntry | ( | IN EFI_MEMORY_TYPE | Type, |
| IN EFI_PHYSICAL_ADDRESS | Memory, | ||
| IN UINTN | NumberOfPages, | ||
| IN BOOLEAN | AddRegion | ||
| ) |
| BOOLEAN InMemMap | ( | IN EFI_PHYSICAL_ADDRESS | Memory, |
| IN UINTN | NumberOfPages | ||
| ) |
| VOID InsertNewEntry | ( | IN LIST_ENTRY * | Link, |
| IN UINT64 | Start, | ||
| IN UINT64 | End, | ||
| IN EFI_MEMORY_TYPE | Type, | ||
| IN BOOLEAN | Next, | ||
| IN BOOLEAN | AddRegion | ||
| ) |
Insert new entry from memory map.
| [in] | Link | The old memory map entry to be linked. |
| [in] | Start | The start address of new memory map entry. |
| [in] | End | The end address of new memory map entry. |
| [in] | Type | The type of new memory map entry. |
| [in] | Next | If new entry is inserted to the next of old entry. |
| [in] | AddRegion | If this memory is new added region. |
| UINTN InternalAllocAddress | ( | IN OUT LIST_ENTRY * | FreePageList, |
| IN UINTN | NumberOfPages, | ||
| IN UINTN | Address | ||
| ) |
Internal Function. Allocate n pages from free page list at given address.
| FreePageList | The free page node. |
| NumberOfPages | Number of pages to be allocated. |
| MaxAddress | Request to allocate memory below this address. |
| UINTN InternalAllocMaxAddress | ( | IN OUT LIST_ENTRY * | FreePageList, |
| IN UINTN | NumberOfPages, | ||
| IN UINTN | MaxAddress | ||
| ) |
Internal Function. Allocate n pages from free page list below MaxAddress.
| FreePageList | The free page node. |
| NumberOfPages | Number of pages to be allocated. |
| MaxAddress | Request to allocate memory below this address. |
| FREE_PAGE_LIST * InternalMergeNodes | ( | IN FREE_PAGE_LIST * | First | ) |
| VOID RemoveOldEntry | ( | IN MEMORY_MAP * | Entry | ) |
| VOID SmmAddMemoryRegion | ( | IN EFI_PHYSICAL_ADDRESS | MemBase, |
| IN UINT64 | MemLength, | ||
| IN EFI_MEMORY_TYPE | Type, | ||
| IN UINT64 | Attributes | ||
| ) |
| EFI_STATUS EFIAPI SmmAllocatePages | ( | IN EFI_ALLOCATE_TYPE | Type, |
| IN EFI_MEMORY_TYPE | MemoryType, | ||
| IN UINTN | NumberOfPages, | ||
| OUT EFI_PHYSICAL_ADDRESS * | Memory | ||
| ) |
Allocates pages from the memory map.
| Type | The type of allocation to perform. |
| MemoryType | The type of memory to turn the allocated pages into. |
| NumberOfPages | The number of pages to allocate. |
| Memory | A pointer to receive the base allocated memory address. |
| EFI_INVALID_PARAMETER | Parameters violate checking rules defined in spec. |
| EFI_NOT_FOUND | Could not allocate pages match the requirement. |
| EFI_OUT_OF_RESOURCES | No enough pages to allocate. |
| EFI_SUCCESS | Pages successfully allocated. |
| EFI_STATUS EFIAPI SmmCoreGetMemoryMap | ( | IN OUT UINTN * | MemoryMapSize, |
| IN OUT EFI_MEMORY_DESCRIPTOR * | MemoryMap, | ||
| OUT UINTN * | MapKey, | ||
| OUT UINTN * | DescriptorSize, | ||
| OUT UINT32 * | DescriptorVersion | ||
| ) |
This function returns a copy of the current memory map. The map is an array of memory descriptors, each of which describes a contiguous block of memory.
| [in,out] | MemoryMapSize | A pointer to the size, in bytes, of the MemoryMap buffer. On input, this is the size of the buffer allocated by the caller. On output, it is the size of the buffer returned by the firmware if the buffer was large enough, or the size of the buffer needed to contain the map if the buffer was too small. |
| [in,out] | MemoryMap | A pointer to the buffer in which firmware places the current memory map. |
| [out] | MapKey | A pointer to the location in which firmware returns the key for the current memory map. |
| [out] | DescriptorSize | A pointer to the location in which firmware returns the size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR. |
| [out] | DescriptorVersion | A pointer to the location in which firmware returns the version number associated with the EFI_MEMORY_DESCRIPTOR. |
| EFI_SUCCESS | The memory map was returned in the MemoryMap buffer. |
| EFI_BUFFER_TOO_SMALL | The MemoryMap buffer was too small. The current buffer size needed to hold the memory map is returned in MemoryMapSize. |
| EFI_INVALID_PARAMETER | One of the parameters has an invalid value. |
| EFI_STATUS EFIAPI SmmFreePages | ( | IN EFI_PHYSICAL_ADDRESS | Memory, |
| IN UINTN | NumberOfPages | ||
| ) |
Frees previous allocated pages.
| Memory | Base address of memory being freed. |
| NumberOfPages | The number of pages to free. |
| EFI_NOT_FOUND | Could not find the entry that covers the range. |
| EFI_INVALID_PARAMETER | Address not aligned, Address is zero or NumberOfPages is zero. |
| EFI_STATUS EFIAPI SmmInternalAllocatePages | ( | IN EFI_ALLOCATE_TYPE | Type, |
| IN EFI_MEMORY_TYPE | MemoryType, | ||
| IN UINTN | NumberOfPages, | ||
| OUT EFI_PHYSICAL_ADDRESS * | Memory, | ||
| IN BOOLEAN | NeedGuard | ||
| ) |
Allocates pages from the memory map.
| [in] | Type | The type of allocation to perform. |
| [in] | MemoryType | The type of memory to turn the allocated pages into. |
| [in] | NumberOfPages | The number of pages to allocate. |
| [out] | Memory | A pointer to receive the base allocated memory address. |
| [in] | NeedGuard | Flag to indicate Guard page is needed or not |
| EFI_INVALID_PARAMETER | Parameters violate checking rules defined in spec. |
| EFI_NOT_FOUND | Could not allocate pages match the requirement. |
| EFI_OUT_OF_RESOURCES | No enough pages to allocate. |
| EFI_SUCCESS | Pages successfully allocated. |
| EFI_STATUS SmmInternalAllocatePagesEx | ( | IN EFI_ALLOCATE_TYPE | Type, |
| IN EFI_MEMORY_TYPE | MemoryType, | ||
| IN UINTN | NumberOfPages, | ||
| OUT EFI_PHYSICAL_ADDRESS * | Memory, | ||
| IN BOOLEAN | AddRegion, | ||
| IN BOOLEAN | NeedGuard | ||
| ) |
Allocates pages from the memory map.
| [in] | Type | The type of allocation to perform. |
| [in] | MemoryType | The type of memory to turn the allocated pages into. |
| [in] | NumberOfPages | The number of pages to allocate. |
| [out] | Memory | A pointer to receive the base allocated memory address. |
| [in] | AddRegion | If this memory is new added region. |
| [in] | NeedGuard | Flag to indicate Guard page is needed or not |
| EFI_INVALID_PARAMETER | Parameters violate checking rules defined in spec. |
| EFI_NOT_FOUND | Could not allocate pages match the requirement. |
| EFI_OUT_OF_RESOURCES | No enough pages to allocate. |
| EFI_SUCCESS | Pages successfully allocated. |
| EFI_STATUS EFIAPI SmmInternalFreePages | ( | IN EFI_PHYSICAL_ADDRESS | Memory, |
| IN UINTN | NumberOfPages, | ||
| IN BOOLEAN | IsGuarded | ||
| ) |
Frees previous allocated pages.
| [in] | Memory | Base address of memory being freed. |
| [in] | NumberOfPages | The number of pages to free. |
| [in] | IsGuarded | Is the memory to free guarded or not. |
| EFI_NOT_FOUND | Could not find the entry that covers the range. |
| EFI_INVALID_PARAMETER | Address not aligned, Address is zero or NumberOfPages is zero. |
| EFI_STATUS SmmInternalFreePagesEx | ( | IN EFI_PHYSICAL_ADDRESS | Memory, |
| IN UINTN | NumberOfPages, | ||
| IN BOOLEAN | AddRegion | ||
| ) |
Frees previous allocated pages.
| [in] | Memory | Base address of memory being freed. |
| [in] | NumberOfPages | The number of pages to free. |
| [in] | AddRegion | If this memory is new added region. |
| EFI_NOT_FOUND | Could not find the entry that covers the range. |
| EFI_INVALID_PARAMETER | Address not aligned, Address is zero or NumberOfPages is zero. |
| LIST_ENTRY gMemoryMap = INITIALIZE_LIST_HEAD_VARIABLE (gMemoryMap) |
| LIST_ENTRY mFreeMemoryMapEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemoryMapEntryList) |
| MEMORY_MAP mMapStack[MAX_MAP_DEPTH] |
| LIST_ENTRY mSmmMemoryMap = INITIALIZE_LIST_HEAD_VARIABLE (mSmmMemoryMap) |