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