1 /** @file
2   Native Platform Configuration Database (PCD) Protocol
3 
4   Different with the EFI_PCD_PROTOCOL defined in PI 1.2 specification, the native
5   PCD protocol provide interfaces for dynamic and dynamic-ex type PCD.
6   The interfaces in dynamic type PCD do not require the token space guid as parameter,
7   but interfaces in dynamic-ex type PCD require token space guid as parameter.
8 
9 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
10 This program and the accompanying materials are licensed and made available under
11 the terms and conditions of the BSD License that accompanies this distribution.
12 The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php.
14 
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 
18 **/
19 
20 #ifndef __PCD_H__
21 #define __PCD_H__
22 
23 extern EFI_GUID gPcdProtocolGuid;
24 
25 #define PCD_PROTOCOL_GUID \
26   { 0x11b34006, 0xd85b, 0x4d0a, { 0xa2, 0x90, 0xd5, 0xa5, 0x71, 0x31, 0xe, 0xf7 } }
27 
28 #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0)
29 
30 
31 /**
32   Sets the SKU value for subsequent calls to set or get PCD token values.
33 
34   SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
35   SetSku() is normally called only once by the system.
36 
37   For each item (token), the database can hold a single value that applies to all SKUs,
38   or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
39   SKU-specific values are called SKU enabled.
40 
41   The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
42   For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
43   single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
44   last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
45   the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
46   set for that Id, the results are unpredictable.
47 
48   @param[in]  SkuId The SKU value that will be used when the PCD service will retrieve and
49                     set values associated with a PCD token.
50 
51 
52 **/
53 typedef
54 VOID
55 (EFIAPI *PCD_PROTOCOL_SET_SKU)(
56   IN  UINTN                  SkuId
57   );
58 
59 
60 
61 /**
62   Retrieves an 8-bit value for a given PCD token.
63 
64   Retrieves the current byte-sized value for a PCD token number.
65   If the TokenNumber is invalid, the results are unpredictable.
66 
67   @param[in]  TokenNumber The PCD token number.
68 
69   @return The UINT8 value.
70 
71 **/
72 typedef
73 UINT8
74 (EFIAPI *PCD_PROTOCOL_GET8)(
75   IN UINTN             TokenNumber
76   );
77 
78 
79 
80 /**
81   Retrieves a 16-bit value for a given PCD token.
82 
83   Retrieves the current 16-bit value for a PCD token number.
84   If the TokenNumber is invalid, the results are unpredictable.
85 
86   @param[in]  TokenNumber The PCD token number.
87 
88   @return The UINT16 value.
89 
90 **/
91 typedef
92 UINT16
93 (EFIAPI *PCD_PROTOCOL_GET16)(
94   IN UINTN             TokenNumber
95   );
96 
97 
98 
99 /**
100   Retrieves a 32-bit value for a given PCD token.
101 
102   Retrieves the current 32-bit value for a PCD token number.
103   If the TokenNumber is invalid, the results are unpredictable.
104 
105   @param[in]  TokenNumber The PCD token number.
106 
107   @return The UINT32 value.
108 
109 **/
110 typedef
111 UINT32
112 (EFIAPI *PCD_PROTOCOL_GET32)(
113   IN UINTN             TokenNumber
114   );
115 
116 
117 
118 /**
119   Retrieves a 64-bit value for a given PCD token.
120 
121   Retrieves the current 64-bit value for a PCD token number.
122   If the TokenNumber is invalid, the results are unpredictable.
123 
124   @param[in]  TokenNumber The PCD token number.
125 
126   @return The UINT64 value.
127 
128 **/
129 typedef
130 UINT64
131 (EFIAPI *PCD_PROTOCOL_GET64)(
132   IN UINTN             TokenNumber
133   );
134 
135 
136 
137 /**
138   Retrieves a pointer to a value for a given PCD token.
139 
140   Retrieves the current pointer to the buffer for a PCD token number.
141   Do not make any assumptions about the alignment of the pointer that
142   is returned by this function call.  If the TokenNumber is invalid,
143   the results are unpredictable.
144 
145   @param[in]  TokenNumber The PCD token number.
146 
147   @return The pointer to the buffer to be retrived.
148 
149 **/
150 typedef
151 VOID *
152 (EFIAPI *PCD_PROTOCOL_GET_POINTER)(
153   IN UINTN             TokenNumber
154   );
155 
156 
157 
158 /**
159   Retrieves a Boolean value for a given PCD token.
160 
161   Retrieves the current boolean value for a PCD token number.
162   Do not make any assumptions about the alignment of the pointer that
163   is returned by this function call.  If the TokenNumber is invalid,
164   the results are unpredictable.
165 
166   @param[in]  TokenNumber The PCD token number.
167 
168   @return The Boolean value.
169 
170 **/
171 typedef
172 BOOLEAN
173 (EFIAPI *PCD_PROTOCOL_GET_BOOLEAN)(
174   IN UINTN             TokenNumber
175   );
176 
177 
178 
179 /**
180   Retrieves the size of the value for a given PCD token.
181 
182   Retrieves the current size of a particular PCD token.
183   If the TokenNumber is invalid, the results are unpredictable.
184 
185   @param[in]  TokenNumber The PCD token number.
186 
187   @return The size of the value for the PCD token.
188 
189 **/
190 typedef
191 UINTN
192 (EFIAPI *PCD_PROTOCOL_GET_SIZE)(
193   IN UINTN             TokenNumber
194   );
195 
196 
197 
198 /**
199   Retrieves an 8-bit value for a given PCD token.
200 
201   Retrieves the 8-bit value of a particular PCD token.
202   If the TokenNumber is invalid or the token space
203   specified by Guid does not exist, the results are
204   unpredictable.
205 
206   @param[in]  Guid        The token space for the token number.
207   @param[in]  TokenNumber The PCD token number.
208 
209   @return The size 8-bit value for the PCD token.
210 
211 **/
212 typedef
213 UINT8
214 (EFIAPI *PCD_PROTOCOL_GET_EX_8)(
215   IN CONST EFI_GUID    *Guid,
216   IN UINTN             TokenNumber
217   );
218 
219 
220 
221 /**
222   Retrieves a 16-bit value for a given PCD token.
223 
224   Retrieves the 16-bit value of a particular PCD token.
225   If the TokenNumber is invalid or the token space
226   specified by Guid does not exist, the results are
227   unpredictable.
228 
229   @param[in]  Guid        The token space for the token number.
230   @param[in]  TokenNumber The PCD token number.
231 
232   @return The size 16-bit value for the PCD token.
233 
234 **/
235 typedef
236 UINT16
237 (EFIAPI *PCD_PROTOCOL_GET_EX_16)(
238   IN CONST EFI_GUID    *Guid,
239   IN UINTN             TokenNumber
240   );
241 
242 
243 
244 /**
245   Retrieves a 32-bit value for a given PCD token.
246 
247   Retrieves the 32-bit value of a particular PCD token.
248   If the TokenNumber is invalid or the token space
249   specified by Guid does not exist, the results are
250   unpredictable.
251 
252   @param[in]  Guid        The token space for the token number.
253   @param[in]  TokenNumber The PCD token number.
254 
255   @return The size 32-bit value for the PCD token.
256 
257 **/
258 typedef
259 UINT32
260 (EFIAPI *PCD_PROTOCOL_GET_EX_32)(
261   IN CONST EFI_GUID    *Guid,
262   IN UINTN             TokenNumber
263   );
264 
265 
266 
267 /**
268   Retrieves an 64-bit value for a given PCD token.
269 
270   Retrieves the 64-bit value of a particular PCD token.
271   If the TokenNumber is invalid or the token space
272   specified by Guid does not exist, the results are
273   unpredictable.
274 
275   @param[in]  Guid        The token space for the token number.
276   @param[in]  TokenNumber The PCD token number.
277 
278   @return The size 64-bit value for the PCD token.
279 
280 **/
281 typedef
282 UINT64
283 (EFIAPI *PCD_PROTOCOL_GET_EX_64)(
284   IN CONST EFI_GUID    *Guid,
285   IN UINTN             TokenNumber
286   );
287 
288 
289 
290 /**
291   Retrieves a pointer to a value for a given PCD token.
292 
293   Retrieves the current pointer to the buffer for a PCD token number.
294   Do not make any assumptions about the alignment of the pointer that
295   is returned by this function call.  If the TokenNumber is invalid,
296   the results are unpredictable.
297 
298   @param[in]  Guid        The token space for the token number.
299   @param[in]  TokenNumber The PCD token number.
300 
301   @return The pointer to the buffer to be retrieved.
302 
303 **/
304 typedef
305 VOID *
306 (EFIAPI *PCD_PROTOCOL_GET_EX_POINTER)(
307   IN CONST EFI_GUID    *Guid,
308   IN UINTN             TokenNumber
309   );
310 
311 
312 
313 /**
314   Retrieves a Boolean value for a given PCD token.
315 
316   Retrieves the Boolean value of a particular PCD token.
317   If the TokenNumber is invalid or the token space
318   specified by Guid does not exist, the results are
319   unpredictable.
320 
321   @param[in]  Guid        The token space for the token number.
322   @param[in]  TokenNumber The PCD token number.
323 
324   @return The size Boolean value for the PCD token.
325 
326 **/
327 typedef
328 BOOLEAN
329 (EFIAPI *PCD_PROTOCOL_GET_EX_BOOLEAN)(
330   IN CONST EFI_GUID    *Guid,
331   IN UINTN             TokenNumber
332   );
333 
334 
335 
336 /**
337   Retrieves the size of the value for a given PCD token.
338 
339   Retrieves the current size of a particular PCD token.
340   If the TokenNumber is invalid, the results are unpredictable.
341 
342   @param[in]  Guid        The token space for the token number.
343   @param[in]  TokenNumber The PCD token number.
344 
345   @return The size of the value for the PCD token.
346 
347 **/
348 typedef
349 UINTN
350 (EFIAPI *PCD_PROTOCOL_GET_EX_SIZE)(
351   IN CONST EFI_GUID    *Guid,
352   IN UINTN             TokenNumber
353   );
354 
355 
356 
357 /**
358   Sets an 8-bit value for a given PCD token.
359 
360   When the PCD service sets a value, it will check to ensure that the
361   size of the value being set is compatible with the Token's existing definition.
362   If it is not, an error will be returned.
363 
364   @param[in]  TokenNumber The PCD token number.
365   @param[in]  Value       The value to set for the PCD token.
366 
367   @retval EFI_SUCCESS  The procedure returned successfully.
368   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
369                                   being set was incompatible with a call to this function.
370                                   Use GetSize() to retrieve the size of the target data.
371   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
372 
373 **/
374 typedef
375 EFI_STATUS
376 (EFIAPI *PCD_PROTOCOL_SET8)(
377   IN UINTN             TokenNumber,
378   IN UINT8             Value
379   );
380 
381 
382 
383 /**
384   Sets a 16-bit value for a given PCD token.
385 
386   When the PCD service sets a value, it will check to ensure that the
387   size of the value being set is compatible with the Token's existing definition.
388   If it is not, an error will be returned.
389 
390   @param[in]  TokenNumber The PCD token number.
391   @param[in]  Value       The value to set for the PCD token.
392 
393   @retval EFI_SUCCESS  The procedure returned successfully.
394   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
395                                   being set was incompatible with a call to this function.
396                                   Use GetSize() to retrieve the size of the target data.
397   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
398 
399 **/
400 typedef
401 EFI_STATUS
402 (EFIAPI *PCD_PROTOCOL_SET16)(
403   IN UINTN              TokenNumber,
404   IN UINT16             Value
405   );
406 
407 
408 
409 /**
410   Sets a 32-bit value for a given PCD token.
411 
412   When the PCD service sets a value, it will check to ensure that the
413   size of the value being set is compatible with the Token's existing definition.
414   If it is not, an error will be returned.
415 
416   @param[in]  TokenNumber The PCD token number.
417   @param[in]  Value       The value to set for the PCD token.
418 
419   @retval EFI_SUCCESS  The procedure returned successfully.
420   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
421                                   being set was incompatible with a call to this function.
422                                   Use GetSize() to retrieve the size of the target data.
423   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
424 
425 **/
426 typedef
427 EFI_STATUS
428 (EFIAPI *PCD_PROTOCOL_SET32)(
429   IN UINTN              TokenNumber,
430   IN UINT32             Value
431   );
432 
433 
434 
435 /**
436   Sets a 64-bit value for a given PCD token.
437 
438   When the PCD service sets a value, it will check to ensure that the
439   size of the value being set is compatible with the Token's existing definition.
440   If it is not, an error will be returned.
441 
442   @param[in]  TokenNumber The PCD token number.
443   @param[in]  Value       The value to set for the PCD token.
444 
445   @retval EFI_SUCCESS  The procedure returned successfully.
446   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
447                                   being set was incompatible with a call to this function.
448                                   Use GetSize() to retrieve the size of the target data.
449   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
450 
451 **/
452 typedef
453 EFI_STATUS
454 (EFIAPI *PCD_PROTOCOL_SET64)(
455   IN UINTN             TokenNumber,
456   IN UINT64            Value
457   );
458 
459 
460 
461 /**
462   Sets a value of a specified size for a given PCD token.
463 
464   When the PCD service sets a value, it will check to ensure that the
465   size of the value being set is compatible with the Token's existing definition.
466   If it is not, an error will be returned.
467 
468   @param[in]      TokenNumber  The PCD token number.
469   @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
470                                On input, if the SizeOfValue is greater than the maximum size supported
471                                for this TokenNumber then the output value of SizeOfValue will reflect
472                                the maximum size supported for this TokenNumber.
473   @param[in]      Buffer       The buffer to set for the PCD token.
474 
475   @retval EFI_SUCCESS  The procedure returned successfully.
476   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
477                                   being set was incompatible with a call to this function.
478                                   Use GetSize() to retrieve the size of the target data.
479   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
480 
481 **/
482 typedef
483 EFI_STATUS
484 (EFIAPI *PCD_PROTOCOL_SET_POINTER)(
485   IN      UINTN             TokenNumber,
486   IN OUT  UINTN             *SizeOfBuffer,
487   IN      VOID              *Buffer
488   );
489 
490 
491 
492 /**
493   Sets a Boolean value for a given PCD token.
494 
495   When the PCD service sets a value, it will check to ensure that the
496   size of the value being set is compatible with the Token's existing definition.
497   If it is not, an error will be returned.
498 
499   @param[in]  TokenNumber The PCD token number.
500   @param[in]  Value       The value to set for the PCD token.
501 
502   @retval EFI_SUCCESS  The procedure returned successfully.
503   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
504                                   being set was incompatible with a call to this function.
505                                   Use GetSize() to retrieve the size of the target data.
506   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
507 
508 **/
509 typedef
510 EFI_STATUS
511 (EFIAPI *PCD_PROTOCOL_SET_BOOLEAN)(
512   IN UINTN             TokenNumber,
513   IN BOOLEAN           Value
514   );
515 
516 
517 
518 /**
519   Sets an 8-bit value for a given PCD token.
520 
521   When the PCD service sets a value, it will check to ensure that the
522   size of the value being set is compatible with the Token's existing definition.
523   If it is not, an error will be returned.
524 
525   @param[in]  Guid        The 128-bit unique value that designates the namespace from which to extract the value.
526   @param[in]  TokenNumber The PCD token number.
527   @param[in]  Value       The value to set for the PCD token.
528 
529   @retval EFI_SUCCESS  The procedure returned successfully.
530   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
531                                   being set was incompatible with a call to this function.
532                                   Use GetSize() to retrieve the size of the target data.
533   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
534 
535 **/
536 typedef
537 EFI_STATUS
538 (EFIAPI *PCD_PROTOCOL_SET_EX_8)(
539   IN CONST EFI_GUID    *Guid,
540   IN UINTN             TokenNumber,
541   IN UINT8             Value
542   );
543 
544 
545 
546 /**
547   Sets an 16-bit value for a given PCD token.
548 
549   When the PCD service sets a value, it will check to ensure that the
550   size of the value being set is compatible with the Token's existing definition.
551   If it is not, an error will be returned.
552 
553   @param[in]  Guid        The 128-bit unique value that designates the namespace from which to extract the value.
554   @param[in]  TokenNumber The PCD token number.
555   @param[in]  Value       The value to set for the PCD token.
556 
557   @retval EFI_SUCCESS  The procedure returned successfully.
558   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
559                                   being set was incompatible with a call to this function.
560                                   Use GetSize() to retrieve the size of the target data.
561   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
562 
563 **/
564 typedef
565 EFI_STATUS
566 (EFIAPI *PCD_PROTOCOL_SET_EX_16)(
567   IN CONST EFI_GUID    *Guid,
568   IN UINTN             TokenNumber,
569   IN UINT16            Value
570   );
571 
572 
573 
574 /**
575   Sets a 32-bit value for a given PCD token.
576 
577   When the PCD service sets a value, it will check to ensure that the
578   size of the value being set is compatible with the Token's existing definition.
579   If it is not, an error will be returned.
580 
581   @param[in]  Guid        The 128-bit unique value that designates the namespace from which to extract the value.
582   @param[in]  TokenNumber The PCD token number.
583   @param[in]  Value       The value to set for the PCD token.
584 
585   @retval EFI_SUCCESS  The procedure returned successfully.
586   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
587                                   being set was incompatible with a call to this function.
588                                   Use GetSize() to retrieve the size of the target data.
589   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
590 
591 **/
592 typedef
593 EFI_STATUS
594 (EFIAPI *PCD_PROTOCOL_SET_EX_32)(
595   IN CONST EFI_GUID     *Guid,
596   IN UINTN              TokenNumber,
597   IN UINT32             Value
598   );
599 
600 
601 
602 /**
603   Sets a 64-bit value for a given PCD token.
604 
605   When the PCD service sets a value, it will check to ensure that the
606   size of the value being set is compatible with the Token's existing definition.
607   If it is not, an error will be returned.
608 
609   @param[in]  Guid        The 128-bit unique value that designates the namespace from which to extract the value.
610   @param[in]  TokenNumber The PCD token number.
611   @param[in]  Value       The value to set for the PCD token.
612 
613   @retval EFI_SUCCESS  The procedure returned successfully.
614   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
615                                   being set was incompatible with a call to this function.
616                                   Use GetSize() to retrieve the size of the target data.
617   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
618 
619 **/
620 typedef
621 EFI_STATUS
622 (EFIAPI *PCD_PROTOCOL_SET_EX_64)(
623   IN CONST EFI_GUID    *Guid,
624   IN UINTN             TokenNumber,
625   IN UINT64            Value
626   );
627 
628 
629 
630 /**
631   Sets a value of a specified size for a given PCD token.
632 
633   When the PCD service sets a value, it will check to ensure that the
634   size of the value being set is compatible with the Token's existing definition.
635   If it is not, an error will be returned.
636 
637   @param[in]  Guid            The 128-bit unique value that designates the namespace from which to extract the value.
638   @param[in]  TokenNumber     The PCD token number.
639   @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
640                               On input, if the SizeOfValue is greater than the maximum size supported
641                               for this TokenNumber then the output value of SizeOfValue will reflect
642                               the maximum size supported for this TokenNumber.
643   @param[in]  Buffer          The buffer to set for the PCD token.
644 
645   @retval EFI_SUCCESS  The procedure returned successfully.
646   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
647                                   being set was incompatible with a call to this function.
648                                   Use GetSize() to retrieve the size of the target data.
649   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
650 
651 **/
652 typedef
653 EFI_STATUS
654 (EFIAPI *PCD_PROTOCOL_SET_EX_POINTER)(
655   IN CONST EFI_GUID          *Guid,
656   IN       UINTN             TokenNumber,
657   IN OUT   UINTN             *SizeOfBuffer,
658   IN       VOID              *Buffer
659   );
660 
661 
662 
663 /**
664   Sets a Boolean value for a given PCD token.
665 
666   When the PCD service sets a value, it will check to ensure that the
667   size of the value being set is compatible with the Token's existing definition.
668   If it is not, an error will be returned.
669 
670   @param[in]  Guid        The 128-bit unique value that designates the namespace from which to extract the value.
671   @param[in]  TokenNumber The PCD token number.
672   @param[in]  Value       The value to set for the PCD token.
673 
674   @retval EFI_SUCCESS  The procedure returned successfully.
675   @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
676                                   being set was incompatible with a call to this function.
677                                   Use GetSize() to retrieve the size of the target data.
678   @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
679 
680 **/
681 typedef
682 EFI_STATUS
683 (EFIAPI *PCD_PROTOCOL_SET_EX_BOOLEAN)(
684   IN CONST EFI_GUID    *Guid,
685   IN UINTN             TokenNumber,
686   IN BOOLEAN           Value
687   );
688 
689 
690 
691 /**
692   Callback on SET function prototype definition.
693 
694   This notification function serves two purposes.
695   Firstly, it notifies the module which did the registration that the value
696   of this PCD token has been set. Secondly, it provides a mechanism for the
697   module that did the registration to intercept the set operation and override
698   the value that has been set, if necessary. After the invocation of the callback function,
699   TokenData will be used by PCD service DXE driver to modify the internal data in
700   PCD database.
701 
702   @param[in]  CallBackGuid    The PCD token GUID being set.
703   @param[in]  CallBackToken   The PCD token number being set.
704   @param[in, out] TokenData   A pointer to the token data being set.
705   @param[in]  TokenDataSize   The size, in bytes, of the data being set.
706 
707   @retval VOID
708 
709 **/
710 typedef
711 VOID
712 (EFIAPI *PCD_PROTOCOL_CALLBACK)(
713   IN CONST EFI_GUID         *CallBackGuid, OPTIONAL
714   IN       UINTN            CallBackToken,
715   IN OUT   VOID             *TokenData,
716   IN       UINTN            TokenDataSize
717   );
718 
719 
720 
721 /**
722   Specifies a function to be called anytime the value of a designated token is changed.
723 
724   @param[in]  TokenNumber       The PCD token number.
725   @param[in]  Guid              The 128-bit unique value that designates the namespace from which to extract the value.
726   @param[in]  CallBackFunction  The function prototype called when the value associated with the CallBackToken is set.
727 
728   @retval EFI_SUCCESS   The PCD service has successfully established a call event
729                         for the CallBackToken requested.
730   @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
731 
732 **/
733 typedef
734 EFI_STATUS
735 (EFIAPI *PCD_PROTOCOL_CALLBACK_ONSET)(
736   IN  CONST EFI_GUID          *Guid, OPTIONAL
737   IN  UINTN                   TokenNumber,
738   IN  PCD_PROTOCOL_CALLBACK   CallBackFunction
739   );
740 
741 
742 
743 /**
744   Cancels a previously set callback function for a particular PCD token number.
745 
746   @param[in]  TokenNumber      The PCD token number.
747   @param[in]  Guid             The 128-bit unique value that designates the namespace from which to extract the value.
748   @param[in]  CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
749 
750   @retval EFI_SUCCESS   The PCD service has successfully established a call event
751                         for the CallBackToken requested.
752   @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
753 
754 **/
755 typedef
756 EFI_STATUS
757 (EFIAPI *PCD_PROTOCOL_CANCEL_CALLBACK)(
758   IN  CONST EFI_GUID          *Guid, OPTIONAL
759   IN  UINTN                   TokenNumber,
760   IN  PCD_PROTOCOL_CALLBACK   CallBackFunction
761   );
762 
763 
764 
765 /**
766   Retrieves the next valid token number in a given namespace.
767 
768   This is useful since the PCD infrastructure contains a sparse list of token numbers,
769   and one cannot a priori know what token numbers are valid in the database.
770 
771   If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
772   If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
773   If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
774   If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
775   The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
776   If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
777   If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
778   If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
779 
780 
781   @param[in]      Guid    The 128-bit unique value that designates the namespace from which to retrieve the next token.
782                           This is an optional parameter that may be NULL. If this parameter is NULL, then a request is
783                           being made to retrieve tokens from the default token space.
784   @param[in,out]  TokenNumber
785                           A pointer to the PCD token number to use to find the subsequent token number.
786 
787   @retval EFI_SUCCESS   The PCD service has retrieved the next valid token number.
788   @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
789 
790 **/
791 typedef
792 EFI_STATUS
793 (EFIAPI *PCD_PROTOCOL_GET_NEXT_TOKEN)(
794   IN      CONST EFI_GUID      *Guid, OPTIONAL
795   IN OUT  UINTN               *TokenNumber
796   );
797 
798 
799 
800 /**
801   Retrieves the next valid PCD token namespace for a given namespace.
802 
803   Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
804   token namespaces on a platform.
805 
806   @param[in, out]   Guid    An indirect pointer to EFI_GUID. On input it designates a known token namespace
807                             from which the search will start. On output, it designates the next valid token
808                             namespace on the platform. If *Guid is NULL, then the GUID of the first token
809                             space of the current platform is returned. If the search cannot locate the next valid
810                             token namespace, an error is returned and the value of *Guid is undefined.
811 
812   @retval   EFI_SUCCESS   The PCD service retrieved the value requested.
813   @retval   EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
814 
815 **/
816 typedef
817 EFI_STATUS
818 (EFIAPI *PCD_PROTOCOL_GET_NEXT_TOKENSPACE)(
819   IN  OUT    CONST EFI_GUID      **Guid
820   );
821 
822 ///
823 /// This service abstracts the ability to set/get Platform Configuration Database (PCD).
824 ///
825 typedef struct {
826   PCD_PROTOCOL_SET_SKU              SetSku;
827 
828   PCD_PROTOCOL_GET8                 Get8;
829   PCD_PROTOCOL_GET16                Get16;
830   PCD_PROTOCOL_GET32                Get32;
831   PCD_PROTOCOL_GET64                Get64;
832   PCD_PROTOCOL_GET_POINTER          GetPtr;
833   PCD_PROTOCOL_GET_BOOLEAN          GetBool;
834   PCD_PROTOCOL_GET_SIZE             GetSize;
835 
836   PCD_PROTOCOL_GET_EX_8             Get8Ex;
837   PCD_PROTOCOL_GET_EX_16            Get16Ex;
838   PCD_PROTOCOL_GET_EX_32            Get32Ex;
839   PCD_PROTOCOL_GET_EX_64            Get64Ex;
840   PCD_PROTOCOL_GET_EX_POINTER       GetPtrEx;
841   PCD_PROTOCOL_GET_EX_BOOLEAN       GetBoolEx;
842   PCD_PROTOCOL_GET_EX_SIZE          GetSizeEx;
843 
844   PCD_PROTOCOL_SET8                 Set8;
845   PCD_PROTOCOL_SET16                Set16;
846   PCD_PROTOCOL_SET32                Set32;
847   PCD_PROTOCOL_SET64                Set64;
848   PCD_PROTOCOL_SET_POINTER          SetPtr;
849   PCD_PROTOCOL_SET_BOOLEAN          SetBool;
850 
851   PCD_PROTOCOL_SET_EX_8             Set8Ex;
852   PCD_PROTOCOL_SET_EX_16            Set16Ex;
853   PCD_PROTOCOL_SET_EX_32            Set32Ex;
854   PCD_PROTOCOL_SET_EX_64            Set64Ex;
855   PCD_PROTOCOL_SET_EX_POINTER       SetPtrEx;
856   PCD_PROTOCOL_SET_EX_BOOLEAN       SetBoolEx;
857 
858   PCD_PROTOCOL_CALLBACK_ONSET       CallbackOnSet;
859   PCD_PROTOCOL_CANCEL_CALLBACK      CancelCallback;
860   PCD_PROTOCOL_GET_NEXT_TOKEN       GetNextToken;
861   PCD_PROTOCOL_GET_NEXT_TOKENSPACE  GetNextTokenSpace;
862 } PCD_PROTOCOL;
863 
864 #endif
865