From nobody Fri Apr 26 09:57:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96274+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96274+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1668157962; cv=none; d=zohomail.com; s=zohoarc; b=d5TLbH01JkvCkkAVFJ08Iw/xaF4UZWyLDIX2H/R6Wy6gVTqnhXBkjc7cS5aCXnYHzHMRuclerp1sDFMyzaN6kywDg1epKaEsPEauYJiZzEB0YfzqYZ+z0SkvaXdJDYmFmYleP86CliFngU8l3CJ5BQGkQzVGuR4+Du5ZoXsXKBY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668157962; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=N6qDGXBkOHzg+CTx8Lr0lby8XJlbNHtcDNTGQabmhAM=; b=UsZBXivd9hNy3lYxvf/k5AfXeG7v/RAm9Ka14UKDTftFHupmov3W7XHCr1ECwdpIlcuq3KgOBd4kxOtBo2e2e83xOCUuB7M60hSqqQua2TpOBUwjKMi+VwgnBCBPUuFRP46YK6XpxJiXcNDP5kR44Dpn7TamK1jk6JH9AjTVPrs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96274+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1668157962006992.5709387616672; Fri, 11 Nov 2022 01:12:42 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id PGGfYY1788612xH6Ezy76Dpt; Fri, 11 Nov 2022 01:12:41 -0800 X-Received: from loongson.cn (loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web11.3589.1668157959848818658 for ; Fri, 11 Nov 2022 01:12:40 -0800 X-Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8DxTLYEEm5jeBMGAA--.7231S3; Fri, 11 Nov 2022 17:12:36 +0800 (CST) X-Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxFlcAEm5jXc0QAA--.27651S5; Fri, 11 Nov 2022 17:12:35 +0800 (CST) From: "xianglai" To: devel@edk2.groups.io Cc: Bibo Mao , Chao Li , Leif Lindholm , Liming Gao , Michael D Kinney Subject: [edk2-devel] [edk2-platforms][PATCH V5 03/15] Platform/Loongson: Add PeiServicesTablePointerLib. Date: Fri, 11 Nov 2022 17:12:18 +0800 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxFlcAEm5jXc0QAA--.27651S5 X-CM-SenderInfo: 5ol0xt5qjotxo6or00hjvr0hdfq/ X-Coremail-Antispam: 1Uk129KBjvJXoW3ArWrWF4DuFyDJrWkXF15XFb_yoW3WFWkpr 43WFs7tr1UJrWIgryYqa15CFW5AFsrCr98Crs7XF1rC34kZry0qryjvFWFkFyrua45Aw1I gryFkw4Uu3WUXF7anT9S1TB71UUUUjUqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bFAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4 AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF 7I0E14v26r4j6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x 0267AKxVWxJr0_GcWln4kS14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF 6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6x8ErcxFaVAv8V WrMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCF 04k20xvE74AGY7Cv6cx26rWl4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_Jr v_JF1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWxJVW8Jr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2Kf nxnUUI43ZEXa7xRihFxUUUUUU== Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lixianglai@loongson.cn X-Gm-Message-State: d6zhKH9mEeKatIXHpelL34F7x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1668157961; bh=zO3hEZk0eeb+5fNmFpUenRY6xQvIqVL/MQi9DXT7wqo=; h=Cc:Date:From:Reply-To:Subject:To; b=Va4gRjSc58h1Oh4r8B3RTRXsNI3lJtLkjkB8od/BC7CpNt8lbSLmYipSfeXmmf+lGxV yEHoaAcaCyD5XSzsfak7bXWHlMROIMKt6ZlWqGeEFWhREqFbHKX4NPCoq3nWSe7sVxHh2 ooIIHpMZps5OrgWUYlmm7g8f0od+e5vXQZE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1668157962470100001 Content-Type: text/plain; charset="utf-8" Use a register to save PeiServicesTable pointer, This lib Provides PeiServicesTable pointer saving and retrieval services. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4054 Cc: Bibo Mao Cc: Chao Li Cc: Leif Lindholm Cc: Liming Gao Cc: Michael D Kinney Signed-off-by: xianglai li Reviewed-by: Chao Li --- .../PeiServicesTablePointer.c | 79 +++++++++++++++++++ .../PeiServicesTablePointer.h | 39 +++++++++ .../PeiServicesTablePointerLib.S | 40 ++++++++++ .../PeiServicesTablePointerLib.inf | 32 ++++++++ 4 files changed, 190 insertions(+) create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesT= ablePointerLib/PeiServicesTablePointer.c create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesT= ablePointerLib/PeiServicesTablePointer.h create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesT= ablePointerLib/PeiServicesTablePointerLib.S 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..204def3bde --- /dev/null +++ b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib= /PeiServicesTablePointer.c @@ -0,0 +1,79 @@ +/** @file + PEI Services Table Pointer Library. + + Copyright (c) 2022 Loongson Technology Corporation Limited. All rights r= eserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include "Library/Cpu.h" +#include "PeiServicesTablePointer.h" + +/** + Caches a pointer PEI Services Table. + + Caches the pointer to the PEI Services Table specified by PeiServicesTab= lePointer + 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 + ) +{ + LoongarchWriteqKs0 ((UINTN)PeiServicesTablePointer); +} + +/** + Retrieves the cached value of the PEI Services Table pointer. + + Returns the cached value of the PEI Services Table pointer in a CPU spec= ific manner + as specified in the CPU binding section of the Platform Initialization P= re-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; + + LoongarchReadqKs0 (&val); + + 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/PeiServicesTablePoi= nterLib/PeiServicesTablePointer.h b/Platform/Loongson/LoongArchQemuPkg/Libr= ary/PeiServicesTablePointerLib/PeiServicesTablePointer.h new file mode 100644 index 0000000000..5bcbc810d0 --- /dev/null +++ b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib= /PeiServicesTablePointer.h @@ -0,0 +1,39 @@ +/** @file + PeiServicesTablePointer + + Copyright (c) 2022 Loongson Technology Corporation Limited. All rights r= eserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef PEISERVICESTABLEPOINTER_H_ +#define PEISERVICESTABLEPOINTER_H_ + +/** + Write Csr KS0 register. + + @param A0 The value used to write to the KS0 register + + @retval none +**/ +extern +VOID +LoongarchWriteqKs0 ( + IN UINT64 Val + ); + +/** + Read Csr KS0 register. + + @param Val Pointer to the variable used to store the KS0 register value + + @retval none +**/ +extern +VOID +LoongarchReadqKs0 ( + IN UINT64 *Val + ); + +#endif // PEISERVICESTABLEPOINTER_H_ diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePoi= nterLib/PeiServicesTablePointerLib.S b/Platform/Loongson/LoongArchQemuPkg/L= ibrary/PeiServicesTablePointerLib/PeiServicesTablePointerLib.S new file mode 100644 index 0000000000..7c6170c5d6 --- /dev/null +++ b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib= /PeiServicesTablePointerLib.S @@ -0,0 +1,40 @@ +#-------------------------------------------------------------------------= ----- +# +# Timer Cfg for LoongArch +# +# Copyright (c) 2022 Loongson Technology Corporation Limited. All rights r= eserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#-------------------------------------------------------------------------= ----- + +#ifndef __ASSEMBLY__ +#define __ASSEMBLY__ +#endif + +#include "Library/Cpu.h" + +ASM_GLOBAL ASM_PFX(LoongarchWriteqKs0) +ASM_GLOBAL ASM_PFX(LoongarchReadqKs0) + +# +# Write Csr KS0 register. +# @param A0 The value used to write to the KS0 register +# @retval none +# + +ASM_PFX(LoongarchWriteqKs0): + csrwr A0, LOONGARCH_CSR_KS0 + jirl ZERO, RA,0 + +# +# Write Csr KS0 register. +# @param A0 Pointer to the variable used to store the KS0 register value +# @retval none +# + +ASM_PFX(LoongarchReadqKs0): + csrrd T0, LOONGARCH_CSR_KS0 + stptr.d T0, A0, 0 + jirl ZERO, RA,0 + jirl ZERO, RA,0 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..2ab0d53d4c --- /dev/null +++ b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib= /PeiServicesTablePointerLib.inf @@ -0,0 +1,32 @@ +## @file +# PEI Services Table Pointer Library. +# +# Copyright (c) 2022 Loongson Technology Corporation Limited. All rights = reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiServicesTablePointerLib + FILE_GUID =3D C3C9C4ED-EB8A-4548-BE1B-ABB0B6F35B1E + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PeiServicesTablePointerLib|PEIM PEI_C= ORE SEC + +# +# VALID_ARCHITECTURES =3D LOONGARCH64 +# + +[Sources] + PeiServicesTablePointer.c + PeiServicesTablePointerLib.S + +[Packages] + Platform/Loongson/LoongArchQemuPkg/Loongson.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib + +[Pcd] --=20 2.31.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96274): https://edk2.groups.io/g/devel/message/96274 Mute This Topic: https://groups.io/mt/94955171/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-