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