]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/PCD/Dxe/Service.h
Enable PCD version check on PCD driver and PCD database.
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Dxe / Service.h
1 /** @file
2 Private functions used by PCD DXE driver.
3
4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _PCD_DXE_SERVICE_H_
16 #define _PCD_DXE_SERVICE_H_
17
18 #include <PiDxe.h>
19 #include <Guid/PcdDataBaseHobGuid.h>
20 #include <Protocol/Pcd.h>
21 #include <Protocol/PiPcd.h>
22 #include <Library/BaseLib.h>
23 #include <Library/DebugLib.h>
24 #include <Library/UefiLib.h>
25 #include <Library/UefiDriverEntryPoint.h>
26 #include <Library/PcdLib.h>
27 #include <Library/HobLib.h>
28 #include <Library/MemoryAllocationLib.h>
29 #include <Library/UefiBootServicesTableLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/UefiRuntimeServicesTableLib.h>
32
33 //
34 // Please make sure the PCD Serivce DXE Version is consistent with
35 // the version of the generated DXE PCD Database by build tool.
36 //
37 #define PCD_SERVICE_DXE_VERSION 2
38
39 //
40 // PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.
41 //
42 #if (PCD_SERVICE_DXE_VERSION != PCD_DXE_SERVICE_DRIVER_VERSION)
43 #error "Please make sure the version of PCD DXE Service and the generated PCD DXE Database match."
44 #endif
45
46 //
47 // Protocol Interface function declaration.
48 //
49 /**
50 Sets the SKU value for subsequent calls to set or get PCD token values.
51
52 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
53 SetSku() is normally called only once by the system.
54
55 For each item (token), the database can hold a single value that applies to all SKUs,
56 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
57 SKU-specific values are called SKU enabled.
58
59 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
60 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
61 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
62 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
63 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
64 set for that Id, the results are unpredictable.
65
66 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
67 set values associated with a PCD token.
68
69 **/
70 VOID
71 EFIAPI
72 DxePcdSetSku (
73 IN UINTN SkuId
74 );
75
76 /**
77 Retrieves an 8-bit value for a given PCD token.
78
79 Retrieves the current byte-sized value for a PCD token number.
80 If the TokenNumber is invalid, the results are unpredictable.
81
82 @param[in] TokenNumber The PCD token number.
83
84 @return The UINT8 value.
85
86 **/
87 UINT8
88 EFIAPI
89 DxePcdGet8 (
90 IN UINTN TokenNumber
91 );
92
93 /**
94 Retrieves an 16-bit value for a given PCD token.
95
96 Retrieves the current 16-bits value for a PCD token number.
97 If the TokenNumber is invalid, the results are unpredictable.
98
99 @param[in] TokenNumber The PCD token number.
100
101 @return The UINT16 value.
102
103 **/
104 UINT16
105 EFIAPI
106 DxePcdGet16 (
107 IN UINTN TokenNumber
108 );
109
110 /**
111 Retrieves an 32-bit value for a given PCD token.
112
113 Retrieves the current 32-bits value for a PCD token number.
114 If the TokenNumber is invalid, the results are unpredictable.
115
116 @param[in] TokenNumber The PCD token number.
117
118 @return The UINT32 value.
119
120 **/
121 UINT32
122 EFIAPI
123 DxePcdGet32 (
124 IN UINTN TokenNumber
125 );
126
127 /**
128 Retrieves an 64-bit value for a given PCD token.
129
130 Retrieves the current 64-bits value for a PCD token number.
131 If the TokenNumber is invalid, the results are unpredictable.
132
133 @param[in] TokenNumber The PCD token number.
134
135 @return The UINT64 value.
136
137 **/
138 UINT64
139 EFIAPI
140 DxePcdGet64 (
141 IN UINTN TokenNumber
142 );
143
144 /**
145 Retrieves a pointer to a value for a given PCD token.
146
147 Retrieves the current pointer to the buffer for a PCD token number.
148 Do not make any assumptions about the alignment of the pointer that
149 is returned by this function call. If the TokenNumber is invalid,
150 the results are unpredictable.
151
152 @param[in] TokenNumber The PCD token number.
153
154 @return The pointer to the buffer to be retrieved.
155
156 **/
157 VOID *
158 EFIAPI
159 DxePcdGetPtr (
160 IN UINTN TokenNumber
161 );
162
163 /**
164 Retrieves a Boolean value for a given PCD token.
165
166 Retrieves the current boolean value for a PCD token number.
167 Do not make any assumptions about the alignment of the pointer that
168 is returned by this function call. If the TokenNumber is invalid,
169 the results are unpredictable.
170
171 @param[in] TokenNumber The PCD token number.
172
173 @return The Boolean value.
174
175 **/
176 BOOLEAN
177 EFIAPI
178 DxePcdGetBool (
179 IN UINTN TokenNumber
180 );
181
182 /**
183 Retrieves the size of the value for a given PCD token.
184
185 Retrieves the current size of a particular PCD token.
186 If the TokenNumber is invalid, the results are unpredictable.
187
188 @param[in] TokenNumber The PCD token number.
189
190 @return The size of the value for the PCD token.
191
192 **/
193 UINTN
194 EFIAPI
195 DxePcdGetSize (
196 IN UINTN TokenNumber
197 );
198
199 /**
200 Retrieves an 8-bit value for a given PCD token.
201
202 Retrieves the 8-bit value of a particular PCD token.
203 If the TokenNumber is invalid or the token space
204 specified by Guid does not exist, the results are
205 unpredictable.
206
207 @param[in] Guid The token space for the token number.
208 @param[in] TokenNumber The PCD token number.
209
210 @return The size 8-bit value for the PCD token.
211
212 **/
213 UINT8
214 EFIAPI
215 DxePcdGet8Ex (
216 IN CONST EFI_GUID *Guid,
217 IN UINTN TokenNumber
218 );
219
220 /**
221 Retrieves an 16-bit value for a given PCD token.
222
223 Retrieves the 16-bit value of a particular PCD token.
224 If the TokenNumber is invalid or the token space
225 specified by Guid does not exist, the results are
226 unpredictable.
227
228 @param[in] Guid The token space for the token number.
229 @param[in] TokenNumber The PCD token number.
230
231 @return The size 16-bit value for the PCD token.
232
233 **/
234 UINT16
235 EFIAPI
236 DxePcdGet16Ex (
237 IN CONST EFI_GUID *Guid,
238 IN UINTN TokenNumber
239 );
240
241 /**
242 Retrieves an 32-bit value for a given PCD token.
243
244 Retrieves the 32-bit value of a particular PCD token.
245 If the TokenNumber is invalid or the token space
246 specified by Guid does not exist, the results are
247 unpredictable.
248
249 @param[in] Guid The token space for the token number.
250 @param[in] TokenNumber The PCD token number.
251
252 @return The size 32-bit value for the PCD token.
253
254 **/
255 UINT32
256 EFIAPI
257 DxePcdGet32Ex (
258 IN CONST EFI_GUID *Guid,
259 IN UINTN TokenNumber
260 );
261
262 /**
263 Retrieves an 64-bit value for a given PCD token.
264
265 Retrieves the 64-bit value of a particular PCD token.
266 If the TokenNumber is invalid or the token space
267 specified by Guid does not exist, the results are
268 unpredictable.
269
270 @param[in] Guid The token space for the token number.
271 @param[in] TokenNumber The PCD token number.
272
273 @return The size 64-bit value for the PCD token.
274
275 **/
276 UINT64
277 EFIAPI
278 DxePcdGet64Ex (
279 IN CONST EFI_GUID *Guid,
280 IN UINTN TokenNumber
281 );
282
283 /**
284 Retrieves a pointer to a value for a given PCD token.
285
286 Retrieves the current pointer to the buffer for a PCD token number.
287 Do not make any assumptions about the alignment of the pointer that
288 is returned by this function call. If the TokenNumber is invalid,
289 the results are unpredictable.
290
291 @param[in] Guid The token space for the token number.
292 @param[in] TokenNumber The PCD token number.
293
294 @return The pointer to the buffer to be retrieved.
295
296 **/
297 VOID *
298 EFIAPI
299 DxePcdGetPtrEx (
300 IN CONST EFI_GUID *Guid,
301 IN UINTN TokenNumber
302 );
303
304 /**
305 Retrieves an Boolean value for a given PCD token.
306
307 Retrieves the Boolean value of a particular PCD token.
308 If the TokenNumber is invalid or the token space
309 specified by Guid does not exist, the results are
310 unpredictable.
311
312 @param[in] Guid The token space for the token number.
313 @param[in] TokenNumber The PCD token number.
314
315 @return The size Boolean value for the PCD token.
316
317 **/
318 BOOLEAN
319 EFIAPI
320 DxePcdGetBoolEx (
321 IN CONST EFI_GUID *Guid,
322 IN UINTN TokenNumber
323 );
324
325 /**
326 Retrieves the size of the value for a given PCD token.
327
328 Retrieves the current size of a particular PCD token.
329 If the TokenNumber is invalid, the results are unpredictable.
330
331 @param[in] Guid The token space for the token number.
332 @param[in] TokenNumber The PCD token number.
333
334 @return The size of the value for the PCD token.
335
336 **/
337 UINTN
338 EFIAPI
339 DxePcdGetSizeEx (
340 IN CONST EFI_GUID *Guid,
341 IN UINTN TokenNumber
342 );
343
344 /**
345 Sets an 8-bit value for a given PCD token.
346
347 When the PCD service sets a value, it will check to ensure that the
348 size of the value being set is compatible with the Token's existing definition.
349 If it is not, an error will be returned.
350
351 @param[in] TokenNumber The PCD token number.
352 @param[in] Value The value to set for the PCD token.
353
354 @retval EFI_SUCCESS Procedure returned successfully.
355 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
356 being set was incompatible with a call to this function.
357 Use GetSize() to retrieve the size of the target data.
358 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
359
360 **/
361 EFI_STATUS
362 EFIAPI
363 DxePcdSet8 (
364 IN UINTN TokenNumber,
365 IN UINT8 Value
366 );
367
368 /**
369 Sets an 16-bit value for a given PCD token.
370
371 When the PCD service sets a value, it will check to ensure that the
372 size of the value being set is compatible with the Token's existing definition.
373 If it is not, an error will be returned.
374
375 @param[in] TokenNumber The PCD token number.
376 @param[in] Value The value to set for the PCD token.
377
378 @retval EFI_SUCCESS Procedure returned successfully.
379 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
380 being set was incompatible with a call to this function.
381 Use GetSize() to retrieve the size of the target data.
382 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
383
384 **/
385 EFI_STATUS
386 EFIAPI
387 DxePcdSet16 (
388 IN UINTN TokenNumber,
389 IN UINT16 Value
390 );
391
392 /**
393 Sets an 32-bit value for a given PCD token.
394
395 When the PCD service sets a value, it will check to ensure that the
396 size of the value being set is compatible with the Token's existing definition.
397 If it is not, an error will be returned.
398
399 @param[in] TokenNumber The PCD token number.
400 @param[in] Value The value to set for the PCD token.
401
402 @retval EFI_SUCCESS Procedure returned successfully.
403 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
404 being set was incompatible with a call to this function.
405 Use GetSize() to retrieve the size of the target data.
406 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
407
408 **/
409 EFI_STATUS
410 EFIAPI
411 DxePcdSet32 (
412 IN UINTN TokenNumber,
413 IN UINT32 Value
414 );
415
416 /**
417 Sets an 64-bit value for a given PCD token.
418
419 When the PCD service sets a value, it will check to ensure that the
420 size of the value being set is compatible with the Token's existing definition.
421 If it is not, an error will be returned.
422
423 @param[in] TokenNumber The PCD token number.
424 @param[in] Value The value to set for the PCD token.
425
426 @retval EFI_SUCCESS Procedure returned successfully.
427 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
428 being set was incompatible with a call to this function.
429 Use GetSize() to retrieve the size of the target data.
430 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
431
432 **/
433 EFI_STATUS
434 EFIAPI
435 DxePcdSet64 (
436 IN UINTN TokenNumber,
437 IN UINT64 Value
438 );
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 DxePcdSetPtr (
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 DxePcdSetBool (
490 IN UINTN TokenNumber,
491 IN BOOLEAN Value
492 );
493
494
495 /**
496 Sets an 8-bit value for a given PCD token.
497
498 When the PCD service sets a value, it will check to ensure that the
499 size of the value being set is compatible with the Token's existing definition.
500 If it is not, an error will be returned.
501
502 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
503 @param[in] TokenNumber The PCD token number.
504 @param[in] Value The value to set for the PCD token.
505
506 @retval EFI_SUCCESS Procedure returned successfully.
507 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
508 being set was incompatible with a call to this function.
509 Use GetSize() to retrieve the size of the target data.
510 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
511
512 **/
513 EFI_STATUS
514 EFIAPI
515 DxePcdSet8Ex (
516 IN CONST EFI_GUID *Guid,
517 IN UINTN TokenNumber,
518 IN UINT8 Value
519 );
520
521 /**
522 Sets an 16-bit value for a given PCD token.
523
524 When the PCD service sets a value, it will check to ensure that the
525 size of the value being set is compatible with the Token's existing definition.
526 If it is not, an error will be returned.
527
528 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
529 @param[in] TokenNumber The PCD token number.
530 @param[in] Value The value to set for the PCD token.
531
532 @retval EFI_SUCCESS Procedure returned successfully.
533 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
534 being set was incompatible with a call to this function.
535 Use GetSize() to retrieve the size of the target data.
536 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
537
538 **/
539 EFI_STATUS
540 EFIAPI
541 DxePcdSet16Ex (
542 IN CONST EFI_GUID *Guid,
543 IN UINTN TokenNumber,
544 IN UINT16 Value
545 );
546
547 /**
548 Sets an 32-bit value for a given PCD token.
549
550 When the PCD service sets a value, it will check to ensure that the
551 size of the value being set is compatible with the Token's existing definition.
552 If it is not, an error will be returned.
553
554 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
555 @param[in] TokenNumber The PCD token number.
556 @param[in] Value The value to set for the PCD token.
557
558 @retval EFI_SUCCESS Procedure returned successfully.
559 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
560 being set was incompatible with a call to this function.
561 Use GetSize() to retrieve the size of the target data.
562 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
563
564 **/
565 EFI_STATUS
566 EFIAPI
567 DxePcdSet32Ex (
568 IN CONST EFI_GUID *Guid,
569 IN UINTN TokenNumber,
570 IN UINT32 Value
571 );
572
573 /**
574 Sets an 64-bit value for a given PCD token.
575
576 When the PCD service sets a value, it will check to ensure that the
577 size of the value being set is compatible with the Token's existing definition.
578 If it is not, an error will be returned.
579
580 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
581 @param[in] TokenNumber The PCD token number.
582 @param[in] Value The value to set for the PCD token.
583
584 @retval EFI_SUCCESS Procedure returned successfully.
585 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
586 being set was incompatible with a call to this function.
587 Use GetSize() to retrieve the size of the target data.
588 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
589
590 **/
591 EFI_STATUS
592 EFIAPI
593 DxePcdSet64Ex (
594 IN CONST EFI_GUID *Guid,
595 IN UINTN TokenNumber,
596 IN UINT64 Value
597 );
598
599 /**
600 Sets a value of a specified size for a given PCD token.
601
602 When the PCD service sets a value, it will check to ensure that the
603 size of the value being set is compatible with the Token's existing definition.
604 If it is not, an error will be returned.
605
606 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
607 @param[in] TokenNumber The PCD token number.
608 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
609 On input, if the SizeOfValue is greater than the maximum size supported
610 for this TokenNumber then the output value of SizeOfValue will reflect
611 the maximum size supported for this TokenNumber.
612 @param[in] Buffer The buffer to set for the PCD token.
613
614 @retval EFI_SUCCESS Procedure returned successfully.
615 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
616 being set was incompatible with a call to this function.
617 Use GetSize() to retrieve the size of the target data.
618 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
619
620 **/
621 EFI_STATUS
622 EFIAPI
623 DxePcdSetPtrEx (
624 IN CONST EFI_GUID *Guid,
625 IN UINTN TokenNumber,
626 IN OUT UINTN *SizeOfBuffer,
627 IN VOID *Buffer
628 );
629
630 /**
631 Sets an Boolean value for a given PCD token.
632
633 When the PCD service sets a value, it will check to ensure that the
634 size of the value being set is compatible with the Token's existing definition.
635 If it is not, an error will be returned.
636
637 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
638 @param[in] TokenNumber The PCD token number.
639 @param[in] Value The value to set for the PCD token.
640
641 @retval EFI_SUCCESS Procedure returned successfully.
642 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
643 being set was incompatible with a call to this function.
644 Use GetSize() to retrieve the size of the target data.
645 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
646
647 **/
648 EFI_STATUS
649 EFIAPI
650 DxePcdSetBoolEx (
651 IN CONST EFI_GUID *Guid,
652 IN UINTN TokenNumber,
653 IN BOOLEAN Value
654 );
655
656 /**
657 Specifies a function to be called anytime the value of a designated token is changed.
658
659 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
660 @param[in] TokenNumber The PCD token number.
661 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
662
663 @retval EFI_SUCCESS The PCD service has successfully established a call event
664 for the CallBackToken requested.
665 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
666
667 **/
668 EFI_STATUS
669 EFIAPI
670 DxeRegisterCallBackOnSet (
671 IN CONST EFI_GUID *Guid, OPTIONAL
672 IN UINTN TokenNumber,
673 IN PCD_PROTOCOL_CALLBACK CallBackFunction
674 );
675
676 /**
677 Cancels a previously set callback function for a particular PCD token number.
678
679 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
680 @param[in] TokenNumber The PCD token number.
681 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
682
683 @retval EFI_SUCCESS The PCD service has successfully established a call event
684 for the CallBackToken requested.
685 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
686
687 **/
688 EFI_STATUS
689 EFIAPI
690 DxeUnRegisterCallBackOnSet (
691 IN CONST EFI_GUID *Guid, OPTIONAL
692 IN UINTN TokenNumber,
693 IN PCD_PROTOCOL_CALLBACK CallBackFunction
694 );
695
696 /**
697 Retrieves the next valid token number in a given namespace.
698
699 This is useful since the PCD infrastructure contains a sparse list of token numbers,
700 and one cannot a priori know what token numbers are valid in the database.
701
702 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
703 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
704 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
705 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
706 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
707 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
708 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
709 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
710
711
712 @param[in] Guid The 128-bit unique value that designates the namespace from which to retrieve the next token.
713 This is an optional parameter that may be NULL. If this parameter is NULL, then a request is
714 being made to retrieve tokens from the default token space.
715 @param[in, out] TokenNumber
716 A pointer to the PCD token number to use to find the subsequent token number.
717
718 @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number
719 is already the last valid token number in the PCD database.
720 In the later case, *TokenNumber is updated with the value of 0.
721 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
722
723 **/
724 EFI_STATUS
725 EFIAPI
726 DxePcdGetNextToken (
727 IN CONST EFI_GUID *Guid, OPTIONAL
728 IN OUT UINTN *TokenNumber
729 );
730
731 /**
732 Get next token space in PCD database according to given token space guid.
733
734 @param Guid Given token space guid. If NULL, then Guid will be set to
735 the first PCD token space in PCD database, If not NULL, then
736 Guid will be set to next PCD token space.
737
738 @retval EFI_NOT_FOUND If PCD database has no token space table or can not find given
739 token space in PCD database.
740 @retval EFI_SUCCESS Success to get next token space guid.
741 **/
742 EFI_STATUS
743 EFIAPI
744 DxePcdGetNextTokenSpace (
745 IN OUT CONST EFI_GUID **Guid
746 );
747
748 typedef struct {
749 LIST_ENTRY Node;
750 PCD_PROTOCOL_CALLBACK CallbackFn;
751 } CALLBACK_FN_ENTRY;
752
753 #define CR_FNENTRY_FROM_LISTNODE(Record, Type, Field) BASE_CR(Record, Type, Field)
754
755 //
756 // Internal Functions
757 //
758
759 /**
760 Wrapper function for setting non-pointer type value for a PCD entry.
761
762 @param TokenNumber Pcd token number autogenerated by build tools.
763 @param Data Value want to be set for PCD entry
764 @param Size Size of value.
765
766 @return status of SetWorker.
767
768 **/
769 EFI_STATUS
770 SetValueWorker (
771 IN UINTN TokenNumber,
772 IN VOID *Data,
773 IN UINTN Size
774 );
775
776 /**
777 Set value for an PCD entry
778
779 @param TokenNumber Pcd token number autogenerated by build tools.
780 @param Data Value want to be set for PCD entry
781 @param Size Size of value.
782 @param PtrType If TRUE, the type of PCD entry's value is Pointer.
783 If False, the type of PCD entry's value is not Pointer.
784
785 @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set.
786 @retval EFI_INVALID_PARAMETER If Size can not be set to size table.
787 @retval EFI_INVALID_PARAMETER If Size of non-Ptr type PCD does not match the size information in PCD database.
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 SetSize
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 dynamic-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 /**
884 Find the local token number according to system SKU ID.
885
886 @param LocalTokenNumber PCD token number
887 @param Size The size of PCD entry.
888 @param IsPeiDb If TRUE, the PCD entry is initialized in PEI phase.
889 If False, the PCD entry is initialized in DXE phase.
890
891 @return Token number according to system SKU ID.
892
893 **/
894 UINT32
895 GetSkuEnabledTokenNumber (
896 UINT32 LocalTokenNumber,
897 UINTN Size,
898 BOOLEAN IsPeiDb
899 );
900
901 /**
902 Get Variable which contains HII type PCD entry.
903
904 @param VariableGuid Variable's guid
905 @param VariableName Variable's unicode name string
906 @param VariableData Variable's data pointer,
907 @param VariableSize Variable's size.
908
909 @return the status of gRT->GetVariable
910 **/
911 EFI_STATUS
912 GetHiiVariable (
913 IN EFI_GUID *VariableGuid,
914 IN UINT16 *VariableName,
915 OUT UINT8 **VariableData,
916 OUT UINTN *VariableSize
917 );
918
919 /**
920 Set value for HII-type PCD.
921
922 A HII-type PCD's value is stored in a variable. Setting/Getting the value of
923 HII-type PCD is to visit this variable.
924
925 @param VariableGuid Guid of variable which stored value of a HII-type PCD.
926 @param VariableName Unicode name of variable which stored value of a HII-type PCD.
927 @param Data Value want to be set.
928 @param DataSize Size of value
929 @param Offset Value offset of HII-type PCD in variable.
930
931 @return status of GetVariable()/SetVariable().
932
933 **/
934 EFI_STATUS
935 SetHiiVariable (
936 IN EFI_GUID *VariableGuid,
937 IN UINT16 *VariableName,
938 IN CONST VOID *Data,
939 IN UINTN DataSize,
940 IN UINTN Offset
941 );
942
943 /**
944 Register the callback function for a PCD entry.
945
946 This routine will register a callback function to a PCD entry by given token number
947 and token space guid.
948
949 @param TokenNumber PCD token's number, it is autogened by build tools.
950 @param Guid PCD token space's guid,
951 if not NULL, this PCD is dynamicEx type PCD.
952 @param CallBackFunction Callback function pointer
953
954 @return EFI_SUCCESS Always success for registering callback function.
955
956 **/
957 EFI_STATUS
958 DxeRegisterCallBackWorker (
959 IN UINTN TokenNumber,
960 IN CONST EFI_GUID *Guid, OPTIONAL
961 IN PCD_PROTOCOL_CALLBACK CallBackFunction
962 );
963
964 /**
965 UnRegister the callback function for a PCD entry.
966
967 This routine will unregister a callback function to a PCD entry by given token number
968 and token space guid.
969
970 @param TokenNumber PCD token's number, it is autogened by build tools.
971 @param Guid PCD token space's guid.
972 if not NULL, this PCD is dynamicEx type PCD.
973 @param CallBackFunction Callback function pointer
974
975 @retval EFI_SUCCESS Callback function is success to be unregister.
976 @retval EFI_INVALID_PARAMETER Can not find the PCD entry by given token number.
977 **/
978 EFI_STATUS
979 DxeUnRegisterCallBackWorker (
980 IN UINTN TokenNumber,
981 IN CONST EFI_GUID *Guid, OPTIONAL
982 IN PCD_PROTOCOL_CALLBACK CallBackFunction
983 );
984
985 /**
986 Initialize the PCD database in DXE phase.
987
988 PCD database in DXE phase also contains PCD database in PEI phase which is copied
989 from GUID Hob.
990
991 **/
992 VOID
993 BuildPcdDxeDataBase (
994 VOID
995 );
996
997 /**
998 Get local token number according to dynamic-ex PCD's {token space guid:token number}
999
1000 A dynamic-ex type PCD, developer must provide pair of token space guid: token number
1001 in DEC file. PCD database maintain a mapping table that translate pair of {token
1002 space guid: token number} to local token number.
1003
1004 @param Guid Token space guid for dynamic-ex PCD entry.
1005 @param ExTokenNumber Dynamic-ex PCD token number.
1006
1007 @return local token number for dynamic-ex PCD.
1008
1009 **/
1010 UINTN
1011 GetExPcdTokenNumber (
1012 IN CONST EFI_GUID *Guid,
1013 IN UINT32 ExTokenNumber
1014 );
1015
1016 /**
1017 Get next token number in given token space.
1018
1019 This routine is used for dynamicEx type PCD. It will firstly scan token space
1020 table to get token space according to given token space guid. Then scan given
1021 token number in found token space, if found, then return next token number in
1022 this token space.
1023
1024 @param Guid Token space guid. Next token number will be scaned in
1025 this token space.
1026 @param TokenNumber Token number.
1027 If PCD_INVALID_TOKEN_NUMBER, return first token number in
1028 token space table.
1029 If not PCD_INVALID_TOKEN_NUMBER, return next token number
1030 in token space table.
1031 @param GuidTable Token space guid table. It will be used for scan token space
1032 by given token space guid.
1033 @param SizeOfGuidTable The size of guid table.
1034 @param ExMapTable DynamicEx token number mapping table.
1035 @param SizeOfExMapTable The size of dynamicEx token number mapping table.
1036
1037 @retval EFI_NOT_FOUND Can not given token space or token number.
1038 @retval EFI_SUCCESS Success to get next token number.
1039
1040 **/
1041 EFI_STATUS
1042 ExGetNextTokeNumber (
1043 IN CONST EFI_GUID *Guid,
1044 IN OUT UINTN *TokenNumber,
1045 IN EFI_GUID *GuidTable,
1046 IN UINTN SizeOfGuidTable,
1047 IN DYNAMICEX_MAPPING *ExMapTable,
1048 IN UINTN SizeOfExMapTable
1049 );
1050
1051 /**
1052 Get size of POINTER type PCD value.
1053
1054 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1055 @param MaxSize Maximum size of POINTER type PCD value.
1056
1057 @return size of POINTER type PCD value.
1058
1059 **/
1060 UINTN
1061 GetPtrTypeSize (
1062 IN UINTN LocalTokenNumberTableIdx,
1063 OUT UINTN *MaxSize
1064 );
1065
1066 /**
1067 Set size of POINTER type PCD value. The size should not exceed the maximum size
1068 of this PCD value.
1069
1070 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1071 @param CurrentSize Size of POINTER type PCD value.
1072
1073 @retval TRUE Success to set size of PCD value.
1074 @retval FALSE Fail to set size of PCD value.
1075 **/
1076 BOOLEAN
1077 SetPtrTypeSize (
1078 IN UINTN LocalTokenNumberTableIdx,
1079 IN OUT UINTN *CurrentSize
1080 );
1081
1082 extern PCD_DATABASE * mPcdDatabase;
1083
1084 extern DXE_PCD_DATABASE_INIT gDXEPcdDbInit;
1085
1086 extern EFI_LOCK mPcdDatabaseLock;
1087
1088 #endif
1089