LoongArch uses the reigster LOONGARCH_CSR_KS0 in the PEI stage to set and get the PEI service table pointer. Add this method to PeiServiceTablePointerLibReg.
This is a code first phase, I will update the PI specification next. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584 Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Leif Lindholm <quic_llind...@quicinc.com> Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Sami Mujawar <sami.muja...@arm.com> Cc: Laszlo Ersek <ler...@redhat.com> Signed-off-by: Chao Li <lic...@loongson.cn> --- .../LoongArch64/PeiServicesTablePointerReg.c | 47 +++++++++++++++++++ .../PeiServicesTablePointerLibReg.inf | 3 ++ 2 files changed, 50 insertions(+) create mode 100644 MdePkg/Library/PeiServicesTablePointerLibReg/LoongArch64/PeiServicesTablePointerReg.c diff --git a/MdePkg/Library/PeiServicesTablePointerLibReg/LoongArch64/PeiServicesTablePointerReg.c b/MdePkg/Library/PeiServicesTablePointerLibReg/LoongArch64/PeiServicesTablePointerReg.c new file mode 100644 index 0000000000..368c907992 --- /dev/null +++ b/MdePkg/Library/PeiServicesTablePointerLibReg/LoongArch64/PeiServicesTablePointerReg.c @@ -0,0 +1,47 @@ +/** @file + PEI Services Table Pointer Library For LoongArch. + + Used Register Mechanism. + + Copyright (c) 2023 Loongson Technology Corporation Limited. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include <Register/LoongArch64/Csr.h> + +/** + Set the pointer PEI Service Table to a CPU register. + + Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer + in a platform specific manner. + + @param PeiServicesTablePointer The address of PeiServices. +**/ +VOID +EFIAPI +SetPeiServicesTablePointerToRegester ( + IN UINTN PeiServicesTablePointer + ) +{ + CsrWrite (LOONGARCH_CSR_KS0, (UINTN)PeiServicesTablePointer); +} + +/** + Retrieves the cached value of the PEI Services Table pointer from a CPU register. + + 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. + + @return The pointer to PeiServices. +**/ +CONST EFI_PEI_SERVICES ** +EFIAPI +GetPeiServicesTablePointerFromRegister ( + VOID + ) +{ + return (CONST EFI_PEI_SERVICES **)(CsrRead (LOONGARCH_CSR_KS0)); +} diff --git a/MdePkg/Library/PeiServicesTablePointerLibReg/PeiServicesTablePointerLibReg.inf b/MdePkg/Library/PeiServicesTablePointerLibReg/PeiServicesTablePointerLibReg.inf index 22499e22ad..b26a970b12 100644 --- a/MdePkg/Library/PeiServicesTablePointerLibReg/PeiServicesTablePointerLibReg.inf +++ b/MdePkg/Library/PeiServicesTablePointerLibReg/PeiServicesTablePointerLibReg.inf @@ -30,6 +30,9 @@ [Sources] PeiServicesTablePointer.c +[Sources.LOONGARCH64] + LoongArch64/PeiServicesTablePointerReg.c + [Packages] MdePkg/MdePkg.dec -- 2.27.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111363): https://edk2.groups.io/g/devel/message/111363 Mute This Topic: https://groups.io/mt/102644762/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-