--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007, Intel Corporation.\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DxeCoreEntryPoint.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseLib.h>\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Entry point to the DXE Core.\r
+\r
+Copyright (c) 2006, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+//\r
+// Cache copy of HobList pointer. \r
+// \r
+VOID *gHobList = NULL;\r
+\r
+/**\r
+ Enrty point to DXE core.\r
+\r
+ @param HobStart Pointer of HobList.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+ IN VOID *HobStart\r
+ )\r
+{\r
+ //\r
+ // Cache a pointer to the HobList\r
+ //\r
+ gHobList = HobStart;\r
+\r
+ //\r
+ // Call the DXE Core entry point\r
+ //\r
+ ProcessModuleEntryPointList (HobStart);\r
+\r
+ //\r
+ // Should never return\r
+ //\r
+ ASSERT(FALSE);\r
+ CpuDeadLoop ();\r
+}\r
+\r
+\r
+/**\r
+ Wrapper of enrty point to DXE CORE.\r
+\r
+ @param HobStart Pointer of HobList.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiMain (\r
+ IN VOID *HobStart\r
+ )\r
+{\r
+ _ModuleEntryPoint (HobStart);\r
+}\r
--- /dev/null
+#/** @file\r
+# Component description file for Dxe Core Entry Point Library\r
+#\r
+# Entry Point Library instance used by Dxe Core\r
+# Copyright (c) 2007, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = DxeCoreEntryPoint\r
+ FILE_GUID = d258d6af-2fc0-4019-9c1f-1101c3dd19b5\r
+ MODULE_TYPE = DXE_CORE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = DxeCoreEntryPoint|DXE_CORE \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ DxeCoreEntryPoint.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ DebugLib\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>DxeCoreEntryPoint</ModuleName>\r
+ <ModuleType>DXE_CORE</ModuleType>\r
+ <GuidValue>d258d6af-2fc0-4019-9c1f-1101c3dd19b5</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for Dxe Core Entry Point Library</Abstract>\r
+ <Description>Entry Point Library instance used by Dxe Core</Description>\r
+ <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>DxeCoreEntryPoint</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_CORE">\r
+ <Keyword>DxeCoreEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>DxeCoreEntryPoint.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Component description file for Dxe Memory Allocation Library\r
+#\r
+# Memory Allocation Library that uses EFI Boot Services to allocate\r
+# and free memory.\r
+# Copyright (c) 2007, Intel Corporation\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = DxeMemoryAllocationLib\r
+ FILE_GUID = 4674739d-3195-4fb2-8094-ac1d22d00194\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = MemoryAllocationLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ MemoryAllocationLibInternals.h\r
+ MemoryAllocationLib.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ DebugLib\r
+ BaseMemoryLib\r
+ UefiBootServicesTableLib\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>DxeMemoryAllocationLib</ModuleName>\r
+ <ModuleType>DXE_DRIVER</ModuleType>\r
+ <GuidValue>4674739d-3195-4fb2-8094-ac1d22d00194</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for Dxe Memory Allocation Library</Abstract>\r
+ <Description>Memory Allocation Library that uses EFI Boot Services to allocate
+ and free memory.</Description>\r
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>DxeMemoryAllocationLib</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">\r
+ <Keyword>MemoryAllocationLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiBootServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>MemoryAllocationLib.c</Filename>\r
+ <Filename>MemoryAllocationLibInternals.h</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/** @file\r
+ Support routines for memory allocation routines for use with drivers.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+ Module Name: MemoryAllocationLib.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "MemoryAllocationLibInternals.h"\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type.\r
+\r
+ Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated\r
+ buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PHYSICAL_ADDRESS Memory; \r
+\r
+ if (Pages == 0) {\r
+ return NULL;\r
+ }\r
+\r
+ Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory);\r
+ if (EFI_ERROR (Status)) {\r
+ Memory = 0;\r
+ }\r
+ return (VOID *) (UINTN) Memory;\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiBootServicesData.\r
+\r
+ Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the\r
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r
+ returned.\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocatePages (\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ return InternalAllocatePages (EfiBootServicesData, Pages);\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiRuntimeServicesData.\r
+\r
+ Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r
+ returned.\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePages (\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ return InternalAllocatePages (EfiRuntimeServicesData, Pages);\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiReservedMemoryType.\r
+\r
+ Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the\r
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r
+ returned.\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPages (\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ return InternalAllocatePages (EfiReservedMemoryType, Pages);\r
+}\r
+\r
+/**\r
+ Frees one or more 4KB pages that were previously allocated with one of the page allocation\r
+ functions in the Memory Allocation Library.\r
+\r
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer\r
+ must have been allocated on a previous call to the page allocation services of the Memory\r
+ Allocation Library.\r
+ If Buffer was not allocated with a page allocation function in the Memory Allocation Library,\r
+ then ASSERT().\r
+ If Pages is zero, then ASSERT().\r
+ \r
+ @param Buffer Pointer to the buffer of pages to free.\r
+ @param Pages The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreePages (\r
+ IN VOID *Buffer,\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (Pages != 0);\r
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
+ ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory at the specified alignment remaining to satisfy the request, then\r
+ NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PHYSICAL_ADDRESS Memory;\r
+ UINTN AlignedMemory;\r
+ UINTN AlignmentMask;\r
+ UINTN UnalignedPages;\r
+ UINTN RealPages;\r
+\r
+ //\r
+ // Alignment must be a power of two or zero.\r
+ //\r
+ ASSERT ((Alignment & (Alignment - 1)) == 0);\r
+ \r
+ if (Pages == 0) {\r
+ return NULL;\r
+ }\r
+ if (Alignment > EFI_PAGE_SIZE) {\r
+ //\r
+ // Caculate the total number of pages since alignment is larger than page size.\r
+ //\r
+ AlignmentMask = Alignment - 1;\r
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);\r
+ //\r
+ // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.\r
+ //\r
+ ASSERT (RealPages > Pages);\r
+ \r
+ Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+ AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;\r
+ UnalignedPages = EFI_SIZE_TO_PAGES ((UINTN) Memory - AlignedMemory);\r
+ if (UnalignedPages > 0) {\r
+ //\r
+ // Free first unaligned page(s).\r
+ //\r
+ Status = gBS->FreePages (Memory, UnalignedPages);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
+ UnalignedPages = RealPages - Pages - UnalignedPages;\r
+ if (UnalignedPages > 0) {\r
+ //\r
+ // Free last unaligned page(s).\r
+ //\r
+ Status = gBS->FreePages (Memory, UnalignedPages);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ } else {\r
+ //\r
+ // Do not over-allocate pages in this case.\r
+ //\r
+ Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory);\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+ AlignedMemory = (UINTN) Memory;\r
+ }\r
+ return (VOID *) AlignedMemory;\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the\r
+ request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPages (\r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the\r
+ request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePages (\r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the\r
+ request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPages (\r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);\r
+}\r
+\r
+/**\r
+ Frees one or more 4KB pages that were previously allocated with one of the aligned page\r
+ allocation functions in the Memory Allocation Library.\r
+\r
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer\r
+ must have been allocated on a previous call to the aligned page allocation services of the Memory\r
+ Allocation Library.\r
+ If Buffer was not allocated with an aligned page allocation function in the Memory Allocation\r
+ Library, then ASSERT().\r
+ If Pages is zero, then ASSERT().\r
+ \r
+ @param Buffer Pointer to the buffer of pages to free.\r
+ @param Pages The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPages (\r
+ IN VOID *Buffer,\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (Pages != 0);\r
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
+ ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type and returns a\r
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePool (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *Memory;\r
+\r
+ Status = gBS->AllocatePool (MemoryType, AllocationSize, &Memory);\r
+ if (EFI_ERROR (Status)) {\r
+ Memory = NULL;\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfiBootServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a\r
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocatePool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ return InternalAllocatePool (EfiBootServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfiRuntimeServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns\r
+ a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfieservedMemoryType.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns\r
+ a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ return InternalAllocatePool (EfiReservedMemoryType, AllocationSize);\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer\r
+ with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,\r
+ then NULL is returned.\r
+\r
+ @param PoolType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize\r
+ ) \r
+{\r
+ VOID *Memory;\r
+\r
+ Memory = InternalAllocatePool (PoolType, AllocationSize);\r
+ if (Memory != NULL) {\r
+ Memory = ZeroMem (Memory, AllocationSize);\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfiBootServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the\r
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r
+ request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateZeroPool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ return InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfiRuntimeServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the\r
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r
+ request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeZeroPool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfiReservedMemoryType.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the\r
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r
+ request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedZeroPool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ ) \r
+{\r
+ VOID *Memory;\r
+\r
+ ASSERT (Buffer != NULL);\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+ Memory = InternalAllocatePool (PoolType, AllocationSize);\r
+ if (Memory != NULL) {\r
+ Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+ }\r
+ return Memory;\r
+} \r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiBootServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ )\r
+{\r
+ return InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ )\r
+{\r
+ return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiReservedMemoryType.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ )\r
+{\r
+ return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+ Frees a buffer that was previously allocated with one of the pool allocation functions in the\r
+ Memory Allocation Library.\r
+\r
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the\r
+ pool allocation services of the Memory Allocation Library.\r
+ If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,\r
+ then ASSERT().\r
+\r
+ @param Buffer Pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreePool (\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = gBS->FreePool (Buffer);\r
+ ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ VOID *RawAddress;\r
+ UINTN AlignedAddress;\r
+ UINTN AlignmentMask;\r
+ UINTN OverAllocationSize;\r
+ UINTN RealAllocationSize;\r
+ VOID **FreePointer;\r
+\r
+ //\r
+ // Alignment must be a power of two or zero.\r
+ //\r
+ ASSERT ((Alignment & (Alignment - 1)) == 0);\r
+ \r
+ if (Alignment == 0) {\r
+ AlignmentMask = Alignment;\r
+ } else {\r
+ AlignmentMask = Alignment - 1;\r
+ }\r
+ //\r
+ // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address. \r
+ //\r
+ OverAllocationSize = sizeof (RawAddress) + AlignmentMask;\r
+ RealAllocationSize = AllocationSize + OverAllocationSize;\r
+ //\r
+ // Make sure that AllocationSize plus OverAllocationSize does not overflow. \r
+ //\r
+ ASSERT (RealAllocationSize > AllocationSize); \r
+\r
+ RawAddress = InternalAllocatePool (PoolType, RealAllocationSize);\r
+ if (RawAddress == NULL) {\r
+ return NULL;\r
+ }\r
+ AlignedAddress = ((UINTN) RawAddress + OverAllocationSize) & ~AlignmentMask;\r
+ //\r
+ // Save the original memory address just before the aligned address.\r
+ //\r
+ FreePointer = (VOID **)(AlignedAddress - sizeof (RawAddress));\r
+ *FreePointer = RawAddress;\r
+\r
+ return (VOID *) AlignedAddress;\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPool (EfiBootServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfieservedMemoryType at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated\r
+ buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not\r
+ enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ VOID *Memory;\r
+ Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
+ if (Memory != NULL) {\r
+ Memory = ZeroMem (Memory, AllocationSize);\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+ returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedZeroPool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedZeroPool (EfiBootServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an\r
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+ returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimeZeroPool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an\r
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+ returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedZeroPool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ VOID *Memory;\r
+ \r
+ ASSERT (Buffer != NULL);\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+ Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
+ if (Memory != NULL) {\r
+ Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedCopyPool (EfiBootServicesData, AllocationSize, Buffer, Alignment);\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimeCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment);\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment);\r
+}\r
+\r
+/**\r
+ Frees a buffer that was previously allocated with one of the aligned pool allocation functions \r
+ in the Memory Allocation Library.\r
+\r
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the\r
+ aligned pool allocation services of the Memory Allocation Library.\r
+ If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation\r
+ Library, then ASSERT().\r
+\r
+ @param Buffer Pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPool (\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ VOID *RawAddress;\r
+ VOID **FreePointer;\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Get the pre-saved original address in the over-allocate pool.\r
+ //\r
+ FreePointer = (VOID **)((UINTN) Buffer - sizeof (RawAddress));\r
+ RawAddress = *FreePointer;\r
+\r
+ Status = gBS->FreePool (RawAddress);\r
+ ASSERT_EFI_ERROR (Status);\r
+}\r
--- /dev/null
+/** @file\r
+ Internal include file of DXE Memory Allocation Library.\r
+\r
+ Copyright (c) 2006, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ Module Name: MemoryAllocationLibInternals.h\r
+\r
+**/\r
+\r
+#ifndef __DXE_MEMORY_ALLOCATION_LIB_INTERNALS_H__\r
+#define __DXE_MEMORY_ALLOCATION_LIB_INTERNALS_H__\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type.\r
+\r
+ Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated\r
+ buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages\r
+ );\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory at the specified alignment remaining to satisfy the request, then\r
+ NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type and returns a\r
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePool (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN AllocationSize\r
+ );\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer\r
+ with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,\r
+ then NULL is returned.\r
+\r
+ @param PoolType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize\r
+ );\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated\r
+ buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not\r
+ enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+#endif\r
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007, Intel Corporation.\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/Pcd.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/PcdLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+Implementation of PcdLib class library for DXE phase.\r
+\r
+Copyright (c) 2006, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+\r
+Module Name: DxePcdLib.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+static PCD_PROTOCOL *mPcd;\r
+\r
+/**\r
+ The constructor function caches the PCD_PROTOCOL pointer.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+ \r
+ @retval EFI_SUCCESS The constructor always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PcdLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.\r
+\r
+ @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and \r
+ set values associated with a PCD token.\r
+\r
+ @retval SKU_ID Return the SKU ID that just be set.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+LibPcdSetSku (\r
+ IN UINTN SkuId\r
+ )\r
+{\r
+ ASSERT (SkuId < 0x100);\r
+\r
+ mPcd->SetSku (SkuId);\r
+\r
+ return SkuId;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 8-bit value for the token specified by TokenNumber. \r
+\r
+ @param[in] The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber. \r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+LibPcdGet8 (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ return mPcd->Get8 (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 16-bit value for the token specified by TokenNumber. \r
+\r
+ @param[in] The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber. \r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+LibPcdGet16 (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ return mPcd->Get16 (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 32-bit value for the token specified by TokenNumber. \r
+\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+LibPcdGet32 (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ return mPcd->Get32 (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 64-bit value for the token specified by TokenNumber.\r
+\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+LibPcdGet64 (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ return mPcd->Get64 (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the pointer to the buffer of the token specified by TokenNumber.\r
+\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval VOID* Returns the pointer to the token specified by TokenNumber.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPcdGetPtr (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ return mPcd->GetPtr (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the Boolean value of the token specified by TokenNumber. \r
+\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber. \r
+\r
+**/\r
+BOOLEAN \r
+EFIAPI\r
+LibPcdGetBool (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ return mPcd->GetBool (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the size of the token specified by TokenNumber. \r
+\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINTN Returns the size of the token specified by TokenNumber. \r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+LibPcdGetSize (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ return mPcd->GetSize (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 8-bit value for the token specified by TokenNumber and Guid.\r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT8 Return the UINT8.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+LibPcdGetEx8 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ ASSERT (Guid != NULL);\r
+ \r
+ return mPcd->Get8Ex (Guid, TokenNumber);\r
+}\r
+\r
+\r
+/**\r
+ Returns the 16-bit value for the token specified by TokenNumber and Guid.\r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT16 Return the UINT16.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+LibPcdGetEx16 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ ASSERT (Guid != NULL);\r
+\r
+ return mPcd->Get16Ex (Guid, TokenNumber);\r
+}\r
+\r
+\r
+/**\r
+ Returns the 32-bit value for the token specified by TokenNumber and Guid.\r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT32 Return the UINT32.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+LibPcdGetEx32 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ ASSERT (Guid != NULL);\r
+\r
+ return mPcd->Get32Ex (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 64-bit value for the token specified by TokenNumber and Guid.\r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT64 Return the UINT64.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+LibPcdGetEx64 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ ASSERT (Guid != NULL);\r
+ \r
+ return mPcd->Get64Ex (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the pointer to the token specified by TokenNumber and Guid.\r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval VOID* Return the VOID* pointer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPcdGetExPtr (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ ASSERT (Guid != NULL);\r
+\r
+ return mPcd->GetPtrEx (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the Boolean value of the token specified by TokenNumber and Guid. \r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval BOOLEAN Return the BOOLEAN.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LibPcdGetExBool (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ ASSERT (Guid != NULL);\r
+\r
+ return mPcd->GetBoolEx (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the size of the token specified by TokenNumber and Guid. \r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINTN Return the size.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+LibPcdGetExSize (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ ASSERT (Guid != NULL);\r
+\r
+ return mPcd->GetSizeEx (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 8-bit value for the token specified by TokenNumber \r
+ to the value specified by Value. Value is returned.\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 8-bit value to set.\r
+\r
+ @retval UINT8 Return the value been set.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+LibPcdSet8 (\r
+ IN UINTN TokenNumber,\r
+ IN UINT8 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = mPcd->Set8 (TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 16-bit value for the token specified by TokenNumber \r
+ to the value specified by Value. Value is returned.\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 16-bit value to set.\r
+\r
+ @retval UINT16 Return the value been set.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+LibPcdSet16 (\r
+ IN UINTN TokenNumber,\r
+ IN UINT16 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = mPcd->Set16 (TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 32-bit value for the token specified by TokenNumber \r
+ to the value specified by Value. Value is returned.\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 32-bit value to set.\r
+\r
+ @retval UINT32 Return the value been set.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+LibPcdSet32 (\r
+ IN UINTN TokenNumber,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ Status = mPcd->Set32 (TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 64-bit value for the token specified by TokenNumber \r
+ to the value specified by Value. Value is returned.\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 64-bit value to set.\r
+\r
+ @retval UINT64 Return the value been set.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+LibPcdSet64 (\r
+ IN UINTN TokenNumber,\r
+ IN UINT64 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = mPcd->Set64 (TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets a buffer for the token specified by TokenNumber to \r
+ the value specified by Buffer and SizeOfValue. Buffer to\r
+ be set is returned. The content of the buffer could be \r
+ overwritten if a Callback on SET is registered with this\r
+ TokenNumber.\r
+ \r
+ If SizeOfValue is greater than the maximum \r
+ size support by TokenNumber, then set SizeOfValue to the \r
+ maximum size supported by TokenNumber and return NULL to \r
+ indicate that the set operation was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.\r
+ @param[in] Value A pointer to the buffer to set.\r
+\r
+ @retval VOID* Return the pointer for the buffer been set.\r
+\r
+**/\r
+\r
+VOID *\r
+EFIAPI\r
+LibPcdSetPtr (\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (SizeOfBuffer != NULL);\r
+\r
+ if (*SizeOfBuffer > 0) {\r
+ ASSERT (Buffer != NULL);\r
+ }\r
+\r
+ Status = mPcd->SetPtr (TokenNumber, SizeOfBuffer, Buffer);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+\r
+ return Buffer;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the Boolean value for the token specified by TokenNumber \r
+ to the value specified by Value. Value is returned.\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The boolean value to set.\r
+\r
+ @retval BOOLEAN Return the value been set.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LibPcdSetBool (\r
+ IN UINTN TokenNumber,\r
+ IN BOOLEAN Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = mPcd->SetBool (TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 8-bit value for the token specified by TokenNumber and \r
+ Guid to the value specified by Value. Value is returned.\r
+ If Guid is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 8-bit value to set.\r
+\r
+ @retval UINT8 Return the value been set.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+LibPcdSetEx8 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN UINT8 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ Status = mPcd->Set8Ex (Guid, TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 16-bit value for the token specified by TokenNumber and \r
+ Guid to the value specified by Value. Value is returned.\r
+ If Guid is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 16-bit value to set.\r
+\r
+ @retval UINT8 Return the value been set.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+LibPcdSetEx16 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN UINT16 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ Status = mPcd->Set16Ex (Guid, TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 32-bit value for the token specified by TokenNumber and \r
+ Guid to the value specified by Value. Value is returned.\r
+ If Guid is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 32-bit value to set.\r
+\r
+ @retval UINT32 Return the value been set.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+LibPcdSetEx32 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ Status = mPcd->Set32Ex (Guid, TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 64-bit value for the token specified by TokenNumber and \r
+ Guid to the value specified by Value. Value is returned.\r
+ If Guid is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 64-bit value to set.\r
+\r
+ @retval UINT64 Return the value been set.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+LibPcdSetEx64 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN UINT64 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ Status = mPcd->Set64Ex (Guid, TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets a buffer for the token specified by TokenNumber to the value specified by \r
+ Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r
+ the maximum size support by TokenNumber, then set SizeOfValue to the maximum size \r
+ supported by TokenNumber and return NULL to indicate that the set operation \r
+ was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
+ @param[in] Buffer A pointer to the buffer to set.\r
+\r
+ @retval VOID * Return the pinter to the buffer been set.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPcdSetExPtr (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ ASSERT (SizeOfBuffer != NULL);\r
+\r
+ if (*SizeOfBuffer > 0) {\r
+ ASSERT (Buffer != NULL);\r
+ }\r
+\r
+ Status = mPcd->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+\r
+ return Buffer;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the Boolean value for the token specified by TokenNumber and \r
+ Guid to the value specified by Value. Value is returned.\r
+ If Guid is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The Boolean value to set.\r
+\r
+ @retval Boolean Return the value been set.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LibPcdSetExBool (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN BOOLEAN Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ Status = mPcd->SetBoolEx (Guid, TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ When the token specified by TokenNumber and Guid is set, \r
+ then notification function specified by NotificationFunction is called. \r
+ If Guid is NULL, then the default token space is used. \r
+ If NotificationFunction is NULL, then ASSERT().\r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates which \r
+ namespace to set a value from. If NULL, then the default \r
+ token space is used.\r
+ @param[in] TokenNumber The PCD token number to monitor.\r
+ @param[in] NotificationFunction The function to call when the token \r
+ specified by Guid and TokenNumber is set.\r
+\r
+ @retval VOID\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdCallbackOnSet (\r
+ IN CONST GUID *Guid, OPTIONAL\r
+ IN UINTN TokenNumber,\r
+ IN PCD_CALLBACK NotificationFunction\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (NotificationFunction != NULL);\r
+\r
+ Status = mPcd->CallbackOnSet (Guid, TokenNumber, NotificationFunction);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Disable a notification function that was established with LibPcdCallbackonSet().\r
+ If NotificationFunction is NULL, then ASSERT().\r
+\r
+ @param[in] Guid Specify the GUID token space.\r
+ @param[in] TokenNumber Specify the token number.\r
+ @param[in] NotificationFunction The callback function to be unregistered.\r
+\r
+ @retval VOID\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdCancelCallback (\r
+ IN CONST GUID *Guid, OPTIONAL\r
+ IN UINTN TokenNumber,\r
+ IN PCD_CALLBACK NotificationFunction\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (NotificationFunction != NULL);\r
+ \r
+ Status = mPcd->CancelCallback (Guid, TokenNumber, NotificationFunction);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Retrieves the next PCD token number from the token space specified by Guid. \r
+ If Guid is NULL, then the default token space is used. If TokenNumber is 0, \r
+ then the first token number is returned. Otherwise, the token number that \r
+ follows TokenNumber in the token space is returned. If TokenNumber is the last \r
+ token number in the token space, then 0 is returned. If TokenNumber is not 0 and \r
+ is not in the token space specified by Guid, then ASSERT().\r
+\r
+ @param[in] Pointer to a 128-bit unique value that designates which namespace \r
+ to set a value from. If NULL, then the default token space is used.\r
+ @param[in] The previous PCD token number. If 0, then retrieves the first PCD \r
+ token number.\r
+\r
+ @retval UINTN The next valid token number.\r
+\r
+**/\r
+UINTN \r
+EFIAPI\r
+LibPcdGetNextToken (\r
+ IN CONST GUID *Guid, OPTIONAL\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = mPcd->GetNextToken (Guid, &TokenNumber);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return TokenNumber;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Retrieves the next PCD token space from a token space specified by Guid.\r
+ Guid of NULL is reserved to mark the default local token namespace on the current\r
+ platform. If Guid is NULL, then the GUID of the first non-local token space of the \r
+ current platform is returned. If Guid is the last non-local token space, \r
+ then NULL is returned. \r
+\r
+ If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().\r
+\r
+\r
+ \r
+ @param[in] Pointer to a 128-bit unique value that designates from which namespace \r
+ to start the search.\r
+\r
+ @retval CONST GUID * The next valid token namespace.\r
+\r
+**/\r
+GUID * \r
+EFIAPI\r
+LibPcdGetNextTokenSpace (\r
+ IN CONST GUID *Guid\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = mPcd->GetNextTokenSpace (&Guid);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return (GUID *) Guid;\r
+}\r
+\r
+\r
+/**\r
+ Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
+ and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r
+ MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return \r
+ NULL to indicate that the set operation was not actually performed. \r
+ If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to \r
+ MaximumDatumSize and NULL must be returned.\r
+ \r
+ If PatchVariable is NULL, then ASSERT().\r
+ If SizeOfValue is NULL, then ASSERT().\r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
+\r
+ @param[in] PatchVariable A pointer to the global variable in a module that is \r
+ the target of the set operation.\r
+ @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
+ @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
+ @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPatchPcdSetPtr (\r
+ IN VOID *PatchVariable,\r
+ IN UINTN MaximumDatumSize,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN CONST VOID *Buffer\r
+ )\r
+{\r
+ ASSERT (PatchVariable != NULL);\r
+ ASSERT (SizeOfBuffer != NULL);\r
+ \r
+ if (*SizeOfBuffer > 0) {\r
+ ASSERT (Buffer != NULL);\r
+ }\r
+\r
+ if ((*SizeOfBuffer > MaximumDatumSize) ||\r
+ (*SizeOfBuffer == MAX_ADDRESS)) {\r
+ *SizeOfBuffer = MaximumDatumSize;\r
+ return NULL;\r
+ }\r
+ \r
+ CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
+ \r
+ return (VOID *) Buffer;\r
+}\r
+\r
+\r
+\r
--- /dev/null
+#/** @file\r
+# PCD Library instance implemented with PCD Protocol\r
+#\r
+# This library instance implement the APIs listed \r
+# in PCD library class defined in MDE library specification.\r
+# It is used by modules in DXE phase.\r
+# Copyright (c) 2007, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = DxePcdLib\r
+ FILE_GUID = af97eb89-4cc6-45f8-a514-ca025b346480\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = PcdLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ CONSTRUCTOR = PcdLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ DxePcdLib.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ BaseMemoryLib\r
+ UefiBootServicesTableLib\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+# that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+ gPcdProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>DxePcdLib</ModuleName>\r
+ <ModuleType>DXE_DRIVER</ModuleType>\r
+ <GuidValue>af97eb89-4cc6-45f8-a514-ca025b346480</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>PCD Library instance implemented with PCD Protocol</Abstract>\r
+ <Description>This library instance implement the APIs listed
+ in PCD library class defined in MDE library specification.
+ It is used by modules in DXE phase.</Description>\r
+ <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>DxePcdLib</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">\r
+ <Keyword>PcdLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiBootServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>DxePcdLib.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Protocols>\r
+ <Protocol Usage="ALWAYS_CONSUMED">\r
+ <ProtocolCName>gPcdProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ </Protocols>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <Constructor>PcdLibConstructor</Constructor>\r
+ </Extern>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007, Intel Corporation.\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Guid/DxeServices.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DxeServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiLib.h>\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ DXE Library.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ Module Name: DxeServicesTableLib.c\r
+\r
+**/\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+//\r
+// Cache copy of the DXE Services Table\r
+//\r
+EFI_DXE_SERVICES *gDS = NULL;\r
+\r
+/**\r
+ The constructor function caches the pointer of DXE Services Table.\r
+\r
+ The constructor function caches the pointer of DXE Services Table.\r
+ It will ASSERT() if that operation fails.\r
+ It will ASSERT() if the pointer of DXE Services Table is NULL.\r
+ It will always return EFI_SUCCESS.\r
+\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
+ @param SystemTable A pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeServicesTableLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Cache copy of the DXE Services Table\r
+ //\r
+ Status = EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r
+ ASSERT_EFI_ERROR (Status);\r
+ ASSERT (gDS != NULL);\r
+\r
+ return Status;\r
+}\r
--- /dev/null
+#/** @file\r
+# Component description file for Dxe Services Table Library.\r
+#\r
+# DXE Services Table Library that retrieves a pointer to the DXE Services\r
+# Table from the Configuration Table in the EFI System Table.\r
+# Copyright (c) 2007, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = DxeServicesTableLib\r
+ FILE_GUID = baa1baa3-0a8d-402c-8042-985115fae953\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = DxeServicesTableLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ CONSTRUCTOR = DxeServicesTableLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ DxeServicesTableLib.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ UefiLib\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+ gEfiDxeServicesTableGuid # ALWAYS_CONSUMED\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>DxeServicesTableLib</ModuleName>\r
+ <ModuleType>DXE_DRIVER</ModuleType>\r
+ <GuidValue>baa1baa3-0a8d-402c-8042-985115fae953</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for Dxe Services Table Library.</Abstract>\r
+ <Description>DXE Services Table Library that retrieves a pointer to the DXE Services
+ Table from the Configuration Table in the EFI System Table.</Description>\r
+ <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>DxeServicesTableLib</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">\r
+ <Keyword>DxeServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>DxeServicesTableLib.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Guids>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiDxeServicesTableGuid</GuidCName>\r
+ </GuidCNames>\r
+ </Guids>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <Constructor>DxeServicesTableLibConstructor</Constructor>\r
+ </Extern>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007 - 2007, Intel Corporation.\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/PeiCoreEntryPoint.h>\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Entry point to a the PEI Core.\r
+\r
+Copyright (c) 2007, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+/**\r
+ Enrty point to PEI core.\r
+\r
+ @param SecCoreData Points to a data structure containing\r
+ information about the PEI core's\r
+ operating environment, such as the size\r
+ and location of temporary RAM, the stack\r
+ location and the BFV location. The type\r
+ EFI_SEC_PEI_HAND_OFF is\r
+\r
+ @param PpiList Points to a list of one or more PPI\r
+ descriptors to be installed initially by\r
+ the PEI core. An empty PPI list consists\r
+ of a single descriptor with the end-tag\r
+ EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST.\r
+ As part of its initialization phase, the\r
+ PEI Foundation will add these SEC-hosted\r
+ PPIs to its PPI database such that both\r
+ the PEI Foundation and any modules can\r
+ leverage the associated service calls\r
+ and/or code in these early PPIs.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
+ )\r
+{\r
+ //\r
+ // Call the PEI Core entry point\r
+ //\r
+ return ProcessModuleEntryPointList (SecCoreData, PpiList, NULL);\r
+}\r
+\r
+\r
+/**\r
+ Wrapper of enrty point to PEI core.\r
+\r
+ @param SecCoreData Points to a data structure containing\r
+ information about the PEI core's\r
+ operating environment, such as the size\r
+ and location of temporary RAM, the stack\r
+ location and the BFV location. The type\r
+ EFI_SEC_PEI_HAND_OFF is\r
+\r
+ @param PpiList Points to a list of one or more PPI\r
+ descriptors to be installed initially by\r
+ the PEI core. An empty PPI list consists\r
+ of a single descriptor with the end-tag\r
+ EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST.\r
+ As part of its initialization phase, the\r
+ PEI Foundation will add these SEC-hosted\r
+ PPIs to its PPI database such that both\r
+ the PEI Foundation and any modules can\r
+ leverage the associated service calls\r
+ and/or code in these early PPIs.\r
+\r
+**/\r
+EFI_STATUS\r
+EfiMain (\r
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
+ )\r
+{\r
+ return _ModuleEntryPoint (SecCoreData, PpiList);\r
+}\r
--- /dev/null
+#/** @file\r
+# Entry point to a the PEI Core\r
+#\r
+# The library contains the entry point to a PEI core Module Type.\r
+# Copyright (c) 2007 - 2007, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = PeiCoreEntryPoint\r
+ FILE_GUID = b3b0654a-969d-4096-86cb-27e262a02083\r
+ MODULE_TYPE = PEI_CORE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = PeiCoreEntryPoint|PEI_CORE \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ PeiCoreEntryPoint.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>PeiCoreEntryPoint</ModuleName>\r
+ <ModuleType>PEI_CORE</ModuleType>\r
+ <GuidValue>b3b0654a-969d-4096-86cb-27e262a02083</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Entry point to a the PEI Core</Abstract>\r
+ <Description>The library contains the entry point to a PEI core Module Type.</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>PeiCoreEntryPoint</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="PEI_CORE">\r
+ <Keyword>PeiCoreEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>PeiCoreEntryPoint.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Support routines for memory allocation routines for use with drivers.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+ Module Name: MemoryAllocationLib.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "MemoryAllocationLibInternals.h"\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type.\r
+\r
+ Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated\r
+ buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PHYSICAL_ADDRESS Memory; \r
+ EFI_PEI_SERVICES **PeiServices;\r
+\r
+ if (Pages == 0) {\r
+ return NULL;\r
+ }\r
+\r
+ PeiServices = GetPeiServicesTablePointer ();\r
+ Status = (*PeiServices)->AllocatePages (PeiServices, MemoryType, Pages, &Memory);\r
+ if (EFI_ERROR (Status)) {\r
+ Memory = 0;\r
+ }\r
+ return (VOID *) (UINTN) Memory;\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiBootServicesData.\r
+\r
+ Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the\r
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r
+ returned.\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocatePages (\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ return InternalAllocatePages (EfiBootServicesData, Pages);\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiRuntimeServicesData.\r
+\r
+ Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r
+ returned.\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePages (\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ return InternalAllocatePages (EfiRuntimeServicesData, Pages);\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiReservedMemoryType.\r
+\r
+ Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the\r
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r
+ returned.\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPages (\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ return InternalAllocatePages (EfiReservedMemoryType, Pages);\r
+}\r
+\r
+/**\r
+ Frees one or more 4KB pages that were previously allocated with one of the page allocation\r
+ functions in the Memory Allocation Library.\r
+\r
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer\r
+ must have been allocated on a previous call to the page allocation services of the Memory\r
+ Allocation Library.\r
+ If Buffer was not allocated with a page allocation function in the Memory Allocation Library,\r
+ then ASSERT().\r
+ If Pages is zero, then ASSERT().\r
+ \r
+ @param Buffer Pointer to the buffer of pages to free.\r
+ @param Pages The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreePages (\r
+ IN VOID *Buffer,\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ //\r
+ // PEI phase does not support to free pages, so leave it as NOP.\r
+ //\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory at the specified alignment remaining to satisfy the request, then\r
+ NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ VOID *Memory;\r
+ UINTN AlignmentMask;\r
+\r
+ //\r
+ // Alignment must be a power of two or zero.\r
+ //\r
+ ASSERT ((Alignment & (Alignment - 1)) == 0);\r
+\r
+ if (Pages == 0) {\r
+ return NULL;\r
+ }\r
+ //\r
+ // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.\r
+ //\r
+ ASSERT (Pages <= (MAX_ADDRESS - EFI_SIZE_TO_PAGES (Alignment)));\r
+ //\r
+ // We would rather waste some memory to save PEI code size.\r
+ //\r
+ Memory = InternalAllocatePages (MemoryType, Pages + EFI_SIZE_TO_PAGES (Alignment));\r
+ if (Alignment == 0) {\r
+ AlignmentMask = Alignment;\r
+ } else {\r
+ AlignmentMask = Alignment - 1; \r
+ }\r
+ return (VOID *) (UINTN) (((UINTN) Memory + AlignmentMask) & ~AlignmentMask);\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the\r
+ request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPages (\r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the\r
+ request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePages (\r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is\r
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the\r
+ request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPages (\r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);\r
+}\r
+\r
+/**\r
+ Frees one or more 4KB pages that were previously allocated with one of the aligned page\r
+ allocation functions in the Memory Allocation Library.\r
+\r
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer\r
+ must have been allocated on a previous call to the aligned page allocation services of the Memory\r
+ Allocation Library.\r
+ If Buffer was not allocated with an aligned page allocation function in the Memory Allocation\r
+ Library, then ASSERT().\r
+ If Pages is zero, then ASSERT().\r
+ \r
+ @param Buffer Pointer to the buffer of pages to free.\r
+ @param Pages The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPages (\r
+ IN VOID *Buffer,\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ //\r
+ // PEI phase does not support to free pages, so leave it as NOP.\r
+ //\r
+}\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type and returns a\r
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePool (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ //\r
+ // If we need lots of small runtime/reserved memory type from PEI in the future, \r
+ // we can consider providing a more complex algorithm that allocates runtime pages and \r
+ // provide pool allocations from those pages. \r
+ //\r
+ return InternalAllocatePages (MemoryType, EFI_SIZE_TO_PAGES (AllocationSize));\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfiBootServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a\r
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocatePool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PEI_SERVICES **PeiServices;\r
+ VOID *Buffer;\r
+ \r
+ PeiServices = GetPeiServicesTablePointer ();\r
+\r
+ Status = (*PeiServices)->AllocatePool (PeiServices, AllocationSize, &Buffer);\r
+ if (EFI_ERROR (Status)) {\r
+ Buffer = NULL;\r
+ }\r
+ return Buffer;\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfiRuntimeServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns\r
+ a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfieservedMemoryType.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns\r
+ a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ return InternalAllocatePool (EfiReservedMemoryType, AllocationSize);\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer\r
+ with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,\r
+ then NULL is returned.\r
+\r
+ @param PoolType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize\r
+ ) \r
+{\r
+ VOID *Memory;\r
+\r
+ Memory = InternalAllocatePool (PoolType, AllocationSize);\r
+ if (Memory != NULL) {\r
+ Memory = ZeroMem (Memory, AllocationSize);\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfiBootServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the\r
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r
+ request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateZeroPool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ VOID *Memory;\r
+\r
+ Memory = AllocatePool (AllocationSize);\r
+ if (Memory != NULL) {\r
+ Memory = ZeroMem (Memory, AllocationSize);\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfiRuntimeServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the\r
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r
+ request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeZeroPool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfiReservedMemoryType.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the\r
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a\r
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the\r
+ request, then NULL is returned.\r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedZeroPool (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ ) \r
+{\r
+ VOID *Memory;\r
+\r
+ ASSERT (Buffer != NULL);\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+ Memory = InternalAllocatePool (PoolType, AllocationSize);\r
+ if (Memory != NULL) {\r
+ Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+ }\r
+ return Memory;\r
+} \r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiBootServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ )\r
+{\r
+ VOID *Memory;\r
+\r
+ ASSERT (Buffer != NULL);\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+ Memory = AllocatePool (AllocationSize);\r
+ if (Memory != NULL) {\r
+ Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ )\r
+{\r
+ return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiReservedMemoryType.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ )\r
+{\r
+ return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+ Frees a buffer that was previously allocated with one of the pool allocation functions in the\r
+ Memory Allocation Library.\r
+\r
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the\r
+ pool allocation services of the Memory Allocation Library.\r
+ If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,\r
+ then ASSERT().\r
+\r
+ @param Buffer Pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreePool (\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ //\r
+ // PEI phase does not support to free pool, so leave it as NOP.\r
+ //\r
+}\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ VOID *RawAddress;\r
+ UINTN AlignedAddress;\r
+ UINTN AlignmentMask;\r
+\r
+ //\r
+ // Alignment must be a power of two or zero.\r
+ //\r
+ ASSERT ((Alignment & (Alignment - 1)) == 0);\r
+ \r
+ if (Alignment == 0) {\r
+ AlignmentMask = Alignment;\r
+ } else {\r
+ AlignmentMask = Alignment - 1;\r
+ }\r
+ //\r
+ // Make sure that AllocationSize plus AlignmentMask does not overflow.\r
+ //\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));\r
+\r
+ RawAddress = InternalAllocatePool (PoolType, AllocationSize + AlignmentMask);\r
+ \r
+ AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask;\r
+ \r
+ return (VOID *) AlignedAddress;\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ VOID *RawAddress;\r
+ UINTN AlignedAddress;\r
+ UINTN AlignmentMask;\r
+\r
+ //\r
+ // Alignment must be a power of two or zero.\r
+ //\r
+ ASSERT ((Alignment & (Alignment - 1)) == 0);\r
+\r
+ if (Alignment == 0) {\r
+ AlignmentMask = Alignment;\r
+ } else {\r
+ AlignmentMask = Alignment - 1;\r
+ }\r
+\r
+ //\r
+ // Make sure that AllocationSize plus AlignmentMask does not overflow.\r
+ //\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));\r
+\r
+ RawAddress = AllocatePool (AllocationSize + AlignmentMask);\r
+ \r
+ AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask;\r
+ \r
+ return (VOID *) AlignedAddress;\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates a buffer of type EfieservedMemoryType at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated\r
+ buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not\r
+ enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ VOID *Memory;\r
+\r
+ Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
+ if (Memory != NULL) {\r
+ Memory = ZeroMem (Memory, AllocationSize);\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+ returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedZeroPool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ VOID *Memory;\r
+\r
+ Memory = AllocateAlignedPool (AllocationSize, Alignment);\r
+ if (Memory != NULL) {\r
+ Memory = ZeroMem (Memory, AllocationSize);\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an\r
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+ returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimeZeroPool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+ Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an\r
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+ returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedZeroPool (\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ VOID *Memory;\r
+ \r
+ ASSERT (Buffer != NULL);\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+ Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
+ if (Memory != NULL) {\r
+ Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ VOID *Memory;\r
+ \r
+ ASSERT (Buffer != NULL);\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+ Memory = AllocateAlignedPool (AllocationSize, Alignment);\r
+ if (Memory != NULL) {\r
+ Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+ }\r
+ return Memory;\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimeCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment);\r
+}\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an\r
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
+ alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedCopyPool (\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ )\r
+{\r
+ return InternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment);\r
+}\r
+\r
+/**\r
+ Frees a buffer that was previously allocated with one of the aligned pool allocation functions \r
+ in the Memory Allocation Library.\r
+\r
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the\r
+ aligned pool allocation services of the Memory Allocation Library.\r
+ If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation\r
+ Library, then ASSERT().\r
+\r
+ @param Buffer Pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPool (\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ //\r
+ // PEI phase does not support to free pool, so leave it as NOP.\r
+ //\r
+}\r
--- /dev/null
+/** @file\r
+ Internal include file of PEI Memory Allocation Library.\r
+\r
+ Copyright (c) 2006, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ Module Name: MemoryAllocationLibInternals.h\r
+\r
+**/\r
+\r
+#ifndef __PEI_MEMORY_ALLOCATION_LIB_INTERNALS_H__\r
+#define __PEI_MEMORY_ALLOCATION_LIB_INTERNALS_H__\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type.\r
+\r
+ Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated\r
+ buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages\r
+ );\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory at the specified alignment remaining to satisfy the request, then\r
+ NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type and returns a\r
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePool (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN AllocationSize\r
+ );\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer\r
+ with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,\r
+ then NULL is returned.\r
+\r
+ @param PoolType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize\r
+ );\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated\r
+ buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not\r
+ enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Component description file for Pei Memory Allocation Library\r
+#\r
+# Memory Allocation Library that uses PEI Services to allocate memory.\r
+# Free operations are ignored.\r
+# Copyright (c) 2007, Intel Corporation\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = PeiMemoryAllocationLib\r
+ FILE_GUID = b694e0dc-cd4e-4b30-885b-9c164ed3e74a\r
+ MODULE_TYPE = PEIM\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = MemoryAllocationLib|PEIM PEI_CORE \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ MemoryAllocationLibInternals.h\r
+ MemoryAllocationLib.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ DebugLib\r
+ BaseMemoryLib\r
+ PeiServicesTablePointerLib\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>PeiMemoryAllocationLib</ModuleName>\r
+ <ModuleType>PEIM</ModuleType>\r
+ <GuidValue>b694e0dc-cd4e-4b30-885b-9c164ed3e74a</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for Pei Memory Allocation Library</Abstract>\r
+ <Description>Memory Allocation Library that uses PEI Services to allocate memory.
+ Free operations are ignored.</Description>\r
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>PeiMemoryAllocationLib</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="PEIM PEI_CORE">\r
+ <Keyword>MemoryAllocationLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PeiServicesTablePointerLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>MemoryAllocationLib.c</Filename>\r
+ <Filename>MemoryAllocationLibInternals.h</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Ppi/Pcd.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/PcdLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+Implementation of PcdLib class library for PEI phase.\r
+\r
+Copyright (c) 2006, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+\r
+Module Name: PeiPcdLib.c\r
+\r
+**/\r
+\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+/**\r
+ The constructor function retrieve the PCD_PPI pointer.\r
+\r
+ @param[in] VOID\r
+ \r
+ @retval PCD_PPI * The pointer to the PCD_PPI.\r
+\r
+**/\r
+STATIC\r
+PCD_PPI *\r
+GetPcdPpiPtr (\r
+ VOID\r
+ ) \r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI *PcdPpi;\r
+ EFI_PEI_SERVICES **PeiServices;\r
+\r
+\r
+ PeiServices = GetPeiServicesTablePointer ();\r
+\r
+ Status = (**PeiServices).LocatePpi (\r
+ PeiServices,\r
+ &gPcdPpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&PcdPpi\r
+ );\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return PcdPpi;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.\r
+\r
+ @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and \r
+ set values associated with a PCD token.\r
+\r
+ @retval SKU_ID Return the SKU ID that just be set.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+LibPcdSetSku (\r
+ IN UINTN SkuId\r
+ )\r
+{\r
+\r
+ ASSERT (SkuId < 0x100);\r
+\r
+ GetPcdPpiPtr()->SetSku (SkuId);;\r
+\r
+ return SkuId;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 8-bit value for the token specified by TokenNumber. \r
+\r
+ @param[in] The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber. \r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+LibPcdGet8 (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->Get8 (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 16-bit value for the token specified by TokenNumber. \r
+\r
+ @param[in] The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber. \r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+LibPcdGet16 (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI *PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->Get16 (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 32-bit value for the token specified by TokenNumber. \r
+\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+LibPcdGet32 (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->Get32 (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 64-bit value for the token specified by TokenNumber.\r
+\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+LibPcdGet64 (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->Get64 (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the pointer to the buffer of the token specified by TokenNumber.\r
+\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval VOID* Returns the pointer to the token specified by TokenNumber.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPcdGetPtr (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->GetPtr (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the Boolean value of the token specified by TokenNumber. \r
+\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber. \r
+\r
+**/\r
+BOOLEAN \r
+EFIAPI\r
+LibPcdGetBool (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->GetBool (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the size of the token specified by TokenNumber. \r
+\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINTN Returns the size of the token specified by TokenNumber. \r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+LibPcdGetSize (\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->GetSize (TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 8-bit value for the token specified by TokenNumber and Guid.\r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT8 Return the UINT8.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+LibPcdGetEx8 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->Get8Ex (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 16-bit value for the token specified by TokenNumber and Guid.\r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT16 Return the UINT16.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+LibPcdGetEx16 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->Get16Ex (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the 32-bit value for the token specified by TokenNumber and Guid.\r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT32 Return the UINT32.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+LibPcdGetEx32 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->Get32Ex (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+\r
+/**\r
+ Returns the 64-bit value for the token specified by TokenNumber and Guid.\r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINT64 Return the UINT64.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+LibPcdGetEx64 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->Get64Ex (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the pointer to the token specified by TokenNumber and Guid.\r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval VOID* Return the VOID* pointer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPcdGetExPtr (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->GetPtrEx (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the Boolean value of the token specified by TokenNumber and Guid. \r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval BOOLEAN Return the BOOLEAN.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LibPcdGetExBool (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->GetBoolEx (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Returns the size of the token specified by TokenNumber and Guid. \r
+ If Guid is NULL, then ASSERT(). \r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates \r
+ which namespace to retrieve a value from.\r
+ @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
+\r
+ @retval UINTN Return the size.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+LibPcdGetExSize (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ PCD_PPI * PcdPpi;\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ return PcdPpi->GetSizeEx (Guid, TokenNumber);\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 8-bit value for the token specified by TokenNumber \r
+ to the value specified by Value. Value is returned.\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 8-bit value to set.\r
+\r
+ @retval UINT8 Return the value been set.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+LibPcdSet8 (\r
+ IN UINTN TokenNumber,\r
+ IN UINT8 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ Status = PcdPpi->Set8 (TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 16-bit value for the token specified by TokenNumber \r
+ to the value specified by Value. Value is returned.\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 16-bit value to set.\r
+\r
+ @retval UINT16 Return the value been set.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+LibPcdSet16 (\r
+ IN UINTN TokenNumber,\r
+ IN UINT16 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ Status = PcdPpi->Set16 (TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 32-bit value for the token specified by TokenNumber \r
+ to the value specified by Value. Value is returned.\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 32-bit value to set.\r
+\r
+ @retval UINT32 Return the value been set.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+LibPcdSet32 (\r
+ IN UINTN TokenNumber,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ Status = PcdPpi->Set32 (TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 64-bit value for the token specified by TokenNumber \r
+ to the value specified by Value. Value is returned.\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 64-bit value to set.\r
+\r
+ @retval UINT64 Return the value been set.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+LibPcdSet64 (\r
+ IN UINTN TokenNumber,\r
+ IN UINT64 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ Status = PcdPpi->Set64 (TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets a buffer for the token specified by TokenNumber to \r
+ the value specified by Buffer and SizeOfValue. Buffer to\r
+ be set is returned. The content of the buffer could be \r
+ overwritten if a Callback on SET is registered with this\r
+ TokenNumber.\r
+ \r
+ If SizeOfValue is greater than the maximum \r
+ size support by TokenNumber, then set SizeOfValue to the \r
+ maximum size supported by TokenNumber and return NULL to \r
+ indicate that the set operation was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.\r
+ @param[in] Value A pointer to the buffer to set.\r
+\r
+ @retval VOID* Return the pointer for the buffer been set.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPcdSetPtr (\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI *PcdPpi;\r
+\r
+ ASSERT (SizeOfBuffer != NULL);\r
+\r
+ if (*SizeOfBuffer > 0) {\r
+ ASSERT (Buffer != NULL);\r
+ }\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+ \r
+ Status = PcdPpi->SetPtr (TokenNumber, SizeOfBuffer, Buffer);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+\r
+ return Buffer;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the Boolean value for the token specified by TokenNumber \r
+ to the value specified by Value. Value is returned.\r
+ \r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The boolean value to set.\r
+\r
+ @retval BOOLEAN Return the value been set.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LibPcdSetBool (\r
+ IN UINTN TokenNumber,\r
+ IN BOOLEAN Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ Status = PcdPpi->SetBool (TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 8-bit value for the token specified by TokenNumber and \r
+ Guid to the value specified by Value. Value is returned.\r
+ If Guid is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 8-bit value to set.\r
+\r
+ @retval UINT8 Return the value been set.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+LibPcdSetEx8 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN UINT8 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ ASSERT (Guid != NULL);\r
+\r
+ Status = PcdPpi->Set8Ex (Guid, TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 16-bit value for the token specified by TokenNumber and \r
+ Guid to the value specified by Value. Value is returned.\r
+ If Guid is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 16-bit value to set.\r
+\r
+ @retval UINT8 Return the value been set.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+LibPcdSetEx16 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN UINT16 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ ASSERT (Guid != NULL);\r
+ Status = PcdPpi->Set16Ex (Guid, TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 32-bit value for the token specified by TokenNumber and \r
+ Guid to the value specified by Value. Value is returned.\r
+ If Guid is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 32-bit value to set.\r
+\r
+ @retval UINT32 Return the value been set.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+LibPcdSetEx32 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+ ASSERT (Guid != NULL);\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+\r
+ Status = PcdPpi->Set32Ex (Guid, TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the 64-bit value for the token specified by TokenNumber and \r
+ Guid to the value specified by Value. Value is returned.\r
+ If Guid is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The 64-bit value to set.\r
+\r
+ @retval UINT64 Return the value been set.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+LibPcdSetEx64 (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN UINT64 Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+ ASSERT (Guid != NULL);\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+\r
+ Status = PcdPpi->Set64Ex (Guid, TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets a buffer for the token specified by TokenNumber to the value specified by \r
+ Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r
+ the maximum size support by TokenNumber, then set SizeOfValue to the maximum size \r
+ supported by TokenNumber and return NULL to indicate that the set operation \r
+ was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
+ @param[in] Buffer A pointer to the buffer to set.\r
+\r
+ @retval VOID * Return the pinter to the buffer been set.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPcdSetExPtr (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI *PcdPpi;\r
+ ASSERT (SizeOfBuffer != NULL);\r
+ if (*SizeOfBuffer > 0) {\r
+ ASSERT (Buffer != NULL);\r
+ }\r
+ ASSERT (Guid != NULL);\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ Status = PcdPpi->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+\r
+ return Buffer;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the Boolean value for the token specified by TokenNumber and \r
+ Guid to the value specified by Value. Value is returned.\r
+ If Guid is NULL, then ASSERT().\r
+ \r
+ @param[in] Guid Pointer to a 128-bit unique value that \r
+ designates which namespace to set a value from.\r
+ @param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in] Value The Boolean value to set.\r
+\r
+ @retval Boolean Return the value been set.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LibPcdSetExBool (\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN BOOLEAN Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+ ASSERT (Guid != NULL);\r
+ Status = PcdPpi->SetBoolEx (Guid, TokenNumber, Value);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Value;\r
+}\r
+\r
+\r
+\r
+/**\r
+ When the token specified by TokenNumber and Guid is set, \r
+ then notification function specified by NotificationFunction is called. \r
+ If Guid is NULL, then the default token space is used. \r
+ If NotificationFunction is NULL, then ASSERT().\r
+\r
+ @param[in] Guid Pointer to a 128-bit unique value that designates which \r
+ namespace to set a value from. If NULL, then the default \r
+ token space is used.\r
+ @param[in] TokenNumber The PCD token number to monitor.\r
+ @param[in] NotificationFunction The function to call when the token \r
+ specified by Guid and TokenNumber is set.\r
+\r
+ @retval VOID\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdCallbackOnSet (\r
+ IN CONST GUID *Guid, OPTIONAL\r
+ IN UINTN TokenNumber,\r
+ IN PCD_CALLBACK NotificationFunction\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+\r
+ Status = PcdPpi->CallbackOnSet (Guid, TokenNumber, NotificationFunction);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Disable a notification function that was established with LibPcdCallbackonSet().\r
+ If NotificationFunction is NULL, then ASSERT().\r
+\r
+ @param[in] Guid Specify the GUID token space.\r
+ @param[in] TokenNumber Specify the token number.\r
+ @param[in] NotificationFunction The callback function to be unregistered.\r
+\r
+ @retval VOID\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdCancelCallback (\r
+ IN CONST GUID *Guid, OPTIONAL\r
+ IN UINTN TokenNumber,\r
+ IN PCD_CALLBACK NotificationFunction\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+\r
+ Status = PcdPpi->CancelCallback (Guid, TokenNumber, NotificationFunction);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Retrieves the next PCD token number from the token space specified by Guid. \r
+ If Guid is NULL, then the default token space is used. If TokenNumber is 0, \r
+ then the first token number is returned. Otherwise, the token number that \r
+ follows TokenNumber in the token space is returned. If TokenNumber is the last \r
+ token number in the token space, then 0 is returned. If TokenNumber is not 0 and \r
+ is not in the token space specified by Guid, then ASSERT().\r
+\r
+ @param[in] Pointer to a 128-bit unique value that designates which namespace \r
+ to set a value from. If NULL, then the default token space is used.\r
+ @param[in] The previous PCD token number. If 0, then retrieves the first PCD \r
+ token number.\r
+\r
+ @retval UINTN The next valid token number.\r
+\r
+**/\r
+UINTN \r
+EFIAPI\r
+LibPcdGetNextToken (\r
+ IN CONST GUID *Guid, OPTIONAL\r
+ IN UINTN TokenNumber\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+\r
+ Status = PcdPpi->GetNextToken (Guid, &TokenNumber);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return TokenNumber;\r
+}\r
+\r
+\r
+/**\r
+ Retrieves the next PCD token space from a token space specified by Guid.\r
+ Guid of NULL is reserved to mark the default local token namespace on the current\r
+ platform. If Guid is NULL, then the GUID of the first non-local token space of the \r
+ current platform is returned. If Guid is the last non-local token space, \r
+ then NULL is returned. \r
+\r
+ If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().\r
+\r
+\r
+ \r
+ @param[in] Pointer to a 128-bit unique value that designates from which namespace \r
+ to start the search.\r
+\r
+ @retval CONST GUID * The next valid token namespace.\r
+\r
+**/\r
+GUID * \r
+EFIAPI\r
+LibPcdGetNextTokenSpace (\r
+ IN CONST GUID *Guid\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+\r
+ Status = PcdPpi->GetNextTokenSpace (&Guid);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return (GUID *)Guid;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
+ and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r
+ MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return \r
+ NULL to indicate that the set operation was not actually performed. \r
+ If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to \r
+ MaximumDatumSize and NULL must be returned.\r
+ \r
+ If PatchVariable is NULL, then ASSERT().\r
+ If SizeOfValue is NULL, then ASSERT().\r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
+\r
+ @param[in] PatchVariable A pointer to the global variable in a module that is \r
+ the target of the set operation.\r
+ @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
+ @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
+ @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPatchPcdSetPtr (\r
+ IN VOID *PatchVariable,\r
+ IN UINTN MaximumDatumSize,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN CONST VOID *Buffer\r
+ )\r
+{\r
+ ASSERT (PatchVariable != NULL);\r
+ ASSERT (SizeOfBuffer != NULL);\r
+ \r
+ if (*SizeOfBuffer > 0) {\r
+ ASSERT (Buffer != NULL);\r
+ }\r
+\r
+ if ((*SizeOfBuffer > MaximumDatumSize) ||\r
+ (*SizeOfBuffer == MAX_ADDRESS)) {\r
+ *SizeOfBuffer = MaximumDatumSize;\r
+ return NULL;\r
+ }\r
+ \r
+ CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
+ \r
+ return (VOID *) Buffer;\r
+}\r
+\r
+\r
--- /dev/null
+#/** @file\r
+# PCD Library instance implemented with PCD PPI.\r
+#\r
+# This library instance implement the APIs listed \r
+# in PCD library class defined in MDE library specification.\r
+# It is used by module in PEI phase.\r
+# Copyright (c) 2007, Intel Corporation\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = PeiPcdLib\r
+ FILE_GUID = 9dbf6f25-0da2-4a1d-8e12-e78de6ab4d0e\r
+ MODULE_TYPE = PEIM\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = PcdLib|PEIM PEI_CORE \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ PeiPcdLib.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ BaseMemoryLib\r
+ PeiServicesTablePointerLib\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# PPI C Name Section - list of PPI and PPI Notify C Names that this module\r
+# uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Ppis]\r
+ gPcdPpiGuid # PPI ALWAYS_CONSUMED\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>PeiPcdLib</ModuleName>\r
+ <ModuleType>PEIM</ModuleType>\r
+ <GuidValue>9dbf6f25-0da2-4a1d-8e12-e78de6ab4d0e</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>PCD Library instance implemented with PCD PPI.</Abstract>\r
+ <Description>This library instance implement the APIs listed
+ in PCD library class defined in MDE library specification.
+ It is used by module in PEI phase.</Description>\r
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>PeiPcdLib</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="PEIM PEI_CORE">\r
+ <Keyword>PcdLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PeiServicesTablePointerLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>PeiPcdLib.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <PPIs>\r
+ <Ppi Usage="ALWAYS_CONSUMED">\r
+ <PpiCName>gPcdPpiGuid</PpiCName>\r
+ </Ppi>\r
+ </PPIs>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/ResourcePublicationLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Resource Publication Library that uses PEI Core Services to publish system memory.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+ Module Name: PeiResourcePublicationLib.c\r
+\r
+**/\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+/**\r
+ \r
+ Declares the presence of permanent system memory in the platform.\r
+\r
+ Declares that the system memory buffer specified by MemoryBegin and MemoryLength\r
+ as permanent memory that may be used for general purpose use by software.\r
+ The amount of memory available to software may be less than MemoryLength\r
+ if published memory has alignment restrictions. \r
+\r
+ @param MemoryBegin The start address of the memory being declared.\r
+ @param MemoryLength The number of bytes of memory being declared.\r
+\r
+ @retval RETURN_SUCCESS The memory buffer was published.\r
+ @retval RETURN_OUT_OF_RESOURCES There are not enough resources to publish the memory buffer\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PublishSystemMemory (\r
+ IN PHYSICAL_ADDRESS MemoryBegin,\r
+ IN UINT64 MemoryLength\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (MemoryLength > 0);\r
+ ASSERT (MemoryLength <= (MAX_ADDRESS - MemoryBegin + 1));\r
+\r
+ Status = PeiServicesInstallPeiMemory (MemoryBegin, MemoryLength);\r
+ \r
+ return (RETURN_STATUS) Status;\r
+}\r
+\r
--- /dev/null
+#/** @file\r
+# Component description file for Pei Resource Publication Library\r
+#\r
+# Resource Publication Library that uses PEI Services to publish system memory.\r
+# Copyright (c) 2007, Intel Corporation\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = PeiResourcePublicationLib\r
+ FILE_GUID = e8d6390d-e190-4957-9ab6-d47d51b01336\r
+ MODULE_TYPE = PEIM\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = ResourcePublicationLib|PEIM \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ PeiResourcePublicationLib.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ DebugLib\r
+ PeiServicesLib\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>PeiResourcePublicationLib</ModuleName>\r
+ <ModuleType>PEIM</ModuleType>\r
+ <GuidValue>e8d6390d-e190-4957-9ab6-d47d51b01336</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for Pei Resource Publication Library</Abstract>\r
+ <Description>Resource Publication Library that uses PEI Services to publish system memory.</Description>\r
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>PeiResourcePublicationLib</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="PEIM">\r
+ <Keyword>ResourcePublicationLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PeiServicesLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>PeiResourcePublicationLib.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007 - 2007, Intel Corporation.\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ PEI Services Table Pointer Library.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ Module Name: PeiServicesTablePointer.c\r
+\r
+**/\r
+\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+static EFI_PEI_SERVICES **gPeiServices;\r
+\r
+/**\r
+ The function returns the pointer to PEI services.\r
+\r
+ The function returns the pointer to PEI services.\r
+ It will ASSERT() if the pointer to PEI services is NULL.\r
+\r
+ @retval The pointer to PeiServices.\r
+\r
+**/\r
+EFI_PEI_SERVICES **\r
+GetPeiServicesTablePointer (\r
+ VOID\r
+ )\r
+{\r
+ ASSERT (gPeiServices != NULL);\r
+ return gPeiServices;\r
+}\r
+\r
+\r
+/**\r
+ The constructor function caches the pointer to PEI services.\r
+ \r
+ The constructor function caches the pointer to PEI services.\r
+ It will always return EFI_SUCCESS.\r
+\r
+ @param FfsHeader Pointer to FFS header the loaded driver.\r
+ @param PeiServices Pointer to the PEI services.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesTablePointerLibConstructor (\r
+ IN EFI_FFS_FILE_HEADER *FfsHeader,\r
+ IN EFI_PEI_SERVICES **PeiServices\r
+ )\r
+{\r
+ gPeiServices = PeiServices;\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+#/** @file\r
+# Component description file for Pei Services Table Library\r
+#\r
+# PEI Services Table Library implementation that retrieves a pointer to the\r
+# PEI Services Table from a global variable. Not available to modules that execute from\r
+# read-only memory.\r
+# Copyright (c) 2007 - 2007, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = PeiServicesTablePointerLib\r
+ FILE_GUID = 1c747f6b-0a58-49ae-8ea3-0327a4fa10e3\r
+ MODULE_TYPE = PEIM\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = PeiServicesTablePointerLib|PEIM PEI_CORE \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ CONSTRUCTOR = PeiServicesTablePointerLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ PeiServicesTablePointer.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ DebugLib\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>PeiServicesTablePointerLib</ModuleName>\r
+ <ModuleType>PEIM</ModuleType>\r
+ <GuidValue>1c747f6b-0a58-49ae-8ea3-0327a4fa10e3</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for Pei Services Table Library</Abstract>\r
+ <Description>PEI Services Table Library implementation that retrieves a pointer to the
+ PEI Services Table from a global variable. Not available to modules that execute from
+ read-only memory.</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>PeiServicesTablePointerLib</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="PEIM PEI_CORE">\r
+ <Keyword>PeiServicesTablePointerLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>PeiServicesTablePointer.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <Constructor>PeiServicesTablePointerLibConstructor</Constructor>\r
+ </Extern>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007 - 2007, Intel Corporation.\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <Base.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/TimerLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Timer Library functions built upon ITC on IPF.\r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ Module Name: IpfTimerLib.c\r
+\r
+**/\r
+\r
+\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+/**\r
+ Performs a delay measured as number of ticks.\r
+\r
+ An internal function to perform a delay measured as number of ticks. It's\r
+ invoked by MicroSecondDelay() and NanoSecondDelay().\r
+\r
+ @param Delay Number of ticks to delay.\r
+\r
+**/\r
+STATIC\r
+VOID\r
+InternalIpfDelay (\r
+ IN INT64 Delay\r
+ )\r
+{\r
+ INT64 Ticks;\r
+\r
+ //\r
+ // The target timer count is calculated here\r
+ //\r
+ Ticks = (INT64)AsmReadItc () + Delay;\r
+\r
+ //\r
+ // Wait until time out\r
+ // Delay > 2^63 could not be handled by this function\r
+ // Timer wrap-arounds are handled correctly by this function\r
+ //\r
+ while (Ticks - (INT64)AsmReadItc() >= 0);\r
+}\r
+\r
+/**\r
+ Stalls the CPU for at least the given number of microseconds.\r
+\r
+ Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+ @param MicroSeconds The minimum number of microseconds to delay.\r
+\r
+ @return MicroSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+ IN UINTN MicroSeconds\r
+ )\r
+{\r
+ InternalIpfDelay (\r
+ GetPerformanceCounterProperties (NULL, NULL) *\r
+ MicroSeconds /\r
+ 1000000\r
+ );\r
+ return MicroSeconds;\r
+}\r
+\r
+/**\r
+ Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+ Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+ @param NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+ @return NanoSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+ IN UINTN NanoSeconds\r
+ )\r
+{\r
+ InternalIpfDelay (\r
+ GetPerformanceCounterProperties (NULL, NULL) *\r
+ NanoSeconds /\r
+ 1000000000\r
+ );\r
+ return NanoSeconds;\r
+}\r
+\r
+/**\r
+ Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+ Retrieves the current value of a 64-bit free running performance counter. The\r
+ counter can either count up by 1 or count down by 1. If the physical\r
+ performance counter counts by a larger increment, then the counter values\r
+ must be translated. The properties of the counter can be retrieved from\r
+ GetPerformanceCounterProperties().\r
+\r
+ @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+ VOID\r
+ )\r
+{\r
+ return AsmReadItc ();\r
+}\r
+\r
+/**\r
+ Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+ values.\r
+\r
+ If StartValue is not NULL, then the value that the performance counter starts\r
+ with immediately after is it rolls over is returned in StartValue. If\r
+ EndValue is not NULL, then the value that the performance counter end with\r
+ immediately before it rolls over is returned in EndValue. The 64-bit\r
+ frequency of the performance counter in Hz is always returned. If StartValue\r
+ is less than EndValue, then the performance counter counts up. If StartValue\r
+ is greater than EndValue, then the performance counter counts down. For\r
+ example, a 64-bit free running counter that counts up would have a StartValue\r
+ of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+ that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+ @param StartValue The value the performance counter starts with when it\r
+ rolls over.\r
+ @param EndValue The value that the performance counter ends with before\r
+ it rolls over.\r
+\r
+ @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+ OUT UINT64 *StartValue, OPTIONAL\r
+ OUT UINT64 *EndValue OPTIONAL\r
+ )\r
+{\r
+ PAL_CALL_RETURN PalRet;\r
+ UINT64 BaseFrequence;\r
+\r
+ PalRet = PalCallStatic (NULL, 13, 0, 0, 0);\r
+ ASSERT (PalRet.Status == 0);\r
+ BaseFrequence = PalRet.r9;\r
+\r
+ PalRet = PalCallStatic (NULL, 14, 0, 0, 0);\r
+ ASSERT (PalRet.Status == 0);\r
+\r
+ if (StartValue != NULL) {\r
+ *StartValue = 0;\r
+ }\r
+\r
+ if (EndValue != NULL) {\r
+ *EndValue = (UINT64)(-1);\r
+ }\r
+\r
+ return BaseFrequence * (PalRet.r11 >> 32) / (UINT32)PalRet.r11;\r
+}\r
--- /dev/null
+#/** @file\r
+# Timer Library implementation for Boot Timer moudles that require timer services.\r
+#\r
+# Timer Library that uses CPU resources to provide calibrated\r
+# delays on IA-32 and x64, and uses ITC on IPF. Note: Because CpuLocalApci\r
+# and ITC could be programmed by OS, it cannot be used by SMM drivers\r
+# and runtime drivers, ACPI timer is recommended for SMM drivers and RUNTIME\r
+# drivers.\r
+# Copyright (c) 2007 - 2007, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = SecPeiDxeTimerLibCpu\r
+ FILE_GUID = b5a05743-9b71-489b-a0ed-a0eb3950d23b\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = TimerLib|BASE DXE_CORE DXE_DRIVER DXE_SAL_DRIVER PEIM PEI_CORE SEC UEFI_APPLICATION UEFI_DRIVER \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ CommonHeader.h\r
+\r
+[Sources.Ia32]\r
+ x86TimerLib.c\r
+\r
+[Sources.X64]\r
+ x86TimerLib.c\r
+\r
+[Sources.IPF]\r
+ IpfTimerLib.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+\r
+[LibraryClasses.IA32]\r
+ PcdLib\r
+ IoLib\r
+\r
+[LibraryClasses.X64]\r
+ PcdLib\r
+ IoLib\r
+\r
+[LibraryClasses.IPF]\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd DYNAMIC - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsDynamic.IA32]\r
+ PcdFSBClock|gEfiMdePkgTokenSpaceGuid\r
+\r
+[PcdsDynamic.X64]\r
+ PcdFSBClock|gEfiMdePkgTokenSpaceGuid\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>SecPeiDxeTimerLibCpu</ModuleName>\r
+ <ModuleType>BASE</ModuleType>\r
+ <GuidValue>b5a05743-9b71-489b-a0ed-a0eb3950d23b</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Timer Library implementation for Boot Timer moudles that require timer services.</Abstract>\r
+ <Description>Timer Library that uses CPU resources to provide calibrated
+ delays on IA-32 and x64, and uses ITC on IPF. Note: Because CpuLocalApci
+ and ITC could be programmed by OS, it cannot be used by SMM drivers
+ and runtime drivers, ACPI timer is recommended for SMM drivers and RUNTIME
+ drivers.</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>SecPeiDxeTimerLibCpu</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="BASE DXE_CORE DXE_DRIVER DXE_SAL_DRIVER PEIM PEI_CORE SEC UEFI_APPLICATION UEFI_DRIVER">\r
+ <Keyword>TimerLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED" SupArchList="IA32 X64">\r
+ <Keyword>IoLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED" SupArchList="IPF">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED" SupArchList="IA32 X64">\r
+ <Keyword>PcdLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename SupArchList="IA32">x86TimerLib.c</Filename>\r
+ <Filename SupArchList="X64">x86TimerLib.c</Filename>\r
+ <Filename SupArchList="IPF">IpfTimerLib.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ </Externs>\r
+ <PcdCoded>\r
+ <PcdEntry PcdItemType="DYNAMIC" Usage="ALWAYS_CONSUMED" SupArchList="IA32 X64">\r
+ <C_Name>PcdFSBClock</C_Name>\r
+ <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This value is FSB Clock frequency. Its unit is Hz and its default value is 200000000, that means FSB frequency is 200Mhz.</HelpText>\r
+ </PcdEntry>\r
+ </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/** @file\r
+ Timer Library functions built upon local APIC on IA32/x64.\r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ Module Name: x86TimerLib.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+//\r
+// The following array is used in calculating the frequency of local APIC\r
+// timer. Refer to IA-32 developers' manual for more details.\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED\r
+CONST UINT8 mTimerLibLocalApicDivisor[] = {\r
+ 0x02, 0x04, 0x08, 0x10,\r
+ 0x02, 0x04, 0x08, 0x10,\r
+ 0x20, 0x40, 0x80, 0x01,\r
+ 0x20, 0x40, 0x80, 0x01\r
+};\r
+\r
+/**\r
+ Internal function to retrieve the base address of local APIC.\r
+\r
+ Internal function to retrieve the base address of local APIC.\r
+\r
+ @return The base address of local APIC\r
+\r
+**/\r
+STATIC\r
+UINTN\r
+InternalX86GetApicBase (\r
+ VOID\r
+ )\r
+{\r
+ return (UINTN)AsmMsrBitFieldRead64 (27, 12, 35) << 12;\r
+}\r
+\r
+/**\r
+ Internal function to return the frequency of the local APIC timer.\r
+\r
+ Internal function to return the frequency of the local APIC timer.\r
+\r
+ @param ApicBase The base address of memory mapped registers of local APIC.\r
+\r
+ @return The frequency of the timer in Hz.\r
+\r
+**/\r
+STATIC\r
+UINT32\r
+InternalX86GetTimerFrequency (\r
+ IN UINTN ApicBase\r
+ )\r
+{\r
+ return\r
+ PcdGet32(PcdFSBClock) /\r
+ mTimerLibLocalApicDivisor[MmioBitFieldRead32 (ApicBase + 0x3e0, 0, 3)];\r
+}\r
+\r
+/**\r
+ Internal function to read the current tick counter of local APIC.\r
+\r
+ Internal function to read the current tick counter of local APIC.\r
+\r
+ @param ApicBase The base address of memory mapped registers of local APIC.\r
+\r
+ @return The tick counter read.\r
+\r
+**/\r
+STATIC\r
+INT32\r
+InternalX86GetTimerTick (\r
+ IN UINTN ApicBase\r
+ )\r
+{\r
+ return MmioRead32 (ApicBase + 0x390);\r
+}\r
+\r
+/**\r
+ Stalls the CPU for at least the given number of ticks.\r
+\r
+ Stalls the CPU for at least the given number of ticks. It's invoked by\r
+ MicroSecondDelay() and NanoSecondDelay().\r
+\r
+ @param ApicBase The base address of memory mapped registers of local APIC.\r
+ @param Delay A period of time to delay in ticks.\r
+\r
+**/\r
+STATIC\r
+VOID\r
+InternalX86Delay (\r
+ IN UINTN ApicBase,\r
+ IN UINT32 Delay\r
+ )\r
+{\r
+ INT32 Ticks;\r
+\r
+ //\r
+ // The target timer count is calculated here\r
+ //\r
+ Ticks = InternalX86GetTimerTick (ApicBase) - Delay;\r
+\r
+ //\r
+ // Wait until time out\r
+ // Delay > 2^31 could not be handled by this function\r
+ // Timer wrap-arounds are handled correctly by this function\r
+ //\r
+ while (InternalX86GetTimerTick (ApicBase) - Ticks >= 0);\r
+}\r
+\r
+/**\r
+ Stalls the CPU for at least the given number of microseconds.\r
+\r
+ Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+ @param MicroSeconds The minimum number of microseconds to delay.\r
+\r
+ @return MicroSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+ IN UINTN MicroSeconds\r
+ )\r
+{\r
+ UINTN ApicBase;\r
+\r
+ ApicBase = InternalX86GetApicBase ();\r
+ InternalX86Delay (\r
+ ApicBase,\r
+ (UINT32)DivU64x32 (\r
+ MultU64x64 (\r
+ InternalX86GetTimerFrequency (ApicBase),\r
+ MicroSeconds\r
+ ),\r
+ 1000000u\r
+ )\r
+ );\r
+ return MicroSeconds;\r
+}\r
+\r
+/**\r
+ Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+ Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+ @param NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+ @return NanoSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+ IN UINTN NanoSeconds\r
+ )\r
+{\r
+ UINTN ApicBase;\r
+\r
+ ApicBase = InternalX86GetApicBase ();\r
+ InternalX86Delay (\r
+ ApicBase,\r
+ (UINT32)DivU64x32 (\r
+ MultU64x64 (\r
+ InternalX86GetTimerFrequency (ApicBase),\r
+ NanoSeconds\r
+ ),\r
+ 1000000000u\r
+ )\r
+ );\r
+ return NanoSeconds;\r
+}\r
+\r
+/**\r
+ Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+ Retrieves the current value of a 64-bit free running performance counter. The\r
+ counter can either count up by 1 or count down by 1. If the physical\r
+ performance counter counts by a larger increment, then the counter values\r
+ must be translated. The properties of the counter can be retrieved from\r
+ GetPerformanceCounterProperties().\r
+\r
+ @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+ VOID\r
+ )\r
+{\r
+ return (UINT64)(UINT32)InternalX86GetTimerTick (InternalX86GetApicBase ());\r
+}\r
+\r
+/**\r
+ Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+ values.\r
+\r
+ If StartValue is not NULL, then the value that the performance counter starts\r
+ with immediately after is it rolls over is returned in StartValue. If\r
+ EndValue is not NULL, then the value that the performance counter end with\r
+ immediately before it rolls over is returned in EndValue. The 64-bit\r
+ frequency of the performance counter in Hz is always returned. If StartValue\r
+ is less than EndValue, then the performance counter counts up. If StartValue\r
+ is greater than EndValue, then the performance counter counts down. For\r
+ example, a 64-bit free running counter that counts up would have a StartValue\r
+ of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+ that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+ @param StartValue The value the performance counter starts with when it\r
+ rolls over.\r
+ @param EndValue The value that the performance counter ends with before\r
+ it rolls over.\r
+\r
+ @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+ OUT UINT64 *StartValue, OPTIONAL\r
+ OUT UINT64 *EndValue OPTIONAL\r
+ )\r
+{\r
+ UINTN ApicBase;\r
+\r
+ ApicBase = InternalX86GetApicBase ();\r
+\r
+ if (StartValue != NULL) {\r
+ *StartValue = MmioRead32 (ApicBase + 0x380);\r
+ }\r
+\r
+ if (EndValue != NULL) {\r
+ *EndValue = 0;\r
+ }\r
+\r
+ return (UINT64) InternalX86GetTimerFrequency (ApicBase);;\r
+}\r
--- /dev/null
+/** @file\r
+ Entry point library instance to a UEFI application.\r
+\r
+Copyright (c) 2007, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+/**\r
+ Enrty point to UEFI application.\r
+\r
+ @param ImageHandle ImageHandle of the loaded driver.\r
+ @param SystemTable Pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.\r
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ if (_gUefiDriverRevision != 0) {\r
+ //\r
+ // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the application.\r
+ //\r
+ if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {\r
+ return EFI_INCOMPATIBLE_VERSION;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Call constructor for all libraries.\r
+ //\r
+ ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
+\r
+ //\r
+ // Call the module's entry point\r
+ //\r
+ Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);\r
+\r
+ //\r
+ // Process destructor for all libraries.\r
+ //\r
+ ProcessLibraryDestructorList (ImageHandle, SystemTable);\r
+\r
+ //\r
+ // Return the return status code from the driver entry point\r
+ //\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Invoke the destuctors of all libraries and call gBS->Exit\r
+ to return control to firmware core.\r
+\r
+ @param Status Status returned by the application that is exiting.\r
+ \r
+ @retval VOID\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Exit (\r
+ IN EFI_STATUS Status\r
+ )\r
+\r
+{\r
+ ProcessLibraryDestructorList (gImageHandle, gST);\r
+\r
+ gBS->Exit (gImageHandle, Status, 0, NULL);\r
+}\r
+\r
+/**\r
+ Enrty point wrapper of UEFI Application.\r
+\r
+ @param ImageHandle ImageHandle of the loaded driver.\r
+ @param SystemTable Pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.\r
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMain (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ return _ModuleEntryPoint (ImageHandle, SystemTable);\r
+}\r
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007, Intel Corporation.\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <Uefi.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/UefiApplicationEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Component description file for the entry point to a EFI Application\r
+#\r
+# Library to abstract entry point to a EFI Application.\r
+# Copyright (c) 2007, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = UefiApplicationEntryPoint\r
+ FILE_GUID = DADE8301-CB29-4fd5-8148-56FD246C5B88\r
+ MODULE_TYPE = UEFI_APPLICATION\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = UefiApplicationEntryPoint|UEFI_APPLICATION \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ ApplicationEntryPoint.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ UefiBootServicesTableLib\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>UefiApplicationEntryPoint</ModuleName>\r
+ <ModuleType>UEFI_APPLICATION</ModuleType>\r
+ <GuidValue>DADE8301-CB29-4fd5-8148-56FD246C5B88</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for the entry point to a EFI Application</Abstract>\r
+ <Description>Library to abstract entry point to a EFI Application.</Description>\r
+ <Copyright>Copyright (c) 2007, Intel Corporation.</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>UefiApplicationEntryPoint</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="UEFI_APPLICATION">\r
+ <Keyword>UefiApplicationEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiBootServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>ApplicationEntryPoint.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007, Intel Corporation.\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ UEFI Boot Services Table Library.\r
+\r
+ Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ Module Name: UefiBootServicesTableLib.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+EFI_HANDLE gImageHandle = NULL;\r
+EFI_SYSTEM_TABLE *gST = NULL;\r
+EFI_BOOT_SERVICES *gBS = NULL;\r
+\r
+/**\r
+ The constructor function caches the pointer of Boot Services Table.\r
+ \r
+ The constructor function caches the pointer of Boot Services Table through System Table.\r
+ It will ASSERT() if the pointer of System Table is NULL.\r
+ It will ASSERT() if the pointer of Boot Services Table is NULL.\r
+ It will always return EFI_SUCCESS.\r
+\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
+ @param SystemTable A pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UefiBootServicesTableLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ //\r
+ // Cache the Image Handle\r
+ //\r
+ gImageHandle = ImageHandle;\r
+ ASSERT (gImageHandle != NULL);\r
+\r
+ //\r
+ // Cache pointer to the EFI System Table\r
+ //\r
+ gST = SystemTable;\r
+ ASSERT (gST != NULL);\r
+\r
+ //\r
+ // Cache pointer to the EFI Boot Services Table\r
+ //\r
+ gBS = SystemTable->BootServices;\r
+ ASSERT (gBS != NULL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+#/** @file\r
+# UEFI Boot Services Table Library\r
+#\r
+# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification\r
+# Copyright (c) 2007, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = UefiBootServicesTableLib\r
+ FILE_GUID = ff5c7a2c-ab7a-4366-8616-11c6e53247b6\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = UefiBootServicesTableLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ CONSTRUCTOR = UefiBootServicesTableLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ UefiBootServicesTableLib.c\r
+ CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg\Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ DebugLib\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>UefiBootServicesTableLib</ModuleName>\r
+ <ModuleType>DXE_DRIVER</ModuleType>\r
+ <GuidValue>ff5c7a2c-ab7a-4366-8616-11c6e53247b6</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>UEFI Boot Services Table Library</Abstract>\r
+ <Description>Library to abstract Framework extensions that conflict with UEFI 2.0 Specification</Description>\r
+ <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+ <License>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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>UefiBootServicesTableLib</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">\r
+ <Keyword>UefiBootServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>UefiBootServicesTableLib.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <Constructor>UefiBootServicesTableLibConstructor</Constructor>\r
+ </Extern>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Common header file shared by all source files.\r
+\r
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+ Copyright (c) 2007, Intel Corporation.\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <Uefi.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+#endif\r