mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
MdePkg: RISC-V: Add PeiServicesTablePointerLib
Based on PI 1.9, the PEI service pointer will be stored in the scratch register. Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
This commit is contained in:
parent
4d80dc68c6
commit
be053713c0
4 changed files with 126 additions and 0 deletions
|
|
@ -0,0 +1,77 @@
|
|||
/** @file
|
||||
PEI Services Table Pointer Library.
|
||||
|
||||
According to PI specification, the peiservice pointer is stored in the SSCRATCH
|
||||
register of RISC-V architecture.
|
||||
|
||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2025, Ventana Micro Systems Inc. All rights reserved.<BR>
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PeiServicesTablePointerLib.h>
|
||||
|
||||
/**
|
||||
Caches a pointer PEI Services Table.
|
||||
|
||||
Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
|
||||
in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
|
||||
Pre-EFI Initialization Core Interface Specification.
|
||||
|
||||
If PeiServicesTablePointer is NULL, then ASSERT().
|
||||
|
||||
@param PeiServicesTablePointer The address of PeiServices pointer.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
SetPeiServicesTablePointer (
|
||||
IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
|
||||
)
|
||||
{
|
||||
ASSERT (PeiServicesTablePointer != NULL);
|
||||
RiscVSetSupervisorScratch ((UINT64)PeiServicesTablePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the cached value of the PEI Services Table pointer.
|
||||
|
||||
Returns the cached value of the PEI Services Table pointer in a CPU specific manner
|
||||
as specified in the CPU binding section of the Platform Initialization Pre-EFI
|
||||
Initialization Core Interface Specification.
|
||||
|
||||
If the cached PEI Services Table pointer is NULL, then ASSERT().
|
||||
|
||||
@return The pointer to PeiServices.
|
||||
|
||||
**/
|
||||
CONST EFI_PEI_SERVICES **
|
||||
EFIAPI
|
||||
GetPeiServicesTablePointer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return (CONST EFI_PEI_SERVICES **)RiscVGetSupervisorScratch ();
|
||||
}
|
||||
|
||||
/**
|
||||
Perform CPU specific actions required to migrate the PEI Services Table
|
||||
pointer from temporary RAM to permanent RAM.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
MigratePeiServicesTablePointer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
//
|
||||
// PEI Services Table pointer is stored in CSR_SSCRATCH register. No additional
|
||||
// migration actions are required.
|
||||
//
|
||||
return;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
## @file
|
||||
# Instance of PEI Services Table Pointer Library using global variable for the table pointer.
|
||||
#
|
||||
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2025, Ventana Micro Systems Inc. All rights reserved.<BR>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 1.30
|
||||
BASE_NAME = PeiServicesTablePointerLib
|
||||
MODULE_UNI_FILE = PeiServicesTablePointerLib.uni
|
||||
FILE_GUID = 3b5bccaa-366f-42d1-93b1-64dd7ecb9fa7
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PeiServicesTablePointerLib|PEIM PEI_CORE SEC
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = RISCV64
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PeiServicesTablePointer.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
DebugLib
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// /** @file
|
||||
// Instance of PEI Services Table Pointer Library for RISCV.
|
||||
//
|
||||
// Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
// Copyright (c) 2025, Ventana Micro Systems Inc. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// **/
|
||||
|
||||
|
||||
#string STR_MODULE_ABSTRACT #language en-US "Instance of PEI Services Table Pointer Library using global variable for the table pointer"
|
||||
|
||||
#string STR_MODULE_DESCRIPTION #language en-US "The PEI Services Table Pointer Library implementation that retrieves a pointer to the PEI Services Table from a global variable. Not available to modules that execute from read-only memory."
|
||||
|
||||
|
|
@ -213,6 +213,7 @@
|
|||
MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.inf
|
||||
MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSbiLib.inf
|
||||
MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSbiLibRam.inf
|
||||
MdePkg/Library/PeiServicesTablePointerLibRiscV/PeiServicesTablePointerLib.inf
|
||||
|
||||
[Components.LOONGARCH64]
|
||||
MdePkg/Library/PeiServicesTablePointerLibKs0/PeiServicesTablePointerLibKs0.inf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue