--- /dev/null
+/** @file\r
+ The Legacy Region Protocol controls the read, write and boot-lock attributes for\r
+ the region 0xC0000 to 0xFFFFF.\r
+\r
+ Copyright (c) 2009, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ @par Revision Reference:\r
+ This Protocol is defined in UEFI Platform Initialization Specification 1.2 \r
+ Volume 5: Standards\r
+\r
+ @attention This protocol appears to be 'EFI_LEGACY_REGION_PROTOCOL' in current PI 1.2\r
+ public spec. Therefore, some names are different from public PI 1.2 spec and we should\r
+ remove this attention when they appear in public PI 1.2 spec in the future. \r
+\r
+**/\r
+\r
+#ifndef __LEGACY_REGION2_H__\r
+#define __LEGACY_REGION2_H__\r
+\r
+\r
+#define EFI_LEGACY_REGION2_PROTOCOL_GUID \\r
+{ \\r
+ 0x70101eaf, 0x85, 0x440c, {0xb3, 0x56, 0x8e, 0xe3, 0x6f, 0xef, 0x24, 0xf0 } \\r
+}\r
+\r
+typedef struct _EFI_LEGACY_REGION2_PROTOCOL EFI_LEGACY_REGION2_PROTOCOL;\r
+\r
+/**\r
+ Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.\r
+\r
+ If the On parameter evaluates to TRUE, this function enables memory reads in the address range \r
+ Start to (Start + Length - 1).\r
+ If the On parameter evaluates to FALSE, this function disables memory reads in the address range \r
+ Start to (Start + Length - 1).\r
+\r
+ @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r
+ @param Start[in] The beginning of the physical address of the region whose attributes\r
+ should be modified.\r
+ @param Length[in] The number of bytes of memory whose attributes should be modified.\r
+ The actual number of bytes modified may be greater than the number\r
+ specified.\r
+ @param Granularity[out] The number of bytes in the last region affected. This may be less\r
+ than the total number of bytes affected if the starting address\r
+ was not aligned to a region's starting address or if the length\r
+ was greater than the number of bytes in the first region.\r
+ @param On[in] Decode / Non-Decode flag.\r
+\r
+ @retval EFI_SUCCESS The region's attributes were successfully modified.\r
+ @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_REGION2_DECODE) (\r
+ IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity,\r
+ IN BOOLEAN *On\r
+ );\r
+\r
+\r
+/**\r
+ Modify the hardware to disallow memory writes in a region.\r
+\r
+ This function changes the attributes of a memory range to not allow writes.\r
+\r
+ @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r
+ @param Start[in] The beginning of the physical address of the region whose\r
+ attributes should be modified.\r
+ @param Length[in] The number of bytes of memory whose attributes should be modified.\r
+ The actual number of bytes modified may be greater than the number\r
+ specified.\r
+ @param Granularity[out] The number of bytes in the last region affected. This may be less\r
+ than the total number of bytes affected if the starting address was\r
+ not aligned to a region's starting address or if the length was\r
+ greater than the number of bytes in the first region.\r
+\r
+ @retval EFI_SUCCESS The region's attributes were successfully modified.\r
+ @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_REGION2_LOCK) (\r
+ IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity\r
+ );\r
+\r
+\r
+/**\r
+ Modify the hardware to disallow memory attribute changes in a region.\r
+\r
+ This function makes the attributes of a region read only. Once a region is boot-locked with this \r
+ function, the read and write attributes of that region cannot be changed until a power cycle has\r
+ reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.\r
+\r
+ @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r
+ @param Start[in] The beginning of the physical address of the region whose\r
+ attributes should be modified.\r
+ @param Length[in] The number of bytes of memory whose attributes should be modified.\r
+ The actual number of bytes modified may be greater than the number\r
+ specified.\r
+ @param Granularity[out] The number of bytes in the last region affected. This may be less\r
+ than the total number of bytes affected if the starting address was\r
+ not aligned to a region's starting address or if the length was\r
+ greater than the number of bytes in the first region.\r
+\r
+ @retval EFI_SUCCESS The region's attributes were successfully modified.\r
+ @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
+ @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in\r
+ a way that will not affect memory regions outside the legacy memory\r
+ region.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_REGION2_BOOT_LOCK)(\r
+ IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity OPTIONAL\r
+ );\r
+\r
+\r
+/**\r
+ Modify the hardware to allow memory writes in a region.\r
+\r
+ This function changes the attributes of a memory range to allow writes. \r
+\r
+ @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r
+ @param Start[in] The beginning of the physical address of the region whose\r
+ attributes should be modified.\r
+ @param Length[in] The number of bytes of memory whose attributes should be modified.\r
+ The actual number of bytes modified may be greater than the number\r
+ specified.\r
+ @param Granularity[out] The number of bytes in the last region affected. This may be less\r
+ than the total number of bytes affected if the starting address was\r
+ not aligned to a region's starting address or if the length was\r
+ greater than the number of bytes in the first region.\r
+\r
+ @retval EFI_SUCCESS The region's attributes were successfully modified.\r
+ @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_REGION2_UNLOCK) (\r
+ IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity\r
+ );\r
+\r
+\r
+typedef enum {\r
+ LegacyRegionDecoded, ///< This region is currently set to allow reads.\r
+ LegacyRegionNotDecoded, ///< This region is currently set to not allow reads.\r
+ LegacyRegionWriteEnabled, ///< This region is currently set to allow writes.\r
+ LegacyRegionWriteDisabled, ///< This region is currently set to write protected.\r
+ LegacyRegionBootLocked, ///< This region's attributes are locked, cannot be modified until\r
+ ///< after a power cycle.\r
+ LegacyRegionNotLocked ///< This region's attributes are not locked.\r
+} EFI_LEGACY_REGION_ATTRIBUTE;\r
+\r
+\r
+typedef struct {\r
+ UINT32 Start; ///< The beginning of the physical address of this\r
+ ///< region.\r
+ UINT32 Length; ///< The number of bytes in this region.\r
+ EFI_LEGACY_REGION_ATTRIBUTE Attribute; ///< Attribute of the Legacy Region Descriptor that\r
+ ///< describes the capabilities for that memory region. \r
+ UINT32 Granularity; ///< Describes the byte length programmability\r
+ ///< associated with the Start address and the specified\r
+ ///< Attribute setting.\r
+} EFI_LEGACY_REGION_DESCRIPTOR;\r
+\r
+\r
+/**\r
+ Get region information for the attributes of the Legacy Region.\r
+\r
+ This function is used to discover the granularity of the attributes for the memory in the legacy \r
+ region. Each attribute may have a different granularity and the granularity may not be the same\r
+ for all memory ranges in the legacy region. \r
+\r
+ @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r
+ @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor\r
+ buffer.\r
+ @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy\r
+ region information is deposited. This buffer will contain a list of\r
+ DescriptorCount number of region descriptors. This function will\r
+ provide the memory for the buffer.\r
+\r
+ @retval EFI_SUCCESS The information structure was returned.\r
+ @retval EFI_UNSUPPORTED This function is not supported.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_REGION_GET_INFO) (\r
+ IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
+ OUT UINT32 *DescriptorCount,\r
+ OUT EFI_LEGACY_REGION_DESCRIPTOR **Descriptor\r
+ );\r
+\r
+\r
+/**\r
+ Abstracts the hardware control of the physical address region 0xC0000-0xFFFFF.\r
+\r
+ The EFI_LEGACY_REGION2_PROTOCOL is used to abstract the hardware control of the memory \r
+ attributes of the Option ROM shadowing region, 0xC0000 to 0xFFFFF.\r
+ \r
+ There are three memory attributes that can be modified through this protocol: read, write and\r
+ boot-lock. These protocols may be set in any combination.\r
+\r
+**/\r
+struct _EFI_LEGACY_REGION2_PROTOCOL {\r
+ EFI_LEGACY_REGION2_DECODE Decode; ///< Modify the read attribute of a memory region. See\r
+ ///< the Decode() function description.\r
+ EFI_LEGACY_REGION2_LOCK Lock; ///< Modify the write attribute of a memory region to\r
+ ///< prevent writes. See the Lock() function description.\r
+ EFI_LEGACY_REGION2_BOOT_LOCK BootLock; ///< Modify the boot-lock attribute of a memory region to\r
+ ///< prevent future changes to the memory attributes for\r
+ ///< this region. See the BootLock() function description.\r
+ EFI_LEGACY_REGION2_UNLOCK UnLock; ///< Modify the write attribute of a memory region to\r
+ ///< allow writes. See the Unlock() function description. \r
+ EFI_LEGACY_REGION_GET_INFO GetInfo; ///< Modify the write attribute of a memory region to\r
+ ///< allow writes. See the GetInfo() function description.\r
+};\r
+\r
+extern EFI_GUID gEfiLegacyRegion2ProtocolGuid;\r
+\r
+#endif\r