--- /dev/null
+/** @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