• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   ARM specifc functionality for DxeLoad.
3 
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6 
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution.  The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11 
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 
15 **/
16 
17 #include "DxeIpl.h"
18 
19 #include <Library/ArmLib.h>
20 
21 /**
22    Transfers control to DxeCore.
23 
24    This function performs a CPU architecture specific operations to execute
25    the entry point of DxeCore with the parameters of HobList.
26    It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.
27 
28    @param DxeCoreEntryPoint         The entry point of DxeCore.
29    @param HobList                   The start of HobList passed to DxeCore.
30 
31 **/
32 VOID
HandOffToDxeCore(IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,IN EFI_PEI_HOB_POINTERS HobList)33 HandOffToDxeCore (
34   IN EFI_PHYSICAL_ADDRESS   DxeCoreEntryPoint,
35   IN EFI_PEI_HOB_POINTERS   HobList
36   )
37 {
38   VOID                *BaseOfStack;
39   VOID                *TopOfStack;
40   EFI_STATUS          Status;
41 
42   //
43   // Allocate 128KB for the Stack
44   //
45   BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
46   ASSERT (BaseOfStack != NULL);
47 
48   if (PcdGetBool (PcdSetNxForStack)) {
49     Status = ArmSetMemoryRegionNoExec ((UINTN)BaseOfStack, STACK_SIZE);
50     ASSERT_EFI_ERROR (Status);
51   }
52 
53   //
54   // Compute the top of the stack we were allocated. Pre-allocate a UINTN
55   // for safety.
56   //
57   TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
58   TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
59 
60   //
61   // End of PEI phase singal
62   //
63   Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);
64   ASSERT_EFI_ERROR (Status);
65 
66   //
67   // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
68   //
69   UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, STACK_SIZE);
70 
71   SwitchStack (
72     (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
73     HobList.Raw,
74     NULL,
75     TopOfStack
76     );
77 }
78