]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/PCD/Dxe/Service.h
MdePkg and MdeModulePkg Pcd: Implement PCD Driver for External PCD Database and SKU...
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Dxe / Service.h
1 /** @file
2 Private functions used by PCD DXE driver.
3
4 Copyright (c) 2006 - 2013, 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 <Guid/PcdDataBaseSignatureGuid.h>
21 #include <Protocol/Pcd.h>
22 #include <Protocol/PiPcd.h>
23 #include <Library/BaseLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/UefiLib.h>
26 #include <Library/UefiDriverEntryPoint.h>
27 #include <Library/PcdLib.h>
28 #include <Library/HobLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/UefiRuntimeServicesTableLib.h>
33
34 //
35 // Please make sure the PCD Serivce DXE Version is consistent with
36 // the version of the generated DXE PCD Database by build tool.
37 //
38 #define PCD_SERVICE_DXE_VERSION 4
39
40 //
41 // PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.
42 //
43 #if (PCD_SERVICE_DXE_VERSION != PCD_DXE_SERVICE_DRIVER_VERSION)
44 #error "Please make sure the version of PCD DXE Service and the generated PCD DXE Database match."
45 #endif
46
47 //
48 // Protocol Interface function declaration.
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 DxePcdSetSku (
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 DxePcdGet8 (
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 DxePcdGet16 (
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 DxePcdGet32 (
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 DxePcdGet64 (
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 retrieved.
156
157 **/
158 VOID *
159 EFIAPI
160 DxePcdGetPtr (
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 DxePcdGetBool (
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 DxePcdGetSize (
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 DxePcdGet8Ex (
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 DxePcdGet16Ex (
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 DxePcdGet32Ex (
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 DxePcdGet64Ex (
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 retrieved.
296
297 **/
298 VOID *
299 EFIAPI
300 DxePcdGetPtrEx (
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 DxePcdGetBoolEx (
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 DxePcdGetSizeEx (
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 DxePcdSet8 (
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 DxePcdSet16 (
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 DxePcdSet32 (
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 DxePcdSet64 (
437 IN UINTN TokenNumber,
438 IN UINT64 Value
439 );
440
441
442 /**
443 Sets a value of a specified size for a given PCD token.
444
445 When the PCD service sets a value, it will check to ensure that the
446 size of the value being set is compatible with the Token's existing definition.
447 If it is not, an error will be returned.
448
449 @param[in] TokenNumber The PCD token number.
450 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
451 On input, if the SizeOfValue is greater than the maximum size supported
452 for this TokenNumber then the output value of SizeOfValue will reflect
453 the maximum size supported for this TokenNumber.
454 @param[in] Buffer The buffer to set for the PCD token.
455
456 @retval EFI_SUCCESS Procedure returned successfully.
457 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
458 being set was incompatible with a call to this function.
459 Use GetSize() to retrieve the size of the target data.
460 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
461
462 **/
463 EFI_STATUS
464 EFIAPI
465 DxePcdSetPtr (
466 IN UINTN TokenNumber,
467 IN OUT UINTN *SizeOfBuffer,
468 IN VOID *Buffer
469 );
470
471 /**
472 Sets an Boolean value for a given PCD token.
473
474 When the PCD service sets a value, it will check to ensure that the
475 size of the value being set is compatible with the Token's existing definition.
476 If it is not, an error will be returned.
477
478 @param[in] TokenNumber The PCD token number.
479 @param[in] Value The value to set for the PCD token.
480
481 @retval EFI_SUCCESS Procedure returned successfully.
482 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
483 being set was incompatible with a call to this function.
484 Use GetSize() to retrieve the size of the target data.
485 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
486
487 **/
488 EFI_STATUS
489 EFIAPI
490 DxePcdSetBool (
491 IN UINTN TokenNumber,
492 IN BOOLEAN Value
493 );
494
495
496 /**
497 Sets an 8-bit value for a given PCD token.
498
499 When the PCD service sets a value, it will check to ensure that the
500 size of the value being set is compatible with the Token's existing definition.
501 If it is not, an error will be returned.
502
503 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
504 @param[in] TokenNumber The PCD token number.
505 @param[in] Value The value to set for the PCD token.
506
507 @retval EFI_SUCCESS Procedure returned successfully.
508 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
509 being set was incompatible with a call to this function.
510 Use GetSize() to retrieve the size of the target data.
511 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
512
513 **/
514 EFI_STATUS
515 EFIAPI
516 DxePcdSet8Ex (
517 IN CONST EFI_GUID *Guid,
518 IN UINTN TokenNumber,
519 IN UINT8 Value
520 );
521
522 /**
523 Sets an 16-bit value for a given PCD token.
524
525 When the PCD service sets a value, it will check to ensure that the
526 size of the value being set is compatible with the Token's existing definition.
527 If it is not, an error will be returned.
528
529 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
530 @param[in] TokenNumber The PCD token number.
531 @param[in] Value The value to set for the PCD token.
532
533 @retval EFI_SUCCESS Procedure returned successfully.
534 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
535 being set was incompatible with a call to this function.
536 Use GetSize() to retrieve the size of the target data.
537 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
538
539 **/
540 EFI_STATUS
541 EFIAPI
542 DxePcdSet16Ex (
543 IN CONST EFI_GUID *Guid,
544 IN UINTN TokenNumber,
545 IN UINT16 Value
546 );
547
548 /**
549 Sets an 32-bit value for a given PCD token.
550
551 When the PCD service sets a value, it will check to ensure that the
552 size of the value being set is compatible with the Token's existing definition.
553 If it is not, an error will be returned.
554
555 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
556 @param[in] TokenNumber The PCD token number.
557 @param[in] Value The value to set for the PCD token.
558
559 @retval EFI_SUCCESS Procedure returned successfully.
560 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
561 being set was incompatible with a call to this function.
562 Use GetSize() to retrieve the size of the target data.
563 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
564
565 **/
566 EFI_STATUS
567 EFIAPI
568 DxePcdSet32Ex (
569 IN CONST EFI_GUID *Guid,
570 IN UINTN TokenNumber,
571 IN UINT32 Value
572 );
573
574 /**
575 Sets an 64-bit value for a given PCD token.
576
577 When the PCD service sets a value, it will check to ensure that the
578 size of the value being set is compatible with the Token's existing definition.
579 If it is not, an error will be returned.
580
581 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
582 @param[in] TokenNumber The PCD token number.
583 @param[in] Value The value to set for the PCD token.
584
585 @retval EFI_SUCCESS Procedure returned successfully.
586 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
587 being set was incompatible with a call to this function.
588 Use GetSize() to retrieve the size of the target data.
589 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
590
591 **/
592 EFI_STATUS
593 EFIAPI
594 DxePcdSet64Ex (
595 IN CONST EFI_GUID *Guid,
596 IN UINTN TokenNumber,
597 IN UINT64 Value
598 );
599
600 /**
601 Sets a value of a specified size for a given PCD token.
602
603 When the PCD service sets a value, it will check to ensure that the
604 size of the value being set is compatible with the Token's existing definition.
605 If it is not, an error will be returned.
606
607 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
608 @param[in] TokenNumber The PCD token number.
609 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
610 On input, if the SizeOfValue is greater than the maximum size supported
611 for this TokenNumber then the output value of SizeOfValue will reflect
612 the maximum size supported for this TokenNumber.
613 @param[in] Buffer The buffer to set for the PCD token.
614
615 @retval EFI_SUCCESS Procedure returned successfully.
616 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
617 being set was incompatible with a call to this function.
618 Use GetSize() to retrieve the size of the target data.
619 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
620
621 **/
622 EFI_STATUS
623 EFIAPI
624 DxePcdSetPtrEx (
625 IN CONST EFI_GUID *Guid,
626 IN UINTN TokenNumber,
627 IN OUT UINTN *SizeOfBuffer,
628 IN VOID *Buffer
629 );
630
631 /**
632 Sets an Boolean value for a given PCD token.
633
634 When the PCD service sets a value, it will check to ensure that the
635 size of the value being set is compatible with the Token's existing definition.
636 If it is not, an error will be returned.
637
638 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
639 @param[in] TokenNumber The PCD token number.
640 @param[in] Value The value to set for the PCD token.
641
642 @retval EFI_SUCCESS Procedure returned successfully.
643 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
644 being set was incompatible with a call to this function.
645 Use GetSize() to retrieve the size of the target data.
646 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
647
648 **/
649 EFI_STATUS
650 EFIAPI
651 DxePcdSetBoolEx (
652 IN CONST EFI_GUID *Guid,
653 IN UINTN TokenNumber,
654 IN BOOLEAN Value
655 );
656
657 /**
658 Specifies a function to be called anytime the value of a designated token is changed.
659
660 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
661 @param[in] TokenNumber The PCD token number.
662 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
663
664 @retval EFI_SUCCESS The PCD service has successfully established a call event
665 for the CallBackToken requested.
666 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
667
668 **/
669 EFI_STATUS
670 EFIAPI
671 DxeRegisterCallBackOnSet (
672 IN CONST EFI_GUID *Guid, OPTIONAL
673 IN UINTN TokenNumber,
674 IN PCD_PROTOCOL_CALLBACK CallBackFunction
675 );
676
677 /**
678 Cancels a previously set callback function for a particular PCD token number.
679
680 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
681 @param[in] TokenNumber The PCD token number.
682 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
683
684 @retval EFI_SUCCESS The PCD service has successfully established a call event
685 for the CallBackToken requested.
686 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
687
688 **/
689 EFI_STATUS
690 EFIAPI
691 DxeUnRegisterCallBackOnSet (
692 IN CONST EFI_GUID *Guid, OPTIONAL
693 IN UINTN TokenNumber,
694 IN PCD_PROTOCOL_CALLBACK CallBackFunction
695 );
696
697 /**
698 Retrieves the next valid token number in a given namespace.
699
700 This is useful since the PCD infrastructure contains a sparse list of token numbers,
701 and one cannot a priori know what token numbers are valid in the database.
702
703 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
704 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
705 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
706 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
707 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
708 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
709 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
710 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
711
712
713 @param[in] Guid The 128-bit unique value that designates the namespace from which to retrieve the next token.
714 This is an optional parameter that may be NULL. If this parameter is NULL, then a request is
715 being made to retrieve tokens from the default token space.
716 @param[in, out] TokenNumber
717 A pointer to the PCD token number to use to find the subsequent token number.
718
719 @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number
720 is already the last valid token number in the PCD database.
721 In the later case, *TokenNumber is updated with the value of 0.
722 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
723
724 **/
725 EFI_STATUS
726 EFIAPI
727 DxePcdGetNextToken (
728 IN CONST EFI_GUID *Guid, OPTIONAL
729 IN OUT UINTN *TokenNumber
730 );
731
732 /**
733 Get next token space in PCD database according to given token space guid.
734
735 @param Guid Given token space guid. If NULL, then Guid will be set to
736 the first PCD token space in PCD database, If not NULL, then
737 Guid will be set to next PCD token space.
738
739 @retval EFI_NOT_FOUND If PCD database has no token space table or can not find given
740 token space in PCD database.
741 @retval EFI_SUCCESS Success to get next token space guid.
742 **/
743 EFI_STATUS
744 EFIAPI
745 DxePcdGetNextTokenSpace (
746 IN OUT CONST EFI_GUID **Guid
747 );
748
749 typedef struct {
750 LIST_ENTRY Node;
751 PCD_PROTOCOL_CALLBACK CallbackFn;
752 } CALLBACK_FN_ENTRY;
753
754 #define CR_FNENTRY_FROM_LISTNODE(Record, Type, Field) BASE_CR(Record, Type, Field)
755
756 //
757 // Internal Functions
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_INVALID_PARAMETER If Size of non-Ptr type PCD does not match the size information in PCD database.
789 @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in
790 range of UINT8, UINT16, UINT32, UINT64
791 @retval EFI_NOT_FOUND Can not find the PCD type according to token number.
792 **/
793 EFI_STATUS
794 SetWorker (
795 IN UINTN TokenNumber,
796 IN VOID *Data,
797 IN OUT UINTN *Size,
798 IN BOOLEAN PtrType
799 );
800
801 /**
802 Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.
803
804 @param ExTokenNumber Token number for dynamic-ex PCD.
805 @param Guid Token space guid for dynamic-ex PCD.
806 @param Data Value want to be set.
807 @param SetSize The size of value.
808
809 @return status of ExSetWorker().
810
811 **/
812 EFI_STATUS
813 ExSetValueWorker (
814 IN UINTN ExTokenNumber,
815 IN CONST EFI_GUID *Guid,
816 IN VOID *Data,
817 IN UINTN SetSize
818 );
819
820 /**
821 Set value for a dynamic PCD entry.
822
823 This routine find the local token number according to dynamic-ex PCD's token
824 space guid and token number firstly, and invoke callback function if this PCD
825 entry registered callback function. Finally, invoken general SetWorker to set
826 PCD value.
827
828 @param ExTokenNumber Dynamic-ex PCD token number.
829 @param Guid Token space guid for dynamic-ex PCD.
830 @param Data PCD value want to be set
831 @param SetSize Size of value.
832 @param PtrType If TRUE, this PCD entry is pointer type.
833 If FALSE, this PCD entry is not pointer type.
834
835 @return status of SetWorker().
836
837 **/
838 EFI_STATUS
839 ExSetWorker (
840 IN UINTN ExTokenNumber,
841 IN CONST EFI_GUID *Guid,
842 IN VOID *Data,
843 IN OUT UINTN *Size,
844 IN BOOLEAN PtrType
845 );
846
847 /**
848 Get the PCD entry pointer in PCD database.
849
850 This routine will visit PCD database to find the PCD entry according to given
851 token number. The given token number is autogened by build tools and it will be
852 translated to local token number. Local token number contains PCD's type and
853 offset of PCD entry in PCD database.
854
855 @param TokenNumber Token's number, it is autogened by build tools
856 @param GetSize The size of token's value
857
858 @return PCD entry pointer in PCD database
859
860 **/
861 VOID *
862 GetWorker (
863 IN UINTN TokenNumber,
864 IN UINTN GetSize
865 );
866
867 /**
868 Wrapper function for get PCD value for dynamic-ex PCD.
869
870 @param Guid Token space guid for dynamic-ex PCD.
871 @param ExTokenNumber Token number for dynamic-ex PCD.
872 @param GetSize The size of dynamic-ex PCD value.
873
874 @return PCD entry in PCD database.
875
876 **/
877 VOID *
878 ExGetWorker (
879 IN CONST EFI_GUID *Guid,
880 IN UINTN ExTokenNumber,
881 IN UINTN GetSize
882 );
883
884 /**
885 Find the local token number according to system SKU ID.
886
887 @param LocalTokenNumber PCD token number
888 @param Size The size of PCD entry.
889 @param IsPeiDb If TRUE, the PCD entry is initialized in PEI phase.
890 If False, the PCD entry is initialized in DXE phase.
891
892 @return Token number according to system SKU ID.
893
894 **/
895 UINT32
896 GetSkuEnabledTokenNumber (
897 UINT32 LocalTokenNumber,
898 UINTN Size,
899 BOOLEAN IsPeiDb
900 );
901
902 /**
903 Get Variable which contains HII type PCD entry.
904
905 @param VariableGuid Variable's guid
906 @param VariableName Variable's unicode name string
907 @param VariableData Variable's data pointer,
908 @param VariableSize Variable's size.
909
910 @return the status of gRT->GetVariable
911 **/
912 EFI_STATUS
913 GetHiiVariable (
914 IN EFI_GUID *VariableGuid,
915 IN UINT16 *VariableName,
916 OUT UINT8 **VariableData,
917 OUT UINTN *VariableSize
918 );
919
920 /**
921 Set value for HII-type PCD.
922
923 A HII-type PCD's value is stored in a variable. Setting/Getting the value of
924 HII-type PCD is to visit this variable.
925
926 @param VariableGuid Guid of variable which stored value of a HII-type PCD.
927 @param VariableName Unicode name of variable which stored value of a HII-type PCD.
928 @param Data Value want to be set.
929 @param DataSize Size of value
930 @param Offset Value offset of HII-type PCD in variable.
931
932 @return status of GetVariable()/SetVariable().
933
934 **/
935 EFI_STATUS
936 SetHiiVariable (
937 IN EFI_GUID *VariableGuid,
938 IN UINT16 *VariableName,
939 IN CONST VOID *Data,
940 IN UINTN DataSize,
941 IN UINTN Offset
942 );
943
944 /**
945 Register the callback function for a PCD entry.
946
947 This routine will register a callback function to a PCD entry by given token number
948 and token space guid.
949
950 @param TokenNumber PCD token's number, it is autogened by build tools.
951 @param Guid PCD token space's guid,
952 if not NULL, this PCD is dynamicEx type PCD.
953 @param CallBackFunction Callback function pointer
954
955 @return EFI_SUCCESS Always success for registering callback function.
956
957 **/
958 EFI_STATUS
959 DxeRegisterCallBackWorker (
960 IN UINTN TokenNumber,
961 IN CONST EFI_GUID *Guid, OPTIONAL
962 IN PCD_PROTOCOL_CALLBACK CallBackFunction
963 );
964
965 /**
966 UnRegister the callback function for a PCD entry.
967
968 This routine will unregister a callback function to a PCD entry by given token number
969 and token space guid.
970
971 @param TokenNumber PCD token's number, it is autogened by build tools.
972 @param Guid PCD token space's guid.
973 if not NULL, this PCD is dynamicEx type PCD.
974 @param CallBackFunction Callback function pointer
975
976 @retval EFI_SUCCESS Callback function is success to be unregister.
977 @retval EFI_INVALID_PARAMETER Can not find the PCD entry by given token number.
978 **/
979 EFI_STATUS
980 DxeUnRegisterCallBackWorker (
981 IN UINTN TokenNumber,
982 IN CONST EFI_GUID *Guid, OPTIONAL
983 IN PCD_PROTOCOL_CALLBACK CallBackFunction
984 );
985
986 /**
987 Initialize the PCD database in DXE phase.
988
989 PCD database in DXE phase also contains PCD database in PEI phase which is copied
990 from GUID Hob.
991
992 **/
993 VOID
994 BuildPcdDxeDataBase (
995 VOID
996 );
997
998 /**
999 Get Token Number according to dynamic-ex PCD's {token space guid:token number}
1000
1001 A dynamic-ex type PCD, developer must provide pair of token space guid: token number
1002 in DEC file. PCD database maintain a mapping table that translate pair of {token
1003 space guid: token number} to Token Number.
1004
1005 @param Guid Token space guid for dynamic-ex PCD entry.
1006 @param ExTokenNumber Dynamic-ex PCD token number.
1007
1008 @return Token Number for dynamic-ex PCD.
1009
1010 **/
1011 UINTN
1012 GetExPcdTokenNumber (
1013 IN CONST EFI_GUID *Guid,
1014 IN UINT32 ExTokenNumber
1015 );
1016
1017 /**
1018 Get next token number in given token space.
1019
1020 This routine is used for dynamicEx type PCD. It will firstly scan token space
1021 table to get token space according to given token space guid. Then scan given
1022 token number in found token space, if found, then return next token number in
1023 this token space.
1024
1025 @param Guid Token space guid. Next token number will be scaned in
1026 this token space.
1027 @param TokenNumber Token number.
1028 If PCD_INVALID_TOKEN_NUMBER, return first token number in
1029 token space table.
1030 If not PCD_INVALID_TOKEN_NUMBER, return next token number
1031 in token space table.
1032 @param GuidTable Token space guid table. It will be used for scan token space
1033 by given token space guid.
1034 @param SizeOfGuidTable The size of guid table.
1035 @param ExMapTable DynamicEx token number mapping table.
1036 @param SizeOfExMapTable The size of dynamicEx token number mapping table.
1037
1038 @retval EFI_NOT_FOUND Can not given token space or token number.
1039 @retval EFI_SUCCESS Success to get next token number.
1040
1041 **/
1042 EFI_STATUS
1043 ExGetNextTokeNumber (
1044 IN CONST EFI_GUID *Guid,
1045 IN OUT UINTN *TokenNumber,
1046 IN EFI_GUID *GuidTable,
1047 IN UINTN SizeOfGuidTable,
1048 IN DYNAMICEX_MAPPING *ExMapTable,
1049 IN UINTN SizeOfExMapTable
1050 );
1051
1052 /**
1053 Get size of POINTER type PCD value.
1054
1055 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1056 @param MaxSize Maximum size of POINTER type PCD value.
1057
1058 @return size of POINTER type PCD value.
1059
1060 **/
1061 UINTN
1062 GetPtrTypeSize (
1063 IN UINTN LocalTokenNumberTableIdx,
1064 OUT UINTN *MaxSize
1065 );
1066
1067 /**
1068 Set size of POINTER type PCD value. The size should not exceed the maximum size
1069 of this PCD value.
1070
1071 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1072 @param CurrentSize Size of POINTER type PCD value.
1073
1074 @retval TRUE Success to set size of PCD value.
1075 @retval FALSE Fail to set size of PCD value.
1076 **/
1077 BOOLEAN
1078 SetPtrTypeSize (
1079 IN UINTN LocalTokenNumberTableIdx,
1080 IN OUT UINTN *CurrentSize
1081 );
1082
1083 extern PCD_DATABASE mPcdDatabase;
1084
1085 extern UINT32 mPcdTotalTokenCount;
1086 extern UINT32 mPeiLocalTokenCount;
1087 extern UINT32 mDxeLocalTokenCount;
1088 extern UINT32 mPeiNexTokenCount;
1089 extern UINT32 mDxeNexTokenCount;
1090 extern UINT32 mPeiExMapppingTableSize;
1091 extern UINT32 mDxeExMapppingTableSize;
1092 extern UINT32 mPeiGuidTableSize;
1093 extern UINT32 mDxeGuidTableSize;
1094
1095 extern BOOLEAN mPeiExMapTableEmpty;
1096 extern BOOLEAN mDxeExMapTableEmpty;
1097 extern BOOLEAN mPeiDatabaseEmpty;
1098
1099 extern EFI_GUID **TmpTokenSpaceBuffer;
1100 extern UINTN TmpTokenSpaceBufferCount;
1101
1102 extern EFI_LOCK mPcdDatabaseLock;
1103
1104 #endif
1105