]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/PCD/Dxe/Service.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Dxe / Service.h
1 /** @file
2 Private functions used by PCD DXE driver.
3
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _PCD_DXE_SERVICE_H_
10 #define _PCD_DXE_SERVICE_H_
11
12 #include <PiDxe.h>
13 #include <Guid/PcdDataBaseHobGuid.h>
14 #include <Guid/PcdDataBaseSignatureGuid.h>
15 #include <Protocol/Pcd.h>
16 #include <Protocol/PiPcd.h>
17 #include <Protocol/PcdInfo.h>
18 #include <Protocol/PiPcdInfo.h>
19 #include <Protocol/VarCheck.h>
20 #include <Protocol/VariableLock.h>
21 #include <Library/BaseLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/UefiLib.h>
24 #include <Library/UefiDriverEntryPoint.h>
25 #include <Library/PcdLib.h>
26 #include <Library/HobLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/UefiRuntimeServicesTableLib.h>
31
32 //
33 // Please make sure the PCD Serivce DXE Version is consistent with
34 // the version of the generated DXE PCD Database by build tool.
35 //
36 #define PCD_SERVICE_DXE_VERSION 7
37
38 //
39 // PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.
40 //
41 #if (PCD_SERVICE_DXE_VERSION != PCD_DXE_SERVICE_DRIVER_VERSION)
42 #error "Please make sure the version of PCD DXE Service and the generated PCD DXE Database match."
43 #endif
44
45 extern UINTN mVpdBaseAddress;
46
47 /**
48 Retrieve additional information associated with a PCD token in the default token space.
49
50 This includes information such as the type of value the TokenNumber is associated with as well as possible
51 human readable name that is associated with the token.
52
53 @param[in] TokenNumber The PCD token number.
54 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
55 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
56
57 @retval EFI_SUCCESS The PCD information was returned successfully.
58 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
59 **/
60 EFI_STATUS
61 EFIAPI
62 DxeGetPcdInfoGetInfo (
63 IN UINTN TokenNumber,
64 OUT EFI_PCD_INFO *PcdInfo
65 );
66
67 /**
68 Retrieve additional information associated with a PCD token.
69
70 This includes information such as the type of value the TokenNumber is associated with as well as possible
71 human readable name that is associated with the token.
72
73 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
74 @param[in] TokenNumber The PCD token number.
75 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
76 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
77
78 @retval EFI_SUCCESS The PCD information was returned successfully.
79 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
80 **/
81 EFI_STATUS
82 EFIAPI
83 DxeGetPcdInfoGetInfoEx (
84 IN CONST EFI_GUID *Guid,
85 IN UINTN TokenNumber,
86 OUT EFI_PCD_INFO *PcdInfo
87 );
88
89 /**
90 Retrieve the currently set SKU Id.
91
92 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
93 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
94 Id is returned.
95 **/
96 UINTN
97 EFIAPI
98 DxeGetPcdInfoGetSku (
99 VOID
100 );
101
102 //
103 // Protocol Interface function declaration.
104 //
105 /**
106 Sets the SKU value for subsequent calls to set or get PCD token values.
107
108 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
109 SetSku() is normally called only once by the system.
110
111 For each item (token), the database can hold a single value that applies to all SKUs,
112 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
113 SKU-specific values are called SKU enabled.
114
115 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
116 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
117 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
118 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
119 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
120 set for that Id, the results are unpredictable.
121
122 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
123 set values associated with a PCD token.
124
125 **/
126 VOID
127 EFIAPI
128 DxePcdSetSku (
129 IN UINTN SkuId
130 );
131
132 /**
133 Retrieves an 8-bit value for a given PCD token.
134
135 Retrieves the current byte-sized 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 UINT8 value.
141
142 **/
143 UINT8
144 EFIAPI
145 DxePcdGet8 (
146 IN UINTN TokenNumber
147 );
148
149 /**
150 Retrieves an 16-bit value for a given PCD token.
151
152 Retrieves the current 16-bits value for a PCD token number.
153 If the TokenNumber is invalid, the results are unpredictable.
154
155 @param[in] TokenNumber The PCD token number.
156
157 @return The UINT16 value.
158
159 **/
160 UINT16
161 EFIAPI
162 DxePcdGet16 (
163 IN UINTN TokenNumber
164 );
165
166 /**
167 Retrieves an 32-bit value for a given PCD token.
168
169 Retrieves the current 32-bits value for a PCD token number.
170 If the TokenNumber is invalid, the results are unpredictable.
171
172 @param[in] TokenNumber The PCD token number.
173
174 @return The UINT32 value.
175
176 **/
177 UINT32
178 EFIAPI
179 DxePcdGet32 (
180 IN UINTN TokenNumber
181 );
182
183 /**
184 Retrieves an 64-bit value for a given PCD token.
185
186 Retrieves the current 64-bits value for a PCD token number.
187 If the TokenNumber is invalid, the results are unpredictable.
188
189 @param[in] TokenNumber The PCD token number.
190
191 @return The UINT64 value.
192
193 **/
194 UINT64
195 EFIAPI
196 DxePcdGet64 (
197 IN UINTN TokenNumber
198 );
199
200 /**
201 Retrieves a pointer to a value for a given PCD token.
202
203 Retrieves the current pointer to the buffer for a PCD token number.
204 Do not make any assumptions about the alignment of the pointer that
205 is returned by this function call. If the TokenNumber is invalid,
206 the results are unpredictable.
207
208 @param[in] TokenNumber The PCD token number.
209
210 @return The pointer to the buffer to be retrieved.
211
212 **/
213 VOID *
214 EFIAPI
215 DxePcdGetPtr (
216 IN UINTN TokenNumber
217 );
218
219 /**
220 Retrieves a Boolean value for a given PCD token.
221
222 Retrieves the current boolean value for a PCD token number.
223 Do not make any assumptions about the alignment of the pointer that
224 is returned by this function call. If the TokenNumber is invalid,
225 the results are unpredictable.
226
227 @param[in] TokenNumber The PCD token number.
228
229 @return The Boolean value.
230
231 **/
232 BOOLEAN
233 EFIAPI
234 DxePcdGetBool (
235 IN UINTN TokenNumber
236 );
237
238 /**
239 Retrieves the size of the value for a given PCD token.
240
241 Retrieves the current size of a particular PCD token.
242 If the TokenNumber is invalid, the results are unpredictable.
243
244 @param[in] TokenNumber The PCD token number.
245
246 @return The size of the value for the PCD token.
247
248 **/
249 UINTN
250 EFIAPI
251 DxePcdGetSize (
252 IN UINTN TokenNumber
253 );
254
255 /**
256 Retrieves an 8-bit value for a given PCD token.
257
258 Retrieves the 8-bit value of a particular PCD token.
259 If the TokenNumber is invalid or the token space
260 specified by Guid does not exist, the results are
261 unpredictable.
262
263 @param[in] Guid The token space for the token number.
264 @param[in] TokenNumber The PCD token number.
265
266 @return The size 8-bit value for the PCD token.
267
268 **/
269 UINT8
270 EFIAPI
271 DxePcdGet8Ex (
272 IN CONST EFI_GUID *Guid,
273 IN UINTN TokenNumber
274 );
275
276 /**
277 Retrieves an 16-bit value for a given PCD token.
278
279 Retrieves the 16-bit value of a particular PCD token.
280 If the TokenNumber is invalid or the token space
281 specified by Guid does not exist, the results are
282 unpredictable.
283
284 @param[in] Guid The token space for the token number.
285 @param[in] TokenNumber The PCD token number.
286
287 @return The size 16-bit value for the PCD token.
288
289 **/
290 UINT16
291 EFIAPI
292 DxePcdGet16Ex (
293 IN CONST EFI_GUID *Guid,
294 IN UINTN TokenNumber
295 );
296
297 /**
298 Retrieves an 32-bit value for a given PCD token.
299
300 Retrieves the 32-bit value of a particular PCD token.
301 If the TokenNumber is invalid or the token space
302 specified by Guid does not exist, the results are
303 unpredictable.
304
305 @param[in] Guid The token space for the token number.
306 @param[in] TokenNumber The PCD token number.
307
308 @return The size 32-bit value for the PCD token.
309
310 **/
311 UINT32
312 EFIAPI
313 DxePcdGet32Ex (
314 IN CONST EFI_GUID *Guid,
315 IN UINTN TokenNumber
316 );
317
318 /**
319 Retrieves an 64-bit value for a given PCD token.
320
321 Retrieves the 64-bit value of a particular PCD token.
322 If the TokenNumber is invalid or the token space
323 specified by Guid does not exist, the results are
324 unpredictable.
325
326 @param[in] Guid The token space for the token number.
327 @param[in] TokenNumber The PCD token number.
328
329 @return The size 64-bit value for the PCD token.
330
331 **/
332 UINT64
333 EFIAPI
334 DxePcdGet64Ex (
335 IN CONST EFI_GUID *Guid,
336 IN UINTN TokenNumber
337 );
338
339 /**
340 Retrieves a pointer to a value for a given PCD token.
341
342 Retrieves the current pointer to the buffer for a PCD token number.
343 Do not make any assumptions about the alignment of the pointer that
344 is returned by this function call. If the TokenNumber is invalid,
345 the results are unpredictable.
346
347 @param[in] Guid The token space for the token number.
348 @param[in] TokenNumber The PCD token number.
349
350 @return The pointer to the buffer to be retrieved.
351
352 **/
353 VOID *
354 EFIAPI
355 DxePcdGetPtrEx (
356 IN CONST EFI_GUID *Guid,
357 IN UINTN TokenNumber
358 );
359
360 /**
361 Retrieves an Boolean value for a given PCD token.
362
363 Retrieves the Boolean value of a particular PCD token.
364 If the TokenNumber is invalid or the token space
365 specified by Guid does not exist, the results are
366 unpredictable.
367
368 @param[in] Guid The token space for the token number.
369 @param[in] TokenNumber The PCD token number.
370
371 @return The size Boolean value for the PCD token.
372
373 **/
374 BOOLEAN
375 EFIAPI
376 DxePcdGetBoolEx (
377 IN CONST EFI_GUID *Guid,
378 IN UINTN TokenNumber
379 );
380
381 /**
382 Retrieves the size of the value for a given PCD token.
383
384 Retrieves the current size of a particular PCD token.
385 If the TokenNumber is invalid, the results are unpredictable.
386
387 @param[in] Guid The token space for the token number.
388 @param[in] TokenNumber The PCD token number.
389
390 @return The size of the value for the PCD token.
391
392 **/
393 UINTN
394 EFIAPI
395 DxePcdGetSizeEx (
396 IN CONST EFI_GUID *Guid,
397 IN UINTN TokenNumber
398 );
399
400 /**
401 Sets an 8-bit value for a given PCD token.
402
403 When the PCD service sets a value, it will check to ensure that the
404 size of the value being set is compatible with the Token's existing definition.
405 If it is not, an error will be returned.
406
407 @param[in] TokenNumber The PCD token number.
408 @param[in] Value The value to set for the PCD token.
409
410 @retval EFI_SUCCESS Procedure returned successfully.
411 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
412 being set was incompatible with a call to this function.
413 Use GetSize() to retrieve the size of the target data.
414 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
415
416 **/
417 EFI_STATUS
418 EFIAPI
419 DxePcdSet8 (
420 IN UINTN TokenNumber,
421 IN UINT8 Value
422 );
423
424 /**
425 Sets an 16-bit value for a given PCD token.
426
427 When the PCD service sets a value, it will check to ensure that the
428 size of the value being set is compatible with the Token's existing definition.
429 If it is not, an error will be returned.
430
431 @param[in] TokenNumber The PCD token number.
432 @param[in] Value The value to set for the PCD token.
433
434 @retval EFI_SUCCESS Procedure returned successfully.
435 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
436 being set was incompatible with a call to this function.
437 Use GetSize() to retrieve the size of the target data.
438 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
439
440 **/
441 EFI_STATUS
442 EFIAPI
443 DxePcdSet16 (
444 IN UINTN TokenNumber,
445 IN UINT16 Value
446 );
447
448 /**
449 Sets an 32-bit value for a given PCD token.
450
451 When the PCD service sets a value, it will check to ensure that the
452 size of the value being set is compatible with the Token's existing definition.
453 If it is not, an error will be returned.
454
455 @param[in] TokenNumber The PCD token number.
456 @param[in] Value The value to set for the PCD token.
457
458 @retval EFI_SUCCESS Procedure returned successfully.
459 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
460 being set was incompatible with a call to this function.
461 Use GetSize() to retrieve the size of the target data.
462 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
463
464 **/
465 EFI_STATUS
466 EFIAPI
467 DxePcdSet32 (
468 IN UINTN TokenNumber,
469 IN UINT32 Value
470 );
471
472 /**
473 Sets an 64-bit value for a given PCD token.
474
475 When the PCD service sets a value, it will check to ensure that the
476 size of the value being set is compatible with the Token's existing definition.
477 If it is not, an error will be returned.
478
479 @param[in] TokenNumber The PCD token number.
480 @param[in] Value The value to set for the PCD token.
481
482 @retval EFI_SUCCESS Procedure returned successfully.
483 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
484 being set was incompatible with a call to this function.
485 Use GetSize() to retrieve the size of the target data.
486 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
487
488 **/
489 EFI_STATUS
490 EFIAPI
491 DxePcdSet64 (
492 IN UINTN TokenNumber,
493 IN UINT64 Value
494 );
495
496
497 /**
498 Sets a value of a specified size for a given PCD token.
499
500 When the PCD service sets a value, it will check to ensure that the
501 size of the value being set is compatible with the Token's existing definition.
502 If it is not, an error will be returned.
503
504 @param[in] TokenNumber The PCD token number.
505 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
506 On input, if the SizeOfValue is greater than the maximum size supported
507 for this TokenNumber then the output value of SizeOfValue will reflect
508 the maximum size supported for this TokenNumber.
509 @param[in] Buffer The buffer to set for the PCD token.
510
511 @retval EFI_SUCCESS Procedure returned successfully.
512 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
513 being set was incompatible with a call to this function.
514 Use GetSize() to retrieve the size of the target data.
515 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
516
517 **/
518 EFI_STATUS
519 EFIAPI
520 DxePcdSetPtr (
521 IN UINTN TokenNumber,
522 IN OUT UINTN *SizeOfBuffer,
523 IN VOID *Buffer
524 );
525
526 /**
527 Sets an Boolean value for a given PCD token.
528
529 When the PCD service sets a value, it will check to ensure that the
530 size of the value being set is compatible with the Token's existing definition.
531 If it is not, an error will be returned.
532
533 @param[in] TokenNumber The PCD token number.
534 @param[in] Value The value to set for the PCD token.
535
536 @retval EFI_SUCCESS Procedure returned successfully.
537 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
538 being set was incompatible with a call to this function.
539 Use GetSize() to retrieve the size of the target data.
540 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
541
542 **/
543 EFI_STATUS
544 EFIAPI
545 DxePcdSetBool (
546 IN UINTN TokenNumber,
547 IN BOOLEAN Value
548 );
549
550
551 /**
552 Sets an 8-bit value for a given PCD token.
553
554 When the PCD service sets a value, it will check to ensure that the
555 size of the value being set is compatible with the Token's existing definition.
556 If it is not, an error will be returned.
557
558 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
559 @param[in] TokenNumber The PCD token number.
560 @param[in] Value The value to set for the PCD token.
561
562 @retval EFI_SUCCESS Procedure returned successfully.
563 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
564 being set was incompatible with a call to this function.
565 Use GetSize() to retrieve the size of the target data.
566 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
567
568 **/
569 EFI_STATUS
570 EFIAPI
571 DxePcdSet8Ex (
572 IN CONST EFI_GUID *Guid,
573 IN UINTN TokenNumber,
574 IN UINT8 Value
575 );
576
577 /**
578 Sets an 16-bit value for a given PCD token.
579
580 When the PCD service sets a value, it will check to ensure that the
581 size of the value being set is compatible with the Token's existing definition.
582 If it is not, an error will be returned.
583
584 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
585 @param[in] TokenNumber The PCD token number.
586 @param[in] Value The value to set for the PCD token.
587
588 @retval EFI_SUCCESS Procedure returned successfully.
589 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
590 being set was incompatible with a call to this function.
591 Use GetSize() to retrieve the size of the target data.
592 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
593
594 **/
595 EFI_STATUS
596 EFIAPI
597 DxePcdSet16Ex (
598 IN CONST EFI_GUID *Guid,
599 IN UINTN TokenNumber,
600 IN UINT16 Value
601 );
602
603 /**
604 Sets an 32-bit value for a given PCD token.
605
606 When the PCD service sets a value, it will check to ensure that the
607 size of the value being set is compatible with the Token's existing definition.
608 If it is not, an error will be returned.
609
610 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
611 @param[in] TokenNumber The PCD token number.
612 @param[in] Value The value 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 DxePcdSet32Ex (
624 IN CONST EFI_GUID *Guid,
625 IN UINTN TokenNumber,
626 IN UINT32 Value
627 );
628
629 /**
630 Sets an 64-bit value for a given PCD token.
631
632 When the PCD service sets a value, it will check to ensure that the
633 size of the value being set is compatible with the Token's existing definition.
634 If it is not, an error will be returned.
635
636 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
637 @param[in] TokenNumber The PCD token number.
638 @param[in] Value The value to set for the PCD token.
639
640 @retval EFI_SUCCESS Procedure returned successfully.
641 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
642 being set was incompatible with a call to this function.
643 Use GetSize() to retrieve the size of the target data.
644 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
645
646 **/
647 EFI_STATUS
648 EFIAPI
649 DxePcdSet64Ex (
650 IN CONST EFI_GUID *Guid,
651 IN UINTN TokenNumber,
652 IN UINT64 Value
653 );
654
655 /**
656 Sets a value of a specified size for a given PCD token.
657
658 When the PCD service sets a value, it will check to ensure that the
659 size of the value being set is compatible with the Token's existing definition.
660 If it is not, an error will be returned.
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, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
665 On input, if the SizeOfValue is greater than the maximum size supported
666 for this TokenNumber then the output value of SizeOfValue will reflect
667 the maximum size supported for this TokenNumber.
668 @param[in] Buffer The buffer to set for the PCD token.
669
670 @retval EFI_SUCCESS Procedure returned successfully.
671 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
672 being set was incompatible with a call to this function.
673 Use GetSize() to retrieve the size of the target data.
674 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
675
676 **/
677 EFI_STATUS
678 EFIAPI
679 DxePcdSetPtrEx (
680 IN CONST EFI_GUID *Guid,
681 IN UINTN TokenNumber,
682 IN OUT UINTN *SizeOfBuffer,
683 IN VOID *Buffer
684 );
685
686 /**
687 Sets an Boolean value for a given PCD token.
688
689 When the PCD service sets a value, it will check to ensure that the
690 size of the value being set is compatible with the Token's existing definition.
691 If it is not, an error will be returned.
692
693 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
694 @param[in] TokenNumber The PCD token number.
695 @param[in] Value The value to set for the PCD token.
696
697 @retval EFI_SUCCESS Procedure returned successfully.
698 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
699 being set was incompatible with a call to this function.
700 Use GetSize() to retrieve the size of the target data.
701 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
702
703 **/
704 EFI_STATUS
705 EFIAPI
706 DxePcdSetBoolEx (
707 IN CONST EFI_GUID *Guid,
708 IN UINTN TokenNumber,
709 IN BOOLEAN Value
710 );
711
712 /**
713 Specifies a function to be called anytime the value of a designated token is changed.
714
715 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
716 @param[in] TokenNumber The PCD token number.
717 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
718
719 @retval EFI_SUCCESS The PCD service has successfully established a call event
720 for the CallBackToken requested.
721 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
722
723 **/
724 EFI_STATUS
725 EFIAPI
726 DxeRegisterCallBackOnSet (
727 IN CONST EFI_GUID *Guid, OPTIONAL
728 IN UINTN TokenNumber,
729 IN PCD_PROTOCOL_CALLBACK CallBackFunction
730 );
731
732 /**
733 Cancels a previously set callback function for a particular PCD token number.
734
735 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
736 @param[in] TokenNumber The PCD token number.
737 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
738
739 @retval EFI_SUCCESS The PCD service has successfully established a call event
740 for the CallBackToken requested.
741 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
742
743 **/
744 EFI_STATUS
745 EFIAPI
746 DxeUnRegisterCallBackOnSet (
747 IN CONST EFI_GUID *Guid, OPTIONAL
748 IN UINTN TokenNumber,
749 IN PCD_PROTOCOL_CALLBACK CallBackFunction
750 );
751
752 /**
753 Retrieves the next valid token number in a given namespace.
754
755 This is useful since the PCD infrastructure contains a sparse list of token numbers,
756 and one cannot a priori know what token numbers are valid in the database.
757
758 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
759 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
760 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
761 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
762 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
763 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
764 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
765 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
766
767
768 @param[in] Guid The 128-bit unique value that designates the namespace from which to retrieve the next token.
769 This is an optional parameter that may be NULL. If this parameter is NULL, then a request is
770 being made to retrieve tokens from the default token space.
771 @param[in, out] TokenNumber
772 A pointer to the PCD token number to use to find the subsequent token number.
773
774 @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number
775 is already the last valid token number in the PCD database.
776 In the later case, *TokenNumber is updated with the value of 0.
777 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
778
779 **/
780 EFI_STATUS
781 EFIAPI
782 DxePcdGetNextToken (
783 IN CONST EFI_GUID *Guid, OPTIONAL
784 IN OUT UINTN *TokenNumber
785 );
786
787 /**
788 Get next token space in PCD database according to given token space guid.
789
790 @param Guid Given token space guid. If NULL, then Guid will be set to
791 the first PCD token space in PCD database, If not NULL, then
792 Guid will be set to next PCD token space.
793
794 @retval EFI_NOT_FOUND If PCD database has no token space table or can not find given
795 token space in PCD database.
796 @retval EFI_SUCCESS Success to get next token space guid.
797 **/
798 EFI_STATUS
799 EFIAPI
800 DxePcdGetNextTokenSpace (
801 IN OUT CONST EFI_GUID **Guid
802 );
803
804 typedef struct {
805 LIST_ENTRY Node;
806 PCD_PROTOCOL_CALLBACK CallbackFn;
807 } CALLBACK_FN_ENTRY;
808
809 #define CR_FNENTRY_FROM_LISTNODE(Record, Type, Field) BASE_CR(Record, Type, Field)
810
811 //
812 // Internal Functions
813 //
814
815 /**
816 Retrieve additional information associated with a PCD token.
817
818 This includes information such as the type of value the TokenNumber is associated with as well as possible
819 human readable name that is associated with the token.
820
821 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
822 @param[in] TokenNumber The PCD token number.
823 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
824 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
825
826 @retval EFI_SUCCESS The PCD information was returned successfully
827 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
828 **/
829 EFI_STATUS
830 DxeGetPcdInfo (
831 IN CONST EFI_GUID *Guid,
832 IN UINTN TokenNumber,
833 OUT EFI_PCD_INFO *PcdInfo
834 );
835
836 /**
837 Wrapper function for setting non-pointer type value for a PCD entry.
838
839 @param TokenNumber Pcd token number autogenerated by build tools.
840 @param Data Value want to be set for PCD entry
841 @param Size Size of value.
842
843 @return status of SetWorker.
844
845 **/
846 EFI_STATUS
847 SetValueWorker (
848 IN UINTN TokenNumber,
849 IN VOID *Data,
850 IN UINTN Size
851 );
852
853 /**
854 Set value for an PCD entry
855
856 @param TokenNumber Pcd token number autogenerated by build tools.
857 @param Data Value want to be set for PCD entry
858 @param Size Size of value.
859 @param PtrType If TRUE, the type of PCD entry's value is Pointer.
860 If False, the type of PCD entry's value is not Pointer.
861
862 @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set.
863 @retval EFI_INVALID_PARAMETER If Size can not be set to size table.
864 @retval EFI_INVALID_PARAMETER If Size of non-Ptr type PCD does not match the size information in PCD database.
865 @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in
866 range of UINT8, UINT16, UINT32, UINT64
867 @retval EFI_NOT_FOUND Can not find the PCD type according to token number.
868 **/
869 EFI_STATUS
870 SetWorker (
871 IN UINTN TokenNumber,
872 IN VOID *Data,
873 IN OUT UINTN *Size,
874 IN BOOLEAN PtrType
875 );
876
877 /**
878 Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.
879
880 @param ExTokenNumber Token number for dynamic-ex PCD.
881 @param Guid Token space guid for dynamic-ex PCD.
882 @param Data Value want to be set.
883 @param SetSize The size of value.
884
885 @return status of ExSetWorker().
886
887 **/
888 EFI_STATUS
889 ExSetValueWorker (
890 IN UINTN ExTokenNumber,
891 IN CONST EFI_GUID *Guid,
892 IN VOID *Data,
893 IN UINTN SetSize
894 );
895
896 /**
897 Set value for a dynamic PCD entry.
898
899 This routine find the local token number according to dynamic-ex PCD's token
900 space guid and token number firstly, and invoke callback function if this PCD
901 entry registered callback function. Finally, invoken general SetWorker to set
902 PCD value.
903
904 @param ExTokenNumber Dynamic-ex PCD token number.
905 @param Guid Token space guid for dynamic-ex PCD.
906 @param Data PCD value want to be set
907 @param SetSize Size of value.
908 @param PtrType If TRUE, this PCD entry is pointer type.
909 If FALSE, this PCD entry is not pointer type.
910
911 @return status of SetWorker().
912
913 **/
914 EFI_STATUS
915 ExSetWorker (
916 IN UINTN ExTokenNumber,
917 IN CONST EFI_GUID *Guid,
918 IN VOID *Data,
919 IN OUT UINTN *Size,
920 IN BOOLEAN PtrType
921 );
922
923 /**
924 Get the PCD entry pointer in PCD database.
925
926 This routine will visit PCD database to find the PCD entry according to given
927 token number. The given token number is autogened by build tools and it will be
928 translated to local token number. Local token number contains PCD's type and
929 offset of PCD entry in PCD database.
930
931 @param TokenNumber Token's number, it is autogened by build tools
932 @param GetSize The size of token's value
933
934 @return PCD entry pointer in PCD database
935
936 **/
937 VOID *
938 GetWorker (
939 IN UINTN TokenNumber,
940 IN UINTN GetSize
941 );
942
943 /**
944 Wrapper function for get PCD value for dynamic-ex PCD.
945
946 @param Guid Token space guid for dynamic-ex PCD.
947 @param ExTokenNumber Token number for dynamic-ex PCD.
948 @param GetSize The size of dynamic-ex PCD value.
949
950 @return PCD entry in PCD database.
951
952 **/
953 VOID *
954 ExGetWorker (
955 IN CONST EFI_GUID *Guid,
956 IN UINTN ExTokenNumber,
957 IN UINTN GetSize
958 );
959
960 /**
961 Get Variable which contains HII type PCD entry.
962
963 @param VariableGuid Variable's guid
964 @param VariableName Variable's unicode name string
965 @param VariableData Variable's data pointer,
966 @param VariableSize Variable's size.
967
968 @return the status of gRT->GetVariable
969 **/
970 EFI_STATUS
971 GetHiiVariable (
972 IN EFI_GUID *VariableGuid,
973 IN UINT16 *VariableName,
974 OUT UINT8 **VariableData,
975 OUT UINTN *VariableSize
976 );
977
978 /**
979 Set value for HII-type PCD.
980
981 A HII-type PCD's value is stored in a variable. Setting/Getting the value of
982 HII-type PCD is to visit this variable.
983
984 @param VariableGuid Guid of variable which stored value of a HII-type PCD.
985 @param VariableName Unicode name of variable which stored value of a HII-type PCD.
986 @param SetAttributes Attributes bitmask to set for the variable.
987 @param Data Value want to be set.
988 @param DataSize Size of value
989 @param Offset Value offset of HII-type PCD in variable.
990
991 @return status of GetVariable()/SetVariable().
992
993 **/
994 EFI_STATUS
995 SetHiiVariable (
996 IN EFI_GUID *VariableGuid,
997 IN UINT16 *VariableName,
998 IN UINT32 SetAttributes,
999 IN CONST VOID *Data,
1000 IN UINTN DataSize,
1001 IN UINTN Offset
1002 );
1003
1004 /**
1005 Register the callback function for a PCD entry.
1006
1007 This routine will register a callback function to a PCD entry by given token number
1008 and token space guid.
1009
1010 @param TokenNumber PCD token's number, it is autogened by build tools.
1011 @param Guid PCD token space's guid,
1012 if not NULL, this PCD is dynamicEx type PCD.
1013 @param CallBackFunction Callback function pointer
1014
1015 @return EFI_SUCCESS Always success for registering callback function.
1016
1017 **/
1018 EFI_STATUS
1019 DxeRegisterCallBackWorker (
1020 IN UINTN TokenNumber,
1021 IN CONST EFI_GUID *Guid, OPTIONAL
1022 IN PCD_PROTOCOL_CALLBACK CallBackFunction
1023 );
1024
1025 /**
1026 UnRegister the callback function for a PCD entry.
1027
1028 This routine will unregister a callback function to a PCD entry by given token number
1029 and token space guid.
1030
1031 @param TokenNumber PCD token's number, it is autogened by build tools.
1032 @param Guid PCD token space's guid.
1033 if not NULL, this PCD is dynamicEx type PCD.
1034 @param CallBackFunction Callback function pointer
1035
1036 @retval EFI_SUCCESS Callback function is success to be unregister.
1037 @retval EFI_INVALID_PARAMETER Can not find the PCD entry by given token number.
1038 **/
1039 EFI_STATUS
1040 DxeUnRegisterCallBackWorker (
1041 IN UINTN TokenNumber,
1042 IN CONST EFI_GUID *Guid, OPTIONAL
1043 IN PCD_PROTOCOL_CALLBACK CallBackFunction
1044 );
1045
1046 /**
1047 Initialize the PCD database in DXE phase.
1048
1049 PCD database in DXE phase also contains PCD database in PEI phase which is copied
1050 from GUID Hob.
1051
1052 **/
1053 VOID
1054 BuildPcdDxeDataBase (
1055 VOID
1056 );
1057
1058 /**
1059 Get Token Number according to dynamic-ex PCD's {token space guid:token number}
1060
1061 A dynamic-ex type PCD, developer must provide pair of token space guid: token number
1062 in DEC file. PCD database maintain a mapping table that translate pair of {token
1063 space guid: token number} to Token Number.
1064
1065 @param Guid Token space guid for dynamic-ex PCD entry.
1066 @param ExTokenNumber Dynamic-ex PCD token number.
1067
1068 @return Token Number for dynamic-ex PCD.
1069
1070 **/
1071 UINTN
1072 GetExPcdTokenNumber (
1073 IN CONST EFI_GUID *Guid,
1074 IN UINT32 ExTokenNumber
1075 );
1076
1077 /**
1078 Get next token number in given token space.
1079
1080 This routine is used for dynamicEx type PCD. It will firstly scan token space
1081 table to get token space according to given token space guid. Then scan given
1082 token number in found token space, if found, then return next token number in
1083 this token space.
1084
1085 @param Guid Token space guid. Next token number will be scaned in
1086 this token space.
1087 @param TokenNumber Token number.
1088 If PCD_INVALID_TOKEN_NUMBER, return first token number in
1089 token space table.
1090 If not PCD_INVALID_TOKEN_NUMBER, return next token number
1091 in token space table.
1092 @param GuidTable Token space guid table. It will be used for scan token space
1093 by given token space guid.
1094 @param SizeOfGuidTable The size of guid table.
1095 @param ExMapTable DynamicEx token number mapping table.
1096 @param SizeOfExMapTable The size of dynamicEx token number mapping table.
1097
1098 @retval EFI_NOT_FOUND Can not given token space or token number.
1099 @retval EFI_SUCCESS Success to get next token number.
1100
1101 **/
1102 EFI_STATUS
1103 ExGetNextTokeNumber (
1104 IN CONST EFI_GUID *Guid,
1105 IN OUT UINTN *TokenNumber,
1106 IN EFI_GUID *GuidTable,
1107 IN UINTN SizeOfGuidTable,
1108 IN DYNAMICEX_MAPPING *ExMapTable,
1109 IN UINTN SizeOfExMapTable
1110 );
1111
1112 /**
1113 Get size of POINTER type PCD value.
1114
1115 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1116 @param MaxSize Maximum size of POINTER type PCD value.
1117
1118 @return size of POINTER type PCD value.
1119
1120 **/
1121 UINTN
1122 GetPtrTypeSize (
1123 IN UINTN LocalTokenNumberTableIdx,
1124 OUT UINTN *MaxSize
1125 );
1126
1127 /**
1128 Set size of POINTER type PCD value. The size should not exceed the maximum size
1129 of this PCD value.
1130
1131 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1132 @param CurrentSize Size of POINTER type PCD value.
1133
1134 @retval TRUE Success to set size of PCD value.
1135 @retval FALSE Fail to set size of PCD value.
1136 **/
1137 BOOLEAN
1138 SetPtrTypeSize (
1139 IN UINTN LocalTokenNumberTableIdx,
1140 IN OUT UINTN *CurrentSize
1141 );
1142
1143 /**
1144 VariableLockProtocol callback
1145 to lock the variables referenced by DynamicHii PCDs with RO property set in *.dsc.
1146
1147 @param[in] Event Event whose notification function is being invoked.
1148 @param[in] Context Pointer to the notification function's context.
1149
1150 **/
1151 VOID
1152 EFIAPI
1153 VariableLockCallBack (
1154 IN EFI_EVENT Event,
1155 IN VOID *Context
1156 );
1157
1158 /**
1159 Update PCD database base on current SkuId
1160
1161 @param SkuId Current SkuId
1162 @param IsPeiDb Whether to update PEI PCD database.
1163
1164 @retval EFI_SUCCESS Update PCD database successfully.
1165 @retval EFI_NOT_FOUND Not found PCD database for current SkuId.
1166 **/
1167 EFI_STATUS
1168 UpdatePcdDatabase (
1169 IN SKU_ID SkuId,
1170 IN BOOLEAN IsPeiDb
1171 );
1172
1173 extern PCD_DATABASE mPcdDatabase;
1174
1175 extern UINT32 mPcdTotalTokenCount;
1176 extern UINT32 mPeiLocalTokenCount;
1177 extern UINT32 mDxeLocalTokenCount;
1178 extern UINT32 mPeiNexTokenCount;
1179 extern UINT32 mDxeNexTokenCount;
1180 extern UINT32 mPeiExMapppingTableSize;
1181 extern UINT32 mDxeExMapppingTableSize;
1182 extern UINT32 mPeiGuidTableSize;
1183 extern UINT32 mDxeGuidTableSize;
1184
1185 extern BOOLEAN mPeiExMapTableEmpty;
1186 extern BOOLEAN mDxeExMapTableEmpty;
1187 extern BOOLEAN mPeiDatabaseEmpty;
1188
1189 extern EFI_GUID **TmpTokenSpaceBuffer;
1190 extern UINTN TmpTokenSpaceBufferCount;
1191
1192 extern EFI_LOCK mPcdDatabaseLock;
1193
1194 #endif
1195