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