Reviewed-by: Ray Ni <[email protected]>

Thanks,
Ray
> -----Original Message-----
> From: Chao Li <[email protected]>
> Sent: Friday, January 5, 2024 5:44 PM
> To: [email protected]
> Cc: Dong, Eric <[email protected]>; Ni, Ray <[email protected]>; Kumar,
> Rahul R <[email protected]>; Gerd Hoffmann <[email protected]>;
> Leif Lindholm <[email protected]>; Ard Biesheuvel
> <[email protected]>; Sami Mujawar <[email protected]>;
> Sunil V L <[email protected]>; Warkentin, Andrei
> <[email protected]>
> Subject: [PATCH v6 12/36] 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=4584
> 
> Cc: Eric Dong <[email protected]>
> Cc: Ray Ni <[email protected]>
> Cc: Rahul Kumar <[email protected]>
> Cc: Gerd Hoffmann <[email protected]>
> Cc: Leif Lindholm <[email protected]>
> Cc: Ard Biesheuvel <[email protected]>
> Cc: Sami Mujawar <[email protected]>
> Cc: Sunil V L <[email protected]>
> Cc: Andrei Warkentin <[email protected]>
> Signed-off-by: Chao Li <[email protected]>
> Reviewed-by: Andrei Warkentin <[email protected]>
> ---
>  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.<BR>
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef CPU_MMU_LIB_H_
> +#define CPU_MMU_LIB_H_
> +
> +#include <Uefi/UefiBaseType.h>
> +
> +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 84f61254bb..9b11a3da72 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 (#113278): https://edk2.groups.io/g/devel/message/113278
Mute This Topic: https://groups.io/mt/103540105/21656
Group Owner: [email protected]
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to