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