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>
---
 .../MemoryAllocationLib.c                          | 33 ++++++++++++++--------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git 
a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c 
b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
index 5378f09..892ba0a 100644
--- a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
+++ b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
@@ -1,5 +1,14 @@
 /** @file
   Support routines for memory allocation routines based on SMM Core internal 
functions.
+  
+  The PI System Management Mode Core Interface Specification only allows the 
use
+  of EfiRuntimeServicesCode and EfiRuntimeServicesData memory types for memory 
+  allocations 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                          
@@ -84,9 +93,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 to the
+  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.
@@ -279,9 +288,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 with an
+  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.
@@ -437,9 +446,9 @@ InternalAllocatePool (
 }
 
 /**
-  Allocates a buffer of type EfiBootServicesData.
+  Allocates a buffer of type EfiRuntimeServicesData.
 
-  Allocates the number bytes specified by AllocationSize of type 
EfiBootServicesData and returns a
+  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.
 
@@ -529,9 +538,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, clears the
+  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.
@@ -631,9 +640,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, copies
+  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 request, then NULL is returned.
@@ -752,10 +761,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

Reply via email to