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