4 Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are
7 licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _LEGACY_REGION_DXE_H_
17 #define _LEGACY_REGION_DXE_H_
21 #include <Protocol/LegacyRegion2.h>
23 #include <IndustryStandard/Pci.h>
24 #include <IndustryStandard/Q35MchIch9.h>
25 #include <IndustryStandard/I440FxPiix4.h>
27 #include <Library/PciLib.h>
28 #include <Library/PcdLib.h>
29 #include <Library/DebugLib.h>
30 #include <Library/MemoryAllocationLib.h>
31 #include <Library/UefiBootServicesTableLib.h>
33 #define PAM_BASE_ADDRESS 0xc0000
34 #define PAM_LIMIT_ADDRESS BASE_1MB
37 // Describes Legacy Region blocks and status.
44 } LEGACY_MEMORY_SECTION_INFO
;
47 // Provides a map of the PAM registers and bits used to set Read/Write access.
50 UINTN PAMRegPciLibAddress
;
52 UINT8 WriteEnableData
;
56 Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.
58 If the On parameter evaluates to TRUE, this function enables memory reads in the address range
59 Start to (Start + Length - 1).
60 If the On parameter evaluates to FALSE, this function disables memory reads in the address range
61 Start to (Start + Length - 1).
63 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
64 @param Start[in] The beginning of the physical address of the region whose attributes
66 @param Length[in] The number of bytes of memory whose attributes should be modified.
67 The actual number of bytes modified may be greater than the number
69 @param Granularity[out] The number of bytes in the last region affected. This may be less
70 than the total number of bytes affected if the starting address
71 was not aligned to a region's starting address or if the length
72 was greater than the number of bytes in the first region.
73 @param On[in] Decode / Non-Decode flag.
75 @retval EFI_SUCCESS The region's attributes were successfully modified.
76 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
82 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
85 OUT UINT32
*Granularity
,
90 Modify the hardware to disallow memory writes in a region.
92 This function changes the attributes of a memory range to not allow writes.
94 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
95 @param Start[in] The beginning of the physical address of the region whose
96 attributes should be modified.
97 @param Length[in] The number of bytes of memory whose attributes should be modified.
98 The actual number of bytes modified may be greater than the number
100 @param Granularity[out] The number of bytes in the last region affected. This may be less
101 than the total number of bytes affected if the starting address was
102 not aligned to a region's starting address or if the length was
103 greater than the number of bytes in the first region.
105 @retval EFI_SUCCESS The region's attributes were successfully modified.
106 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
112 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
115 OUT UINT32
*Granularity
119 Modify the hardware to disallow memory attribute changes in a region.
121 This function makes the attributes of a region read only. Once a region is boot-locked with this
122 function, the read and write attributes of that region cannot be changed until a power cycle has
123 reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.
125 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
126 @param Start[in] The beginning of the physical address of the region whose
127 attributes should be modified.
128 @param Length[in] The number of bytes of memory whose attributes should be modified.
129 The actual number of bytes modified may be greater than the number
131 @param Granularity[out] The number of bytes in the last region affected. This may be less
132 than the total number of bytes affected if the starting address was
133 not aligned to a region's starting address or if the length was
134 greater than the number of bytes in the first region.
136 @retval EFI_SUCCESS The region's attributes were successfully modified.
137 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
138 @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in
139 a way that will not affect memory regions outside the legacy memory
145 LegacyRegion2BootLock (
146 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
149 OUT UINT32
*Granularity
153 Modify the hardware to allow memory writes in a region.
155 This function changes the attributes of a memory range to allow writes.
157 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
158 @param Start[in] The beginning of the physical address of the region whose
159 attributes should be modified.
160 @param Length[in] The number of bytes of memory whose attributes should be modified.
161 The actual number of bytes modified may be greater than the number
163 @param Granularity[out] The number of bytes in the last region affected. This may be less
164 than the total number of bytes affected if the starting address was
165 not aligned to a region's starting address or if the length was
166 greater than the number of bytes in the first region.
168 @retval EFI_SUCCESS The region's attributes were successfully modified.
169 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
174 LegacyRegion2Unlock (
175 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
178 OUT UINT32
*Granularity
182 Get region information for the attributes of the Legacy Region.
184 This function is used to discover the granularity of the attributes for the memory in the legacy
185 region. Each attribute may have a different granularity and the granularity may not be the same
186 for all memory ranges in the legacy region.
188 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
189 @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor
191 @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy
192 region information is deposited. This buffer will contain a list of
193 DescriptorCount number of region descriptors. This function will
194 provide the memory for the buffer.
196 @retval EFI_SUCCESS The region's attributes were successfully modified.
197 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
202 LegacyRegionGetInfo (
203 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
204 OUT UINT32
*DescriptorCount
,
205 OUT EFI_LEGACY_REGION_DESCRIPTOR
**Descriptor