]> xenbits.xensource.com Git - ovmf.git/commitdiff
MdePkg: Add Memory Attribute Protocol definition
authorArd Biesheuvel <ardb@kernel.org>
Thu, 2 Feb 2023 09:29:07 +0000 (10:29 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 16 Mar 2023 21:14:49 +0000 (21:14 +0000)
Add the Memory Attribute Protocol definition, which was adopted and
included in version 2.10 of the UEFI specification.

Link: https://bugzilla.tianocore.org/show_bug.cgi?id=3519
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
MdePkg/Include/Protocol/MemoryAttribute.h [new file with mode: 0644]
MdePkg/MdePkg.dec

diff --git a/MdePkg/Include/Protocol/MemoryAttribute.h b/MdePkg/Include/Protocol/MemoryAttribute.h
new file mode 100644 (file)
index 0000000..e1530ed
--- /dev/null
@@ -0,0 +1,142 @@
+/** @file\r
+\r
+  EFI Memory Attribute Protocol provides retrieval and update service\r
+  for memory attributes in EFI environment.\r
+\r
+  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2023, Google LLC. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef EFI_MEMORY_ATTRIBUTE_H_\r
+#define EFI_MEMORY_ATTRIBUTE_H_\r
+\r
+#define EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID \\r
+  { \\r
+    0xf4560cf6, 0x40ec, 0x4b4a, { 0xa1, 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1, 0x89 } \\r
+  }\r
+\r
+typedef struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL EFI_MEMORY_ATTRIBUTE_PROTOCOL;\r
+\r
+/**\r
+  This function set given attributes of the memory region specified by\r
+  BaseAddress and Length.\r
+\r
+  The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and EFI_MEMORY_RO.\r
+\r
+  @param  This              The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.\r
+  @param  BaseAddress       The physical address that is the start address of\r
+                            a memory region.\r
+  @param  Length            The size in bytes of the memory region.\r
+  @param  Attributes        The bit mask of attributes to set for the memory\r
+                            region.\r
+\r
+  @retval EFI_SUCCESS           The attributes were set for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero.\r
+                                Attributes specified an illegal combination of\r
+                                attributes that cannot be set together.\r
+  @retval EFI_UNSUPPORTED       The processor does not support one or more\r
+                                bytes of the memory resource range specified\r
+                                by BaseAddress and Length.\r
+                                The bit mask of attributes is not supported for\r
+                                the memory resource range specified by\r
+                                BaseAddress and Length.\r
+  @retval EFI_OUT_OF_RESOURCES  Requested attributes cannot be applied due to\r
+                                lack of system resources.\r
+  @retval EFI_ACCESS_DENIED     Attributes for the requested memory region are\r
+                                controlled by system firmware and cannot be\r
+                                updated via the protocol.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SET_MEMORY_ATTRIBUTES)(\r
+  IN  EFI_MEMORY_ATTRIBUTE_PROTOCOL       *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                BaseAddress,\r
+  IN  UINT64                              Length,\r
+  IN  UINT64                              Attributes\r
+  );\r
+\r
+/**\r
+  This function clears given attributes of the memory region specified by\r
+  BaseAddress and Length.\r
+\r
+  The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and EFI_MEMORY_RO.\r
+\r
+  @param  This              The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.\r
+  @param  BaseAddress       The physical address that is the start address of\r
+                            a memory region.\r
+  @param  Length            The size in bytes of the memory region.\r
+  @param  Attributes        The bit mask of attributes to clear for the memory\r
+                            region.\r
+\r
+  @retval EFI_SUCCESS           The attributes were cleared for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero.\r
+                                Attributes specified an illegal combination of\r
+                                attributes that cannot be cleared together.\r
+  @retval EFI_UNSUPPORTED       The processor does not support one or more\r
+                                bytes of the memory resource range specified\r
+                                by BaseAddress and Length.\r
+                                The bit mask of attributes is not supported for\r
+                                the memory resource range specified by\r
+                                BaseAddress and Length.\r
+  @retval EFI_OUT_OF_RESOURCES  Requested attributes cannot be applied due to\r
+                                lack of system resources.\r
+  @retval EFI_ACCESS_DENIED     Attributes for the requested memory region are\r
+                                controlled by system firmware and cannot be\r
+                                updated via the protocol.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CLEAR_MEMORY_ATTRIBUTES)(\r
+  IN  EFI_MEMORY_ATTRIBUTE_PROTOCOL       *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                BaseAddress,\r
+  IN  UINT64                              Length,\r
+  IN  UINT64                              Attributes\r
+  );\r
+\r
+/**\r
+  This function retrieves the attributes of the memory region specified by\r
+  BaseAddress and Length. If different attributes are obtained from different\r
+  parts of the memory region, EFI_NO_MAPPING will be returned.\r
+\r
+  @param  This              The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.\r
+  @param  BaseAddress       The physical address that is the start address of\r
+                            a memory region.\r
+  @param  Length            The size in bytes of the memory region.\r
+  @param  Attributes        Pointer to attributes returned.\r
+\r
+  @retval EFI_SUCCESS           The attributes got for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero.\r
+                                Attributes is NULL.\r
+  @retval EFI_NO_MAPPING        Attributes are not consistent cross the memory\r
+                                region.\r
+  @retval EFI_UNSUPPORTED       The processor does not support one or more\r
+                                bytes of the memory resource range specified\r
+                                by BaseAddress and Length.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_MEMORY_ATTRIBUTES)(\r
+  IN  EFI_MEMORY_ATTRIBUTE_PROTOCOL       *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                BaseAddress,\r
+  IN  UINT64                              Length,\r
+  OUT UINT64                              *Attributes\r
+  );\r
+\r
+///\r
+/// EFI Memory Attribute Protocol provides services to retrieve or update\r
+/// attribute of memory in the EFI environment.\r
+///\r
+struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL {\r
+  EFI_GET_MEMORY_ATTRIBUTES      GetMemoryAttributes;\r
+  EFI_SET_MEMORY_ATTRIBUTES      SetMemoryAttributes;\r
+  EFI_CLEAR_MEMORY_ATTRIBUTES    ClearMemoryAttributes;\r
+};\r
+\r
+extern EFI_GUID  gEfiMemoryAttributeProtocolGuid;\r
+\r
+#endif\r
index 80b655905314786ea96062d15b2c4174f4e1bc82..2d643bede1d7a3afc9614fcbca10da7ad9bfb94b 100644 (file)
   ## Include/Protocol/RedfishDiscover.h\r
   gEfiRedfishDiscoverProtocolGuid      = { 0x5db12509, 0x4550, 0x4347, { 0x96, 0xb3, 0x73, 0xc0, 0xff, 0x6e, 0x86, 0x9f }}\r
 \r
+  ## Include/Protocol/MemoryAttribute.h\r
+  gEfiMemoryAttributeProtocolGuid = { 0xf4560cf6, 0x40ec, 0x4b4a, { 0xa1, 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1, 0x89 }}\r
+\r
   #\r
   # Protocols defined in Shell2.0\r
   #\r