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