From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from loongson.cn (loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web12.442.1648174607222867850 for ; Thu, 24 Mar 2022 19:16:47 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: loongson.cn, ip: 114.242.206.163, mailfrom: lixianglai@loongson.cn) Received: from localhost.localdomain (unknown [10.2.10.197]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx3xMIJj1irWAPAA--.15467S5; Fri, 25 Mar 2022 10:16:45 +0800 (CST) From: "xianglai" 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 Message-Id: <164505fdf36123818f31f19c977331d034c12985.1648171285.git.lixianglai@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: AQAAf9Dx3xMIJj1irWAPAA--.15467S5 X-Coremail-Antispam: 1UD129KBjvJXoWxZF48AF15Wr18CrW8Xr1xGrg_yoWrZw1fpw 4UGF4kKr45JryIgryYqa15CFW5AFsrCr98Crs7XF15Cw1kAry0qr12vFyFkF1rua1rAw1I gryFkw4Uua4UXF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBa14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0 owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE-syl42xK82 IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC2 0s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1Y6r17MIIYrxkI7VAKI48JMI IF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF 0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87 Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JUkUUUUUUUU= X-CM-SenderInfo: 5ol0xt5qjotxo6or00hjvr0hdfq/ Content-Transfer-Encoding: quoted-printable Use a register to save PeiServicesTable pointer, This lib Provides PeiServicesTable pointer saving and retrieval services. Signed-off-by: xianglai li --- .../PeiServicesTablePointer.c | 78 +++++++++++++++++++ .../PeiServicesTablePointerLib.inf | 32 ++++++++ 2 files changed, 110 insertions(+) create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesT= ablePointerLib/PeiServicesTablePointer.c create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesT= ablePointerLib/PeiServicesTablePointerLib.inf diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePoi= nterLib/PeiServicesTablePointer.c b/Platform/Loongson/LoongArchQemuPkg/Libr= ary/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=0D + PEI Services Table Pointer Library.=0D +=0D + Copyright (c) 2021 Loongson Technology Corporation Limited. All rights r= eserved.
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include "Library/Cpu.h"=0D +=0D +/**=0D + Caches a pointer PEI Services Table.=0D +=0D + Caches the pointer to the PEI Services Table specified by PeiServicesTab= lePointer=0D + in a platform specific manner.=0D +=0D + If PeiServicesTablePointer is NULL, then ASSERT ().=0D +=0D + @param PeiServicesTablePointer The address of PeiServices pointer.= =0D +**/=0D +VOID=0D +EFIAPI=0D +SetPeiServicesTablePointer (=0D + IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer=0D + )=0D +{=0D + LOONGARCH_CSR_WRITEQ ((UINTN)PeiServicesTablePointer, LOONGARCH_CSR_KS0)= ;=0D +}=0D +=0D +/**=0D + Retrieves the cached value of the PEI Services Table pointer.=0D +=0D + Returns the cached value of the PEI Services Table pointer in a CPU spec= ific manner=0D + as specified in the CPU binding section of the Platform Initialization P= re-EFI=0D + Initialization Core Interface Specification.=0D +=0D + If the cached PEI Services Table pointer is NULL, then ASSERT ().=0D +=0D + @return The pointer to PeiServices.=0D +**/=0D +CONST EFI_PEI_SERVICES **=0D +EFIAPI=0D +GetPeiServicesTablePointer (=0D + VOID=0D + )=0D +{=0D + UINTN val;=0D +=0D + LOONGARCH_CSR_READQ (val, LOONGARCH_CSR_KS0);=0D + return (CONST EFI_PEI_SERVICES **)val;=0D +}=0D +=0D +/**=0D +Perform CPU specific actions required to migrate the PEI Services Table=0D +pointer from temporary RAM to permanent RAM.=0D +=0D +For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes=0D +immediately preceding the Interrupt Descriptor Table (IDT) in memory.=0D +For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes=0D +immediately preceding the Interrupt Descriptor Table (IDT) in memory.=0D +For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in=0D +a dedicated CPU register. This means that there is no memory storage=0D +associated with storing the PEI Services Table pointer, so no additional=0D +migration actions are required for Itanium or ARM CPUs.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +MigratePeiServicesTablePointer (=0D +VOID=0D +)=0D +{=0D + return;=0D +}=0D diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePoi= nterLib/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=0D +# PEI Services Table Pointer Library.=0D +#=0D +# Copyright (c) 2021 Loongson Technology Corporation Limited. All rights = reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D PeiServicesTablePointerLib=0D + FILE_GUID =3D C3C9C4ED-EB8A-4548-BE1B-ABB0B6F35B1E= =0D + MODULE_TYPE =3D PEIM=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D PeiServicesTablePointerLib|PEIM PEI_C= ORE SEC=0D +=0D +#=0D +# VALID_ARCHITECTURES =3D LOONGARCH64=0D +#=0D +=0D +[Sources]=0D + PeiServicesTablePointer.c=0D +=0D +[Packages]=0D + Platform/Loongson/LoongArchQemuPkg/Loongson.dec=0D + MdePkg/MdePkg.dec=0D +=0D +[LibraryClasses]=0D + DebugLib=0D +=0D +[Pcd]=0D +=0D --=20 2.31.1