From 19e14fc9d947eccdfcfe2d1464dfac791015b465 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Tue, 2 Sep 2008 05:51:05 +0000 Subject: 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/Misc/DebugImageInfo.c | 41 ++--------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) (limited to 'MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c') 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; -- cgit v1.2.3