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