4 Copyright (c) 2008 - 2011, 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>
25 #include <Library/PciLib.h>
26 #include <Library/PcdLib.h>
27 #include <Library/DebugLib.h>
28 #include <Library/MemoryAllocationLib.h>
29 #include <Library/UefiBootServicesTableLib.h>
33 #define PAM_PCI_FUNC 0
35 #define REG_PAM0_OFFSET 0x59 // Programmable Attribute Map 0
36 #define REG_PAM1_OFFSET 0x5a // Programmable Attribute Map 1
37 #define REG_PAM2_OFFSET 0x5b // Programmable Attribute Map 2
38 #define REG_PAM3_OFFSET 0x5c // Programmable Attribute Map 3
39 #define REG_PAM4_OFFSET 0x5d // Programmable Attribute Map 4
40 #define REG_PAM5_OFFSET 0x5e // Programmable Attribute Map 5
41 #define REG_PAM6_OFFSET 0x5f // Programmable Attribute Map 6
43 #define PAM_BASE_ADDRESS 0xc0000
44 #define PAM_LIMIT_ADDRESS BASE_1MB
47 // Describes Legacy Region blocks and status.
54 } LEGACY_MEMORY_SECTION_INFO
;
57 // Provides a map of the PAM registers and bits used to set Read/Write access.
62 UINT8 WriteEnableData
;
66 Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.
68 If the On parameter evaluates to TRUE, this function enables memory reads in the address range
69 Start to (Start + Length - 1).
70 If the On parameter evaluates to FALSE, this function disables memory reads in the address range
71 Start to (Start + Length - 1).
73 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
74 @param Start[in] The beginning of the physical address of the region whose attributes
76 @param Length[in] The number of bytes of memory whose attributes should be modified.
77 The actual number of bytes modified may be greater than the number
79 @param Granularity[out] The number of bytes in the last region affected. This may be less
80 than the total number of bytes affected if the starting address
81 was not aligned to a region's starting address or if the length
82 was greater than the number of bytes in the first region.
83 @param On[in] Decode / Non-Decode flag.
85 @retval EFI_SUCCESS The region's attributes were successfully modified.
86 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
92 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
95 OUT UINT32
*Granularity
,
100 Modify the hardware to disallow memory writes in a region.
102 This function changes the attributes of a memory range to not allow writes.
104 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
105 @param Start[in] The beginning of the physical address of the region whose
106 attributes should be modified.
107 @param Length[in] The number of bytes of memory whose attributes should be modified.
108 The actual number of bytes modified may be greater than the number
110 @param Granularity[out] The number of bytes in the last region affected. This may be less
111 than the total number of bytes affected if the starting address was
112 not aligned to a region's starting address or if the length was
113 greater than the number of bytes in the first region.
115 @retval EFI_SUCCESS The region's attributes were successfully modified.
116 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
122 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
125 OUT UINT32
*Granularity
129 Modify the hardware to disallow memory attribute changes in a region.
131 This function makes the attributes of a region read only. Once a region is boot-locked with this
132 function, the read and write attributes of that region cannot be changed until a power cycle has
133 reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.
135 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
136 @param Start[in] The beginning of the physical address of the region whose
137 attributes should be modified.
138 @param Length[in] The number of bytes of memory whose attributes should be modified.
139 The actual number of bytes modified may be greater than the number
141 @param Granularity[out] The number of bytes in the last region affected. This may be less
142 than the total number of bytes affected if the starting address was
143 not aligned to a region's starting address or if the length was
144 greater than the number of bytes in the first region.
146 @retval EFI_SUCCESS The region's attributes were successfully modified.
147 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
148 @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in
149 a way that will not affect memory regions outside the legacy memory
155 LegacyRegion2BootLock (
156 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
159 OUT UINT32
*Granularity
163 Modify the hardware to allow memory writes in a region.
165 This function changes the attributes of a memory range to allow writes.
167 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
168 @param Start[in] The beginning of the physical address of the region whose
169 attributes should be modified.
170 @param Length[in] The number of bytes of memory whose attributes should be modified.
171 The actual number of bytes modified may be greater than the number
173 @param Granularity[out] The number of bytes in the last region affected. This may be less
174 than the total number of bytes affected if the starting address was
175 not aligned to a region's starting address or if the length was
176 greater than the number of bytes in the first region.
178 @retval EFI_SUCCESS The region's attributes were successfully modified.
179 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
184 LegacyRegion2Unlock (
185 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
188 OUT UINT32
*Granularity
192 Get region information for the attributes of the Legacy Region.
194 This function is used to discover the granularity of the attributes for the memory in the legacy
195 region. Each attribute may have a different granularity and the granularity may not be the same
196 for all memory ranges in the legacy region.
198 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
199 @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor
201 @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy
202 region information is deposited. This buffer will contain a list of
203 DescriptorCount number of region descriptors. This function will
204 provide the memory for the buffer.
206 @retval EFI_SUCCESS The region's attributes were successfully modified.
207 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
212 LegacyRegionGetInfo (
213 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
214 OUT UINT32
*DescriptorCount
,
215 OUT EFI_LEGACY_REGION_DESCRIPTOR
**Descriptor