From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id E9AA0740032 for ; Wed, 8 Nov 2023 22:22:27 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KwpYvYHrEsRUla79U3zHGESqbvfysp1eMR7Iyo5nT+k=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699482146; v=1; b=jYJ+4PFaCOxNJEFntG5jJdNGv6XClLx0ZNG3MojrVk7oRPXymdFgWWmnESpPwstp3m/Ftxf5 43dce4i1D5dhIOEckp6U2CXR6JoLab6KtLlFLJpx1mkBGGVntAnXn+s+k2oaG0WHcaI4BDLSCOT HS4xgvaE2DksFl0/pJ8hB+Xw= X-Received: by 127.0.0.2 with SMTP id KKrEYY7687511x7jAC08s7rA; Wed, 08 Nov 2023 14:22:26 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.105969.1699482145541539875 for ; Wed, 08 Nov 2023 14:22:25 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-60-Ngbc80MVP3GRta-cSUNwPg-1; Wed, 08 Nov 2023 17:22:21 -0500 X-MC-Unique: Ngbc80MVP3GRta-cSUNwPg-1 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 169EB852AC6; Wed, 8 Nov 2023 22:22:21 +0000 (UTC) X-Received: from [10.39.192.41] (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 079172026D37; Wed, 8 Nov 2023 22:22:18 +0000 (UTC) Message-ID: Date: Wed, 8 Nov 2023 23:22:17 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2 23/30] OvmfPkg/LoongArchVirt: Add PeiServiceTablePointerLib To: devel@edk2.groups.io, lichao@loongson.cn Cc: Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann , Xianglai Li , Bibo Mao References: <20231106032521.2251143-1-lichao@loongson.cn> <20231106033012.2294174-1-lichao@loongson.cn> From: "Laszlo Ersek" In-Reply-To: <20231106033012.2294174-1-lichao@loongson.cn> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 0dhEwL8g2Y77JanQcmuWyjYVx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=jYJ+4PFa; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 11/6/23 04:30, Chao Li wrote: > Use a register to save PeiServiceTable pointer. This Library provides > PeiServiceTable pointer saveing and retrieval serivces. >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4584 >=20 > Cc: Ard Biesheuvel > Cc: Jiewen Yao > Cc: Jordan Justen > Cc: Gerd Hoffmann > Signed-off-by: Chao Li > Co-authored-by: Xianglai Li > Co-authored-by: Bibo Mao > --- > .../PeiServicesTablePointer.c | 75 +++++++++++++++++++ > .../PeiServicesTablePointerLib.inf | 31 ++++++++ > 2 files changed, 106 insertions(+) > create mode 100644 OvmfPkg/LoongArchVirt/Library/PeiServicesTablePointer= Lib/PeiServicesTablePointer.c > create mode 100644 OvmfPkg/LoongArchVirt/Library/PeiServicesTablePointer= Lib/PeiServicesTablePointerLib.inf Why is this under OvmfPkg? Laszlo >=20 > diff --git a/OvmfPkg/LoongArchVirt/Library/PeiServicesTablePointerLib/Pei= ServicesTablePointer.c b/OvmfPkg/LoongArchVirt/Library/PeiServicesTablePoin= terLib/PeiServicesTablePointer.c > new file mode 100644 > index 0000000000..dcbcb50131 > --- /dev/null > +++ b/OvmfPkg/LoongArchVirt/Library/PeiServicesTablePointerLib/PeiService= sTablePointer.c > @@ -0,0 +1,75 @@ > +/** @file > + PEI Services Table Pointer Library. > + > + Copyright (c) 2023 Loongson Technology Corporation Limited. All rights= reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > + > +/** > + Caches a pointer PEI Services Table. > + > + Caches the pointer to the PEI Services Table specified by PeiServicesT= ablePointer > + 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 > + ) > +{ > + CsrWrite (LOONGARCH_CSR_KS0, (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 sp= ecific 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 **)(CsrRead (LOONGARCH_CSR_KS0)); > +} > + > +/** > +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/OvmfPkg/LoongArchVirt/Library/PeiServicesTablePointerLib/Pei= ServicesTablePointerLib.inf b/OvmfPkg/LoongArchVirt/Library/PeiServicesTabl= ePointerLib/PeiServicesTablePointerLib.inf > new file mode 100644 > index 0000000000..274cb2f781 > --- /dev/null > +++ b/OvmfPkg/LoongArchVirt/Library/PeiServicesTablePointerLib/PeiService= sTablePointerLib.inf > @@ -0,0 +1,31 @@ > +## @file > +# PEI Services Table Pointer Library. > +# > +# Copyright (c) 2023 Loongson Technology Corporation Limited. All right= s reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D PeiServicesTablePointerLib > + FILE_GUID =3D 098B0DB0-AD01-8886-D409-90CBC7E8915= 4 > + MODULE_TYPE =3D PEIM > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D PeiServicesTablePointerLib|PEIM PEI= _CORE SEC > + > +# > +# VALID_ARCHITECTURES =3D LOONGARCH64 > +# > + > +[Sources] > + PeiServicesTablePointer.c > + > +[Packages] > + MdePkg/MdePkg.dec > + > +[LibraryClasses] > + BaseLib > + DebugLib > + > +[Pcd] -=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 (#110932): https://edk2.groups.io/g/devel/message/110932 Mute This Topic: https://groups.io/mt/102413901/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-