]>
Commit | Line | Data |
---|---|---|
fc547e08 | 1 | /** @file \r |
5944a83b | 2 | All Pcd Ppi services are implemented here.\r |
fc547e08 | 3 | \r |
cebc8d48 | 4 | Copyright (c) 2006 - 2008, Intel Corporation \r |
80408db0 | 5 | All rights reserved. This program and the accompanying materials \r |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
12 | \r | |
80408db0 | 13 | **/\r |
14 | \r | |
80408db0 | 15 | #include "Service.h"\r |
16 | \r | |
80408db0 | 17 | PCD_PPI mPcdPpiInstance = {\r |
18 | PeiPcdSetSku,\r | |
19 | \r | |
20 | PeiPcdGet8,\r | |
21 | PeiPcdGet16, \r | |
22 | PeiPcdGet32, \r | |
23 | PeiPcdGet64, \r | |
24 | PeiPcdGetPtr, \r | |
25 | PeiPcdGetBool, \r | |
26 | PeiPcdGetSize,\r | |
27 | \r | |
28 | PeiPcdGet8Ex,\r | |
29 | PeiPcdGet16Ex, \r | |
30 | PeiPcdGet32Ex, \r | |
31 | PeiPcdGet64Ex, \r | |
32 | PeiPcdGetPtrEx, \r | |
33 | PeiPcdGetBoolEx, \r | |
34 | PeiPcdGetSizeEx,\r | |
35 | \r | |
36 | PeiPcdSet8,\r | |
37 | PeiPcdSet16, \r | |
38 | PeiPcdSet32, \r | |
39 | PeiPcdSet64, \r | |
40 | PeiPcdSetPtr, \r | |
41 | PeiPcdSetBool, \r | |
42 | \r | |
43 | PeiPcdSet8Ex,\r | |
44 | PeiPcdSet16Ex, \r | |
45 | PeiPcdSet32Ex, \r | |
46 | PeiPcdSet64Ex, \r | |
47 | PeiPcdSetPtrEx, \r | |
48 | PeiPcdSetBoolEx,\r | |
49 | \r | |
50 | PeiRegisterCallBackOnSet,\r | |
51 | PcdUnRegisterCallBackOnSet,\r | |
52 | PeiPcdGetNextToken,\r | |
53 | PeiPcdGetNextTokenSpace\r | |
54 | };\r | |
55 | \r | |
fe1e36e5 | 56 | EFI_PEI_PPI_DESCRIPTOR mPpiPCD = {\r |
80408db0 | 57 | (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r |
58 | &gPcdPpiGuid,\r | |
59 | &mPcdPpiInstance\r | |
60 | };\r | |
61 | \r | |
fc547e08 | 62 | /**\r |
63 | Main entry for PCD PEIM driver.\r | |
64 | \r | |
65 | This routine initialize the PCD database for PEI phase and install PCD_PPI.\r | |
80408db0 | 66 | \r |
8bd22b8a LG |
67 | @param FileHandle Handle of the file being invoked.\r |
68 | @param PeiServices Describes the list of possible PEI Services.\r | |
80408db0 | 69 | \r |
fc547e08 | 70 | @return Status of install PCD_PPI\r |
71 | \r | |
72 | **/\r | |
80408db0 | 73 | EFI_STATUS\r |
74 | EFIAPI\r | |
75 | PcdPeimInit (\r | |
8bd22b8a LG |
76 | IN EFI_PEI_FILE_HANDLE FileHandle,\r |
77 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
80408db0 | 78 | )\r |
79 | {\r | |
80408db0 | 80 | BuildPcdDatabase ();\r |
80408db0 | 81 | \r |
fc547e08 | 82 | return PeiServicesInstallPpi (&mPpiPCD);\r |
80408db0 | 83 | }\r |
84 | \r | |
fc547e08 | 85 | /**\r |
86 | Sets the SKU value for subsequent calls to set or get PCD token values.\r | |
87 | \r | |
88 | SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values. \r | |
89 | SetSku() is normally called only once by the system.\r | |
90 | \r | |
91 | For each item (token), the database can hold a single value that applies to all SKUs, \r | |
92 | or multiple values, where each value is associated with a specific SKU Id. Items with multiple, \r | |
93 | SKU-specific values are called SKU enabled. \r | |
94 | \r | |
95 | The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255. \r | |
96 | For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the \r | |
97 | single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the \r | |
98 | last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token, \r | |
99 | the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been \r | |
100 | set for that Id, the results are unpredictable.\r | |
101 | \r | |
102 | @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and \r | |
103 | set values associated with a PCD token.\r | |
104 | \r | |
fc547e08 | 105 | **/\r |
80408db0 | 106 | VOID\r |
107 | EFIAPI\r | |
108 | PeiPcdSetSku (\r | |
109 | IN UINTN SkuId\r | |
110 | )\r | |
111 | {\r | |
112 | \r | |
113 | GetPcdDatabase()->Init.SystemSkuId = (SKU_ID) SkuId;\r | |
114 | \r | |
115 | return;\r | |
116 | }\r | |
117 | \r | |
fc547e08 | 118 | /**\r |
119 | Retrieves an 8-bit value for a given PCD token.\r | |
80408db0 | 120 | \r |
fc547e08 | 121 | Retrieves the current byte-sized value for a PCD token number. \r |
122 | If the TokenNumber is invalid, the results are unpredictable.\r | |
123 | \r | |
124 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 125 | \r |
fc547e08 | 126 | @return The UINT8 value.\r |
127 | \r | |
128 | **/\r | |
80408db0 | 129 | UINT8\r |
130 | EFIAPI\r | |
131 | PeiPcdGet8 (\r | |
132 | IN UINTN TokenNumber\r | |
133 | )\r | |
134 | {\r | |
135 | return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));\r | |
136 | }\r | |
137 | \r | |
fc547e08 | 138 | /**\r |
139 | Retrieves an 16-bit value for a given PCD token.\r | |
80408db0 | 140 | \r |
fc547e08 | 141 | Retrieves the current 16-bits value for a PCD token number. \r |
142 | If the TokenNumber is invalid, the results are unpredictable.\r | |
143 | \r | |
144 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 145 | \r |
fc547e08 | 146 | @return The UINT16 value.\r |
147 | \r | |
148 | **/\r | |
80408db0 | 149 | UINT16\r |
150 | EFIAPI\r | |
151 | PeiPcdGet16 (\r | |
152 | IN UINTN TokenNumber\r | |
153 | )\r | |
154 | {\r | |
155 | return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));\r | |
156 | }\r | |
157 | \r | |
fc547e08 | 158 | /**\r |
159 | Retrieves an 32-bit value for a given PCD token.\r | |
80408db0 | 160 | \r |
fc547e08 | 161 | Retrieves the current 32-bits value for a PCD token number. \r |
162 | If the TokenNumber is invalid, the results are unpredictable.\r | |
163 | \r | |
164 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 165 | \r |
fc547e08 | 166 | @return The UINT32 value.\r |
167 | \r | |
168 | **/\r | |
80408db0 | 169 | UINT32\r |
170 | EFIAPI\r | |
171 | PeiPcdGet32 (\r | |
172 | IN UINTN TokenNumber\r | |
173 | )\r | |
174 | {\r | |
175 | return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));\r | |
176 | }\r | |
177 | \r | |
fc547e08 | 178 | /**\r |
179 | Retrieves an 64-bit value for a given PCD token.\r | |
80408db0 | 180 | \r |
fc547e08 | 181 | Retrieves the current 64-bits value for a PCD token number. \r |
182 | If the TokenNumber is invalid, the results are unpredictable.\r | |
183 | \r | |
184 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 185 | \r |
fc547e08 | 186 | @return The UINT64 value.\r |
187 | \r | |
188 | **/\r | |
80408db0 | 189 | UINT64\r |
190 | EFIAPI\r | |
191 | PeiPcdGet64 (\r | |
192 | IN UINTN TokenNumber\r | |
193 | )\r | |
194 | {\r | |
195 | return ReadUnaligned64 (GetWorker (TokenNumber, sizeof (UINT64)));\r | |
196 | }\r | |
197 | \r | |
fc547e08 | 198 | /**\r |
199 | Retrieves a pointer to a value for a given PCD token.\r | |
200 | \r | |
201 | Retrieves the current pointer to the buffer for a PCD token number. \r | |
202 | Do not make any assumptions about the alignment of the pointer that \r | |
203 | is returned by this function call. If the TokenNumber is invalid, \r | |
204 | the results are unpredictable.\r | |
80408db0 | 205 | \r |
fc547e08 | 206 | @param[in] TokenNumber The PCD token number. \r |
80408db0 | 207 | \r |
3fd8027e | 208 | @return The pointer to the buffer to be retrieved.\r |
fc547e08 | 209 | \r |
210 | **/\r | |
80408db0 | 211 | VOID *\r |
212 | EFIAPI\r | |
213 | PeiPcdGetPtr (\r | |
214 | IN UINTN TokenNumber\r | |
215 | )\r | |
216 | {\r | |
217 | return GetWorker (TokenNumber, 0);\r | |
218 | }\r | |
219 | \r | |
fc547e08 | 220 | /**\r |
221 | Retrieves a Boolean value for a given PCD token.\r | |
80408db0 | 222 | \r |
fc547e08 | 223 | Retrieves the current boolean value for a PCD token number. \r |
224 | Do not make any assumptions about the alignment of the pointer that \r | |
225 | is returned by this function call. If the TokenNumber is invalid, \r | |
226 | the results are unpredictable.\r | |
80408db0 | 227 | \r |
fc547e08 | 228 | @param[in] TokenNumber The PCD token number. \r |
229 | \r | |
230 | @return The Boolean value.\r | |
231 | \r | |
232 | **/\r | |
80408db0 | 233 | BOOLEAN\r |
234 | EFIAPI\r | |
235 | PeiPcdGetBool (\r | |
236 | IN UINTN TokenNumber\r | |
237 | )\r | |
238 | {\r | |
239 | return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));\r | |
240 | }\r | |
241 | \r | |
fc547e08 | 242 | /**\r |
243 | Retrieves the size of the value for a given PCD token.\r | |
244 | \r | |
245 | Retrieves the current size of a particular PCD token. \r | |
246 | If the TokenNumber is invalid, the results are unpredictable.\r | |
80408db0 | 247 | \r |
fc547e08 | 248 | @param[in] TokenNumber The PCD token number. \r |
80408db0 | 249 | \r |
fc547e08 | 250 | @return The size of the value for the PCD token.\r |
251 | \r | |
252 | **/\r | |
80408db0 | 253 | UINTN\r |
254 | EFIAPI\r | |
255 | PeiPcdGetSize (\r | |
256 | IN UINTN TokenNumber\r | |
257 | )\r | |
258 | {\r | |
259 | PEI_PCD_DATABASE *PeiPcdDb;\r | |
260 | UINTN Size;\r | |
261 | UINTN MaxSize;\r | |
262 | \r | |
263 | //\r | |
264 | // If DebugAssertEnabled is TRUE, we still need to provide the GET size\r | |
265 | // function as GetWorker and SetWoker need this function to do ASSERT.\r | |
266 | //\r | |
267 | if ((!FeaturePcdGet(PcdPeiPcdDatabaseGetSizeEnabled)) &&\r | |
268 | (!DebugAssertEnabled ())) {\r | |
269 | return 0;\r | |
270 | }\r | |
271 | \r | |
272 | PeiPcdDb = GetPcdDatabase ();\r | |
273 | //\r | |
274 | // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r | |
275 | // We have to decrement TokenNumber by 1 to make it usable\r | |
276 | // as the array index.\r | |
277 | //\r | |
278 | TokenNumber--;\r | |
279 | \r | |
280 | // EBC compiler is very choosy. It may report warning about comparison\r | |
281 | // between UINTN and 0 . So we add 1 in each size of the \r | |
282 | // comparison.\r | |
283 | ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r | |
284 | \r | |
285 | Size = (PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r | |
286 | \r | |
287 | if (Size == 0) {\r | |
288 | //\r | |
289 | // For pointer type, we need to scan the SIZE_TABLE to get the current size.\r | |
290 | //\r | |
291 | return GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);\r | |
292 | } else {\r | |
293 | return Size;\r | |
294 | }\r | |
295 | \r | |
296 | }\r | |
297 | \r | |
fc547e08 | 298 | /**\r |
299 | Retrieves an 8-bit value for a given PCD token.\r | |
80408db0 | 300 | \r |
fc547e08 | 301 | Retrieves the 8-bit value of a particular PCD token. \r |
302 | If the TokenNumber is invalid or the token space\r | |
303 | specified by Guid does not exist, the results are \r | |
304 | unpredictable.\r | |
80408db0 | 305 | \r |
fc547e08 | 306 | @param[in] Guid The token space for the token number.\r |
307 | @param[in] ExTokenNumber The PCD token number. \r | |
308 | \r | |
309 | @return The size 8-bit value for the PCD token.\r | |
310 | \r | |
311 | **/\r | |
80408db0 | 312 | UINT8\r |
313 | EFIAPI\r | |
314 | PeiPcdGet8Ex (\r | |
315 | IN CONST EFI_GUID *Guid,\r | |
316 | IN UINTN ExTokenNumber\r | |
317 | )\r | |
318 | {\r | |
319 | return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof (UINT8)));\r | |
320 | }\r | |
321 | \r | |
fc547e08 | 322 | /**\r |
323 | Retrieves an 16-bit value for a given PCD token.\r | |
80408db0 | 324 | \r |
fc547e08 | 325 | Retrieves the 16-bit value of a particular PCD token. \r |
326 | If the TokenNumber is invalid or the token space\r | |
327 | specified by Guid does not exist, the results are \r | |
328 | unpredictable.\r | |
80408db0 | 329 | \r |
fc547e08 | 330 | @param[in] Guid The token space for the token number.\r |
331 | @param[in] ExTokenNumber The PCD token number. \r | |
332 | \r | |
333 | @return The size 16-bit value for the PCD token.\r | |
334 | \r | |
335 | **/\r | |
80408db0 | 336 | UINT16\r |
337 | EFIAPI\r | |
338 | PeiPcdGet16Ex (\r | |
339 | IN CONST EFI_GUID *Guid,\r | |
340 | IN UINTN ExTokenNumber\r | |
341 | )\r | |
342 | {\r | |
343 | return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT16)));\r | |
344 | }\r | |
345 | \r | |
fc547e08 | 346 | /**\r |
347 | Retrieves an 32-bit value for a given PCD token.\r | |
348 | \r | |
349 | Retrieves the 32-bit value of a particular PCD token. \r | |
350 | If the TokenNumber is invalid or the token space\r | |
351 | specified by Guid does not exist, the results are \r | |
352 | unpredictable.\r | |
80408db0 | 353 | \r |
fc547e08 | 354 | @param[in] Guid The token space for the token number.\r |
355 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 356 | \r |
fc547e08 | 357 | @return The size 32-bit value for the PCD token.\r |
358 | \r | |
359 | **/\r | |
80408db0 | 360 | UINT32\r |
361 | EFIAPI\r | |
362 | PeiPcdGet32Ex (\r | |
363 | IN CONST EFI_GUID *Guid,\r | |
364 | IN UINTN ExTokenNumber\r | |
365 | )\r | |
366 | {\r | |
367 | return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT32)));\r | |
368 | }\r | |
369 | \r | |
fc547e08 | 370 | /**\r |
371 | Retrieves an 64-bit value for a given PCD token.\r | |
372 | \r | |
373 | Retrieves the 64-bit value of a particular PCD token. \r | |
374 | If the TokenNumber is invalid or the token space\r | |
375 | specified by Guid does not exist, the results are \r | |
376 | unpredictable.\r | |
80408db0 | 377 | \r |
fc547e08 | 378 | @param[in] Guid The token space for the token number.\r |
379 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 380 | \r |
fc547e08 | 381 | @return The size 64-bit value for the PCD token.\r |
382 | \r | |
383 | **/\r | |
80408db0 | 384 | UINT64\r |
385 | EFIAPI\r | |
386 | PeiPcdGet64Ex (\r | |
387 | IN CONST EFI_GUID *Guid,\r | |
388 | IN UINTN ExTokenNumber\r | |
389 | )\r | |
390 | {\r | |
391 | return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT64)));\r | |
392 | }\r | |
393 | \r | |
fc547e08 | 394 | /**\r |
395 | Retrieves a pointer to a value for a given PCD token.\r | |
80408db0 | 396 | \r |
fc547e08 | 397 | Retrieves the current pointer to the buffer for a PCD token number. \r |
398 | Do not make any assumptions about the alignment of the pointer that \r | |
399 | is returned by this function call. If the TokenNumber is invalid, \r | |
400 | the results are unpredictable.\r | |
80408db0 | 401 | \r |
fc547e08 | 402 | @param[in] Guid The token space for the token number.\r |
403 | @param[in] ExTokenNumber The PCD token number. \r | |
404 | \r | |
3fd8027e | 405 | @return The pointer to the buffer to be retrieved.\r |
fc547e08 | 406 | \r |
407 | **/\r | |
80408db0 | 408 | VOID *\r |
409 | EFIAPI\r | |
410 | PeiPcdGetPtrEx (\r | |
411 | IN CONST EFI_GUID *Guid,\r | |
412 | IN UINTN ExTokenNumber\r | |
413 | )\r | |
414 | {\r | |
415 | return ExGetWorker (Guid, ExTokenNumber, 0);\r | |
416 | }\r | |
417 | \r | |
fc547e08 | 418 | /**\r |
419 | Retrieves an Boolean value for a given PCD token.\r | |
420 | \r | |
421 | Retrieves the Boolean value of a particular PCD token. \r | |
422 | If the TokenNumber is invalid or the token space\r | |
423 | specified by Guid does not exist, the results are \r | |
424 | unpredictable.\r | |
80408db0 | 425 | \r |
fc547e08 | 426 | @param[in] Guid The token space for the token number.\r |
427 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 428 | \r |
fc547e08 | 429 | @return The size Boolean value for the PCD token.\r |
430 | \r | |
431 | **/\r | |
80408db0 | 432 | BOOLEAN\r |
433 | EFIAPI\r | |
434 | PeiPcdGetBoolEx (\r | |
435 | IN CONST EFI_GUID *Guid,\r | |
436 | IN UINTN ExTokenNumber\r | |
437 | )\r | |
438 | {\r | |
439 | return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof (BOOLEAN)));\r | |
440 | }\r | |
441 | \r | |
fc547e08 | 442 | /**\r |
443 | Retrieves the size of the value for a given PCD token.\r | |
444 | \r | |
445 | Retrieves the current size of a particular PCD token. \r | |
446 | If the TokenNumber is invalid, the results are unpredictable.\r | |
80408db0 | 447 | \r |
fc547e08 | 448 | @param[in] Guid The token space for the token number.\r |
449 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 450 | \r |
fc547e08 | 451 | @return The size of the value for the PCD token.\r |
452 | \r | |
453 | **/\r | |
80408db0 | 454 | UINTN\r |
455 | EFIAPI\r | |
456 | PeiPcdGetSizeEx (\r | |
457 | IN CONST EFI_GUID *Guid,\r | |
458 | IN UINTN ExTokenNumber\r | |
459 | )\r | |
460 | {\r | |
461 | if ((!FeaturePcdGet (PcdPeiPcdDatabaseGetSizeEnabled)) || !FeaturePcdGet (PcdPeiPcdDatabaseExEnabled)) {\r | |
462 | return 0;\r | |
463 | }\r | |
464 | \r | |
465 | return PeiPcdGetSize (GetExPcdTokenNumber (Guid, ExTokenNumber));\r | |
466 | }\r | |
467 | \r | |
fc547e08 | 468 | /**\r |
469 | Sets an 8-bit value for a given PCD token.\r | |
80408db0 | 470 | \r |
fc547e08 | 471 | When the PCD service sets a value, it will check to ensure that the \r |
472 | size of the value being set is compatible with the Token's existing definition. \r | |
473 | If it is not, an error will be returned.\r | |
80408db0 | 474 | \r |
fc547e08 | 475 | @param[in] TokenNumber The PCD token number. \r |
476 | @param[in] Value The value to set for the PCD token.\r | |
477 | \r | |
478 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
479 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
480 | being set was incompatible with a call to this function. \r | |
481 | Use GetSize() to retrieve the size of the target data.\r | |
482 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
483 | \r | |
484 | **/\r | |
80408db0 | 485 | EFI_STATUS\r |
486 | EFIAPI\r | |
487 | PeiPcdSet8 (\r | |
488 | IN UINTN TokenNumber,\r | |
489 | IN UINT8 Value\r | |
490 | )\r | |
491 | {\r | |
492 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
493 | }\r | |
494 | \r | |
fc547e08 | 495 | /**\r |
496 | Sets an 16-bit value for a given PCD token.\r | |
497 | \r | |
498 | When the PCD service sets a value, it will check to ensure that the \r | |
499 | size of the value being set is compatible with the Token's existing definition. \r | |
500 | If it is not, an error will be returned.\r | |
80408db0 | 501 | \r |
fc547e08 | 502 | @param[in] TokenNumber The PCD token number. \r |
503 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 504 | \r |
fc547e08 | 505 | @retval EFI_SUCCESS Procedure returned successfully.\r |
506 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
507 | being set was incompatible with a call to this function. \r | |
508 | Use GetSize() to retrieve the size of the target data.\r | |
509 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
510 | \r | |
511 | **/\r | |
80408db0 | 512 | EFI_STATUS\r |
513 | EFIAPI\r | |
514 | PeiPcdSet16 (\r | |
515 | IN UINTN TokenNumber,\r | |
516 | IN UINT16 Value\r | |
517 | )\r | |
518 | {\r | |
519 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
520 | }\r | |
521 | \r | |
fc547e08 | 522 | /**\r |
523 | Sets an 32-bit value for a given PCD token.\r | |
80408db0 | 524 | \r |
fc547e08 | 525 | When the PCD service sets a value, it will check to ensure that the \r |
526 | size of the value being set is compatible with the Token's existing definition. \r | |
527 | If it is not, an error will be returned.\r | |
80408db0 | 528 | \r |
fc547e08 | 529 | @param[in] TokenNumber The PCD token number. \r |
530 | @param[in] Value The value to set for the PCD token.\r | |
531 | \r | |
532 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
533 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
534 | being set was incompatible with a call to this function. \r | |
535 | Use GetSize() to retrieve the size of the target data.\r | |
536 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
537 | \r | |
538 | **/\r | |
80408db0 | 539 | EFI_STATUS\r |
540 | EFIAPI\r | |
541 | PeiPcdSet32 (\r | |
542 | IN UINTN TokenNumber,\r | |
543 | IN UINT32 Value\r | |
544 | )\r | |
545 | {\r | |
546 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
547 | }\r | |
548 | \r | |
fc547e08 | 549 | /**\r |
550 | Sets an 64-bit value for a given PCD token.\r | |
551 | \r | |
552 | When the PCD service sets a value, it will check to ensure that the \r | |
553 | size of the value being set is compatible with the Token's existing definition. \r | |
554 | If it is not, an error will be returned.\r | |
80408db0 | 555 | \r |
fc547e08 | 556 | @param[in] TokenNumber The PCD token number. \r |
557 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 558 | \r |
fc547e08 | 559 | @retval EFI_SUCCESS Procedure returned successfully.\r |
560 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
561 | being set was incompatible with a call to this function. \r | |
562 | Use GetSize() to retrieve the size of the target data.\r | |
563 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
564 | \r | |
565 | **/\r | |
80408db0 | 566 | EFI_STATUS\r |
567 | EFIAPI\r | |
568 | PeiPcdSet64 (\r | |
569 | IN UINTN TokenNumber,\r | |
570 | IN UINT64 Value\r | |
571 | )\r | |
572 | {\r | |
573 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
574 | }\r | |
575 | \r | |
fc547e08 | 576 | /**\r |
577 | Sets a value of a specified size for a given PCD token.\r | |
578 | \r | |
579 | When the PCD service sets a value, it will check to ensure that the \r | |
580 | size of the value being set is compatible with the Token's existing definition. \r | |
581 | If it is not, an error will be returned.\r | |
582 | \r | |
583 | @param[in] TokenNumber The PCD token number. \r | |
584 | @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r | |
585 | On input, if the SizeOfValue is greater than the maximum size supported \r | |
586 | for this TokenNumber then the output value of SizeOfValue will reflect \r | |
587 | the maximum size supported for this TokenNumber.\r | |
588 | @param[in] Buffer The buffer to set for the PCD token.\r | |
589 | \r | |
590 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
591 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
592 | being set was incompatible with a call to this function. \r | |
593 | Use GetSize() to retrieve the size of the target data.\r | |
594 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
595 | \r | |
596 | **/\r | |
80408db0 | 597 | EFI_STATUS\r |
598 | EFIAPI\r | |
599 | PeiPcdSetPtr (\r | |
600 | IN UINTN TokenNumber,\r | |
601 | IN OUT UINTN *SizeOfBuffer,\r | |
602 | IN VOID *Buffer\r | |
603 | )\r | |
604 | {\r | |
605 | return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);\r | |
606 | }\r | |
607 | \r | |
fc547e08 | 608 | /**\r |
609 | Sets an Boolean value for a given PCD token.\r | |
80408db0 | 610 | \r |
fc547e08 | 611 | When the PCD service sets a value, it will check to ensure that the \r |
612 | size of the value being set is compatible with the Token's existing definition. \r | |
613 | If it is not, an error will be returned.\r | |
80408db0 | 614 | \r |
fc547e08 | 615 | @param[in] TokenNumber The PCD token number. \r |
616 | @param[in] Value The value to set for the PCD token.\r | |
617 | \r | |
618 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
619 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
620 | being set was incompatible with a call to this function. \r | |
621 | Use GetSize() to retrieve the size of the target data.\r | |
622 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
623 | \r | |
624 | **/\r | |
80408db0 | 625 | EFI_STATUS\r |
626 | EFIAPI\r | |
627 | PeiPcdSetBool (\r | |
628 | IN UINTN TokenNumber,\r | |
629 | IN BOOLEAN Value\r | |
630 | )\r | |
631 | {\r | |
632 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
633 | }\r | |
634 | \r | |
fc547e08 | 635 | /**\r |
636 | Sets an 8-bit value for a given PCD token.\r | |
80408db0 | 637 | \r |
fc547e08 | 638 | When the PCD service sets a value, it will check to ensure that the \r |
639 | size of the value being set is compatible with the Token's existing definition. \r | |
640 | If it is not, an error will be returned.\r | |
80408db0 | 641 | \r |
fc547e08 | 642 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
643 | @param[in] ExTokenNumber The PCD token number. \r | |
644 | @param[in] Value The value to set for the PCD token.\r | |
645 | \r | |
646 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
647 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
648 | being set was incompatible with a call to this function. \r | |
649 | Use GetSize() to retrieve the size of the target data.\r | |
650 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
651 | \r | |
652 | **/\r | |
80408db0 | 653 | EFI_STATUS\r |
654 | EFIAPI\r | |
655 | PeiPcdSet8Ex (\r | |
656 | IN CONST EFI_GUID *Guid,\r | |
657 | IN UINTN ExTokenNumber,\r | |
658 | IN UINT8 Value\r | |
659 | )\r | |
660 | {\r | |
661 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
662 | }\r | |
663 | \r | |
fc547e08 | 664 | /**\r |
665 | Sets an 16-bit value for a given PCD token.\r | |
666 | \r | |
667 | When the PCD service sets a value, it will check to ensure that the \r | |
668 | size of the value being set is compatible with the Token's existing definition. \r | |
669 | If it is not, an error will be returned.\r | |
80408db0 | 670 | \r |
fc547e08 | 671 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
672 | @param[in] ExTokenNumber The PCD token number. \r | |
673 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 674 | \r |
fc547e08 | 675 | @retval EFI_SUCCESS Procedure returned successfully.\r |
676 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
677 | being set was incompatible with a call to this function. \r | |
678 | Use GetSize() to retrieve the size of the target data.\r | |
679 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
680 | \r | |
681 | **/\r | |
80408db0 | 682 | EFI_STATUS\r |
683 | EFIAPI\r | |
684 | PeiPcdSet16Ex (\r | |
685 | IN CONST EFI_GUID *Guid,\r | |
686 | IN UINTN ExTokenNumber,\r | |
687 | IN UINT16 Value\r | |
688 | )\r | |
689 | {\r | |
690 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
691 | }\r | |
692 | \r | |
fc547e08 | 693 | /**\r |
694 | Sets an 32-bit value for a given PCD token.\r | |
695 | \r | |
696 | When the PCD service sets a value, it will check to ensure that the \r | |
697 | size of the value being set is compatible with the Token's existing definition. \r | |
698 | If it is not, an error will be returned.\r | |
80408db0 | 699 | \r |
fc547e08 | 700 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
701 | @param[in] ExTokenNumber The PCD token number. \r | |
702 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 703 | \r |
fc547e08 | 704 | @retval EFI_SUCCESS Procedure returned successfully.\r |
705 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
706 | being set was incompatible with a call to this function. \r | |
707 | Use GetSize() to retrieve the size of the target data.\r | |
708 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
709 | \r | |
710 | **/\r | |
80408db0 | 711 | EFI_STATUS\r |
712 | EFIAPI\r | |
713 | PeiPcdSet32Ex (\r | |
714 | IN CONST EFI_GUID *Guid,\r | |
715 | IN UINTN ExTokenNumber,\r | |
716 | IN UINT32 Value\r | |
717 | )\r | |
718 | {\r | |
719 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
720 | }\r | |
721 | \r | |
fc547e08 | 722 | /**\r |
723 | Sets an 64-bit value for a given PCD token.\r | |
80408db0 | 724 | \r |
fc547e08 | 725 | When the PCD service sets a value, it will check to ensure that the \r |
726 | size of the value being set is compatible with the Token's existing definition. \r | |
727 | If it is not, an error will be returned.\r | |
80408db0 | 728 | \r |
fc547e08 | 729 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
730 | @param[in] ExTokenNumber The PCD token number. \r | |
731 | @param[in] Value The value to set for the PCD token.\r | |
732 | \r | |
733 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
734 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
735 | being set was incompatible with a call to this function. \r | |
736 | Use GetSize() to retrieve the size of the target data.\r | |
737 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
738 | \r | |
739 | **/\r | |
80408db0 | 740 | EFI_STATUS\r |
741 | EFIAPI\r | |
742 | PeiPcdSet64Ex (\r | |
743 | IN CONST EFI_GUID *Guid,\r | |
744 | IN UINTN ExTokenNumber,\r | |
745 | IN UINT64 Value\r | |
746 | )\r | |
747 | {\r | |
748 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
749 | }\r | |
750 | \r | |
fc547e08 | 751 | /**\r |
752 | Sets a value of a specified size for a given PCD token.\r | |
753 | \r | |
754 | When the PCD service sets a value, it will check to ensure that the \r | |
755 | size of the value being set is compatible with the Token's existing definition. \r | |
756 | If it is not, an error will be returned.\r | |
757 | \r | |
758 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
759 | @param[in] ExTokenNumber The PCD token number. \r | |
760 | @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r | |
761 | On input, if the SizeOfValue is greater than the maximum size supported \r | |
762 | for this TokenNumber then the output value of SizeOfValue will reflect \r | |
763 | the maximum size supported for this TokenNumber.\r | |
764 | @param[in] Value The buffer to set for the PCD token.\r | |
765 | \r | |
766 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
767 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
768 | being set was incompatible with a call to this function. \r | |
769 | Use GetSize() to retrieve the size of the target data.\r | |
770 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
771 | \r | |
772 | **/\r | |
80408db0 | 773 | EFI_STATUS\r |
774 | EFIAPI\r | |
775 | PeiPcdSetPtrEx (\r | |
fc547e08 | 776 | IN CONST EFI_GUID *Guid,\r |
777 | IN UINTN ExTokenNumber,\r | |
778 | IN OUT UINTN *SizeOfBuffer,\r | |
779 | IN VOID *Value\r | |
80408db0 | 780 | )\r |
781 | {\r | |
782 | return ExSetWorker (ExTokenNumber, Guid, Value, SizeOfBuffer, TRUE);\r | |
783 | }\r | |
784 | \r | |
fc547e08 | 785 | /**\r |
786 | Sets an Boolean value for a given PCD token.\r | |
787 | \r | |
788 | When the PCD service sets a value, it will check to ensure that the \r | |
789 | size of the value being set is compatible with the Token's existing definition. \r | |
790 | If it is not, an error will be returned.\r | |
80408db0 | 791 | \r |
fc547e08 | 792 | @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
793 | @param [in] ExTokenNumber The PCD token number. \r | |
794 | @param [in] Value The value to set for the PCD token.\r | |
80408db0 | 795 | \r |
fc547e08 | 796 | @retval EFI_SUCCESS Procedure returned successfully.\r |
797 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
798 | being set was incompatible with a call to this function. \r | |
799 | Use GetSize() to retrieve the size of the target data.\r | |
800 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
801 | \r | |
802 | **/\r | |
80408db0 | 803 | EFI_STATUS\r |
804 | EFIAPI\r | |
805 | PeiPcdSetBoolEx (\r | |
806 | IN CONST EFI_GUID *Guid,\r | |
807 | IN UINTN ExTokenNumber,\r | |
808 | IN BOOLEAN Value\r | |
809 | )\r | |
810 | {\r | |
811 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
812 | }\r | |
813 | \r | |
fc547e08 | 814 | /**\r |
815 | Specifies a function to be called anytime the value of a designated token is changed.\r | |
80408db0 | 816 | \r |
fc547e08 | 817 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
818 | @param[in] ExTokenNumber The PCD token number. \r | |
819 | @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r | |
80408db0 | 820 | \r |
fc547e08 | 821 | @retval EFI_SUCCESS The PCD service has successfully established a call event \r |
822 | for the CallBackToken requested.\r | |
823 | @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r | |
80408db0 | 824 | \r |
fc547e08 | 825 | **/\r |
80408db0 | 826 | EFI_STATUS\r |
827 | EFIAPI\r | |
828 | PeiRegisterCallBackOnSet (\r | |
829 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
830 | IN UINTN ExTokenNumber,\r | |
831 | IN PCD_PPI_CALLBACK CallBackFunction\r | |
832 | )\r | |
833 | {\r | |
834 | if (!FeaturePcdGet(PcdPeiPcdDatabaseCallbackOnSetEnabled)) {\r | |
835 | return EFI_UNSUPPORTED;\r | |
836 | }\r | |
837 | \r | |
e4a3922f | 838 | if (CallBackFunction == NULL) {\r |
839 | return EFI_INVALID_PARAMETER;\r | |
840 | }\r | |
841 | \r | |
80408db0 | 842 | return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, TRUE);\r |
843 | }\r | |
844 | \r | |
fc547e08 | 845 | /**\r |
846 | Cancels a previously set callback function for a particular PCD token number.\r | |
80408db0 | 847 | \r |
fc547e08 | 848 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
849 | @param[in] ExTokenNumber The PCD token number. \r | |
850 | @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r | |
80408db0 | 851 | \r |
fc547e08 | 852 | @retval EFI_SUCCESS The PCD service has successfully established a call event \r |
853 | for the CallBackToken requested.\r | |
854 | @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r | |
855 | \r | |
856 | **/\r | |
80408db0 | 857 | EFI_STATUS\r |
858 | EFIAPI\r | |
859 | PcdUnRegisterCallBackOnSet (\r | |
860 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
861 | IN UINTN ExTokenNumber,\r | |
862 | IN PCD_PPI_CALLBACK CallBackFunction\r | |
863 | )\r | |
864 | {\r | |
865 | if (!FeaturePcdGet(PcdPeiPcdDatabaseCallbackOnSetEnabled)) {\r | |
866 | return EFI_UNSUPPORTED;\r | |
867 | }\r | |
868 | \r | |
e4a3922f | 869 | if (CallBackFunction == NULL) {\r |
870 | return EFI_INVALID_PARAMETER;\r | |
871 | }\r | |
872 | \r | |
80408db0 | 873 | return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, FALSE);\r |
874 | }\r | |
875 | \r | |
fc547e08 | 876 | /**\r |
877 | Retrieves the next valid PCD token for a given namespace.\r | |
80408db0 | 878 | \r |
fc547e08 | 879 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
880 | @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number. \r | |
881 | If the input token namespace or token number does not exist on the platform, \r | |
882 | an error is returned and the value of *TokenNumber is undefined. To retrieve the "first" token, \r | |
883 | have the pointer reference a TokenNumber value of 0. If the input token number is 0 and \r | |
884 | there is no valid token number for this token namespace, *TokenNumber will be assigned to \r | |
885 | 0 and the function return EFI_SUCCESS. If the token number is the last valid token number, \r | |
886 | *TokenNumber will be assigned to 0 and the function return EFI_SUCCESS.\r | |
80408db0 | 887 | \r |
fc547e08 | 888 | @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number \r |
889 | is already the last valid token number in the PCD database. \r | |
890 | In the later case, *TokenNumber is updated with the value of 0.\r | |
891 | @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r | |
892 | \r | |
893 | **/\r | |
80408db0 | 894 | EFI_STATUS\r |
895 | EFIAPI\r | |
896 | PeiPcdGetNextToken (\r | |
897 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
898 | IN OUT UINTN *TokenNumber\r | |
899 | )\r | |
900 | {\r | |
901 | UINTN GuidTableIdx;\r | |
902 | PEI_PCD_DATABASE *PeiPcdDb;\r | |
903 | EFI_GUID *MatchGuid;\r | |
904 | DYNAMICEX_MAPPING *ExMapTable;\r | |
fc547e08 | 905 | UINTN Index;\r |
80408db0 | 906 | BOOLEAN Found;\r |
907 | BOOLEAN PeiExMapTableEmpty;\r | |
908 | \r | |
909 | if (!FeaturePcdGet (PcdPeiPcdDatabaseTraverseEnabled)) {\r | |
910 | return EFI_UNSUPPORTED;\r | |
911 | }\r | |
912 | \r | |
913 | PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r | |
914 | \r | |
915 | if (Guid == NULL) {\r | |
916 | if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {\r | |
917 | return EFI_NOT_FOUND;\r | |
918 | }\r | |
919 | (*TokenNumber)++;\r | |
920 | if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {\r | |
921 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
922 | }\r | |
923 | return EFI_SUCCESS;\r | |
924 | } else {\r | |
925 | if (PeiExMapTableEmpty) {\r | |
926 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
927 | return EFI_SUCCESS;\r | |
928 | }\r | |
929 | \r | |
930 | //\r | |
931 | // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order\r | |
932 | // 1) ExGuid\r | |
933 | // 2) ExTokenNumber\r | |
934 | //\r | |
935 | PeiPcdDb = GetPcdDatabase ();\r | |
936 | \r | |
937 | MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);\r | |
938 | \r | |
939 | if (MatchGuid == NULL) {\r | |
940 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
941 | return EFI_NOT_FOUND;\r | |
942 | }\r | |
943 | \r | |
944 | GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r | |
945 | \r | |
946 | ExMapTable = PeiPcdDb->Init.ExMapTable;\r | |
947 | \r | |
948 | Found = FALSE;\r | |
949 | //\r | |
950 | // Locate the GUID in ExMapTable first.\r | |
951 | //\r | |
fc547e08 | 952 | for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r |
953 | if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r | |
80408db0 | 954 | Found = TRUE;\r |
955 | break;\r | |
956 | }\r | |
957 | }\r | |
958 | \r | |
959 | if (Found) {\r | |
960 | if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r | |
fc547e08 | 961 | *TokenNumber = ExMapTable[Index].ExTokenNumber;\r |
80408db0 | 962 | return EFI_SUCCESS;\r |
963 | }\r | |
964 | \r | |
fc547e08 | 965 | for ( ; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r |
966 | if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {\r | |
967 | Index++;\r | |
968 | if (Index == PEI_EXMAPPING_TABLE_SIZE) {\r | |
80408db0 | 969 | //\r |
970 | // Exceed the length of ExMap Table\r | |
971 | //\r | |
972 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
973 | return EFI_SUCCESS;\r | |
974 | }\r | |
fc547e08 | 975 | if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r |
976 | *TokenNumber = ExMapTable[Index].ExTokenNumber;\r | |
80408db0 | 977 | return EFI_SUCCESS;\r |
978 | } else {\r | |
979 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
980 | return EFI_SUCCESS;\r | |
981 | }\r | |
982 | }\r | |
983 | }\r | |
984 | return EFI_NOT_FOUND;\r | |
985 | }\r | |
986 | }\r | |
987 | \r | |
988 | return EFI_NOT_FOUND;\r | |
989 | }\r | |
990 | \r | |
fc547e08 | 991 | /**\r |
992 | Retrieves the next valid PCD token namespace for a given namespace.\r | |
993 | \r | |
994 | @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates \r | |
995 | a known token namespace from which the search will start. On output, \r | |
996 | it designates the next valid token namespace on the platform. If the input \r | |
997 | token namespace does not exist on the platform, an error is returned and \r | |
998 | the value of *Guid is undefined. If *Guid is NULL, then the GUID of the \r | |
999 | first token space of the current platform is assigned to *Guid the function \r | |
1000 | return EFI_SUCCESS. If *Guid is NULL and there is no namespace exist in \r | |
1001 | the platform other than the default (NULL) tokennamespace, *Guid is unchanged \r | |
1002 | and the function return EFI_SUCCESS. If this input token namespace is the last \r | |
1003 | namespace on the platform, *Guid will be assigned to NULL and the function return \r | |
1004 | EFI_SUCCESS. \r | |
1005 | \r | |
1006 | @retval EFI_SUCCESS The PCD service retrieved the next valid token space Guid. \r | |
1007 | Or the input token space Guid is already the last valid token space Guid \r | |
1008 | in the PCD database. In the later case, *Guid is updated with the value of NULL.\r | |
1009 | @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.\r | |
80408db0 | 1010 | \r |
fc547e08 | 1011 | **/\r |
80408db0 | 1012 | EFI_STATUS\r |
1013 | EFIAPI\r | |
1014 | PeiPcdGetNextTokenSpace (\r | |
1015 | IN OUT CONST EFI_GUID **Guid\r | |
1016 | )\r | |
1017 | {\r | |
1018 | UINTN GuidTableIdx;\r | |
1019 | EFI_GUID *MatchGuid;\r | |
1020 | PEI_PCD_DATABASE *PeiPcdDb;\r | |
1021 | DYNAMICEX_MAPPING *ExMapTable;\r | |
fc547e08 | 1022 | UINTN Index;\r |
80408db0 | 1023 | BOOLEAN Found;\r |
1024 | BOOLEAN PeiExMapTableEmpty;\r | |
1025 | \r | |
1026 | if (!FeaturePcdGet (PcdPeiPcdDatabaseTraverseEnabled)) {\r | |
1027 | return EFI_UNSUPPORTED;\r | |
1028 | }\r | |
1029 | \r | |
1030 | ASSERT (Guid != NULL);\r | |
1031 | \r | |
1032 | PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r | |
1033 | \r | |
1034 | if (PeiExMapTableEmpty) {\r | |
1035 | if (*Guid != NULL) {\r | |
1036 | return EFI_NOT_FOUND;\r | |
1037 | } else {\r | |
1038 | return EFI_SUCCESS;\r | |
1039 | }\r | |
1040 | }\r | |
1041 | \r | |
1042 | //\r | |
1043 | // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order\r | |
1044 | // 1) ExGuid\r | |
1045 | // 2) ExTokenNumber\r | |
1046 | //\r | |
1047 | PeiPcdDb = GetPcdDatabase ();\r | |
1048 | \r | |
1049 | ExMapTable = PeiPcdDb->Init.ExMapTable;\r | |
1050 | \r | |
1051 | if (*Guid == NULL) {\r | |
1052 | //\r | |
1053 | // return the first Token Space Guid.\r | |
1054 | //\r | |
1055 | *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[0].ExGuidIndex];\r | |
1056 | return EFI_SUCCESS;\r | |
1057 | }\r | |
1058 | \r | |
1059 | MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), *Guid);\r | |
1060 | \r | |
1061 | if (MatchGuid == NULL) {\r | |
1062 | return EFI_NOT_FOUND;\r | |
1063 | }\r | |
1064 | \r | |
1065 | GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r | |
1066 | \r | |
1067 | Found = FALSE;\r | |
fc547e08 | 1068 | for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r |
1069 | if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r | |
80408db0 | 1070 | Found = TRUE;\r |
1071 | break;\r | |
1072 | }\r | |
1073 | }\r | |
1074 | \r | |
1075 | if (Found) {\r | |
fc547e08 | 1076 | Index++;\r |
1077 | for ( ; Index < PEI_EXMAPPING_TABLE_SIZE; Index++ ) {\r | |
1078 | if (ExMapTable[Index].ExGuidIndex != GuidTableIdx ) {\r | |
1079 | *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[Index].ExGuidIndex];\r | |
80408db0 | 1080 | return EFI_SUCCESS;\r |
1081 | }\r | |
1082 | }\r | |
1083 | *Guid = NULL;\r | |
1084 | return EFI_SUCCESS;\r | |
1085 | }\r | |
1086 | \r | |
1087 | return EFI_NOT_FOUND;\r | |
1088 | \r | |
1089 | }\r | |
1090 | \r | |
fc547e08 | 1091 | /**\r |
1092 | Get PCD value's size for POINTER type PCD.\r | |
1093 | \r | |
1094 | The POINTER type PCD's value will be stored into a buffer in specificed size.\r | |
1095 | The max size of this PCD's value is described in PCD's definition in DEC file.\r | |
1096 | \r | |
1097 | @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r | |
3fd8027e | 1098 | @param MaxSize Maximum size of PCD's value\r |
fc547e08 | 1099 | @param Database Pcd database in PEI phase.\r |
1100 | \r | |
1101 | @return PCD value's size for POINTER type PCD.\r | |
1102 | \r | |
1103 | **/\r | |
80408db0 | 1104 | UINTN\r |
1105 | GetPtrTypeSize (\r | |
1106 | IN UINTN LocalTokenNumberTableIdx,\r | |
1107 | OUT UINTN *MaxSize,\r | |
1108 | IN PEI_PCD_DATABASE *Database\r | |
1109 | )\r | |
1110 | {\r | |
1111 | INTN SizeTableIdx;\r | |
1112 | UINTN LocalTokenNumber;\r | |
1113 | SKU_ID *SkuIdTable;\r | |
1114 | SIZE_INFO *SizeTable;\r | |
fc547e08 | 1115 | UINTN Index;\r |
80408db0 | 1116 | \r |
1117 | SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r | |
1118 | \r | |
1119 | LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];\r | |
1120 | \r | |
1121 | ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);\r | |
1122 | \r | |
1123 | SizeTable = Database->Init.SizeTable;\r | |
1124 | \r | |
1125 | *MaxSize = SizeTable[SizeTableIdx];\r | |
1126 | //\r | |
1127 | // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type \r | |
1128 | // PCD entry.\r | |
1129 | //\r | |
fc547e08 | 1130 | if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r |
80408db0 | 1131 | //\r |
1132 | // We have only one entry for VPD enabled PCD entry:\r | |
1133 | // 1) MAX Size.\r | |
1134 | // We consider current size is equal to MAX size.\r | |
1135 | //\r | |
1136 | return *MaxSize;\r | |
1137 | } else {\r | |
1138 | if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {\r | |
1139 | //\r | |
1140 | // We have only two entry for Non-Sku enabled PCD entry:\r | |
1141 | // 1) MAX SIZE\r | |
1142 | // 2) Current Size\r | |
1143 | //\r | |
1144 | return SizeTable[SizeTableIdx + 1];\r | |
1145 | } else {\r | |
1146 | //\r | |
1147 | // We have these entry for SKU enabled PCD entry\r | |
1148 | // 1) MAX SIZE\r | |
1149 | // 2) Current Size for each SKU_ID (It is equal to MaxSku).\r | |
1150 | //\r | |
1151 | SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);\r | |
fc547e08 | 1152 | for (Index = 0; Index < SkuIdTable[0]; Index++) {\r |
1153 | if (SkuIdTable[1 + Index] == Database->Init.SystemSkuId) {\r | |
1154 | return SizeTable[SizeTableIdx + 1 + Index];\r | |
80408db0 | 1155 | }\r |
1156 | }\r | |
1157 | return SizeTable[SizeTableIdx + 1];\r | |
1158 | }\r | |
1159 | }\r | |
1160 | }\r | |
1161 | \r | |
fc547e08 | 1162 | /**\r |
1163 | Set PCD value's size for POINTER type PCD.\r | |
1164 | \r | |
1165 | The POINTER type PCD's value will be stored into a buffer in specificed size.\r | |
1166 | The max size of this PCD's value is described in PCD's definition in DEC file.\r | |
1167 | \r | |
1168 | @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r | |
3fd8027e | 1169 | @param CurrentSize Maximum size of PCD's value\r |
fc547e08 | 1170 | @param Database Pcd database in PEI phase.\r |
80408db0 | 1171 | \r |
3fd8027e | 1172 | @retval TRUE Success to set PCD's value size, which is not exceed maximum size\r |
1173 | @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size\r | |
80408db0 | 1174 | \r |
fc547e08 | 1175 | **/\r |
80408db0 | 1176 | BOOLEAN\r |
1177 | SetPtrTypeSize (\r | |
1178 | IN UINTN LocalTokenNumberTableIdx,\r | |
1179 | IN OUT UINTN *CurrentSize,\r | |
1180 | IN PEI_PCD_DATABASE *Database\r | |
1181 | )\r | |
1182 | {\r | |
1183 | INTN SizeTableIdx;\r | |
1184 | UINTN LocalTokenNumber;\r | |
1185 | SKU_ID *SkuIdTable;\r | |
1186 | SIZE_INFO *SizeTable;\r | |
fc547e08 | 1187 | UINTN Index;\r |
80408db0 | 1188 | UINTN MaxSize;\r |
1189 | \r | |
1190 | SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r | |
1191 | \r | |
1192 | LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];\r | |
1193 | \r | |
1194 | ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);\r | |
1195 | \r | |
1196 | SizeTable = Database->Init.SizeTable;\r | |
1197 | \r | |
1198 | MaxSize = SizeTable[SizeTableIdx];\r | |
1199 | //\r | |
1200 | // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type \r | |
1201 | // PCD entry.\r | |
1202 | //\r | |
fc547e08 | 1203 | if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r |
80408db0 | 1204 | //\r |
1205 | // We shouldn't come here as we don't support SET for VPD\r | |
1206 | //\r | |
1207 | ASSERT (FALSE);\r | |
1208 | return FALSE;\r | |
1209 | } else {\r | |
1210 | if ((*CurrentSize > MaxSize) ||\r | |
1211 | (*CurrentSize == MAX_ADDRESS)) {\r | |
1212 | *CurrentSize = MaxSize;\r | |
1213 | return FALSE;\r | |
5944a83b | 1214 | }\r |
80408db0 | 1215 | \r |
1216 | if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {\r | |
1217 | //\r | |
1218 | // We have only two entry for Non-Sku enabled PCD entry:\r | |
1219 | // 1) MAX SIZE\r | |
1220 | // 2) Current Size\r | |
1221 | //\r | |
1222 | SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;\r | |
1223 | return TRUE;\r | |
1224 | } else {\r | |
1225 | //\r | |
1226 | // We have these entry for SKU enabled PCD entry\r | |
1227 | // 1) MAX SIZE\r | |
1228 | // 2) Current Size for each SKU_ID (It is equal to MaxSku).\r | |
1229 | //\r | |
1230 | SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);\r | |
fc547e08 | 1231 | for (Index = 0; Index < SkuIdTable[0]; Index++) {\r |
1232 | if (SkuIdTable[1 + Index] == Database->Init.SystemSkuId) {\r | |
1233 | SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;\r | |
80408db0 | 1234 | return TRUE;\r |
1235 | }\r | |
1236 | }\r | |
1237 | SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;\r | |
1238 | return TRUE;\r | |
1239 | }\r | |
1240 | }\r | |
1241 | \r | |
1242 | }\r |