/** @file\r
\r
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- \r
- 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
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
IN EFI_PHYSICAL_ADDRESS *EntryPoint\r
);\r
\r
+STATIC\r
+VOID*\r
+EFIAPI\r
+AllocateCodePages (\r
+ IN UINTN Pages\r
+ )\r
+{\r
+ VOID *Alloc;\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+\r
+ Alloc = AllocatePages (Pages);\r
+ if (Alloc == NULL) {\r
+ return NULL;\r
+ }\r
+\r
+ // find the HOB we just created, and change the type to EfiBootServicesCode\r
+ Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);\r
+ while (Hob.Raw != NULL) {\r
+ if (Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress == (UINTN)Alloc) {\r
+ Hob.MemoryAllocation->AllocDescriptor.MemoryType = EfiBootServicesCode;\r
+ return Alloc;\r
+ }\r
+ Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (Hob));\r
+ }\r
+\r
+ ASSERT (FALSE);\r
+\r
+ FreePages (Alloc, Pages);\r
+ return NULL;\r
+}\r
+\r
\r
EFI_STATUS\r
EFIAPI\r
VOID *Buffer;\r
\r
ZeroMem (&ImageContext, sizeof (ImageContext));\r
- \r
+\r
ImageContext.Handle = PeCoffImage;\r
ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;\r
\r
Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
ASSERT_EFI_ERROR (Status);\r
- \r
+\r
\r
//\r
// Allocate Memory for the image\r
//\r
- Buffer = AllocatePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.ImageSize));\r
+ Buffer = AllocateCodePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.ImageSize));\r
ASSERT (Buffer != 0);\r
\r
\r
\r
\r
\r
-typedef \r
+typedef\r
VOID\r
(EFIAPI *DXE_CORE_ENTRY_POINT) (\r
IN VOID *HobStart\r
return Status;\r
}\r
\r
- \r
+\r
Status = LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);\r
// For NT32 Debug Status = SecWinNtPeiLoadFile (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);\r
ASSERT_EFI_ERROR (Status);\r
ASSERT_EFI_ERROR (Status);\r
\r
BuildModuleHob (&FvFileInfo.FileName, (EFI_PHYSICAL_ADDRESS)(UINTN)ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE, EntryPoint);\r
- \r
+\r
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading DxeCore at 0x%10p EntryPoint=0x%10p\n", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)EntryPoint));\r
\r
Hob = GetHobList ();\r
if (StackSize == 0) {\r
// User the current stack\r
- \r
+\r
((DXE_CORE_ENTRY_POINT)(UINTN)EntryPoint) (Hob);\r
} else {\r
- \r
+\r
//\r
// Allocate 128KB for the Stack\r
//\r
BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (StackSize));\r
ASSERT (BaseOfStack != NULL);\r
- \r
+\r
//\r
// Compute the top of the stack we were allocated. Pre-allocate a UINTN\r
// for safety.\r
\r
//\r
// Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.\r
- // \r
+ //\r
UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, StackSize);\r
\r
SwitchStack (\r
);\r
\r
}\r
- \r
+\r
// Should never get here as DXE Core does not return\r
DEBUG ((EFI_D_ERROR, "DxeCore returned\n"));\r
ASSERT (FALSE);\r
- \r
+\r
return EFI_DEVICE_ERROR;\r
}\r
\r
\r
if (!EFI_ERROR (Status)) {\r
return LoadDxeCoreFromFfsFile (FileHandle, StackSize);\r
- } \r
- \r
- return Status; \r
+ }\r
+\r
+ return Status;\r
}\r
\r
\r
if (!EFI_ERROR (Status)) {\r
Status = FfsProcessFvFile (FileHandle);\r
}\r
- \r
+\r
return Status;\r
}\r
\r