From nobody Tue Feb 10 20:31:07 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+112403+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+112403+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1702386741; cv=none; d=zohomail.com; s=zohoarc; b=X4TL4QoW6S9Q4L/X7nN4FDwnfLA3c27IVUsDp7gbVmQQjbGPgIt5H6uC3c/ii42rPwOeJOfx6surFRNR/lhMacBpuoUO6dOnAaW7t/4cfEUkPbqC10IXNHu6RCiXxyA4++ho/EDM1iRAVDV6CGJRzdXPA25LhJ3qSYqP3bbH7Os= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702386741; 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=+fIKsju6NNcwymzBvEd9rvmptoI7vU7Nsqn8MUtrJzM=; b=iM+f2ih7qzhaRUZdKWND0l1R5t/M9gwjuSpgT3CbMCn2piMNIAjIdboOWMNA9+DWrPrKMRKGNZTg6+ROKc/ivSs6A6FMiFFauhxLAd9aZX5eCyCG5V4jANTa50Px3ybIAVxxjykDbI1tHpBKfqb7Y1chanh8INy+itbZUS89KY4= 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+112403+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1702386741332690.9497666015048; Tue, 12 Dec 2023 05:12:21 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=iDGsQSUwzcPZ7GnGPVT0eKDqTuL2o/H1GfHOSdxXi4Y=; 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=1702386741; v=1; b=IrDgrC0UKeDxmQ9T7trwwyPKsKNmi/rnG+nHy/iexyBJ0ca3M8K9j9ChMVQCe5ihcfY71nNC vHqc90Pocm3jNEVa5dE7TwH4VRUArqI6HzGpBnvIgF6he6kwNpFMz1jYYYdO6e/Dem21fgRZoyT oq5xqcR/+i0nkjZ/4d3zc8XQ= X-Received: by 127.0.0.2 with SMTP id ELptYY1788612xrOd89YD0lP; Tue, 12 Dec 2023 05:12:21 -0800 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web10.1263.1702386739877196279 for ; Tue, 12 Dec 2023 05:12:20 -0800 X-Received: from loongson.cn (unknown [10.2.9.245]) by gateway (Coremail) with SMTP id _____8AxJPAxXHhlkFkAAA--.2128S3; Tue, 12 Dec 2023 21:12:17 +0800 (CST) X-Received: from code-server.gen (unknown [10.2.9.245]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxrnMxXHhl1aMAAA--.2689S2; Tue, 12 Dec 2023 21:12:17 +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 v4 12/37] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg Date: Tue, 12 Dec 2023 21:12:16 +0800 Message-Id: <20231212131216.2470799-1-lichao@loongson.cn> In-Reply-To: <20231212130932.2467028-1-lichao@loongson.cn> References: <20231212130932.2467028-1-lichao@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxrnMxXHhl1aMAAA--.2689S2 X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQADCGV3wy0H6gAUsP 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: Jxs6FCNrDLFJFtFVOwxNjfakx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1702386741761100006 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 --- UefiCpuPkg/Include/Library/CpuMmuLib.h | 67 ++++++++++++++++++++++++++ UefiCpuPkg/UefiCpuPkg.dec | 4 ++ 2 files changed, 71 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..97e0ec0586 --- /dev/null +++ b/UefiCpuPkg/Include/Library/CpuMmuLib.h @@ -0,0 +1,67 @@ +/** @file + + Copyright (c) 2023 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 + +#define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | \ + EFI_MEMORY_WC | \ + EFI_MEMORY_WT | \ + EFI_MEMORY_WB | \ + EFI_MEMORY_UCE \ + ) + +typedef struct { + EFI_PHYSICAL_ADDRESS PhysicalBase; + EFI_VIRTUAL_ADDRESS VirtualBase; + UINTN Length; + UINTN Attributes; +} MEMORY_REGION_DESCRIPTOR; + +/** + Finds the length and memory properties of the memory region correspondin= g to the specified base address. + + @param[in] BaseAddress To find the base address of the memory region. + @param[in] EndAddress To find the end address of the memory region. + @param[out] RegionLength 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 UINTN EndAddress, + 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 154b1d06fe..150beae981 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 (#112403): https://edk2.groups.io/g/devel/message/112403 Mute This Topic: https://groups.io/mt/103129095/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-