From nobody Wed Feb 11 05:36:43 2026 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+113667+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+113667+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1705047858; cv=none; d=zohomail.com; s=zohoarc; b=QHW5zbsv7bGvKRVFvCthRPuPbkOmucyQ4BP6ILkGFpkbgViuCCmvnQ9lZX0dvJVXYEOrCUA8Rpvo9debtaDDXcSr/sm8eo+WKPGJxTwPnFxLorJXZ8k9zbmlIEoQ5e5bOUbJ/LdnGNOxTfVfqsZw7dYJg0FsN+5RcONliysZQZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705047858; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=cmCHKMW9oe7KyR6cthahGs267A4tl9Emo9/7kaF4XdA=; b=EPKZl8v3Wcc3DeNcNb8t4TkX54OaMSkFCdGglTXBcNB1xnwC9+gVz10DW9WVn24+X1eNzPnqER1JWcd13P8JUR3z1icxUaWV2wadMBP+KiYxwdgH6ODz7xzW/cx4NyA/uTro+L1nq6EBky45T2adfSmohjdR214VnbjJit6+E5A= 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+113667+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1705047858154604.9041421735072; Fri, 12 Jan 2024 00:24:18 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=I+7yMfdSJy2j0XYwbgpAj4KVtV7mOQ19FSSNOcpl77Y=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1705047857; v=1; b=CJsolMbZ3J2gjhDZNmABS03GUmPSGvRk0HMPqENO84SQ5Kk2Wr2StqkGvNBBYXO4M05R/d1R J7QwsmdFtsgtehcAeoItU7ousCN7EIdY+j2saKA9ISKlCyCP0/vwNrrHE6EQBd0ddXktn9NgSgM jwkU4SDvNKkMqUvjlqHbBqvk= X-Received: by 127.0.0.2 with SMTP id btfAYY1788612xDE7xdXmHUl; Fri, 12 Jan 2024 00:24:17 -0800 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web11.3022.1705047855980298255 for ; Fri, 12 Jan 2024 00:24:17 -0800 X-Received: from loongson.cn (unknown [10.2.9.245]) by gateway (Coremail) with SMTP id _____8BxXess96BlCX4EAA--.13100S3; Fri, 12 Jan 2024 16:24:12 +0800 (CST) X-Received: from code-server.gen (unknown [10.2.9.245]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Axz98q96Bl64gTAA--.50856S2; Fri, 12 Jan 2024 16:24:10 +0800 (CST) From: "Chao Li" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Leif Lindholm , Ard Biesheuvel , Sami Mujawar , Sunil V L , Andrei Warkentin Subject: [edk2-devel] [PATCH v7 13/37] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg Date: Fri, 12 Jan 2024 16:24:08 +0800 Message-Id: <20240112082408.3288494-1-lichao@loongson.cn> In-Reply-To: <20240112082153.3284189-1-lichao@loongson.cn> References: <20240112082153.3284189-1-lichao@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Axz98q96Bl64gTAA--.50856S2 X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQAOCGWgj6kGSgAbsz 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 Reply-To: devel@edk2.groups.io,lichao@loongson.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: MRYSe30LZxMwvQEGuQeyD1Xmx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1705047858666100005 Content-Type: text/plain; charset="utf-8" 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=3D4584 Cc: Eric Dong 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 Reviewed-by: Andrei Warkentin Reviewed-by: Ray Ni --- UefiCpuPkg/Include/Library/CpuMmuLib.h | 62 ++++++++++++++++++++++++++ UefiCpuPkg/UefiCpuPkg.dec | 4 ++ 2 files changed, 66 insertions(+) create mode 100644 UefiCpuPkg/Include/Library/CpuMmuLib.h diff --git a/UefiCpuPkg/Include/Library/CpuMmuLib.h b/UefiCpuPkg/Include/Li= brary/CpuMmuLib.h new file mode 100644 index 0000000000..f88ec4eb2e --- /dev/null +++ b/UefiCpuPkg/Include/Library/CpuMmuLib.h @@ -0,0 +1,62 @@ +/** @file + + Copyright (c) 2024 Loongson Technology Corporation Limited. All rights r= eserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef CPU_MMU_LIB_H_ +#define CPU_MMU_LIB_H_ + +#include + +typedef struct { + EFI_PHYSICAL_ADDRESS PhysicalBase; + EFI_VIRTUAL_ADDRESS VirtualBase; + UINTN Length; + UINTN Attributes; +} MEMORY_REGION_DESCRIPTOR; + +/** + Finds the first of the length and memory properties of the memory region= corresponding + to the specified base address. + + @param[in] BaseAddress To find the base address of the memor= y region. + @param[in, out] RegionLength Pointer holding: + - At entry, the length of the memory= region + expected to be found. + - At exit, the length of the memory = region found. + @param[out] RegionAttributes Properties of the memory region found. + + @retval EFI_SUCCESS The corresponding memory area was successfully f= ound + EFI_NOT_FOUND No memory area found +**/ +EFI_STATUS +EFIAPI +GetMemoryRegionAttributes ( + IN UINTN BaseAddress, + IN OUT UINTN *RegionLength, + OUT UINTN *RegionAttributes + ); + +/** + 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 At= tributes. + @param[in] Attributes The Attributes to be set. + @param[in] AttributeMask Mask of memory attributes to take into accoun= t. + + @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 84f61254bb..9b11a3da72 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -62,6 +62,10 @@ ## @libraryclass Provides function for manipulating x86 paging structu= res. CpuPageTableLib|Include/Library/CpuPageTableLib.h =20 +[LibraryClasses.LoongArch64] + ## @libraryclass Provides macros and functions for the memory manageme= nt unit. + CpuMmuLib|Include/Library/CpuMmuLib.h + ## @libraryclass Provides functions for manipulating smram savestate r= egisters. MmSaveStateLib|Include/Library/MmSaveStateLib.h =20 --=20 2.27.0 -=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 (#113667): https://edk2.groups.io/g/devel/message/113667 Mute This Topic: https://groups.io/mt/103679448/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-