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