c4e5502a0d065fff9c328aabd7a5c2430fa1dfb3
[mirror_edk2.git] / MdePkg / Include / Library / PcdLib.h
1 /** @file
2 PCD Library Class Interface Declarations
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. 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 Module Name: PcdLib.h
15
16 **/
17
18 #ifndef __PCD_LIB_H__
19 #define __PCD_LIB_H__
20
21 #define PCD_INVALID_TOKEN_NUMBER ((UINTN) -1)
22
23 #define PcdToken(TokenName) _PCD_TOKEN_##TokenName
24
25
26 //
27 // Feature Flag is in the form of a global constant
28 //
29 #define FeaturePcdGet(TokenName) _gPcd_FixedAtBuild_##TokenName
30
31
32 //
33 // Fixed is fixed at build time
34 //
35 #define FixedPcdGet8(TokenName) _gPcd_FixedAtBuild_##TokenName
36 #define FixedPcdGet16(TokenName) _gPcd_FixedAtBuild_##TokenName
37 #define FixedPcdGet32(TokenName) _gPcd_FixedAtBuild_##TokenName
38 #define FixedPcdGet64(TokenName) _gPcd_FixedAtBuild_##TokenName
39 #define FixedPcdGetBool(TokenName) _gPcd_FixedAtBuild_##TokenName
40
41
42 //
43 // BugBug: This works for strings, but not constants.
44 //
45 #define FixedPcdGetPtr(TokenName) ((VOID *)_gPcd_FixedAtBuild_##TokenName)
46
47
48 //
49 // (Binary) Patch is in the form of a global variable
50 //
51 #define PatchPcdGet8(TokenName) _gPcd_BinaryPatch_##TokenName
52 #define PatchPcdGet16(TokenName) _gPcd_BinaryPatch_##TokenName
53 #define PatchPcdGet32(TokenName) _gPcd_BinaryPatch_##TokenName
54 #define PatchPcdGet64(TokenName) _gPcd_BinaryPatch_##TokenName
55 #define PatchPcdGetBool(TokenName) _gPcd_BinaryPatch_##TokenName
56 #define PatchPcdGetPtr(TokenName) ((VOID *)_gPcd_BinaryPatch_##TokenName)
57
58 #define PatchPcdSet8(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = Value)
59 #define PatchPcdSet16(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = Value)
60 #define PatchPcdSet32(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = Value)
61 #define PatchPcdSet64(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = Value)
62 #define PatchPcdSetBool(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = Value)
63 #define PatchPcdSetPtr(TokenName, Size, Buffer) CopyMem (_gPcd_BinaryPatch_##TokenName, Buffer, Size)
64
65 //
66 // Dynamic is via the protocol with only the TokenNumber as argument
67 // It can also be Patch or Fixed type based on a build option
68 //
69 #define PcdGet8(TokenName) _PCD_MODE_8_##TokenName
70 #define PcdGet16(TokenName) _PCD_MODE_16_##TokenName
71 #define PcdGet32(TokenName) _PCD_MODE_32_##TokenName
72 #define PcdGet64(TokenName) _PCD_MODE_64_##TokenName
73 #define PcdGetPtr(TokenName) _PCD_MODE_PTR_##TokenName
74 #define PcdGetBool(TokenName) _PCD_MODE_BOOL_##TokenName
75
76
77 //
78 // Dynamic Ex is to support binary distribution
79 //
80 #define PcdGetEx8(Guid, TokenName) LibPcdGetEx8 (Guid, _PCD_TOKEN_##TokenName)
81 #define PcdGetEx16(Guid, TokenName) LibPcdGetEx16 (Guid, _PCD_TOKEN_##TokenName)
82 #define PcdGetEx32(Guid, TokenName) LibPcdGetEx32 (Guid, _PCD_TOKEN_##TokenName)
83 #define PcdGetEx64(Guid, TokenName) LibPcdGetEx64 (Guid, _PCD_TOKEN_##TokenName)
84 #define PcdGetExPtr(Guid, TokenName) LibPcdGetExPtr (Guid, _PCD_TOKEN_##TokenName)
85 #define PcdGetExBool(Guid, TokenName) LibPcdGetExBool (Guid, _PCD_TOKEN_##TokenName)
86
87
88 //
89 // Dynamic Set
90 //
91 #define PcdSet8(TokenName, Value) LibPcdSet8 (_PCD_TOKEN_##TokenName, Value)
92 #define PcdSet16(TokenName, Value) LibPcdSet16 (_PCD_TOKEN_##TokenName, Value)
93 #define PcdSet32(TokenName, Value) LibPcdSet32 (_PCD_TOKEN_##TokenName, Value)
94 #define PcdSet64(TokenName, Value) LibPcdSet64 (_PCD_TOKEN_##TokenName, Value)
95 #define PcdSetPtr(TokenName, SizeOfBuffer, Buffer) LibPcdSetPtr (_PCD_TOKEN_##TokenName, SizeOfBuffer, Buffer)
96 #define PcdSetBool(TokenName, Value) LibPcdSetBool(_PCD_TOKEN_##TokenName, Value)
97
98
99 //
100 // Dynamic Set Ex
101 //
102 #define PcdSetEx8(Guid, TokenName, Value) LibPcdSetEx8 (Guid, _PCD_TOKEN_##TokenName, Value)
103 #define PcdSetEx16(Guid, TokenName, Value) LibPcdSetEx16 (Guid, _PCD_TOKEN_##TokenName, Value)
104 #define PcdSetEx32(Guid, TokenName, Value) LibPcdSetEx32 (Guid, _PCD_TOKEN_##TokenName, Value)
105 #define PcdSetEx64(Guid, TokenName, Value) LibPcdSetEx64 (Guid, _PCD_TOKEN_##TokenName, Value)
106 #define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer) LibPcdSetExPtr (Guid, _PCD_TOKEN_##TokenName, SizeOfBuffer, Buffer)
107 #define PcdSetExBool(Guid, TokenName, Value) LibPcdSetExBool(Guid, _PCD_TOKEN_##TokenName, Value)
108
109
110 /**
111 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
112
113 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
114 set values associated with a PCD token.
115
116 @retval SKU_ID Return the SKU ID that just be set.
117
118 **/
119 UINTN
120 EFIAPI
121 LibPcdSetSku (
122 IN UINTN SkuId
123 );
124
125
126 /**
127 Returns the 8-bit value for the token specified by TokenNumber.
128
129 @param[in] The PCD token number to retrieve a current value for.
130
131 @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber.
132
133 **/
134 UINT8
135 EFIAPI
136 LibPcdGet8 (
137 IN UINTN TokenNumber
138 );
139
140
141 /**
142 Returns the 16-bit value for the token specified by TokenNumber.
143
144 @param[in] The PCD token number to retrieve a current value for.
145
146 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber.
147
148 **/
149 UINT16
150 EFIAPI
151 LibPcdGet16 (
152 IN UINTN TokenNumber
153 );
154
155
156 /**
157 Returns the 32-bit value for the token specified by TokenNumber.
158
159 @param[in] TokenNumber The PCD token number to retrieve a current value for.
160
161 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.
162
163 **/
164 UINT32
165 EFIAPI
166 LibPcdGet32 (
167 IN UINTN TokenNumber
168 );
169
170
171 /**
172 Returns the 64-bit value for the token specified by TokenNumber.
173
174 @param[in] TokenNumber The PCD token number to retrieve a current value for.
175
176 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.
177
178 **/
179 UINT64
180 EFIAPI
181 LibPcdGet64 (
182 IN UINTN TokenNumber
183 );
184
185
186 /**
187 Returns the pointer to the buffer of the token specified by TokenNumber.
188
189 @param[in] TokenNumber The PCD token number to retrieve a current value for.
190
191 @retval VOID* Returns the pointer to the token specified by TokenNumber.
192
193 **/
194 VOID *
195 EFIAPI
196 LibPcdGetPtr (
197 IN UINTN TokenNumber
198 );
199
200
201 /**
202 Returns the Boolean value of the token specified by TokenNumber.
203
204 @param[in] TokenNumber The PCD token number to retrieve a current value for.
205
206 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber.
207
208 **/
209 BOOLEAN
210 EFIAPI
211 LibPcdGetBool (
212 IN UINTN TokenNumber
213 );
214
215
216 /**
217 Returns the size of the token specified by TokenNumber.
218
219 @param[in] TokenNumber The PCD token number to retrieve a current value for.
220
221 @retval UINTN Returns the size of the token specified by TokenNumber.
222
223 **/
224 UINTN
225 EFIAPI
226 LibPcdGetSize (
227 IN UINTN TokenNumber
228 );
229
230
231 /**
232 Returns the 8-bit value for the token specified by TokenNumber and Guid.
233 If Guid is NULL, then ASSERT().
234
235 @param[in] Guid Pointer to a 128-bit unique value that designates
236 which namespace to retrieve a value from.
237 @param[in] TokenNumber The PCD token number to retrieve a current value for.
238
239 @retval UINT8 Return the UINT8.
240
241 **/
242 UINT8
243 EFIAPI
244 LibPcdGetEx8 (
245 IN CONST GUID *Guid,
246 IN UINTN TokenNumber
247 );
248
249
250 /**
251 Returns the 16-bit value for the token specified by TokenNumber and Guid.
252 If Guid is NULL, then ASSERT().
253
254 @param[in] Guid Pointer to a 128-bit unique value that designates
255 which namespace to retrieve a value from.
256 @param[in] TokenNumber The PCD token number to retrieve a current value for.
257
258 @retval UINT16 Return the UINT16.
259
260 **/
261 UINT16
262 EFIAPI
263 LibPcdGetEx16 (
264 IN CONST GUID *Guid,
265 IN UINTN TokenNumber
266 );
267
268
269 /**
270 Returns the 32-bit value for the token specified by TokenNumber and Guid.
271 If Guid is NULL, then ASSERT().
272
273 @param[in] Guid Pointer to a 128-bit unique value that designates
274 which namespace to retrieve a value from.
275 @param[in] TokenNumber The PCD token number to retrieve a current value for.
276
277 @retval UINT32 Return the UINT32.
278
279 **/
280 UINT32
281 EFIAPI
282 LibPcdGetEx32 (
283 IN CONST GUID *Guid,
284 IN UINTN TokenNumber
285 );
286
287
288 /**
289 Returns the 64-bit value for the token specified by TokenNumber and Guid.
290 If Guid is NULL, then ASSERT().
291
292 @param[in] Guid Pointer to a 128-bit unique value that designates
293 which namespace to retrieve a value from.
294 @param[in] TokenNumber The PCD token number to retrieve a current value for.
295
296 @retval UINT64 Return the UINT64.
297
298 **/
299 UINT64
300 EFIAPI
301 LibPcdGetEx64 (
302 IN CONST GUID *Guid,
303 IN UINTN TokenNumber
304 );
305
306
307 /**
308 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
309 If Guid is NULL, then ASSERT().
310
311 @param[in] Guid Pointer to a 128-bit unique value that designates
312 which namespace to retrieve a value from.
313 @param[in] TokenNumber The PCD token number to retrieve a current value for.
314
315 @retval VOID* Return the VOID* pointer.
316
317 **/
318 VOID *
319 EFIAPI
320 LibPcdGetExPtr (
321 IN CONST GUID *Guid,
322 IN UINTN TokenNumber
323 );
324
325
326 /**
327 Returns the Boolean value of the token specified by TokenNumber and Guid.
328 If Guid is NULL, then ASSERT().
329
330 @param[in] Guid Pointer to a 128-bit unique value that designates
331 which namespace to retrieve a value from.
332 @param[in] TokenNumber The PCD token number to retrieve a current value for.
333
334 @retval BOOLEAN Return the BOOLEAN.
335
336 **/
337 BOOLEAN
338 EFIAPI
339 LibPcdGetExBool (
340 IN CONST GUID *Guid,
341 IN UINTN TokenNumber
342 );
343
344
345 /**
346 Returns the size of the token specified by TokenNumber and Guid.
347 If Guid is NULL, then ASSERT().
348
349 @param[in] Guid Pointer to a 128-bit unique value that designates
350 which namespace to retrieve a value from.
351 @param[in] TokenNumber The PCD token number to retrieve a current value for.
352
353 @retval UINTN Return the size.
354
355 **/
356 UINTN
357 EFIAPI
358 LibPcdGetExSize (
359 IN CONST GUID *Guid,
360 IN UINTN TokenNumber
361 );
362
363
364 /**
365 Sets the 8-bit value for the token specified by TokenNumber
366 to the value specified by Value. Value is returned.
367
368 @param[in] TokenNumber The PCD token number to set a current value for.
369 @param[in] Value The 8-bit value to set.
370
371 @retval UINT8 Return the value been set.
372
373 **/
374 UINT8
375 EFIAPI
376 LibPcdSet8 (
377 IN UINTN TokenNumber,
378 IN UINT8 Value
379 );
380
381
382 /**
383 Sets the 16-bit value for the token specified by TokenNumber
384 to the value specified by Value. Value is returned.
385
386 @param[in] TokenNumber The PCD token number to set a current value for.
387 @param[in] Value The 16-bit value to set.
388
389 @retval UINT16 Return the value been set.
390
391 **/
392 UINT16
393 EFIAPI
394 LibPcdSet16 (
395 IN UINTN TokenNumber,
396 IN UINT16 Value
397 );
398
399
400 /**
401 Sets the 32-bit value for the token specified by TokenNumber
402 to the value specified by Value. Value is returned.
403
404 @param[in] TokenNumber The PCD token number to set a current value for.
405 @param[in] Value The 32-bit value to set.
406
407 @retval UINT32 Return the value been set.
408
409 **/
410 UINT32
411 EFIAPI
412 LibPcdSet32 (
413 IN UINTN TokenNumber,
414 IN UINT32 Value
415 );
416
417
418 /**
419 Sets the 64-bit value for the token specified by TokenNumber
420 to the value specified by Value. Value is returned.
421
422 @param[in] TokenNumber The PCD token number to set a current value for.
423 @param[in] Value The 64-bit value to set.
424
425 @retval UINT64 Return the value been set.
426
427 **/
428 UINT64
429 EFIAPI
430 LibPcdSet64 (
431 IN UINTN TokenNumber,
432 IN UINT64 Value
433 );
434
435
436 /**
437 Sets a buffer for the token specified by TokenNumber to
438 the value specified by Value. Value is returned.
439 If Value is NULL, then ASSERT().
440
441 @param[in] TokenNumber The PCD token number to set a current value for.
442 @param[in] Value A pointer to the buffer to set.
443
444 @retval VOID* Return the pointer for the buffer been set.
445
446 **/
447 VOID*
448 EFIAPI
449 LibPcdSetPtr (
450 IN UINTN TokenNumber,
451 IN UINTN SizeOfBuffer,
452 IN VOID *Value
453 );
454
455
456 /**
457 Sets the Boolean value for the token specified by TokenNumber
458 to the value specified by Value. Value is returned.
459
460 @param[in] TokenNumber The PCD token number to set a current value for.
461 @param[in] Value The boolean value to set.
462
463 @retval BOOLEAN Return the value been set.
464
465 **/
466 BOOLEAN
467 EFIAPI
468 LibPcdSetBool (
469 IN UINTN TokenNumber,
470 IN BOOLEAN Value
471 );
472
473
474 /**
475 Sets the 8-bit value for the token specified by TokenNumber and
476 Guid to the value specified by Value. Value is returned.
477 If Guid is NULL, then ASSERT().
478
479 @param[in] Guid Pointer to a 128-bit unique value that
480 designates which namespace to set a value from.
481 @param[in] TokenNumber The PCD token number to set a current value for.
482 @param[in] Value The 8-bit value to set.
483
484 @retval UINT8 Return the value been set.
485
486 **/
487 UINT8
488 EFIAPI
489 LibPcdSetEx8 (
490 IN CONST GUID *Guid,
491 IN UINTN TokenNumber,
492 IN UINT8 Value
493 );
494
495
496 /**
497 Sets the 16-bit value for the token specified by TokenNumber and
498 Guid to the value specified by Value. Value is returned.
499 If Guid is NULL, then ASSERT().
500
501 @param[in] Guid Pointer to a 128-bit unique value that
502 designates which namespace to set a value from.
503 @param[in] TokenNumber The PCD token number to set a current value for.
504 @param[in] Value The 16-bit value to set.
505
506 @retval UINT8 Return the value been set.
507
508 **/
509 UINT16
510 EFIAPI
511 LibPcdSetEx16 (
512 IN CONST GUID *Guid,
513 IN UINTN TokenNumber,
514 IN UINT16 Value
515 );
516
517
518 /**
519 Sets the 32-bit value for the token specified by TokenNumber and
520 Guid to the value specified by Value. Value is returned.
521 If Guid is NULL, then ASSERT().
522
523 @param[in] Guid Pointer to a 128-bit unique value that
524 designates which namespace to set a value from.
525 @param[in] TokenNumber The PCD token number to set a current value for.
526 @param[in] Value The 32-bit value to set.
527
528 @retval UINT32 Return the value been set.
529
530 **/
531 UINT32
532 EFIAPI
533 LibPcdSetEx32 (
534 IN CONST GUID *Guid,
535 IN UINTN TokenNumber,
536 IN UINT32 Value
537 );
538
539
540 /**
541 Sets the 64-bit value for the token specified by TokenNumber and
542 Guid to the value specified by Value. Value is returned.
543 If Guid is NULL, then ASSERT().
544
545 @param[in] Guid Pointer to a 128-bit unique value that
546 designates which namespace to set a value from.
547 @param[in] TokenNumber The PCD token number to set a current value for.
548 @param[in] Value The 64-bit value to set.
549
550 @retval UINT64 Return the value been set.
551
552 **/
553 UINT64
554 EFIAPI
555 LibPcdSetEx64 (
556 IN CONST GUID *Guid,
557 IN UINTN TokenNumber,
558 IN UINT64 Value
559 );
560
561
562 /**
563 Sets a buffer for the token specified by TokenNumber and
564 Guid to the value specified by Value. Value is returned.
565 If Guid is NULL, then ASSERT().
566 If Value is NULL, then ASSERT().
567
568 @param[in] Guid Pointer to a 128-bit unique value that
569 designates which namespace to set a value from.
570 @param[in] TokenNumber The PCD token number to set a current value for.
571 @param[in] Value The 8-bit value to set.
572
573 @retval VOID * Return the value been set.
574
575 **/
576 VOID *
577 EFIAPI
578 LibPcdSetExPtr (
579 IN CONST GUID *Guid,
580 IN UINTN TokenNumber,
581 IN UINTN SizeOfBuffer,
582 IN VOID *Value
583 );
584
585
586 /**
587 Sets the Boolean value for the token specified by TokenNumber and
588 Guid to the value specified by Value. Value is returned.
589 If Guid is NULL, then ASSERT().
590
591 @param[in] Guid Pointer to a 128-bit unique value that
592 designates which namespace to set a value from.
593 @param[in] TokenNumber The PCD token number to set a current value for.
594 @param[in] Value The Boolean value to set.
595
596 @retval Boolean Return the value been set.
597
598 **/
599 BOOLEAN
600 EFIAPI
601 LibPcdSetExBool (
602 IN CONST GUID *Guid,
603 IN UINTN TokenNumber,
604 IN BOOLEAN Value
605 );
606
607
608 /**
609 When the token specified by TokenNumber and Guid is set,
610 then notification function specified by NotificationFunction is called.
611 If Guid is NULL, then the default token space is used.
612 If NotificationFunction is NULL, then ASSERT().
613
614 @param[in] CallBackGuid The PCD token GUID being set.
615 @param[in] CallBackToken The PCD token number being set.
616 @param[in] TokenData A pointer to the token data being set.
617 @param[in] TokenDataSize The size, in bytes, of the data being set.
618
619 @retval VOID
620
621 **/
622 typedef
623 VOID
624 (EFIAPI *PCD_CALLBACK) (
625 IN CONST GUID *CallBackGuid, OPTIONAL
626 IN UINTN CallBackToken,
627 IN OUT VOID *TokenData,
628 IN UINTN TokenDataSize
629 );
630
631
632 /**
633 When the token specified by TokenNumber and Guid is set,
634 then notification function specified by NotificationFunction is called.
635 If Guid is NULL, then the default token space is used.
636 If NotificationFunction is NULL, then ASSERT().
637
638 @param[in] Guid Pointer to a 128-bit unique value that designates which
639 namespace to set a value from. If NULL, then the default
640 token space is used.
641 @param[in] TokenNumber The PCD token number to monitor.
642 @param[in] NotificationFunction The function to call when the token
643 specified by Guid and TokenNumber is set.
644
645 @retval VOID
646
647 **/
648 VOID
649 EFIAPI
650 LibPcdCallbackOnSet (
651 IN CONST GUID *Guid, OPTIONAL
652 IN UINTN TokenNumber,
653 IN PCD_CALLBACK NotificationFunction
654 );
655
656
657 /**
658 Disable a notification function that was established with LibPcdCallbackonSet().
659
660 @param[in] Guid Specify the GUID token space.
661 @param[in] TokenNumber Specify the token number.
662 @param[in] NotificationFunction The callback function to be unregistered.
663
664 @retval VOID
665
666 **/
667 VOID
668 EFIAPI
669 LibPcdCancelCallback (
670 IN CONST GUID *Guid, OPTIONAL
671 IN UINTN TokenNumber,
672 IN PCD_CALLBACK NotificationFunction
673 );
674
675
676 /**
677 Retrieves the next PCD token number from the token space specified by Guid.
678 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
679 then the first token number is returned. Otherwise, the token number that
680 follows TokenNumber in the token space is returned. If TokenNumber is the last
681 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
682 is not in the token space specified by Guid, then ASSERT().
683
684 @param[in] Pointer to a 128-bit unique value that designates which namespace
685 to set a value from. If NULL, then the default token space is used.
686 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
687 token number.
688
689 @retval UINTN The next valid token number.
690
691 **/
692 UINTN
693 EFIAPI
694 LibPcdGetNextToken (
695 IN CONST GUID *Guid, OPTIONAL
696 IN UINTN TokenNumber
697 );
698
699 #endif