From 19e14fc9d947eccdfcfe2d1464dfac791015b465 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Tue, 2 Sep 2008 05:51:05 +0000 Subject: [PATCH] 1. Use AllocateAlignedPages() to remove tricky logic in DebugImageInfo.c 2. Add ReportStatusCodeLib instance in MdeModulePkg.dsc for DxeCore. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5774 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/DebugImageInfo.h | 3 +- MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c | 41 +-------------------- MdeModulePkg/MdeModulePkg.dsc | 1 + 3 files changed, 4 insertions(+), 41 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/DebugImageInfo.h b/MdeModulePkg/Core/Dxe/DebugImageInfo.h index 8074fa2098..317546b5ba 100644 --- a/MdeModulePkg/Core/Dxe/DebugImageInfo.h +++ b/MdeModulePkg/Core/Dxe/DebugImageInfo.h @@ -16,8 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __DEBUG_IMAGE_INFO_H__ #define __DEBUG_IMAGE_INFO_H__ -#define FOUR_MEG_PAGES 0x400 -#define FOUR_MEG_MASK ((FOUR_MEG_PAGES * EFI_PAGE_SIZE) - 1) +#define FOUR_MEG_ALIGNMENT 0x400000 #define EFI_DEBUG_TABLE_ENTRY_SIZE (sizeof (VOID *)) diff --git a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c index 50e4468399..556c14c585 100644 --- a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c +++ b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c @@ -30,12 +30,6 @@ EFI_SYSTEM_TABLE_POINTER *mDebugTable = NULL; Creates and initializes the DebugImageInfo Table. Also creates the configuration table and registers it into the system table. - Note: - This function allocates memory, frees it, and then allocates memory at an - address within the initial allocation. Since this function is called early - in DXE core initialization (before drivers are dispatched), this should not - be a problem. - **/ VOID CoreInitializeDebugImageInfoTable ( @@ -43,44 +37,13 @@ CoreInitializeDebugImageInfoTable ( ) { EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Mem; - UINTN NumberOfPages; // - // Allocate boot services memory for the structure. It's required to be aligned on - // a 4M boundary, so allocate a 4M block (plus what we require), free it up, calculate - // a 4M aligned address within the memory we just freed, and then allocate memory at that - // address for our initial structure. - // - NumberOfPages = FOUR_MEG_PAGES + EFI_SIZE_TO_PAGES(sizeof (EFI_SYSTEM_TABLE_POINTER)); - - Status = CoreAllocatePages (AllocateAnyPages, EfiBootServicesData, NumberOfPages , &Mem); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR(Status)) { - return; - } - Status = CoreFreePages (Mem, NumberOfPages); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR(Status)) { - return; - } - // - // Now get a 4M aligned address within the memory range we were given. - // Then allocate memory at that address - // - Mem = (Mem + FOUR_MEG_MASK) & (~FOUR_MEG_MASK); - - Status = CoreAllocatePages (AllocateAddress, EfiBootServicesData, NumberOfPages - FOUR_MEG_PAGES, &Mem); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR(Status)) { - return; - } - // - // We now have a 4M aligned page allocated, so fill in the data structure. + // 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 = (EFI_SYSTEM_TABLE_POINTER *)(UINTN)Mem; + mDebugTable = AllocateAlignedPages (EFI_SIZE_TO_PAGES (sizeof (EFI_SYSTEM_TABLE_POINTER)), FOUR_MEG_ALIGNMENT); mDebugTable->Signature = EFI_SYSTEM_TABLE_SIGNATURE; mDebugTable->EfiSystemTableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) gDxeCoreST; mDebugTable->Crc32 = 0; diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index a4ad566373..fc876ce495 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -115,6 +115,7 @@ HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf + ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf [LibraryClasses.common.DXE_DRIVER] HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf