From: "xianglai" <lixianglai@loongson.cn>
To: devel@edk2.groups.io
Cc: maobibo@loongson.cn
Subject: [edk2-platforms][PATCH V2 03/16] Platform/Loongson: Add PeiServicesTablePointerLib.
Date: Fri, 25 Mar 2022 10:16:07 +0800 [thread overview]
Message-ID: <164505fdf36123818f31f19c977331d034c12985.1648171285.git.lixianglai@loongson.cn> (raw)
In-Reply-To: <cover.1648171285.git.lixianglai@loongson.cn>
Use a register to save PeiServicesTable pointer,
This lib Provides PeiServicesTable pointer saving
and retrieval services.
Signed-off-by: xianglai li <lixianglai@loongson.cn>
---
.../PeiServicesTablePointer.c | 78 +++++++++++++++++++
.../PeiServicesTablePointerLib.inf | 32 ++++++++
2 files changed, 110 insertions(+)
create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
new file mode 100644
index 0000000000..068960d4ce
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
@@ -0,0 +1,78 @@
+/** @file
+ PEI Services Table Pointer Library.
+
+ Copyright (c) 2021 Loongson Technology Corporation Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Library/PeiServicesTablePointerLib.h>
+#include <Library/DebugLib.h>
+#include "Library/Cpu.h"
+
+/**
+ Caches a pointer PEI Services Table.
+
+ Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
+ in a platform specific manner.
+
+ If PeiServicesTablePointer is NULL, then ASSERT ().
+
+ @param PeiServicesTablePointer The address of PeiServices pointer.
+**/
+VOID
+EFIAPI
+SetPeiServicesTablePointer (
+ IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
+ )
+{
+ LOONGARCH_CSR_WRITEQ ((UINTN)PeiServicesTablePointer, LOONGARCH_CSR_KS0);
+}
+
+/**
+ 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
+ )
+{
+ UINTN val;
+
+ LOONGARCH_CSR_READQ (val, LOONGARCH_CSR_KS0);
+ return (CONST EFI_PEI_SERVICES **)val;
+}
+
+/**
+Perform CPU specific actions required to migrate the PEI Services Table
+pointer from temporary RAM to permanent RAM.
+
+For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
+immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
+immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
+a dedicated CPU register. This means that there is no memory storage
+associated with storing the PEI Services Table pointer, so no additional
+migration actions are required for Itanium or ARM CPUs.
+
+**/
+VOID
+EFIAPI
+MigratePeiServicesTablePointer (
+VOID
+)
+{
+ return;
+}
diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
new file mode 100644
index 0000000000..6fe76d1351
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
@@ -0,0 +1,32 @@
+## @file
+# PEI Services Table Pointer Library.
+#
+# Copyright (c) 2021 Loongson Technology Corporation Limited. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiServicesTablePointerLib
+ FILE_GUID = C3C9C4ED-EB8A-4548-BE1B-ABB0B6F35B1E
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PeiServicesTablePointerLib|PEIM PEI_CORE SEC
+
+#
+# VALID_ARCHITECTURES = LOONGARCH64
+#
+
+[Sources]
+ PeiServicesTablePointer.c
+
+[Packages]
+ Platform/Loongson/LoongArchQemuPkg/Loongson.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ DebugLib
+
+[Pcd]
+
--
2.31.1
next prev parent reply other threads:[~2022-03-25 2:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 2:16 [edk2-platforms][PATCH V2 00/16] Platform: Add Loongson support xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 01/16] Platform/Loongson: Add Serial Port library xianglai
2022-03-25 2:16 ` xianglai [this message]
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 04/16] Platform/Loongson: Add QemuFwCfgLib xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 05/16] Platform/Loongson: Add MmuLib xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 06/16] Platform/Loongson: Add StableTimerLib xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 07/16] Platform/Loongson: Support PEI phase xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 08/16] Platform/Loongson: Add CPU DXE driver xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 09/16] Platform/Loongson: Add PciCpuIoDxe driver xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 10/16] Platform/Loongson: Add timer Dxe driver xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 11/16] Platform/Loongson: Add RealTime Clock lib xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 12/16] Platform/Loongson: Add Platform Boot Manager Lib xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 13/16] Platform/Loongson: Add Reset System Lib xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 14/16] Platform/Loongson: Support Dxe xianglai
2022-03-25 2:16 ` [edk2-platforms][PATCH V2 15/16] Platform/Loongson: Add QemuFlashFvbServicesRuntimeDxe driver xianglai
2022-03-25 2:51 ` [edk2-platforms][PATCH V2 16/16] Platform/Loongson: Support for saving variables to flash xianglai
2022-03-25 3:37 ` [edk2-platforms][PATCH V2 02/16] Platform/Loongson: Support SEC And Add Readme.md xianglai
-- strict thread matches above, loose matches on Subject: below --
2022-09-16 3:36 [edk2-platforms][PATCH V2 00/16] Platform: Add Loongson support xianglai
2022-09-16 3:36 ` [edk2-platforms][PATCH V2 03/16] Platform/Loongson: Add PeiServicesTablePointerLib xianglai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=164505fdf36123818f31f19c977331d034c12985.1648171285.git.lixianglai@loongson.cn \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox