--- /dev/null
+/** @file\r
+ Legacy Region Support\r
+\r
+ Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
+\r
+ This program and the accompanying materials are\r
+ 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
+**/\r
+\r
+#ifndef _LEGACY_REGION_DXE_H_\r
+#define _LEGACY_REGION_DXE_H_\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/LegacyRegion2.h>\r
+\r
+#include <IndustryStandard/Pci.h>\r
+\r
+#include <Library/PciLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+#define PAM_PCI_BUS 0\r
+#define PAM_PCI_DEV 0\r
+#define PAM_PCI_FUNC 0\r
+\r
+#define REG_PAM0_OFFSET 0x59 // Programmable Attribute Map 0\r
+#define REG_PAM1_OFFSET 0x5a // Programmable Attribute Map 1\r
+#define REG_PAM2_OFFSET 0x5b // Programmable Attribute Map 2\r
+#define REG_PAM3_OFFSET 0x5c // Programmable Attribute Map 3\r
+#define REG_PAM4_OFFSET 0x5d // Programmable Attribute Map 4\r
+#define REG_PAM5_OFFSET 0x5e // Programmable Attribute Map 5\r
+#define REG_PAM6_OFFSET 0x5f // Programmable Attribute Map 6\r
+\r
+#define PAM_BASE_ADDRESS 0xc0000\r
+#define PAM_LIMIT_ADDRESS BASE_1MB\r
+\r
+//\r
+// Describes Legacy Region blocks and status.\r
+//\r
+typedef struct {\r
+ UINT32 Start;\r
+ UINT32 Length;\r
+ BOOLEAN ReadEnabled;\r
+ BOOLEAN WriteEnabled;\r
+} LEGACY_MEMORY_SECTION_INFO;\r
+\r
+//\r
+// Provides a map of the PAM registers and bits used to set Read/Write access.\r
+//\r
+typedef struct {\r
+ UINT8 PAMRegOffset;\r
+ UINT8 ReadEnableData;\r
+ UINT8 WriteEnableData;\r
+} PAM_REGISTER_VALUE;\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_REGION_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
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegion2Decode (\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
+ 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_REGION_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
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegion2Lock (\r
+ IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity\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_REGION_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
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegion2BootLock (\r
+ IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity\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_REGION_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
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegion2Unlock (\r
+ IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
+ IN UINT32 Start,\r
+ IN UINT32 Length,\r
+ OUT UINT32 *Granularity\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_REGION_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 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
+EFI_STATUS\r
+EFIAPI\r
+LegacyRegionGetInfo (\r
+ IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
+ OUT UINT32 *DescriptorCount,\r
+ OUT EFI_LEGACY_REGION_DESCRIPTOR **Descriptor\r
+ );\r
+\r
+#endif\r
+\r