VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFunc.c@ 108794

Last change on this file since 108794 was 108794, checked in by vboxsync, 2 weeks ago

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1/** @file
2 RISC-V specific functionality for DxeLoad.
3
4 Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
5 Copyright (c) 2023, Rivos Inc
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9**/
10#include <PiPei.h>
11#include <Library/BaseLib.h>
12#include <Library/DebugLib.h>
13#include <Library/BaseMemoryLib.h>
14#include <Library/MemoryAllocationLib.h>
15#include <Library/PcdLib.h>
16#include <Library/HobLib.h>
17#include "UefiPayloadEntry.h"
18
19#define STACK_SIZE 0x20000
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**/
32VOID
33HandOffToDxeCore (
34 IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
35 IN EFI_PEI_HOB_POINTERS HobList
36 )
37{
38 VOID *BaseOfStack;
39 VOID *TopOfStack;
40
41 //
42 //
43 // Allocate 128KB for the Stack
44 //
45 BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
46 if (BaseOfStack == NULL) {
47 DEBUG ((DEBUG_ERROR, "%a: Can't allocate memory for stack.", __func__));
48 ASSERT (FALSE);
49 }
50
51 //
52 // Compute the top of the stack we were allocated. Pre-allocate a UINTN
53 // for safety.
54 //
55 TopOfStack = (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
56 TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
57
58 //
59 // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
60 //
61 UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE);
62
63 DEBUG ((DEBUG_INFO, "DXE Core new stack at %x, stack pointer at %x\n", BaseOfStack, TopOfStack));
64
65 //
66 // Transfer the control to the entry point of DxeCore.
67 //
68 SwitchStack (
69 (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
70 HobList.Raw,
71 NULL,
72 TopOfStack
73 );
74}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette