diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-11 05:55:43 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-11 05:55:43 +0000 |
commit | 5a2487132ec07c5ddab6d379301660e0b0c21ddd (patch) | |
tree | 14e2b0f7712401ba3ad3c7cadb924586ed2e5bad | |
parent | 2ce2c0328e7a9714742a305eb856e65d1c348203 (diff) | |
download | edk2-5a2487132ec07c5ddab6d379301660e0b0c21ddd.tar.gz |
sync patch r11018 from main trunk.
Add new PCD gEfiMdeModulePkgTokenSpaceGuid.PcdMaxEfiSystemTablePointerAddress for the
MdeModulePkg that allows the platform DSC file to specify the address below which the
EFI_SYSTEM_TABLE_POINTER structure is allocated.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2010@11035 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | MdeModulePkg/Core/Dxe/DxeMain.inf | 4 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c | 94 | ||||
-rw-r--r-- | MdeModulePkg/MdeModulePkg.dec | 12 |
3 files changed, 101 insertions, 9 deletions
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf index 2f50ed0223..dae26a6121 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -145,4 +145,6 @@ [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressBootTimeCodePageNumber ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressRuntimeCodePageNumber ## SOMETIMES_CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdLoadModuleAtFixAddressEnable ## CONSUMES
\ No newline at end of file + gEfiMdeModulePkgTokenSpaceGuid.PcdLoadModuleAtFixAddressEnable ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxEfiSystemTablePointerAddress ## CONSUMES
+
\ No newline at end of file diff --git a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c index 6d5f5c0f89..a3f08bc8d7 100644 --- a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c +++ b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c @@ -2,7 +2,7 @@ Support functions for managing debug image info table when loading and unloading
images.
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>
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
@@ -24,9 +24,7 @@ EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugInfoTableHeader = { UINTN mMaxTableEntries = 0;
-EFI_SYSTEM_TABLE_POINTER *mDebugTable = NULL;
-
-#define FOUR_MEG_ALIGNMENT 0x400000
+EFI_SYSTEM_TABLE_POINTER *mDebugTable = NULL;
#define EFI_DEBUG_TABLE_ENTRY_SIZE (sizeof (VOID *))
@@ -40,18 +38,98 @@ CoreInitializeDebugImageInfoTable ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ UINTN Pages;
+ EFI_PHYSICAL_ADDRESS Memory;
+ UINTN AlignedMemory;
+ UINTN AlignmentMask;
+ UINTN UnalignedPages;
+ UINTN RealPages;
//
// Allocate 4M aligned page for the structure and fill in the data.
// Ideally we would update the CRC now as well, but the service may not yet be available.
// See comments in the CoreUpdateDebugTableCrc32() function below for details.
//
- mDebugTable = AllocateAlignedPages (EFI_SIZE_TO_PAGES (sizeof (EFI_SYSTEM_TABLE_POINTER)), FOUR_MEG_ALIGNMENT);
+ Pages = EFI_SIZE_TO_PAGES (sizeof (EFI_SYSTEM_TABLE_POINTER));
+ AlignmentMask = SIZE_4MB - 1;
+ RealPages = Pages + EFI_SIZE_TO_PAGES (SIZE_4MB);
+
+ //
+ // Attempt to allocate memory below PcdMaxEfiSystemTablePointerAddress
+ // If PcdMaxEfiSystemTablePointerAddress is 0, then allocate memory below
+ // MAX_ADDRESS
+ //
+ Memory = PcdGet64 (PcdMaxEfiSystemTablePointerAddress);
+ if (Memory == 0) {
+ Memory = MAX_ADDRESS;
+ }
+ Status = CoreAllocatePages (
+ AllocateMaxAddress,
+ EfiBootServicesData,
+ RealPages,
+ &Memory
+ );
+ if (EFI_ERROR (Status)) {
+ if (PcdGet64 (PcdMaxEfiSystemTablePointerAddress) != 0) {
+ DEBUG ((EFI_D_INFO, "Allocate memory for EFI_SYSTEM_TABLE_POINTER below PcdMaxEfiSystemTablePointerAddress failed. \
+ Retry to allocate memroy as close to the top of memory as feasible.\n"));
+ }
+ //
+ // If the initial memory allocation fails, then reattempt allocation
+ // as close to the top of memory as feasible.
+ //
+ Status = CoreAllocatePages (
+ AllocateAnyPages,
+ EfiBootServicesData,
+ RealPages,
+ &Memory
+ );
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+ }
+
+ //
+ // Free overallocated pages
+ //
+ AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
+ UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
+ if (UnalignedPages > 0) {
+ //
+ // Free first unaligned page(s).
+ //
+ Status = CoreFreePages (Memory, UnalignedPages);
+ ASSERT_EFI_ERROR (Status);
+ }
+ Memory = (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
+ UnalignedPages = RealPages - Pages - UnalignedPages;
+ if (UnalignedPages > 0) {
+ //
+ // Free last unaligned page(s).
+ //
+ Status = CoreFreePages (Memory, UnalignedPages);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ //
+ // Set mDebugTable to the 4MB aligned allocated pages
+ //
+ mDebugTable = (EFI_SYSTEM_TABLE_POINTER *)(AlignedMemory);
ASSERT (mDebugTable != NULL);
- mDebugTable->Signature = EFI_SYSTEM_TABLE_SIGNATURE;
+
+ //
+ // Initialize EFI_SYSTEM_TABLE_POINTER structure
+ //
+ mDebugTable->Signature = EFI_SYSTEM_TABLE_SIGNATURE;
mDebugTable->EfiSystemTableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) gDxeCoreST;
- mDebugTable->Crc32 = 0;
+ mDebugTable->Crc32 = 0;
+
+ //
+ // Install the EFI_SYSTEM_TABLE_POINTER structure in the EFI System
+ // Configuration Table
+ //
Status = CoreInstallConfigurationTable (&gEfiDebugImageInfoTableGuid, &mDebugInfoTableHeader);
ASSERT_EFI_ERROR (Status);
}
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 89beb6897e..cd1270ec2a 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -77,6 +77,7 @@ ## @libraryclass Debug Agent is used to provide soft debug capability.
#
DebugAgentLib|Include/Library/DebugAgentLib.h
+
[Guids]
## MdeModule package token space guid
# Include/Guid/MdeModulePkgTokenSpace.h
@@ -373,6 +374,17 @@ ## RTC Update Timeout Value
gEfiMdeModulePkgTokenSpaceGuid.PcdRealTimeClockUpdateTimeout|100000|UINT32|0x00010034
+ ## Maximum address that the DXE Core will allocate the EFI_SYSTEM_TABLE_POINTER
+ # structure. The default value for this PCD is 0, which means that the DXE Core
+ # will allocate the buffer from the EFI_SYSTEM_TABLE_POINTER structure on a 4MB
+ # boundary as close to the top of memory as feasible. If this PCD is set to a
+ # value other than 0, then the DXE Core will first attempt to allocate the
+ # EFI_SYSTEM_TABLE_POINTER structure on a 4MB boundary below the address specified
+ # by this PCD, and if that allocation fails, retry the allocation on a 4MB
+ # boundary as close to the top of memory as feasible.
+ #
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxEfiSystemTablePointerAddress|0x0|UINT64|0x30001027
+
[PcdsPatchableInModule,PcdsDynamic]
## This PCD defines the Console output column and the default value is 25 according to UEFI spec
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|25|UINT32|0x40000006
|