]>
Commit | Line | Data |
---|---|---|
9b6bbcdb MK |
1 | /** @file\r |
2 | QNC Legacy Region Driver\r | |
3 | \r | |
4 | Copyright (c) 2013-2015 Intel Corporation.\r | |
5 | \r | |
c9f231d0 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
9b6bbcdb MK |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include "CommonHeader.h"\r | |
11 | #include "LegacyRegion.h"\r | |
12 | \r | |
13 | //\r | |
14 | // Handle used to install the Legacy Region Protocol\r | |
15 | //\r | |
16 | EFI_HANDLE mLegacyRegion2Handle = NULL;\r | |
17 | \r | |
18 | //\r | |
19 | // Instance of the Legacy Region Protocol to install into the handle database\r | |
20 | //\r | |
21 | EFI_LEGACY_REGION2_PROTOCOL mLegacyRegion2 = {\r | |
22 | LegacyRegion2Decode,\r | |
23 | LegacyRegion2Lock,\r | |
24 | LegacyRegion2BootLock,\r | |
25 | LegacyRegion2Unlock,\r | |
26 | LegacyRegionGetInfo\r | |
27 | };\r | |
28 | \r | |
29 | \r | |
30 | /**\r | |
31 | Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.\r | |
32 | \r | |
33 | If the On parameter evaluates to TRUE, this function enables memory reads in the address range\r | |
34 | Start to (Start + Length - 1).\r | |
35 | If the On parameter evaluates to FALSE, this function disables memory reads in the address range\r | |
36 | Start to (Start + Length - 1).\r | |
37 | \r | |
38 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
39 | @param Start[in] The beginning of the physical address of the region whose attributes\r | |
40 | should be modified.\r | |
41 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
42 | The actual number of bytes modified may be greater than the number\r | |
43 | specified.\r | |
44 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
45 | than the total number of bytes affected if the starting address\r | |
46 | was not aligned to a region's starting address or if the length\r | |
47 | was greater than the number of bytes in the first region.\r | |
48 | @param On[in] Decode / Non-Decode flag.\r | |
49 | \r | |
50 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
51 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
52 | \r | |
53 | **/\r | |
54 | EFI_STATUS\r | |
55 | EFIAPI\r | |
56 | LegacyRegion2Decode (\r | |
57 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
58 | IN UINT32 Start,\r | |
59 | IN UINT32 Length,\r | |
60 | OUT UINT32 *Granularity,\r | |
61 | IN BOOLEAN *On\r | |
62 | )\r | |
63 | {\r | |
64 | return QNCLegacyRegionManipulation (Start, Length, On, NULL, Granularity);\r | |
65 | }\r | |
66 | \r | |
67 | \r | |
68 | /**\r | |
69 | Modify the hardware to disallow memory attribute changes in a region.\r | |
70 | \r | |
71 | This function makes the attributes of a region read only. Once a region is boot-locked with this\r | |
72 | function, the read and write attributes of that region cannot be changed until a power cycle has\r | |
73 | reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.\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 | @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in\r | |
89 | a way that will not affect memory regions outside the legacy memory\r | |
90 | region.\r | |
91 | \r | |
92 | **/\r | |
93 | EFI_STATUS\r | |
94 | EFIAPI\r | |
95 | LegacyRegion2BootLock (\r | |
96 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
97 | IN UINT32 Start,\r | |
98 | IN UINT32 Length,\r | |
99 | OUT UINT32 *Granularity\r | |
100 | )\r | |
101 | {\r | |
102 | if ((Start < 0xC0000) || ((Start + Length - 1) > 0xFFFFF)) {\r | |
103 | return EFI_INVALID_PARAMETER;\r | |
104 | }\r | |
105 | \r | |
106 | return EFI_UNSUPPORTED;\r | |
107 | }\r | |
108 | \r | |
109 | \r | |
110 | /**\r | |
111 | Modify the hardware to disallow memory writes in a region.\r | |
112 | \r | |
113 | This function changes the attributes of a memory range to not allow writes.\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 | \r | |
129 | **/\r | |
130 | EFI_STATUS\r | |
131 | EFIAPI\r | |
132 | LegacyRegion2Lock (\r | |
133 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
134 | IN UINT32 Start,\r | |
135 | IN UINT32 Length,\r | |
136 | OUT UINT32 *Granularity\r | |
137 | )\r | |
138 | {\r | |
139 | BOOLEAN WriteEnable;\r | |
140 | \r | |
141 | WriteEnable = FALSE;\r | |
142 | return QNCLegacyRegionManipulation (Start, Length, NULL, &WriteEnable, Granularity);\r | |
143 | }\r | |
144 | \r | |
145 | \r | |
146 | /**\r | |
147 | Modify the hardware to allow memory writes in a region.\r | |
148 | \r | |
149 | This function changes the attributes of a memory range to allow writes.\r | |
150 | \r | |
151 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
152 | @param Start[in] The beginning of the physical address of the region whose\r | |
153 | attributes should be modified.\r | |
154 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
155 | The actual number of bytes modified may be greater than the number\r | |
156 | specified.\r | |
157 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
158 | than the total number of bytes affected if the starting address was\r | |
159 | not aligned to a region's starting address or if the length was\r | |
160 | greater than the number of bytes in the first region.\r | |
161 | \r | |
162 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
163 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
164 | \r | |
165 | **/\r | |
166 | EFI_STATUS\r | |
167 | EFIAPI\r | |
168 | LegacyRegion2Unlock (\r | |
169 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
170 | IN UINT32 Start,\r | |
171 | IN UINT32 Length,\r | |
172 | OUT UINT32 *Granularity\r | |
173 | )\r | |
174 | {\r | |
175 | BOOLEAN WriteEnable;\r | |
176 | \r | |
177 | WriteEnable = TRUE;\r | |
178 | return QNCLegacyRegionManipulation (Start, Length, NULL, &WriteEnable, 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 | \r | |
209 | return EFI_UNSUPPORTED;\r | |
210 | }\r | |
211 | \r | |
212 | /**\r | |
213 | Entry point to the DXE Driver that produces the Legacy Region Protocol.\r | |
214 | \r | |
215 | @retval EFI_SUCCESS One or more of the drivers returned a success code.\r | |
216 | @retval !EFI_SUCESS The return status from the last driver entry point in the list.\r | |
217 | \r | |
218 | **/\r | |
219 | EFI_STATUS\r | |
220 | LegacyRegionInit (\r | |
221 | )\r | |
222 | {\r | |
223 | EFI_STATUS Status;\r | |
224 | \r | |
225 | //\r | |
226 | // Install the Legacy Region Protocol on a new handle\r | |
227 | //\r | |
228 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
229 | &mLegacyRegion2Handle,\r | |
230 | &gEfiLegacyRegion2ProtocolGuid, &mLegacyRegion2,\r | |
231 | NULL\r | |
232 | );\r | |
233 | \r | |
234 | ASSERT_EFI_ERROR (Status);\r | |
235 | \r | |
236 | return Status;\r | |
237 | }\r |