]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/PCD/Pei/Service.h
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Pei / Service.h
... / ...
CommitLineData
1/** @file\r
2 The internal header file declares the private functions used by PeiPcd driver.\r
3\r
4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#ifndef _PEI_PCD_SERVICE_H_\r
10#define _PEI_PCD_SERVICE_H_\r
11\r
12#include <PiPei.h>\r
13#include <Ppi/ReadOnlyVariable2.h>\r
14#include <Ppi/Pcd.h>\r
15#include <Ppi/PiPcd.h>\r
16#include <Ppi/PcdInfo.h>\r
17#include <Ppi/PiPcdInfo.h>\r
18#include <Guid/PcdDataBaseHobGuid.h>\r
19#include <Guid/PcdDataBaseSignatureGuid.h>\r
20#include <Guid/VariableFormat.h>\r
21#include <Library/DebugLib.h>\r
22#include <Library/PeimEntryPoint.h>\r
23#include <Library/BaseLib.h>\r
24#include <Library/HobLib.h>\r
25#include <Library/PeiServicesLib.h>\r
26#include <Library/PcdLib.h>\r
27#include <Library/BaseMemoryLib.h>\r
28#include <Library/MemoryAllocationLib.h>\r
29\r
30//\r
31// Please make sure the PCD Serivce PEIM Version is consistent with\r
32// the version of the generated PEIM PCD Database by build tool.\r
33//\r
34#define PCD_SERVICE_PEIM_VERSION 7\r
35\r
36//\r
37// PCD_PEI_SERVICE_DRIVER_VERSION is defined in Autogen.h.\r
38//\r
39#if (PCD_SERVICE_PEIM_VERSION != PCD_PEI_SERVICE_DRIVER_VERSION)\r
40 #error "Please make sure the version of PCD PEIM Service and the generated PCD PEI Database match."\r
41#endif\r
42\r
43/**\r
44 Retrieve additional information associated with a PCD token in the default token space.\r
45\r
46 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
47 human readable name that is associated with the token.\r
48\r
49 @param[in] TokenNumber The PCD token number.\r
50 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
51 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
52\r
53 @retval EFI_SUCCESS The PCD information was returned successfully.\r
54 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
55**/\r
56EFI_STATUS\r
57EFIAPI\r
58PeiGetPcdInfoGetInfo (\r
59 IN UINTN TokenNumber,\r
60 OUT EFI_PCD_INFO *PcdInfo\r
61 );\r
62\r
63/**\r
64 Retrieve additional information associated with a PCD token.\r
65\r
66 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
67 human readable name that is associated with the token.\r
68\r
69 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
70 @param[in] TokenNumber The PCD token number.\r
71 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
72 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
73\r
74 @retval EFI_SUCCESS The PCD information was returned successfully.\r
75 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
76**/\r
77EFI_STATUS\r
78EFIAPI\r
79PeiGetPcdInfoGetInfoEx (\r
80 IN CONST EFI_GUID *Guid,\r
81 IN UINTN TokenNumber,\r
82 OUT EFI_PCD_INFO *PcdInfo\r
83 );\r
84\r
85/**\r
86 Retrieve the currently set SKU Id.\r
87\r
88 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
89 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
90 Id is returned.\r
91**/\r
92UINTN\r
93EFIAPI\r
94PeiGetPcdInfoGetSku (\r
95 VOID\r
96 );\r
97\r
98//\r
99// PPI Interface Implementation Declaration.\r
100//\r
101\r
102/**\r
103 Sets the SKU value for subsequent calls to set or get PCD token values.\r
104\r
105 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.\r
106 SetSku() is normally called only once by the system.\r
107\r
108 For each item (token), the database can hold a single value that applies to all SKUs,\r
109 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,\r
110 SKU-specific values are called SKU enabled.\r
111\r
112 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.\r
113 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the\r
114 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the\r
115 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,\r
116 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been\r
117 set for that Id, the results are unpredictable.\r
118\r
119 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and\r
120 set values associated with a PCD token.\r
121\r
122**/\r
123VOID\r
124EFIAPI\r
125PeiPcdSetSku (\r
126 IN UINTN SkuId\r
127 );\r
128\r
129/**\r
130 Retrieves an 8-bit value for a given PCD token.\r
131\r
132 Retrieves the current byte-sized value for a PCD token number.\r
133 If the TokenNumber is invalid, the results are unpredictable.\r
134\r
135 @param[in] TokenNumber The PCD token number.\r
136\r
137 @return The UINT8 value.\r
138\r
139**/\r
140UINT8\r
141EFIAPI\r
142PeiPcdGet8 (\r
143 IN UINTN TokenNumber\r
144 );\r
145\r
146/**\r
147 Retrieves an 16-bit value for a given PCD token.\r
148\r
149 Retrieves the current 16-bits value for a PCD token number.\r
150 If the TokenNumber is invalid, the results are unpredictable.\r
151\r
152 @param[in] TokenNumber The PCD token number.\r
153\r
154 @return The UINT16 value.\r
155\r
156**/\r
157UINT16\r
158EFIAPI\r
159PeiPcdGet16 (\r
160 IN UINTN TokenNumber\r
161 );\r
162\r
163/**\r
164 Retrieves an 32-bit value for a given PCD token.\r
165\r
166 Retrieves the current 32-bits value for a PCD token number.\r
167 If the TokenNumber is invalid, the results are unpredictable.\r
168\r
169 @param[in] TokenNumber The PCD token number.\r
170\r
171 @return The UINT32 value.\r
172\r
173**/\r
174UINT32\r
175EFIAPI\r
176PeiPcdGet32 (\r
177 IN UINTN TokenNumber\r
178 );\r
179\r
180/**\r
181 Retrieves an 64-bit value for a given PCD token.\r
182\r
183 Retrieves the current 64-bits value for a PCD token number.\r
184 If the TokenNumber is invalid, the results are unpredictable.\r
185\r
186 @param[in] TokenNumber The PCD token number.\r
187\r
188 @return The UINT64 value.\r
189\r
190**/\r
191UINT64\r
192EFIAPI\r
193PeiPcdGet64 (\r
194 IN UINTN TokenNumber\r
195 );\r
196\r
197/**\r
198 Retrieves a pointer to a value for a given PCD token.\r
199\r
200 Retrieves the current pointer to the buffer for a PCD token number.\r
201 Do not make any assumptions about the alignment of the pointer that\r
202 is returned by this function call. If the TokenNumber is invalid,\r
203 the results are unpredictable.\r
204\r
205 @param[in] TokenNumber The PCD token number.\r
206\r
207 @return The pointer to the buffer to be retrived.\r
208\r
209**/\r
210VOID *\r
211EFIAPI\r
212PeiPcdGetPtr (\r
213 IN UINTN TokenNumber\r
214 );\r
215\r
216/**\r
217 Retrieves a Boolean value for a given PCD token.\r
218\r
219 Retrieves the current boolean value for a PCD token number.\r
220 Do not make any assumptions about the alignment of the pointer that\r
221 is returned by this function call. If the TokenNumber is invalid,\r
222 the results are unpredictable.\r
223\r
224 @param[in] TokenNumber The PCD token number.\r
225\r
226 @return The Boolean value.\r
227\r
228**/\r
229BOOLEAN\r
230EFIAPI\r
231PeiPcdGetBool (\r
232 IN UINTN TokenNumber\r
233 );\r
234\r
235/**\r
236 Retrieves the size of the value for a given PCD token.\r
237\r
238 Retrieves the current size of a particular PCD token.\r
239 If the TokenNumber is invalid, the results are unpredictable.\r
240\r
241 @param[in] TokenNumber The PCD token number.\r
242\r
243 @return The size of the value for the PCD token.\r
244\r
245**/\r
246UINTN\r
247EFIAPI\r
248PeiPcdGetSize (\r
249 IN UINTN TokenNumber\r
250 );\r
251\r
252/**\r
253 Retrieves an 8-bit value for a given PCD token.\r
254\r
255 Retrieves the 8-bit value of a particular PCD token.\r
256 If the TokenNumber is invalid or the token space\r
257 specified by Guid does not exist, the results are\r
258 unpredictable.\r
259\r
260 @param[in] Guid The token space for the token number.\r
261 @param[in] TokenNumber The PCD token number.\r
262\r
263 @return The size 8-bit value for the PCD token.\r
264\r
265**/\r
266UINT8\r
267EFIAPI\r
268PeiPcdGet8Ex (\r
269 IN CONST EFI_GUID *Guid,\r
270 IN UINTN TokenNumber\r
271 );\r
272\r
273/**\r
274 Retrieves an 16-bit value for a given PCD token.\r
275\r
276 Retrieves the 16-bit value of a particular PCD token.\r
277 If the TokenNumber is invalid or the token space\r
278 specified by Guid does not exist, the results are\r
279 unpredictable.\r
280\r
281 @param[in] Guid The token space for the token number.\r
282 @param[in] TokenNumber The PCD token number.\r
283\r
284 @return The size 16-bit value for the PCD token.\r
285\r
286**/\r
287UINT16\r
288EFIAPI\r
289PeiPcdGet16Ex (\r
290 IN CONST EFI_GUID *Guid,\r
291 IN UINTN TokenNumber\r
292 );\r
293\r
294/**\r
295 Retrieves an 32-bit value for a given PCD token.\r
296\r
297 Retrieves the 32-bit value of a particular PCD token.\r
298 If the TokenNumber is invalid or the token space\r
299 specified by Guid does not exist, the results are\r
300 unpredictable.\r
301\r
302 @param[in] Guid The token space for the token number.\r
303 @param[in] TokenNumber The PCD token number.\r
304\r
305 @return The size 32-bit value for the PCD token.\r
306\r
307**/\r
308UINT32\r
309EFIAPI\r
310PeiPcdGet32Ex (\r
311 IN CONST EFI_GUID *Guid,\r
312 IN UINTN TokenNumber\r
313 );\r
314\r
315/**\r
316 Retrieves an 64-bit value for a given PCD token.\r
317\r
318 Retrieves the 64-bit value of a particular PCD token.\r
319 If the TokenNumber is invalid or the token space\r
320 specified by Guid does not exist, the results are\r
321 unpredictable.\r
322\r
323 @param[in] Guid The token space for the token number.\r
324 @param[in] TokenNumber The PCD token number.\r
325\r
326 @return The size 64-bit value for the PCD token.\r
327\r
328**/\r
329UINT64\r
330EFIAPI\r
331PeiPcdGet64Ex (\r
332 IN CONST EFI_GUID *Guid,\r
333 IN UINTN TokenNumber\r
334 );\r
335\r
336/**\r
337 Retrieves a pointer to a value for a given PCD token.\r
338\r
339 Retrieves the current pointer to the buffer for a PCD token number.\r
340 Do not make any assumptions about the alignment of the pointer that\r
341 is returned by this function call. If the TokenNumber is invalid,\r
342 the results are unpredictable.\r
343\r
344 @param[in] Guid The token space for the token number.\r
345 @param[in] TokenNumber The PCD token number.\r
346\r
347 @return The pointer to the buffer to be retrived.\r
348\r
349**/\r
350VOID *\r
351EFIAPI\r
352PeiPcdGetPtrEx (\r
353 IN CONST EFI_GUID *Guid,\r
354 IN UINTN TokenNumber\r
355 );\r
356\r
357/**\r
358 Retrieves an Boolean value for a given PCD token.\r
359\r
360 Retrieves the Boolean value of a particular PCD token.\r
361 If the TokenNumber is invalid or the token space\r
362 specified by Guid does not exist, the results are\r
363 unpredictable.\r
364\r
365 @param[in] Guid The token space for the token number.\r
366 @param[in] TokenNumber The PCD token number.\r
367\r
368 @return The size Boolean value for the PCD token.\r
369\r
370**/\r
371BOOLEAN\r
372EFIAPI\r
373PeiPcdGetBoolEx (\r
374 IN CONST EFI_GUID *Guid,\r
375 IN UINTN TokenNumber\r
376 );\r
377\r
378/**\r
379 Retrieves the size of the value for a given PCD token.\r
380\r
381 Retrieves the current size of a particular PCD token.\r
382 If the TokenNumber is invalid, the results are unpredictable.\r
383\r
384 @param[in] Guid The token space for the token number.\r
385 @param[in] TokenNumber The PCD token number.\r
386\r
387 @return The size of the value for the PCD token.\r
388\r
389**/\r
390UINTN\r
391EFIAPI\r
392PeiPcdGetSizeEx (\r
393 IN CONST EFI_GUID *Guid,\r
394 IN UINTN TokenNumber\r
395 );\r
396\r
397/**\r
398 Sets an 8-bit value for a given PCD token.\r
399\r
400 When the PCD service sets a value, it will check to ensure that the\r
401 size of the value being set is compatible with the Token's existing definition.\r
402 If it is not, an error will be returned.\r
403\r
404 @param[in] TokenNumber The PCD token number.\r
405 @param[in] Value The value to set for the PCD token.\r
406\r
407 @retval EFI_SUCCESS Procedure returned successfully.\r
408 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
409 being set was incompatible with a call to this function.\r
410 Use GetSize() to retrieve the size of the target data.\r
411 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
412\r
413**/\r
414EFI_STATUS\r
415EFIAPI\r
416PeiPcdSet8 (\r
417 IN UINTN TokenNumber,\r
418 IN UINT8 Value\r
419 );\r
420\r
421/**\r
422 Sets an 16-bit value for a given PCD token.\r
423\r
424 When the PCD service sets a value, it will check to ensure that the\r
425 size of the value being set is compatible with the Token's existing definition.\r
426 If it is not, an error will be returned.\r
427\r
428 @param[in] TokenNumber The PCD token number.\r
429 @param[in] Value The value to set for the PCD token.\r
430\r
431 @retval EFI_SUCCESS Procedure returned successfully.\r
432 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
433 being set was incompatible with a call to this function.\r
434 Use GetSize() to retrieve the size of the target data.\r
435 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
436\r
437**/\r
438EFI_STATUS\r
439EFIAPI\r
440PeiPcdSet16 (\r
441 IN UINTN TokenNumber,\r
442 IN UINT16 Value\r
443 );\r
444\r
445/**\r
446 Sets an 32-bit value for a given PCD token.\r
447\r
448 When the PCD service sets a value, it will check to ensure that the\r
449 size of the value being set is compatible with the Token's existing definition.\r
450 If it is not, an error will be returned.\r
451\r
452 @param[in] TokenNumber The PCD token number.\r
453 @param[in] Value The value to set for the PCD token.\r
454\r
455 @retval EFI_SUCCESS Procedure returned successfully.\r
456 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
457 being set was incompatible with a call to this function.\r
458 Use GetSize() to retrieve the size of the target data.\r
459 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
460\r
461**/\r
462EFI_STATUS\r
463EFIAPI\r
464PeiPcdSet32 (\r
465 IN UINTN TokenNumber,\r
466 IN UINT32 Value\r
467 );\r
468\r
469/**\r
470 Sets an 64-bit value for a given PCD token.\r
471\r
472 When the PCD service sets a value, it will check to ensure that the\r
473 size of the value being set is compatible with the Token's existing definition.\r
474 If it is not, an error will be returned.\r
475\r
476 @param[in] TokenNumber The PCD token number.\r
477 @param[in] Value The value to set for the PCD token.\r
478\r
479 @retval EFI_SUCCESS Procedure returned successfully.\r
480 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
481 being set was incompatible with a call to this function.\r
482 Use GetSize() to retrieve the size of the target data.\r
483 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
484\r
485**/\r
486EFI_STATUS\r
487EFIAPI\r
488PeiPcdSet64 (\r
489 IN UINTN TokenNumber,\r
490 IN UINT64 Value\r
491 );\r
492\r
493/**\r
494 Sets a value of a specified size for a given PCD token.\r
495\r
496 When the PCD service sets a value, it will check to ensure that the\r
497 size of the value being set is compatible with the Token's existing definition.\r
498 If it is not, an error will be returned.\r
499\r
500 @param[in] TokenNumber The PCD token number.\r
501 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.\r
502 On input, if the SizeOfValue is greater than the maximum size supported\r
503 for this TokenNumber then the output value of SizeOfValue will reflect\r
504 the maximum size supported for this TokenNumber.\r
505 @param[in] Buffer The buffer to set for the PCD token.\r
506\r
507 @retval EFI_SUCCESS Procedure returned successfully.\r
508 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
509 being set was incompatible with a call to this function.\r
510 Use GetSize() to retrieve the size of the target data.\r
511 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
512\r
513**/\r
514EFI_STATUS\r
515EFIAPI\r
516PeiPcdSetPtr (\r
517 IN UINTN TokenNumber,\r
518 IN OUT UINTN *SizeOfBuffer,\r
519 IN VOID *Buffer\r
520 );\r
521\r
522/**\r
523 Sets an Boolean value for a given PCD token.\r
524\r
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
528\r
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
539EFI_STATUS\r
540EFIAPI\r
541PeiPcdSetBool (\r
542 IN UINTN TokenNumber,\r
543 IN BOOLEAN Value\r
544 );\r
545\r
546/**\r
547 Sets an 8-bit value for a given PCD token.\r
548\r
549 When the PCD service sets a value, it will check to ensure that the\r
550 size of the value being set is compatible with the Token's existing definition.\r
551 If it is not, an error will be returned.\r
552\r
553 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
554 @param[in] TokenNumber The PCD token number.\r
555 @param[in] Value The value to set for the PCD token.\r
556\r
557 @retval EFI_SUCCESS Procedure returned successfully.\r
558 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
559 being set was incompatible with a call to this function.\r
560 Use GetSize() to retrieve the size of the target data.\r
561 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
562\r
563**/\r
564EFI_STATUS\r
565EFIAPI\r
566PeiPcdSet8Ex (\r
567 IN CONST EFI_GUID *Guid,\r
568 IN UINTN TokenNumber,\r
569 IN UINT8 Value\r
570 );\r
571\r
572/**\r
573 Sets an 16-bit value for a given PCD token.\r
574\r
575 When the PCD service sets a value, it will check to ensure that the\r
576 size of the value being set is compatible with the Token's existing definition.\r
577 If it is not, an error will be returned.\r
578\r
579 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
580 @param[in] TokenNumber The PCD token number.\r
581 @param[in] Value The value to set for the PCD token.\r
582\r
583 @retval EFI_SUCCESS Procedure returned successfully.\r
584 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
585 being set was incompatible with a call to this function.\r
586 Use GetSize() to retrieve the size of the target data.\r
587 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
588\r
589**/\r
590EFI_STATUS\r
591EFIAPI\r
592PeiPcdSet16Ex (\r
593 IN CONST EFI_GUID *Guid,\r
594 IN UINTN TokenNumber,\r
595 IN UINT16 Value\r
596 );\r
597\r
598/**\r
599 Sets an 32-bit value for a given PCD token.\r
600\r
601 When the PCD service sets a value, it will check to ensure that the\r
602 size of the value being set is compatible with the Token's existing definition.\r
603 If it is not, an error will be returned.\r
604\r
605 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
606 @param[in] TokenNumber The PCD token number.\r
607 @param[in] Value The value to set for the PCD token.\r
608\r
609 @retval EFI_SUCCESS Procedure returned successfully.\r
610 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
611 being set was incompatible with a call to this function.\r
612 Use GetSize() to retrieve the size of the target data.\r
613 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
614\r
615**/\r
616EFI_STATUS\r
617EFIAPI\r
618PeiPcdSet32Ex (\r
619 IN CONST EFI_GUID *Guid,\r
620 IN UINTN TokenNumber,\r
621 IN UINT32 Value\r
622 );\r
623\r
624/**\r
625 Sets an 64-bit value for a given PCD token.\r
626\r
627 When the PCD service sets a value, it will check to ensure that the\r
628 size of the value being set is compatible with the Token's existing definition.\r
629 If it is not, an error will be returned.\r
630\r
631 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
632 @param[in] TokenNumber The PCD token number.\r
633 @param[in] Value The value to set for the PCD token.\r
634\r
635 @retval EFI_SUCCESS Procedure returned successfully.\r
636 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
637 being set was incompatible with a call to this function.\r
638 Use GetSize() to retrieve the size of the target data.\r
639 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
640\r
641**/\r
642EFI_STATUS\r
643EFIAPI\r
644PeiPcdSet64Ex (\r
645 IN CONST EFI_GUID *Guid,\r
646 IN UINTN TokenNumber,\r
647 IN UINT64 Value\r
648 );\r
649\r
650/**\r
651 Sets a value of a specified size for a given PCD token.\r
652\r
653 When the PCD service sets a value, it will check to ensure that the\r
654 size of the value being set is compatible with the Token's existing definition.\r
655 If it is not, an error will be returned.\r
656\r
657 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
658 @param[in] TokenNumber The PCD token number.\r
659 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.\r
660 On input, if the SizeOfValue is greater than the maximum size supported\r
661 for this TokenNumber then the output value of SizeOfValue will reflect\r
662 the maximum size supported for this TokenNumber.\r
663 @param[in] Buffer The buffer to set for the PCD token.\r
664\r
665 @retval EFI_SUCCESS Procedure returned successfully.\r
666 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
667 being set was incompatible with a call to this function.\r
668 Use GetSize() to retrieve the size of the target data.\r
669 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
670\r
671**/\r
672EFI_STATUS\r
673EFIAPI\r
674PeiPcdSetPtrEx (\r
675 IN CONST EFI_GUID *Guid,\r
676 IN UINTN TokenNumber,\r
677 IN OUT UINTN *SizeOfBuffer,\r
678 IN VOID *Buffer\r
679 );\r
680\r
681/**\r
682 Sets an Boolean value for a given PCD token.\r
683\r
684 When the PCD service sets a value, it will check to ensure that the\r
685 size of the value being set is compatible with the Token's existing definition.\r
686 If it is not, an error will be returned.\r
687\r
688 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
689 @param[in] TokenNumber The PCD token number.\r
690 @param[in] Value The value to set for the PCD token.\r
691\r
692 @retval EFI_SUCCESS Procedure returned successfully.\r
693 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data\r
694 being set was incompatible with a call to this function.\r
695 Use GetSize() to retrieve the size of the target data.\r
696 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
697\r
698**/\r
699EFI_STATUS\r
700EFIAPI\r
701PeiPcdSetBoolEx (\r
702 IN CONST EFI_GUID *Guid,\r
703 IN UINTN TokenNumber,\r
704 IN BOOLEAN Value\r
705 );\r
706\r
707/**\r
708 Specifies a function to be called anytime the value of a designated token is changed.\r
709\r
710 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
711 @param[in] TokenNumber The PCD token number.\r
712 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.\r
713\r
714 @retval EFI_SUCCESS The PCD service has successfully established a call event\r
715 for the CallBackToken requested.\r
716 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r
717\r
718**/\r
719EFI_STATUS\r
720EFIAPI\r
721PeiRegisterCallBackOnSet (\r
722 IN CONST EFI_GUID *Guid OPTIONAL,\r
723 IN UINTN TokenNumber,\r
724 IN PCD_PPI_CALLBACK CallBackFunction\r
725 );\r
726\r
727/**\r
728 Cancels a previously set callback function for a particular PCD token number.\r
729\r
730 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
731 @param [in] TokenNumber The PCD token number.\r
732 @param [in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.\r
733\r
734 @retval EFI_SUCCESS The PCD service has successfully established a call event\r
735 for the CallBackToken requested.\r
736 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r
737\r
738**/\r
739EFI_STATUS\r
740EFIAPI\r
741PcdUnRegisterCallBackOnSet (\r
742 IN CONST EFI_GUID *Guid OPTIONAL,\r
743 IN UINTN TokenNumber,\r
744 IN PCD_PPI_CALLBACK CallBackFunction\r
745 );\r
746\r
747/**\r
748 Retrieves the next valid token number in a given namespace.\r
749\r
750 This is useful since the PCD infrastructure contains a sparse list of token numbers,\r
751 and one cannot a priori know what token numbers are valid in the database.\r
752\r
753 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.\r
754 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.\r
755 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.\r
756 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.\r
757 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.\r
758 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.\r
759 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.\r
760 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.\r
761\r
762\r
763 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
764 This is an optional parameter that may be NULL. If this parameter is NULL, then a request\r
765 is being made to retrieve tokens from the default token space.\r
766 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.\r
767\r
768 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.\r
769 Or the input token number is already the last valid token number in the PCD database.\r
770 In the later case, *TokenNumber is updated with the value of 0.\r
771 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r
772\r
773**/\r
774EFI_STATUS\r
775EFIAPI\r
776PeiPcdGetNextToken (\r
777 IN CONST EFI_GUID *Guid OPTIONAL,\r
778 IN OUT UINTN *TokenNumber\r
779 );\r
780\r
781/**\r
782 Retrieves the next valid PCD token namespace for a given namespace.\r
783\r
784 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates\r
785 a known token namespace from which the search will start. On output,\r
786 it designates the next valid token namespace on the platform. If the input\r
787 token namespace does not exist on the platform, an error is returned and\r
788 the value of *Guid is undefined. If *Guid is NULL, then the GUID of the\r
789 first token space of the current platform is assigned to *Guid the function\r
790 return EFI_SUCCESS. If *Guid is NULL and there is no namespace exist in\r
791 the platform other than the default (NULL) tokennamespace, *Guid is unchanged\r
792 and the function return EFI_SUCCESS. If this input token namespace is the last\r
793 namespace on the platform, *Guid will be assigned to NULL and the function return\r
794 EFI_SUCCESS.\r
795\r
796 @retval EFI_SUCCESS The PCD service retrieved the next valid token space Guid.\r
797 Or the input token space Guid is already the last valid token space Guid\r
798 in the PCD database. In the later case, *Guid is updated with the value of NULL.\r
799 @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.\r
800\r
801**/\r
802EFI_STATUS\r
803EFIAPI\r
804PeiPcdGetNextTokenSpace (\r
805 IN OUT CONST EFI_GUID **Guid\r
806 );\r
807\r
808/**\r
809 Retrieve additional information associated with a PCD token.\r
810\r
811 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
812 human readable name that is associated with the token.\r
813\r
814 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
815 @param[in] TokenNumber The PCD token number.\r
816 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
817 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
818\r
819 @retval EFI_SUCCESS The PCD information was returned successfully\r
820 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
821**/\r
822EFI_STATUS\r
823PeiGetPcdInfo (\r
824 IN CONST EFI_GUID *Guid,\r
825 IN UINTN TokenNumber,\r
826 OUT EFI_PCD_INFO *PcdInfo\r
827 );\r
828\r
829/* Internal Function definitions */\r
830\r
831/**\r
832 Get PCD database from GUID HOB in PEI phase.\r
833\r
834 @return Pointer to PCD database.\r
835\r
836**/\r
837PEI_PCD_DATABASE *\r
838GetPcdDatabase (\r
839 VOID\r
840 );\r
841\r
842/**\r
843 Wrapper function for setting non-pointer type value for a PCD entry.\r
844\r
845 @param TokenNumber Pcd token number autogenerated by build tools.\r
846 @param Data Value want to be set for PCD entry\r
847 @param Size Size of value.\r
848\r
849 @return status of SetWorker.\r
850\r
851**/\r
852EFI_STATUS\r
853SetValueWorker (\r
854 IN UINTN TokenNumber,\r
855 IN VOID *Data,\r
856 IN UINTN Size\r
857 );\r
858\r
859/**\r
860 Set value for an PCD entry\r
861\r
862 @param TokenNumber Pcd token number autogenerated by build tools.\r
863 @param Data Value want to be set for PCD entry\r
864 @param Size Size of value.\r
865 @param PtrType If TRUE, the type of PCD entry's value is Pointer.\r
866 If False, the type of PCD entry's value is not Pointer.\r
867\r
868 @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set.\r
869 @retval EFI_INVALID_PARAMETER If Size can not be set to size table.\r
870 @retval EFI_INVALID_PARAMETER If Size of non-Ptr type PCD does not match the size information in PCD database.\r
871 @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in\r
872 range of UINT8, UINT16, UINT32, UINT64\r
873 @retval EFI_NOT_FOUND Can not find the PCD type according to token number.\r
874**/\r
875EFI_STATUS\r
876SetWorker (\r
877 IN UINTN TokenNumber,\r
878 IN VOID *Data,\r
879 IN OUT UINTN *Size,\r
880 IN BOOLEAN PtrType\r
881 );\r
882\r
883/**\r
884 Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.\r
885\r
886 @param ExTokenNumber Token number for dynamic-ex PCD.\r
887 @param Guid Token space guid for dynamic-ex PCD.\r
888 @param Data Value want to be set.\r
889 @param SetSize The size of value.\r
890\r
891 @return status of ExSetWorker().\r
892\r
893**/\r
894EFI_STATUS\r
895ExSetValueWorker (\r
896 IN UINTN ExTokenNumber,\r
897 IN CONST EFI_GUID *Guid,\r
898 IN VOID *Data,\r
899 IN UINTN Size\r
900 );\r
901\r
902/**\r
903 Set value for a dynamic PCD entry.\r
904\r
905 This routine find the local token number according to dynamic-ex PCD's token\r
906 space guid and token number firstly, and invoke callback function if this PCD\r
907 entry registered callback function. Finally, invoken general SetWorker to set\r
908 PCD value.\r
909\r
910 @param ExTokenNumber Dynamic-ex PCD token number.\r
911 @param Guid Token space guid for dynamic-ex PCD.\r
912 @param Data PCD value want to be set\r
913 @param SetSize Size of value.\r
914 @param PtrType If TRUE, this PCD entry is pointer type.\r
915 If FALSE, this PCD entry is not pointer type.\r
916\r
917 @return status of SetWorker().\r
918\r
919**/\r
920EFI_STATUS\r
921ExSetWorker (\r
922 IN UINTN ExTokenNumber,\r
923 IN CONST EFI_GUID *Guid,\r
924 IN VOID *Data,\r
925 IN OUT UINTN *Size,\r
926 IN BOOLEAN PtrType\r
927 );\r
928\r
929/**\r
930 Get the PCD entry pointer in PCD database.\r
931\r
932 This routine will visit PCD database to find the PCD entry according to given\r
933 token number. The given token number is autogened by build tools and it will be\r
934 translated to local token number. Local token number contains PCD's type and\r
935 offset of PCD entry in PCD database.\r
936\r
937 @param TokenNumber Token's number, it is autogened by build tools\r
938 @param GetSize The size of token's value\r
939\r
940 @return PCD entry pointer in PCD database\r
941\r
942**/\r
943VOID *\r
944GetWorker (\r
945 IN UINTN TokenNumber,\r
946 IN UINTN GetSize\r
947 );\r
948\r
949/**\r
950 Wrapper function for get PCD value for dynamic-ex PCD.\r
951\r
952 @param Guid Token space guid for dynamic-ex PCD.\r
953 @param ExTokenNumber Token number for dyanmic-ex PCD.\r
954 @param GetSize The size of dynamic-ex PCD value.\r
955\r
956 @return PCD entry in PCD database.\r
957\r
958**/\r
959VOID *\r
960ExGetWorker (\r
961 IN CONST EFI_GUID *Guid,\r
962 IN UINTN ExTokenNumber,\r
963 IN UINTN GetSize\r
964 );\r
965\r
966typedef struct {\r
967 UINTN TokenNumber;\r
968 UINTN Size;\r
969 UINT32 LocalTokenNumberAlias;\r
970} EX_PCD_ENTRY_ATTRIBUTE;\r
971\r
972/**\r
973 Get Token Number according to dynamic-ex PCD's {token space guid:token number}\r
974\r
975 A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
976 in DEC file. PCD database maintain a mapping table that translate pair of {token\r
977 space guid: token number} to Token Number.\r
978\r
979 @param Guid Token space guid for dynamic-ex PCD entry.\r
980 @param ExTokenNumber Token number for dynamic-ex PCD.\r
981\r
982 @return Token Number for dynamic-ex PCD.\r
983\r
984**/\r
985UINTN\r
986GetExPcdTokenNumber (\r
987 IN CONST EFI_GUID *Guid,\r
988 IN UINTN ExTokenNumber\r
989 );\r
990\r
991/**\r
992 The function registers the CallBackOnSet fucntion\r
993 according to TokenNumber and EFI_GUID space.\r
994\r
995 @param TokenNumber The token number.\r
996 @param Guid The GUID space.\r
997 @param CallBackFunction The Callback function to be registered.\r
998 @param Register To register or unregister the callback function.\r
999\r
1000 @retval EFI_SUCCESS If the Callback function is registered.\r
1001 @retval EFI_NOT_FOUND If the PCD Entry is not found according to Token Number and GUID space.\r
1002 @retval EFI_OUT_OF_RESOURCES If the callback function can't be registered because there is not free\r
1003 slot left in the CallbackFnTable.\r
1004**/\r
1005EFI_STATUS\r
1006PeiRegisterCallBackWorker (\r
1007 IN UINTN TokenNumber,\r
1008 IN CONST EFI_GUID *Guid OPTIONAL,\r
1009 IN PCD_PPI_CALLBACK CallBackFunction,\r
1010 IN BOOLEAN Register\r
1011 );\r
1012\r
1013/**\r
1014 The function builds the PCD database.\r
1015\r
1016 @param FileHandle Handle of the file the external PCD database binary located.\r
1017\r
1018 @return Pointer to PCD database.\r
1019\r
1020**/\r
1021PEI_PCD_DATABASE *\r
1022BuildPcdDatabase (\r
1023 IN EFI_PEI_FILE_HANDLE FileHandle\r
1024 );\r
1025\r
1026/**\r
1027 Get index of PCD entry in size table.\r
1028\r
1029 @param LocalTokenNumberTableIdx Index of this PCD in local token number table.\r
1030 @param Database Pointer to PCD database.\r
1031\r
1032 @return index of PCD entry in size table.\r
1033\r
1034**/\r
1035UINTN\r
1036GetSizeTableIndex (\r
1037 IN UINTN LocalTokenNumberTableIdx,\r
1038 IN PEI_PCD_DATABASE *Database\r
1039 );\r
1040\r
1041/**\r
1042 Get PCD value's size for POINTER type PCD.\r
1043\r
1044 The POINTER type PCD's value will be stored into a buffer in specificed size.\r
1045 The max size of this PCD's value is described in PCD's definition in DEC file.\r
1046\r
1047 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r
1048 @param MaxSize Maxmium size of PCD's value\r
1049 @param Database Pcd database in PEI phase.\r
1050\r
1051 @return PCD value's size for POINTER type PCD.\r
1052\r
1053**/\r
1054UINTN\r
1055GetPtrTypeSize (\r
1056 IN UINTN LocalTokenNumberTableIdx,\r
1057 OUT UINTN *MaxSize,\r
1058 IN PEI_PCD_DATABASE *Database\r
1059 );\r
1060\r
1061/**\r
1062 Set PCD value's size for POINTER type PCD.\r
1063\r
1064 The POINTER type PCD's value will be stored into a buffer in specificed size.\r
1065 The max size of this PCD's value is described in PCD's definition in DEC file.\r
1066\r
1067 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r
1068 @param CurrentSize Maxmium size of PCD's value\r
1069 @param Database Pcd database in PEI phase.\r
1070\r
1071 @retval TRUE Success to set PCD's value size, which is not exceed maxmium size\r
1072 @retval FALSE Fail to set PCD's value size, which maybe exceed maxmium size\r
1073\r
1074**/\r
1075BOOLEAN\r
1076SetPtrTypeSize (\r
1077 IN UINTN LocalTokenNumberTableIdx,\r
1078 IN OUT UINTN *CurrentSize,\r
1079 IN PEI_PCD_DATABASE *Database\r
1080 );\r
1081\r
1082#endif\r