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