Per PI spec all allocation of SMRAM should use EfiRuntimeServicesCode or EfiRuntimeServicesData. So SMM instance use EfiRuntimeServicesCode as the default memory allocation type instead of EfiBootServicesData. This patch clarify this usage in comments.
Signed-off-by: Qiu Shumin <shumin....@intel.com> --- .../SmmMemoryAllocationLib/MemoryAllocationLib.c | 37 +++++++++++----------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/MdePkg/Library/SmmMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/SmmMemoryAllocationLib/MemoryAllocationLib.c index ab27ac6..30670bf 100644 --- a/MdePkg/Library/SmmMemoryAllocationLib/MemoryAllocationLib.c +++ b/MdePkg/Library/SmmMemoryAllocationLib/MemoryAllocationLib.c @@ -4,12 +4,13 @@ The PI System Management Mode Core Interface Specification only allows the use of EfiRuntimeServicesCode and EfiRuntimeServicesData memory types for memory - allocations through the SMM Services Table. The functions in the Memory - Allocation Library use EfiBootServicesData as the default memory allocation - type. For this SMM specific instance of the Memory Allocation Library, - EfiRuntimeServicesData is used as the default memory type for all allocations. - In addition, allocation for the Reserved memory types are not supported and - will always return NULL. + allocations through the SMM Services Table as the SMRAM space should be + reserved after BDS phase. The functions in the Memory Allocation Library use + EfiBootServicesData as the default memory allocation type. For this SMM + specific instance of the Memory Allocation Library, EfiRuntimeServicesData + is used as the default memory type for all allocations. In addition, + allocation for the Reserved memory types are not supported and will always + return NULL. Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials @@ -169,9 +170,9 @@ InternalAllocatePages ( } /** - Allocates one or more 4KB pages of type EfiBootServicesData. + Allocates one or more 4KB pages of type EfiRuntimeServicesData. - Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. @@ -365,9 +366,9 @@ InternalAllocateAlignedPages ( } /** - Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment. + Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment. - Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData + Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned. If there is not enough memory at the specified alignment remaining to satisfy the request, then NULL is returned. @@ -525,9 +526,9 @@ InternalAllocatePool ( } /** - Allocates a buffer of type EfiBootServicesData. + Allocates a buffer of type EfiRuntimeServicesData. - Allocates the number bytes specified by AllocationSize of type EfiBootServicesData + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. @@ -620,9 +621,9 @@ InternalAllocateZeroPool ( } /** - Allocates and zeros a buffer of type EfiBootServicesData. + Allocates and zeros a buffer of type EfiRuntimeServicesData. - Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. @@ -722,9 +723,9 @@ InternalAllocateCopyPool ( } /** - Copies a buffer to an allocated buffer of type EfiBootServicesData. + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. - Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the @@ -846,10 +847,10 @@ InternalReallocatePool ( } /** - Reallocates a buffer of type EfiBootServicesData. + Reallocates a buffer of type EfiRuntimeServicesData. Allocates and zeros the number bytes specified by NewSize from memory of type - EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and + EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and NewSize bytes are copied from OldBuffer to the newly allocated buffer, and OldBuffer is freed. A pointer to the newly allocated buffer is returned. If NewSize is 0, then a valid buffer of 0 size is returned. If there is not -- 1.9.5.msysgit.1 ------------------------------------------------------------------------------ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel