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 9105294112C for ; Fri, 26 Jan 2024 06:29:20 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=1KvV391PAzytm0iTs1Qglvx135k8E29cW6J8SnkW41Q=; 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=1706250559; v=1; b=geBpykGr+32DbWbTrGqDmo7mqmTprGHaklsuKBWiTMZyHVmKEkFoUxbw/eg3jA4LkOf3QdPx y/85sB3c6HlRdu8CMD8BvSfHjk/D4s6MFzK8Oqt47tLoJh/CLv37JR0F/3gzBvWvCe33BZEv2wT c9ro9LsKcjr33StJCllf7tEo= X-Received: by 127.0.0.2 with SMTP id rmr0YY7687511xfCImcKjhIT; Thu, 25 Jan 2024 22:29:19 -0800 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web10.10132.1706250558268462608 for ; Thu, 25 Jan 2024 22:29:18 -0800 X-Received: from loongson.cn (unknown [10.2.9.245]) by gateway (Coremail) with SMTP id _____8Axeeg7UbNlDh4GAA--.2132S3; Fri, 26 Jan 2024 14:29:15 +0800 (CST) X-Received: from code-server.gen (unknown [10.2.9.245]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx_c46UbNlPnIbAA--.53339S2; Fri, 26 Jan 2024 14:29:14 +0800 (CST) From: "Chao Li" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar , Gerd Hoffmann , Leif Lindholm , Ard Biesheuvel , Sami Mujawar , Sunil V L , Andrei Warkentin Subject: [edk2-devel] [PATCH v8 13/37] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg Date: Fri, 26 Jan 2024 14:29:13 +0800 Message-Id: <20240126062913.3101629-1-lichao@loongson.cn> In-Reply-To: <20240126062715.3099433-1-lichao@loongson.cn> References: <20240126062715.3099433-1-lichao@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Cx_c46UbNlPnIbAA--.53339S2 X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQAICGWyG+ALOQBKsV 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: Ztepen8LFY5Tp4KbxSQcG7nTx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=geBpykGr; 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 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=4584 Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek 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/Library/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 reserved.
+ + 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 memory 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 found + 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 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 f5febe46ba..9992626e62 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -62,6 +62,10 @@ ## @libraryclass Provides function for manipulating x86 paging structures. CpuPageTableLib|Include/Library/CpuPageTableLib.h +[LibraryClasses.LoongArch64] + ## @libraryclass Provides macros and functions for the memory management unit. + CpuMmuLib|Include/Library/CpuMmuLib.h + ## @libraryclass Provides functions for manipulating smram savestate registers. MmSaveStateLib|Include/Library/MmSaveStateLib.h -- 2.27.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114539): https://edk2.groups.io/g/devel/message/114539 Mute This Topic: https://groups.io/mt/103971652/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-