]>
Commit | Line | Data |
---|---|---|
8016da21 | 1 | /** @file\r |
2 | Legacy Region Support\r | |
3 | \r | |
db27e9f3 | 4 | Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r |
8016da21 | 5 | \r |
6 | This program and the accompanying materials are\r | |
7 | licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef _LEGACY_REGION_DXE_H_\r | |
17 | #define _LEGACY_REGION_DXE_H_\r | |
18 | \r | |
19 | #include <PiDxe.h>\r | |
20 | \r | |
21 | #include <Protocol/LegacyRegion2.h>\r | |
22 | \r | |
23 | #include <IndustryStandard/Pci.h>\r | |
db27e9f3 RN |
24 | #include <IndustryStandard/Q35MchIch9.h>\r |
25 | #include <IndustryStandard/I440FxPiix4.h>\r | |
8016da21 | 26 | \r |
27 | #include <Library/PciLib.h>\r | |
28 | #include <Library/PcdLib.h>\r | |
29 | #include <Library/DebugLib.h>\r | |
30 | #include <Library/MemoryAllocationLib.h>\r | |
31 | #include <Library/UefiBootServicesTableLib.h>\r | |
32 | \r | |
8016da21 | 33 | #define PAM_BASE_ADDRESS 0xc0000\r |
34 | #define PAM_LIMIT_ADDRESS BASE_1MB\r | |
35 | \r | |
36 | //\r | |
37 | // Describes Legacy Region blocks and status.\r | |
38 | //\r | |
39 | typedef struct {\r | |
40 | UINT32 Start;\r | |
41 | UINT32 Length;\r | |
42 | BOOLEAN ReadEnabled;\r | |
43 | BOOLEAN WriteEnabled;\r | |
44 | } LEGACY_MEMORY_SECTION_INFO;\r | |
45 | \r | |
46 | //\r | |
47 | // Provides a map of the PAM registers and bits used to set Read/Write access.\r | |
48 | //\r | |
49 | typedef struct {\r | |
ba1d245f | 50 | UINTN PAMRegPciLibAddress;\r |
8016da21 | 51 | UINT8 ReadEnableData;\r |
52 | UINT8 WriteEnableData;\r | |
53 | } PAM_REGISTER_VALUE;\r | |
54 | \r | |
55 | /**\r | |
56 | Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.\r | |
57 | \r | |
58 | If the On parameter evaluates to TRUE, this function enables memory reads in the address range\r | |
59 | Start to (Start + Length - 1).\r | |
60 | If the On parameter evaluates to FALSE, this function disables memory reads in the address range\r | |
61 | Start to (Start + Length - 1).\r | |
62 | \r | |
63 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
64 | @param Start[in] The beginning of the physical address of the region whose attributes\r | |
65 | should be modified.\r | |
66 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
67 | The actual number of bytes modified may be greater than the number\r | |
68 | specified.\r | |
69 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
70 | than the total number of bytes affected if the starting address\r | |
71 | was not aligned to a region's starting address or if the length\r | |
72 | was greater than the number of bytes in the first region.\r | |
73 | @param On[in] Decode / Non-Decode flag.\r | |
74 | \r | |
75 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
76 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
77 | \r | |
78 | **/\r | |
79 | EFI_STATUS\r | |
80 | EFIAPI\r | |
81 | LegacyRegion2Decode (\r | |
82 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
83 | IN UINT32 Start,\r | |
84 | IN UINT32 Length,\r | |
85 | OUT UINT32 *Granularity,\r | |
86 | IN BOOLEAN *On\r | |
87 | );\r | |
88 | \r | |
89 | /**\r | |
90 | Modify the hardware to disallow memory writes in a region.\r | |
91 | \r | |
92 | This function changes the attributes of a memory range to not allow writes.\r | |
93 | \r | |
94 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
95 | @param Start[in] The beginning of the physical address of the region whose\r | |
96 | attributes should be modified.\r | |
97 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
98 | The actual number of bytes modified may be greater than the number\r | |
99 | specified.\r | |
100 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
101 | than the total number of bytes affected if the starting address was\r | |
102 | not aligned to a region's starting address or if the length was\r | |
103 | greater than the number of bytes in the first region.\r | |
104 | \r | |
105 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
106 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
107 | \r | |
108 | **/\r | |
109 | EFI_STATUS\r | |
110 | EFIAPI\r | |
111 | LegacyRegion2Lock (\r | |
112 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
113 | IN UINT32 Start,\r | |
114 | IN UINT32 Length,\r | |
115 | OUT UINT32 *Granularity\r | |
116 | );\r | |
117 | \r | |
118 | /**\r | |
119 | Modify the hardware to disallow memory attribute changes in a region.\r | |
120 | \r | |
121 | This function makes the attributes of a region read only. Once a region is boot-locked with this\r | |
122 | function, the read and write attributes of that region cannot be changed until a power cycle has\r | |
123 | reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.\r | |
124 | \r | |
125 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
126 | @param Start[in] The beginning of the physical address of the region whose\r | |
127 | attributes should be modified.\r | |
128 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
129 | The actual number of bytes modified may be greater than the number\r | |
130 | specified.\r | |
131 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
132 | than the total number of bytes affected if the starting address was\r | |
133 | not aligned to a region's starting address or if the length was\r | |
134 | greater than the number of bytes in the first region.\r | |
135 | \r | |
136 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
137 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
138 | @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in\r | |
139 | a way that will not affect memory regions outside the legacy memory\r | |
140 | region.\r | |
141 | \r | |
142 | **/\r | |
143 | EFI_STATUS\r | |
144 | EFIAPI\r | |
145 | LegacyRegion2BootLock (\r | |
146 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
147 | IN UINT32 Start,\r | |
148 | IN UINT32 Length,\r | |
149 | OUT UINT32 *Granularity\r | |
150 | );\r | |
151 | \r | |
152 | /**\r | |
153 | Modify the hardware to allow memory writes in a region.\r | |
154 | \r | |
155 | This function changes the attributes of a memory range to allow writes.\r | |
156 | \r | |
157 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
158 | @param Start[in] The beginning of the physical address of the region whose\r | |
159 | attributes should be modified.\r | |
160 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
161 | The actual number of bytes modified may be greater than the number\r | |
162 | specified.\r | |
163 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
164 | than the total number of bytes affected if the starting address was\r | |
165 | not aligned to a region's starting address or if the length was\r | |
166 | greater than the number of bytes in the first region.\r | |
167 | \r | |
168 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
169 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
170 | \r | |
171 | **/\r | |
172 | EFI_STATUS\r | |
173 | EFIAPI\r | |
174 | LegacyRegion2Unlock (\r | |
175 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
176 | IN UINT32 Start,\r | |
177 | IN UINT32 Length,\r | |
178 | OUT UINT32 *Granularity\r | |
179 | );\r | |
180 | \r | |
181 | /**\r | |
182 | Get region information for the attributes of the Legacy Region.\r | |
183 | \r | |
184 | This function is used to discover the granularity of the attributes for the memory in the legacy\r | |
185 | region. Each attribute may have a different granularity and the granularity may not be the same\r | |
186 | for all memory ranges in the legacy region.\r | |
187 | \r | |
188 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
189 | @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor\r | |
190 | buffer.\r | |
191 | @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy\r | |
192 | region information is deposited. This buffer will contain a list of\r | |
193 | DescriptorCount number of region descriptors. This function will\r | |
194 | provide the memory for the buffer.\r | |
195 | \r | |
196 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
197 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
198 | \r | |
199 | **/\r | |
200 | EFI_STATUS\r | |
201 | EFIAPI\r | |
202 | LegacyRegionGetInfo (\r | |
203 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
204 | OUT UINT32 *DescriptorCount,\r | |
205 | OUT EFI_LEGACY_REGION_DESCRIPTOR **Descriptor\r | |
206 | );\r | |
207 | \r | |
208 | #endif\r | |
209 | \r |