TianoCore EDK2 master
|
#include "PeiMain.h"
Go to the source code of this file.
EFI PEI Core memory services
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file MemoryServices.c.
Migrate the base address in firmware volume allocation HOBs from temporary memory to PEI installed memory.
[in] | PrivateData | Pointer to PeiCore's private data structure. |
[in] | OrgFvHandle | Address of FV Handle in temporary memory. |
[in] | FvHandle | Address of FV Handle in permanent memory. |
Definition at line 179 of file MemoryServices.c.
VOID ConvertMemoryAllocationHobs | ( | IN PEI_CORE_INSTANCE * | PrivateData | ) |
Migrate MemoryBaseAddress in memory allocation HOBs from the temporary memory to PEI installed memory.
[in] | PrivateData | Pointer to PeiCore's private data structure. |
Definition at line 220 of file MemoryServices.c.
EFI_STATUS FindFreeMemoryFromMemoryAllocationHob | ( | IN EFI_MEMORY_TYPE | MemoryType, |
IN UINTN | Pages, | ||
IN UINTN | Granularity, | ||
OUT EFI_PHYSICAL_ADDRESS * | Memory | ||
) |
Find free memory by searching memory allocation HOBs.
[in] | MemoryType | The type of memory to allocate. |
[in] | Pages | The number of contiguous 4 KB pages to allocate. |
[in] | Granularity | Page allocation granularity. |
[out] | Memory | Pointer to a physical address. On output, the address is set to the base of the page range that was allocated. |
EFI_SUCCESS | The memory range was successfully allocated. |
EFI_NOT_FOUND | No memory allocation HOB with big enough free memory found. |
Definition at line 459 of file MemoryServices.c.
VOID FreeMemoryAllocationHob | ( | IN PEI_CORE_INSTANCE * | PrivateData, |
IN OUT EFI_HOB_MEMORY_ALLOCATION * | MemoryAllocationHobToFree | ||
) |
Mark the memory allocation HOB to be unused(freed) and update *FreeMemoryTop if MemoryBaseAddress == *FreeMemoryTop.
[in] | PrivateData | Pointer to PeiCore's private data structure. |
[in,out] | MemoryAllocationHobToFree | Pointer to memory allocation HOB to be freed. |
Definition at line 696 of file MemoryServices.c.
VOID InitializeMemoryServices | ( | IN PEI_CORE_INSTANCE * | PrivateData, |
IN CONST EFI_SEC_PEI_HAND_OFF * | SecCoreData, | ||
IN PEI_CORE_INSTANCE * | OldCoreData | ||
) |
Initialize the memory services.
PrivateData | Points to PeiCore's private instance data. |
SecCoreData | Points to a data structure containing information about the PEI core's operating environment, such as the size and location of temporary RAM, the stack location and the BFV location. |
OldCoreData | Pointer to the PEI Core data. NULL if being run in non-permanent memory mode. |
Definition at line 24 of file MemoryServices.c.
VOID InternalBuildMemoryAllocationHob | ( | IN EFI_PHYSICAL_ADDRESS | BaseAddress, |
IN UINT64 | Length, | ||
IN EFI_MEMORY_TYPE | MemoryType | ||
) |
Internal function to build a HOB for the memory allocation. It will search and reuse the unused(freed) memory allocation HOB, or build memory allocation HOB normally if no unused(freed) memory allocation HOB found.
[in] | BaseAddress | The 64 bit physical address of the memory. |
[in] | Length | The length of the memory allocation in bytes. |
[in] | MemoryType | The type of memory allocated by this HOB. |
Definition at line 270 of file MemoryServices.c.
BOOLEAN MergeFreeMemoryInMemoryAllocationHob | ( | VOID | ) |
Merge adjacent free memory ranges in memory allocation HOBs.
TRUE | There are free memory ranges merged. |
FALSE | No free memory ranges merged. |
Definition at line 381 of file MemoryServices.c.
VOID MigrateMemoryPages | ( | IN PEI_CORE_INSTANCE * | Private, |
IN BOOLEAN | TemporaryRamMigrated | ||
) |
Migrate memory pages allocated in pre-memory phase. Copy memory pages at temporary heap top to permanent heap top.
[in] | Private | Pointer to the private data passed in from caller. |
[in] | TemporaryRamMigrated | Temporary memory has been migrated to permanent memory. |
Definition at line 113 of file MemoryServices.c.
EFI_STATUS EFIAPI PeiAllocatePages | ( | IN CONST EFI_PEI_SERVICES ** | PeiServices, |
IN EFI_MEMORY_TYPE | MemoryType, | ||
IN UINTN | Pages, | ||
OUT EFI_PHYSICAL_ADDRESS * | Memory | ||
) |
The purpose of the service is to publish an interface that allows PEIMs to allocate memory ranges that are managed by the PEI Foundation.
Prior to InstallPeiMemory() being called, PEI will allocate pages from the heap. After InstallPeiMemory() is called, PEI will allocate pages within the region of memory provided by InstallPeiMemory() service in a best-effort fashion. Location-specific allocations are not managed by the PEI foundation code.
PeiServices | An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. |
MemoryType | The type of memory to allocate. |
Pages | The number of contiguous 4 KB pages to allocate. |
Memory | Pointer to a physical address. On output, the address is set to the base of the page range that was allocated. |
EFI_SUCCESS | The memory range was successfully allocated. |
EFI_OUT_OF_RESOURCES | The pages could not be allocated. |
EFI_INVALID_PARAMETER | Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode, EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData, EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS. |
Definition at line 545 of file MemoryServices.c.
EFI_STATUS EFIAPI PeiAllocatePool | ( | IN CONST EFI_PEI_SERVICES ** | PeiServices, |
IN UINTN | Size, | ||
OUT VOID ** | Buffer | ||
) |
Pool allocation service. Before permanent memory is discovered, the pool will be allocated in the heap in temporary memory. Generally, the size of the heap in temporary memory does not exceed 64K, so the biggest pool size could be allocated is 64K.
PeiServices | An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. |
Size | Amount of memory required |
Buffer | Address of pointer to the buffer |
EFI_SUCCESS | The allocation was successful |
EFI_OUT_OF_RESOURCES | There is not enough heap to satisfy the requirement to allocate the requested size. |
Definition at line 845 of file MemoryServices.c.
EFI_STATUS EFIAPI PeiFreePages | ( | IN CONST EFI_PEI_SERVICES ** | PeiServices, |
IN EFI_PHYSICAL_ADDRESS | Memory, | ||
IN UINTN | Pages | ||
) |
Frees memory pages.
[in] | PeiServices | An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. |
[in] | Memory | The base physical address of the pages to be freed. |
[in] | Pages | The number of contiguous 4 KB pages to free. |
EFI_SUCCESS | The requested pages were freed. |
EFI_INVALID_PARAMETER | Memory is not a page-aligned address or Pages is invalid. |
EFI_NOT_FOUND | The requested memory pages were not allocated with AllocatePages(). |
Definition at line 769 of file MemoryServices.c.
EFI_STATUS EFIAPI PeiInstallPeiMemory | ( | IN CONST EFI_PEI_SERVICES ** | PeiServices, |
IN EFI_PHYSICAL_ADDRESS | MemoryBegin, | ||
IN UINT64 | MemoryLength | ||
) |
This function registers the found memory configuration with the PEI Foundation.
The usage model is that the PEIM that discovers the permanent memory shall invoke this service. This routine will hold discoveried memory information into PeiCore's private data, and set SwitchStackSignal flag. After PEIM who discovery memory is dispatched, PeiDispatcher will migrate temporary memory to permanent memory.
PeiServices | An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. |
MemoryBegin | Start of memory address. |
MemoryLength | Length of memory. |
Definition at line 73 of file MemoryServices.c.
VOID UpdateOrSplitMemoryAllocationHob | ( | IN OUT EFI_HOB_MEMORY_ALLOCATION * | MemoryAllocationHob, |
IN EFI_PHYSICAL_ADDRESS | Memory, | ||
IN UINT64 | Bytes, | ||
IN EFI_MEMORY_TYPE | MemoryType | ||
) |
Update or split memory allocation HOB for memory pages allocate and free.
[in,out] | MemoryAllocationHob | Pointer to the memory allocation HOB that needs to be updated or split. On output, it will be filled with the input Memory, Bytes and MemoryType. |
[in] | Memory | Memory to allocate or free. |
[in] | Bytes | Bytes to allocate or free. |
[in] | MemoryType | EfiConventionalMemory for pages free, others for pages allocate. |
Definition at line 334 of file MemoryServices.c.