]>
Commit | Line | Data |
---|---|---|
2719803b | 1 | /** @file\r |
2 | Dummy implementation of Legacy Region 2 Protocol.\r | |
3 | \r | |
d1102dba LG |
4 | This generic implementation of the Legacy Region 2 Protocol does not actually\r |
5 | perform any lock/unlock operations. This module may be used on platforms\r | |
6 | that do not provide HW locking of the legacy memory regions. It can also\r | |
2719803b | 7 | be used as a template driver for implementing the Legacy Region 2 Protocol on\r |
8 | a platform that does support HW locking of the legacy memory regions.\r | |
9 | \r | |
d1102dba | 10 | Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 11 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
2719803b | 12 | \r |
13 | **/\r | |
14 | \r | |
15 | #include <LegacyRegion2.h>\r | |
16 | \r | |
17 | EFI_HANDLE mLegacyRegion2Handle = NULL;\r | |
18 | \r | |
19 | EFI_LEGACY_REGION2_PROTOCOL mLegacyRegion2 = {\r | |
20 | LegacyRegion2Decode,\r | |
21 | LegacyRegion2Lock,\r | |
22 | LegacyRegion2BootLock,\r | |
23 | LegacyRegion2Unlock,\r | |
24 | LegacyRegionGetInfo\r | |
25 | };\r | |
26 | \r | |
27 | /**\r | |
28 | Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.\r | |
29 | \r | |
d1102dba | 30 | If the On parameter evaluates to TRUE, this function enables memory reads in the address range\r |
2719803b | 31 | Start to (Start + Length - 1).\r |
d1102dba | 32 | If the On parameter evaluates to FALSE, this function disables memory reads in the address range\r |
2719803b | 33 | Start to (Start + Length - 1).\r |
34 | \r | |
35 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
36 | @param Start[in] The beginning of the physical address of the region whose attributes\r | |
37 | should be modified.\r | |
38 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
39 | The actual number of bytes modified may be greater than the number\r | |
40 | specified.\r | |
41 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
42 | than the total number of bytes affected if the starting address\r | |
43 | was not aligned to a region's starting address or if the length\r | |
44 | was greater than the number of bytes in the first region.\r | |
45 | @param On[in] Decode / Non-Decode flag.\r | |
46 | \r | |
47 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
48 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
49 | \r | |
50 | **/\r | |
51 | EFI_STATUS\r | |
52 | EFIAPI\r | |
53 | LegacyRegion2Decode (\r | |
54 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
55 | IN UINT32 Start,\r | |
56 | IN UINT32 Length,\r | |
57 | OUT UINT32 *Granularity,\r | |
58 | IN BOOLEAN *On\r | |
59 | )\r | |
60 | {\r | |
601afc03 | 61 | if ((Start < 0xC0000) || ((Start + Length - 1) > 0xFFFFF)) {\r |
62 | return EFI_INVALID_PARAMETER;\r | |
63 | }\r | |
64 | \r | |
2719803b | 65 | ASSERT (Granularity != NULL);\r |
66 | *Granularity = 0;\r | |
67 | return EFI_SUCCESS;\r | |
68 | }\r | |
69 | \r | |
70 | /**\r | |
71 | Modify the hardware to disallow memory writes in a region.\r | |
72 | \r | |
73 | This function changes the attributes of a memory range to not allow writes.\r | |
74 | \r | |
75 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
76 | @param Start[in] The beginning of the physical address of the region whose\r | |
77 | attributes should be modified.\r | |
78 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
79 | The actual number of bytes modified may be greater than the number\r | |
80 | specified.\r | |
81 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
82 | than the total number of bytes affected if the starting address was\r | |
83 | not aligned to a region's starting address or if the length was\r | |
84 | greater than the number of bytes in the first region.\r | |
85 | \r | |
86 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
87 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
88 | \r | |
89 | **/\r | |
90 | EFI_STATUS\r | |
91 | EFIAPI\r | |
92 | LegacyRegion2Lock (\r | |
93 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
94 | IN UINT32 Start,\r | |
95 | IN UINT32 Length,\r | |
96 | OUT UINT32 *Granularity\r | |
97 | )\r | |
98 | {\r | |
601afc03 | 99 | if ((Start < 0xC0000) || ((Start + Length - 1) > 0xFFFFF)) {\r |
100 | return EFI_INVALID_PARAMETER;\r | |
101 | }\r | |
102 | \r | |
2719803b | 103 | ASSERT (Granularity != NULL);\r |
104 | *Granularity = 0;\r | |
105 | return EFI_SUCCESS;\r | |
106 | }\r | |
107 | \r | |
108 | /**\r | |
109 | Modify the hardware to disallow memory attribute changes in a region.\r | |
110 | \r | |
d1102dba | 111 | This function makes the attributes of a region read only. Once a region is boot-locked with this\r |
2719803b | 112 | function, the read and write attributes of that region cannot be changed until a power cycle has\r |
113 | reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.\r | |
114 | \r | |
115 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
116 | @param Start[in] The beginning of the physical address of the region whose\r | |
117 | attributes should be modified.\r | |
118 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
119 | The actual number of bytes modified may be greater than the number\r | |
120 | specified.\r | |
121 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
122 | than the total number of bytes affected if the starting address was\r | |
123 | not aligned to a region's starting address or if the length was\r | |
124 | greater than the number of bytes in the first region.\r | |
125 | \r | |
126 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
127 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
128 | @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in\r | |
129 | a way that will not affect memory regions outside the legacy memory\r | |
130 | region.\r | |
131 | \r | |
132 | **/\r | |
133 | EFI_STATUS\r | |
134 | EFIAPI\r | |
135 | LegacyRegion2BootLock (\r | |
136 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
137 | IN UINT32 Start,\r | |
138 | IN UINT32 Length,\r | |
139 | OUT UINT32 *Granularity\r | |
140 | )\r | |
141 | {\r | |
601afc03 | 142 | if ((Start < 0xC0000) || ((Start + Length - 1) > 0xFFFFF)) {\r |
143 | return EFI_INVALID_PARAMETER;\r | |
144 | }\r | |
145 | \r | |
2c4297cf | 146 | return EFI_UNSUPPORTED;\r |
2719803b | 147 | }\r |
148 | \r | |
149 | /**\r | |
150 | Modify the hardware to allow memory writes in a region.\r | |
151 | \r | |
d1102dba | 152 | This function changes the attributes of a memory range to allow writes.\r |
2719803b | 153 | \r |
154 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
155 | @param Start[in] The beginning of the physical address of the region whose\r | |
156 | attributes should be modified.\r | |
157 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
158 | The actual number of bytes modified may be greater than the number\r | |
159 | specified.\r | |
160 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
161 | than the total number of bytes affected if the starting address was\r | |
162 | not aligned to a region's starting address or if the length was\r | |
163 | greater than the number of bytes in the first region.\r | |
164 | \r | |
165 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
166 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
167 | \r | |
168 | **/\r | |
169 | EFI_STATUS\r | |
170 | EFIAPI\r | |
171 | LegacyRegion2Unlock (\r | |
172 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
173 | IN UINT32 Start,\r | |
174 | IN UINT32 Length,\r | |
175 | OUT UINT32 *Granularity\r | |
176 | )\r | |
177 | {\r | |
601afc03 | 178 | if ((Start < 0xC0000) || ((Start + Length - 1) > 0xFFFFF)) {\r |
179 | return EFI_INVALID_PARAMETER;\r | |
180 | }\r | |
181 | \r | |
2719803b | 182 | ASSERT (Granularity != NULL);\r |
183 | *Granularity = 0;\r | |
184 | return EFI_SUCCESS;\r | |
185 | }\r | |
186 | \r | |
187 | /**\r | |
188 | Get region information for the attributes of the Legacy Region.\r | |
189 | \r | |
d1102dba | 190 | This function is used to discover the granularity of the attributes for the memory in the legacy\r |
2719803b | 191 | region. Each attribute may have a different granularity and the granularity may not be the same\r |
d1102dba | 192 | for all memory ranges in the legacy region.\r |
2719803b | 193 | \r |
2c4297cf | 194 | @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r |
2719803b | 195 | @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor\r |
196 | buffer.\r | |
197 | @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy\r | |
198 | region information is deposited. This buffer will contain a list of\r | |
199 | DescriptorCount number of region descriptors. This function will\r | |
200 | provide the memory for the buffer.\r | |
201 | \r | |
2c4297cf | 202 | @retval EFI_SUCCESS The information structure was returned.\r |
203 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
2719803b | 204 | \r |
205 | **/\r | |
206 | EFI_STATUS\r | |
207 | EFIAPI\r | |
208 | LegacyRegionGetInfo (\r | |
209 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
210 | OUT UINT32 *DescriptorCount,\r | |
211 | OUT EFI_LEGACY_REGION_DESCRIPTOR **Descriptor\r | |
212 | )\r | |
213 | {\r | |
2c4297cf | 214 | return EFI_UNSUPPORTED;\r |
2719803b | 215 | }\r |
216 | \r | |
217 | /**\r | |
218 | The user Entry Point for module LegacyRegionDxe. The user code starts with this function.\r | |
219 | \r | |
d1102dba | 220 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r |
2719803b | 221 | @param[in] SystemTable A pointer to the EFI System Table.\r |
d1102dba | 222 | \r |
2719803b | 223 | @retval EFI_SUCCESS The entry point is executed successfully.\r |
224 | \r | |
225 | **/\r | |
226 | EFI_STATUS\r | |
227 | EFIAPI\r | |
228 | LegacyRegion2Install (\r | |
229 | IN EFI_HANDLE ImageHandle,\r | |
230 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
231 | )\r | |
232 | {\r | |
233 | EFI_STATUS Status;\r | |
d1102dba | 234 | \r |
2719803b | 235 | //\r |
236 | // Make sure the Legacy Region 2 Protocol is not already installed in the system\r | |
237 | //\r | |
238 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiLegacyRegion2ProtocolGuid);\r | |
d1102dba | 239 | \r |
2719803b | 240 | //\r |
241 | // Install the protocol on a new handle.\r | |
242 | //\r | |
243 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
244 | &mLegacyRegion2Handle,\r | |
245 | &gEfiLegacyRegion2ProtocolGuid, &mLegacyRegion2,\r | |
246 | NULL\r | |
247 | );\r | |
248 | ASSERT_EFI_ERROR (Status);\r | |
249 | \r | |
250 | return EFI_SUCCESS;\r | |
251 | }\r |