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