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