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 45A07740035 for ; Mon, 25 Mar 2024 02:52:37 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=XGuiOMpd/SSypd1D8/2ZCEXzUFLg2gW7NTaWK6X7hA8=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1711335155; v=1; b=YSTHQ5sG2IH6kvmugoo/4/s9hF/2VDVziuoJkzwduOAMBHzCCo+LA0htJFZiLD3cwFswJcHD ymp9mr7YoWX5SUbk6gDRZffcyEBnxE6xL4rxpUSvSQv8UpVj5SdPYxZZqcr71DoIGYaWei+Xfbx TjvlCPO4zSbbgK4JnABcNbyXrQmHt1G5c624NkduLrk1KIULRGecuQiMsDfvkCPLlZYWXV4jSCL rZxo+JJ1ANipX1mXilc+n6SyEVgu1fdjEppA6qovJYfY/9mIC88pBdX/HqXFS1rKdjZdON1O82X M8H+n6TdTyrdc2A5fu+A8Km5XkFvSPNnfu8Nigw+1r2RQ== X-Received: by 127.0.0.2 with SMTP id D5sEYY7687511xCyTMTaGuVq; Sun, 24 Mar 2024 19:52:35 -0700 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web11.43688.1711335154219606122 for ; Sun, 24 Mar 2024 19:52:34 -0700 X-Received: from loongson.cn (unknown [10.40.24.149]) by gateway (Coremail) with SMTP id _____8AxDOvp5gBmgYodAA--.59569S3; Mon, 25 Mar 2024 10:52:25 +0800 (CST) X-Received: from [10.40.24.149] (unknown [10.40.24.149]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxHs_o5gBmcX1mAA--.4545S3; Mon, 25 Mar 2024 10:52:24 +0800 (CST) Message-ID: <2c9e1255-013f-4b81-95d4-e05f0966170c@loongson.cn> Date: Mon, 25 Mar 2024 10:52:24 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v2 07/13] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg To: devel@edk2.groups.io, ray.ni@intel.com Cc: "Kumar, Rahul R" , Gerd Hoffmann , Leif Lindholm , Ard Biesheuvel , Sami Mujawar , Sunil V L , "Warkentin, Andrei" References: <20240320084152.268323-1-lichao@loongson.cn> <20240320084319.276603-1-lichao@loongson.cn> From: "Chao Li" In-Reply-To: X-CM-TRANSID: AQAAf8AxHs_o5gBmcX1mAA--.4545S3 X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQAHCGX-5GgCswALsi X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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 Resent-Date: Sun, 24 Mar 2024 19:52:34 -0700 Reply-To: devel@edk2.groups.io,lichao@loongson.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 6cGLMhdwspU6Q0irTKChE6VYx7686176AA= Content-Type: multipart/alternative; boundary="------------0rxePY0JqErLTLjiNUTA2zp2" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=YSTHQ5sG; dmarc=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 --------------0rxePY0JqErLTLjiNUTA2zp2 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Ray, Thanks, Chao On 2024/3/25 10:31, Ni, Ray wrote: > Just curious, how many modules need to call this API? > If there is only one (I guess CpuDxe driver), should LoongArch CPU > driver implement the logic internally so that the lib class/API can be > avoided? This API will be consumed in the PEI and DXE stage. In the PEI stage, we will use them to configure the MMU, and the DXE, through which we can set memory region attributes. > > Thanks, > Ray > ------------------------------------------------------------------------ > *From:* Chao Li > *Sent:* Wednesday, March 20, 2024 16:43 > *To:* devel@edk2.groups.io > *Cc:* Ni, Ray ; Kumar, Rahul R > ; Gerd Hoffmann ; Leif > Lindholm ; Ard Biesheuvel > ; Sami Mujawar ; > Sunil V L ; Warkentin, Andrei > > *Subject:* [PATCH v2 07/13] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg > Add a new header file CpuMmuLib.h, whitch is referenced from > ArmPkg/Include/Library/ArmMmuLib.h. Currently, only support for > LoongArch64 is added, and more architectures can be accommodated in the > future. > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4734 > > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Gerd Hoffmann > Cc: Leif Lindholm > Cc: Ard Biesheuvel > Cc: Sami Mujawar > Cc: Sunil V L > Cc: Andrei Warkentin > Signed-off-by: Chao Li > Acked-by: Gerd Hoffmann > --- >  UefiCpuPkg/Include/Library/CpuMmuLib.h | 55 ++++++++++++++++++++++++++ >  UefiCpuPkg/UefiCpuPkg.dec              |  4 ++ >  2 files changed, 59 insertions(+) >  create mode 100644 UefiCpuPkg/Include/Library/CpuMmuLib.h > > diff --git a/UefiCpuPkg/Include/Library/CpuMmuLib.h > b/UefiCpuPkg/Include/Library/CpuMmuLib.h > new file mode 100644 > index 0000000000..26d2d65524 > --- /dev/null > +++ b/UefiCpuPkg/Include/Library/CpuMmuLib.h > @@ -0,0 +1,33 @@ > +/** @file > + > +  Copyright (c) 2024 Loongson Technology Corporation Limited. All > rights reserved.
> + > +  SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef CPU_MMU_LIB_H_ > +#define CPU_MMU_LIB_H_ > + > +#include > + > +/** > +  Sets the Attributes  of the specified memory region. > + > +  @param[in]  BaseAddress    The base address of the memory region to > set the Attributes. > +  @param[in]  Length         The length of the memory region to set > the Attributes. > +  @param[in]  Attributes     The Attributes to be set. > +  @param[in]  AttributeMask  Mask of memory attributes to take into > account. > + > +  @retval  EFI_SUCCESS    The Attributes was set successfully > +**/ > +EFI_STATUS > +EFIAPI > +SetMemoryRegionAttributes ( > +  IN EFI_PHYSICAL_ADDRESS  BaseAddress, > +  IN UINTN                 Length, > +  IN UINTN                 Attributes, > +  IN UINT64                AttributeMask > +  ); > + > +#endif // CPU_MMU_LIB_H_ > diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec > index 571b59b36f..ca744fab55 100644 > --- a/UefiCpuPkg/UefiCpuPkg.dec > +++ b/UefiCpuPkg/UefiCpuPkg.dec > @@ -72,6 +72,10 @@ [LibraryClasses.RISCV64] >    ## >    RiscVMmuLib|Include/Library/BaseRiscVMmuLib.h > > +[LibraryClasses.LoongArch64] > +  ##  @libraryclass  Provides functions for the memory management unit. > +  CpuMmuLib|Include/Library/CpuMmuLib.h > + >  [Guids] >    gUefiCpuPkgTokenSpaceGuid      = { 0xac05bf33, 0x995a, 0x4ed4, { > 0xaa, 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }} >    gMsegSmramGuid                 = { 0x5802bce4, 0xeeee, 0x4e33, { > 0xa1, 0x30, 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }} -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117079): https://edk2.groups.io/g/devel/message/117079 Mute This Topic: https://groups.io/mt/105041094/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- --------------0rxePY0JqErLTLjiNUTA2zp2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi Ray,



Thanks,
Chao
On 2024/3/25 10:31, Ni, Ray wrote:
Just curious, how many modules need to call this API?
If there is only one (I guess CpuDxe driver), should LoongArch CPU driver implement the logic internally so that the lib class/API can be avoided?
This API will be consumed in the PEI and DXE stage. In the PEI stage, we will use them to configure the MMU, and the DXE, through which we can set memory region attributes.

Thanks,
Ray

From: Chao Li <lichao@loongson.cn>
Sent: Wednesday, March 20, 2024 16:43
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Ni, Ray <ray.ni@intel.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>; Gerd Hoffmann <kraxel@redhat.com>; Leif Lindholm <quic_llindhol@quicinc.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>; Sami Mujawar <sami.mujawar@arm.com>; Sunil V L <sunilvl@ventanamicro.com>; Warkentin, Andrei <andrei.warkentin@intel.com>
Subject: [PATCH v2 07/13] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg
 
Add a new header file CpuMmuLib.h, whitch is referenced from
ArmPkg/Include/Library/ArmMmuLib.h. Currently, only support for
LoongArch64 is added, and more architectures can be accommodated in the
future.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4734

Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Sunil V L <sunilvl@ventanamicro.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
---
 UefiCpuPkg/Include/Library/CpuMmuLib.h | 55 ++++++++++++++++++++++++++
 UefiCpuPkg/UefiCpuPkg.dec              |  4 ++
 2 files changed, 59 insertions(+)
 create mode 100644 UefiCpuPkg/Include/Library/CpuMmuLib.h

diff --git a/UefiCpuPkg/Include/Library/CpuMmuLib.h b/UefiCpuPkg/Include/Library/CpuMmuLib.h
new file mode 100644
index 0000000000..26d2d65524
--- /dev/null
+++ b/UefiCpuPkg/Include/Library/CpuMmuLib.h
@@ -0,0 +1,33 @@
+/** @file
+
+  Copyright (c) 2024 Loongson Technology Corporation Limited. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_MMU_LIB_H_
+#define CPU_MMU_LIB_H_
+
+#include <Uefi/UefiBaseType.h>
+
+/**
+  Sets the Attributes  of the specified memory region.
+
+  @param[in]  BaseAddress    The base address of the memory region to set the Attributes.
+  @param[in]  Length         The length of the memory region to set the Attributes.
+  @param[in]  Attributes     The Attributes to be set.
+  @param[in]  AttributeMask  Mask of memory attributes to take into account.
+
+  @retval  EFI_SUCCESS    The Attributes was set successfully
+**/
+EFI_STATUS
+EFIAPI
+SetMemoryRegionAttributes (
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN UINTN                 Length,
+  IN UINTN                 Attributes,
+  IN UINT64                AttributeMask
+  );
+
+#endif // CPU_MMU_LIB_H_
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 571b59b36f..ca744fab55 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -72,6 +72,10 @@ [LibraryClasses.RISCV64]
   ##
   RiscVMmuLib|Include/Library/BaseRiscVMmuLib.h
 
+[LibraryClasses.LoongArch64]
+  ##  @libraryclass  Provides functions for the memory management unit.
+  CpuMmuLib|Include/Library/CpuMmuLib.h
+
 [Guids]
   gUefiCpuPkgTokenSpaceGuid      = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa, 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}
   gMsegSmramGuid                 = { 0x5802bce4, 0xeeee, 0x4e33, { 0xa1, 0x30, 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}
_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#117079) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--------------0rxePY0JqErLTLjiNUTA2zp2--