-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RiscVPkg/Library: RISC-V platform level
DxeIPL libraries. RiscVDxeIplHandoffLib.inf: Simply use stack switch to hand off to DXE phase. RiscVDxeIplHandoffOpenSbiLib.inf: Hand off to DXE phase using OpenSBI interface. Signed-off-by: Abner Chang <abner.chang@hpe.com> Co-authored-by: Daniel Helmut Schaefer <daniel.schaefer@hpe.com> Co-authored-by: Gilbert Chen <gilbert.chen@hpe.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org> Cc: Leif Lindholm <leif.lindholm@linaro.org> Cc: Gilbert Chen <gilbert.chen@hpe.com>
- Loading branch information
Abner Chang
committed
Feb 28, 2020
1 parent
18de3e1
commit 33a9bd8
Showing
4 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
RiscVPkg/Library/RiscVDxeIplHandoffLib/RiscVDxeIplHandoffLib.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** @file | ||
RISC-V platform level DXE core hand off library | ||
Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
/** | ||
RISC-V platform DXE IPL to DXE core handoff process. | ||
This function performs a CPU architecture specific operations to execute | ||
the entry point of DxeCore with the parameters of HobList. | ||
It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase. | ||
@param BaseOfStack Base address of stack | ||
@param TopOfStack Top address of stack | ||
@param DxeCoreEntryPoint The entry point of DxeCore. | ||
@param HobList The start of HobList passed to DxeCore. | ||
**/ | ||
|
||
VOID | ||
RiscVPlatformHandOffToDxeCore ( | ||
IN VOID *BaseOfStack, | ||
IN VOID *TopOfStack, | ||
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, | ||
IN EFI_PEI_HOB_POINTERS HobList | ||
) | ||
{ | ||
|
||
// | ||
// Transfer the control to the entry point of DxeCore. | ||
// | ||
SwitchStack ( | ||
(SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint, | ||
HobList.Raw, | ||
NULL, | ||
TopOfStack | ||
); | ||
} |
30 changes: 30 additions & 0 deletions
30
RiscVPkg/Library/RiscVDxeIplHandoffLib/RiscVDxeIplHandoffLib.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## @file | ||
# Instance of RISC-V DXE IPL to DXE core handoff platform library | ||
# | ||
# Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR> | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x0001001b | ||
BASE_NAME = RiscVPlatformDxeIplLib | ||
FILE_GUID = 2A77EE71-9F55-43F9-8773-7854A5B56086 | ||
MODULE_TYPE = PEIM | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = RiscVPlatformDxeIplLib|PEIM PEI_CORE | ||
|
||
# | ||
# VALID_ARCHITECTURES = RISCV64 | ||
# | ||
|
||
[Sources] | ||
RiscVDxeIplHandoffLib.c | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
|
||
[LibraryClasses] | ||
DebugLib | ||
|
||
|
109 changes: 109 additions & 0 deletions
109
RiscVPkg/Library/RiscVDxeIplHandoffOpenSbiLib/RiscVDxeIplHandoffOpenSbiLib.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/** @file | ||
RISC-V DXE IPL to DXE core handoff platform library using OpenSBI | ||
Copyright (c) 2019 - 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <Core/DxeIplPeim/DxeIpl.h> | ||
#include <IndustryStandard/RiscVOpensbi.h> | ||
#include <PiPei.h> | ||
#include <Library/BaseLib.h> | ||
#include <Library/DebugLib.h> | ||
#include <sbi/riscv_encoding.h> | ||
#include <sbi/sbi_hart.h> | ||
#include <sbi/sbi_init.h> | ||
#include <sbi/sbi_scratch.h> | ||
#include <Library/RiscVCpuLib.h> | ||
#include <Library/RiscVPlatformDxeIpl.h> | ||
|
||
/** | ||
RISC-V platform DXE IPL to DXE OpenSBI mdoe switch handler. | ||
This function is executed in RISC-V Supervisor mode. | ||
This function performs a CPU architecture specific operations to execute | ||
the entry point of DxeCore with the parameters of HobList. | ||
It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase. | ||
@param BaseOfStack Base address of stack | ||
@param TopOfStack Top address of stack | ||
@param DxeCoreEntryPoint The entry point of DxeCore. | ||
@param HobList The start of HobList passed to DxeCore. | ||
**/ | ||
VOID | ||
RiscVDxeIplHandoffOpenSbiHandler ( | ||
IN UINTN HardId, | ||
IN OPENSBI_SWITCH_MODE_CONTEXT *ThisSwitchContext | ||
) | ||
{ | ||
DEBUG ((DEBUG_INFO, "OpenSBI mode switch DXE IPL Handoff handler entry\n")); | ||
|
||
SwitchStack ( | ||
(SWITCH_STACK_ENTRY_POINT)(UINTN)ThisSwitchContext->DxeCoreEntryPoint, | ||
ThisSwitchContext->HobList.Raw, | ||
NULL, | ||
ThisSwitchContext->TopOfStack | ||
); | ||
|
||
// | ||
// Shold never came back. | ||
// | ||
UNREACHABLE(); | ||
} | ||
|
||
|
||
/** | ||
RISC-V platform DXE IPL to DXE core handoff process. | ||
This function performs a CPU architecture specific operations to execute | ||
the entry point of DxeCore with the parameters of HobList. | ||
It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase. | ||
@param BaseOfStack Base address of stack | ||
@param TopOfStack Top address of stack | ||
@param DxeCoreEntryPoint The entry point of DxeCore. | ||
@param HobList The start of HobList passed to DxeCore. | ||
**/ | ||
VOID | ||
RiscVPlatformHandOffToDxeCore ( | ||
IN VOID *BaseOfStack, | ||
IN VOID *TopOfStack, | ||
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, | ||
IN EFI_PEI_HOB_POINTERS HobList | ||
) | ||
{ | ||
EFI_STATUS Status; | ||
struct sbi_scratch *ThisScratch; | ||
OPENSBI_SWITCH_MODE_CONTEXT OpenSbiSwitchModeContext; | ||
|
||
// | ||
// End of PEI phase signal | ||
// | ||
Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi); | ||
ASSERT_EFI_ERROR (Status); | ||
|
||
DEBUG ((DEBUG_INFO, "DXE IPL to DXE Core using OpenSBI\n")); | ||
// | ||
// Setup next address in OpenSBI scratch | ||
// | ||
OpenSbiSwitchModeContext.BaseOfStack = BaseOfStack; | ||
OpenSbiSwitchModeContext.TopOfStack = TopOfStack; | ||
OpenSbiSwitchModeContext.HobList = HobList; | ||
OpenSbiSwitchModeContext.DxeCoreEntryPoint = DxeCoreEntryPoint; | ||
ThisScratch = sbi_scratch_thishart_ptr (); | ||
ThisScratch->next_arg1 = (UINTN)&OpenSbiSwitchModeContext; | ||
ThisScratch->next_addr = (UINTN)RiscVDxeIplHandoffOpenSbiHandler; | ||
ThisScratch->next_mode = PRV_S; | ||
|
||
DEBUG ((DEBUG_INFO, " Base address of satck: 0x%x\n", BaseOfStack)); | ||
DEBUG ((DEBUG_INFO, " Top address of satck: 0x%x\n", TopOfStack)); | ||
DEBUG ((DEBUG_INFO, " HOB list address: 0x%x\n", &HobList)); | ||
DEBUG ((DEBUG_INFO, " DXE core entry pointer: 0x%x\n", DxeCoreEntryPoint)); | ||
DEBUG ((DEBUG_INFO, " OpenSBI Switch mode arg1: 0x%x\n", (UINTN)&OpenSbiSwitchModeContext)); | ||
DEBUG ((DEBUG_INFO, " OpenSBI Switch mode handler address: 0x%x\n", (UINTN)RiscVDxeIplHandoffOpenSbiHandler)); | ||
DEBUG ((DEBUG_INFO, " OpenSBI Switch mode to privilege 0x%x\n", PRV_S)); | ||
sbi_init (ThisScratch); | ||
} |
34 changes: 34 additions & 0 deletions
34
RiscVPkg/Library/RiscVDxeIplHandoffOpenSbiLib/RiscVDxeIplHandoffOpenSbiLib.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## @file | ||
# Instance of RISC-V DXE IPL to DXE core handoff platform library using OpenSBI | ||
# | ||
# Copyright (c) 2019 - 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR> | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x0001001b | ||
BASE_NAME = RiscVPlatformDxeIplLib | ||
FILE_GUID = 906A4BB9-8DE2-4CE0-A609-23818A8FF514 | ||
MODULE_TYPE = PEIM | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = RiscVPlatformDxeIplLib|PEIM PEI_CORE | ||
|
||
# | ||
# VALID_ARCHITECTURES = RISCV64 | ||
# | ||
|
||
[Sources] | ||
RiscVDxeIplHandoffOpenSbiLib.c | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
MdeModulePkg/MdeModulePkg.dec | ||
RiscVPkg/RiscVPkg.dec | ||
|
||
[LibraryClasses] | ||
DebugLib | ||
RiscVCpuLib | ||
RiscVOpensbiLib | ||
|