]>
Commit | Line | Data |
---|---|---|
e386b444 | 1 | /** @file\r |
2 | Implementation of PcdLib class library for DXE phase.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation<BR>\r | |
5 | All rights reserved. This program and the accompanying materials \r | |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
12 | \r | |
13 | \r | |
14 | Module Name: DxePcdLib.c\r | |
15 | \r | |
16 | **/\r | |
17 | \r | |
18 | //\r | |
c7d265a9 | 19 | // The package level header files this module uses\r |
e386b444 | 20 | //\r |
c7d265a9 | 21 | #include <PiDxe.h>\r |
22 | //\r | |
23 | // The protocols, PPI and GUID defintions for this module\r | |
24 | //\r | |
25 | #include <Protocol/Pcd.h>\r | |
26 | //\r | |
27 | // The Library classes this module consumes\r | |
28 | //\r | |
29 | #include <Library/PcdLib.h>\r | |
30 | #include <Library/DebugLib.h>\r | |
31 | #include <Library/UefiBootServicesTableLib.h>\r | |
32 | #include <Library/BaseMemoryLib.h>\r | |
e386b444 | 33 | \r |
34 | static PCD_PROTOCOL *mPcd;\r | |
35 | \r | |
36 | /**\r | |
37 | The constructor function caches the PCD_PROTOCOL pointer.\r | |
38 | \r | |
39 | @param[in] ImageHandle The firmware allocated handle for the EFI image. \r | |
40 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
41 | \r | |
42 | @retval EFI_SUCCESS The constructor always return EFI_SUCCESS.\r | |
43 | \r | |
44 | **/\r | |
45 | EFI_STATUS\r | |
46 | EFIAPI\r | |
47 | PcdLibConstructor (\r | |
48 | IN EFI_HANDLE ImageHandle,\r | |
49 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
50 | )\r | |
51 | {\r | |
52 | EFI_STATUS Status;\r | |
53 | \r | |
54 | Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd);\r | |
55 | ASSERT_EFI_ERROR (Status);\r | |
56 | \r | |
57 | return EFI_SUCCESS;\r | |
58 | }\r | |
59 | \r | |
60 | \r | |
61 | /**\r | |
62 | Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.\r | |
63 | \r | |
64 | @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and \r | |
65 | set values associated with a PCD token.\r | |
66 | \r | |
67 | @retval SKU_ID Return the SKU ID that just be set.\r | |
68 | \r | |
69 | **/\r | |
70 | UINTN\r | |
71 | EFIAPI\r | |
72 | LibPcdSetSku (\r | |
73 | IN UINTN SkuId\r | |
74 | )\r | |
75 | {\r | |
76 | ASSERT (SkuId < 0x100);\r | |
77 | \r | |
78 | mPcd->SetSku (SkuId);\r | |
79 | \r | |
80 | return SkuId;\r | |
81 | }\r | |
82 | \r | |
83 | \r | |
84 | \r | |
85 | /**\r | |
86 | Returns the 8-bit value for the token specified by TokenNumber. \r | |
87 | \r | |
88 | @param[in] The PCD token number to retrieve a current value for.\r | |
89 | \r | |
90 | @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber. \r | |
91 | \r | |
92 | **/\r | |
93 | UINT8\r | |
94 | EFIAPI\r | |
95 | LibPcdGet8 (\r | |
96 | IN UINTN TokenNumber\r | |
97 | )\r | |
98 | {\r | |
99 | return mPcd->Get8 (TokenNumber);\r | |
100 | }\r | |
101 | \r | |
102 | \r | |
103 | \r | |
104 | /**\r | |
105 | Returns the 16-bit value for the token specified by TokenNumber. \r | |
106 | \r | |
107 | @param[in] The PCD token number to retrieve a current value for.\r | |
108 | \r | |
109 | @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber. \r | |
110 | \r | |
111 | **/\r | |
112 | UINT16\r | |
113 | EFIAPI\r | |
114 | LibPcdGet16 (\r | |
115 | IN UINTN TokenNumber\r | |
116 | )\r | |
117 | {\r | |
118 | return mPcd->Get16 (TokenNumber);\r | |
119 | }\r | |
120 | \r | |
121 | \r | |
122 | \r | |
123 | /**\r | |
124 | Returns the 32-bit value for the token specified by TokenNumber. \r | |
125 | \r | |
126 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
127 | \r | |
128 | @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.\r | |
129 | \r | |
130 | **/\r | |
131 | UINT32\r | |
132 | EFIAPI\r | |
133 | LibPcdGet32 (\r | |
134 | IN UINTN TokenNumber\r | |
135 | )\r | |
136 | {\r | |
137 | return mPcd->Get32 (TokenNumber);\r | |
138 | }\r | |
139 | \r | |
140 | \r | |
141 | \r | |
142 | /**\r | |
143 | Returns the 64-bit value for the token specified by TokenNumber.\r | |
144 | \r | |
145 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
146 | \r | |
147 | @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.\r | |
148 | \r | |
149 | **/\r | |
150 | UINT64\r | |
151 | EFIAPI\r | |
152 | LibPcdGet64 (\r | |
153 | IN UINTN TokenNumber\r | |
154 | )\r | |
155 | {\r | |
156 | return mPcd->Get64 (TokenNumber);\r | |
157 | }\r | |
158 | \r | |
159 | \r | |
160 | \r | |
161 | /**\r | |
162 | Returns the pointer to the buffer of the token specified by TokenNumber.\r | |
163 | \r | |
164 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
165 | \r | |
166 | @retval VOID* Returns the pointer to the token specified by TokenNumber.\r | |
167 | \r | |
168 | **/\r | |
169 | VOID *\r | |
170 | EFIAPI\r | |
171 | LibPcdGetPtr (\r | |
172 | IN UINTN TokenNumber\r | |
173 | )\r | |
174 | {\r | |
175 | return mPcd->GetPtr (TokenNumber);\r | |
176 | }\r | |
177 | \r | |
178 | \r | |
179 | \r | |
180 | /**\r | |
181 | Returns the Boolean value of the token specified by TokenNumber. \r | |
182 | \r | |
183 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
184 | \r | |
185 | @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber. \r | |
186 | \r | |
187 | **/\r | |
188 | BOOLEAN \r | |
189 | EFIAPI\r | |
190 | LibPcdGetBool (\r | |
191 | IN UINTN TokenNumber\r | |
192 | )\r | |
193 | {\r | |
194 | return mPcd->GetBool (TokenNumber);\r | |
195 | }\r | |
196 | \r | |
197 | \r | |
198 | \r | |
199 | /**\r | |
200 | Returns the size of the token specified by TokenNumber. \r | |
201 | \r | |
202 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
203 | \r | |
204 | @retval UINTN Returns the size of the token specified by TokenNumber. \r | |
205 | \r | |
206 | **/\r | |
207 | UINTN\r | |
208 | EFIAPI\r | |
209 | LibPcdGetSize (\r | |
210 | IN UINTN TokenNumber\r | |
211 | )\r | |
212 | {\r | |
213 | return mPcd->GetSize (TokenNumber);\r | |
214 | }\r | |
215 | \r | |
216 | \r | |
217 | \r | |
218 | /**\r | |
219 | Returns the 8-bit value for the token specified by TokenNumber and Guid.\r | |
220 | If Guid is NULL, then ASSERT(). \r | |
221 | \r | |
222 | @param[in] Guid Pointer to a 128-bit unique value that designates \r | |
223 | which namespace to retrieve a value from.\r | |
224 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
225 | \r | |
226 | @retval UINT8 Return the UINT8.\r | |
227 | \r | |
228 | **/\r | |
229 | UINT8\r | |
230 | EFIAPI\r | |
231 | LibPcdGetEx8 (\r | |
232 | IN CONST GUID *Guid,\r | |
233 | IN UINTN TokenNumber\r | |
234 | )\r | |
235 | {\r | |
236 | ASSERT (Guid != NULL);\r | |
237 | \r | |
238 | return mPcd->Get8Ex (Guid, TokenNumber);\r | |
239 | }\r | |
240 | \r | |
241 | \r | |
242 | /**\r | |
243 | Returns the 16-bit value for the token specified by TokenNumber and Guid.\r | |
244 | If Guid is NULL, then ASSERT(). \r | |
245 | \r | |
246 | @param[in] Guid Pointer to a 128-bit unique value that designates \r | |
247 | which namespace to retrieve a value from.\r | |
248 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
249 | \r | |
250 | @retval UINT16 Return the UINT16.\r | |
251 | \r | |
252 | **/\r | |
253 | UINT16\r | |
254 | EFIAPI\r | |
255 | LibPcdGetEx16 (\r | |
256 | IN CONST GUID *Guid,\r | |
257 | IN UINTN TokenNumber\r | |
258 | )\r | |
259 | {\r | |
260 | ASSERT (Guid != NULL);\r | |
261 | \r | |
262 | return mPcd->Get16Ex (Guid, TokenNumber);\r | |
263 | }\r | |
264 | \r | |
265 | \r | |
266 | /**\r | |
267 | Returns the 32-bit value for the token specified by TokenNumber and Guid.\r | |
268 | If Guid is NULL, then ASSERT(). \r | |
269 | \r | |
270 | @param[in] Guid Pointer to a 128-bit unique value that designates \r | |
271 | which namespace to retrieve a value from.\r | |
272 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
273 | \r | |
274 | @retval UINT32 Return the UINT32.\r | |
275 | \r | |
276 | **/\r | |
277 | UINT32\r | |
278 | EFIAPI\r | |
279 | LibPcdGetEx32 (\r | |
280 | IN CONST GUID *Guid,\r | |
281 | IN UINTN TokenNumber\r | |
282 | )\r | |
283 | {\r | |
284 | ASSERT (Guid != NULL);\r | |
285 | \r | |
286 | return mPcd->Get32Ex (Guid, TokenNumber);\r | |
287 | }\r | |
288 | \r | |
289 | \r | |
290 | \r | |
291 | /**\r | |
292 | Returns the 64-bit value for the token specified by TokenNumber and Guid.\r | |
293 | If Guid is NULL, then ASSERT(). \r | |
294 | \r | |
295 | @param[in] Guid Pointer to a 128-bit unique value that designates \r | |
296 | which namespace to retrieve a value from.\r | |
297 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
298 | \r | |
299 | @retval UINT64 Return the UINT64.\r | |
300 | \r | |
301 | **/\r | |
302 | UINT64\r | |
303 | EFIAPI\r | |
304 | LibPcdGetEx64 (\r | |
305 | IN CONST GUID *Guid,\r | |
306 | IN UINTN TokenNumber\r | |
307 | )\r | |
308 | {\r | |
309 | ASSERT (Guid != NULL);\r | |
310 | \r | |
311 | return mPcd->Get64Ex (Guid, TokenNumber);\r | |
312 | }\r | |
313 | \r | |
314 | \r | |
315 | \r | |
316 | /**\r | |
317 | Returns the pointer to the token specified by TokenNumber and Guid.\r | |
318 | If Guid is NULL, then ASSERT(). \r | |
319 | \r | |
320 | @param[in] Guid Pointer to a 128-bit unique value that designates \r | |
321 | which namespace to retrieve a value from.\r | |
322 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
323 | \r | |
324 | @retval VOID* Return the VOID* pointer.\r | |
325 | \r | |
326 | **/\r | |
327 | VOID *\r | |
328 | EFIAPI\r | |
329 | LibPcdGetExPtr (\r | |
330 | IN CONST GUID *Guid,\r | |
331 | IN UINTN TokenNumber\r | |
332 | )\r | |
333 | {\r | |
334 | ASSERT (Guid != NULL);\r | |
335 | \r | |
336 | return mPcd->GetPtrEx (Guid, TokenNumber);\r | |
337 | }\r | |
338 | \r | |
339 | \r | |
340 | \r | |
341 | /**\r | |
342 | Returns the Boolean value of the token specified by TokenNumber and Guid. \r | |
343 | If Guid is NULL, then ASSERT(). \r | |
344 | \r | |
345 | @param[in] Guid Pointer to a 128-bit unique value that designates \r | |
346 | which namespace to retrieve a value from.\r | |
347 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
348 | \r | |
349 | @retval BOOLEAN Return the BOOLEAN.\r | |
350 | \r | |
351 | **/\r | |
352 | BOOLEAN\r | |
353 | EFIAPI\r | |
354 | LibPcdGetExBool (\r | |
355 | IN CONST GUID *Guid,\r | |
356 | IN UINTN TokenNumber\r | |
357 | )\r | |
358 | {\r | |
359 | ASSERT (Guid != NULL);\r | |
360 | \r | |
361 | return mPcd->GetBoolEx (Guid, TokenNumber);\r | |
362 | }\r | |
363 | \r | |
364 | \r | |
365 | \r | |
366 | /**\r | |
367 | Returns the size of the token specified by TokenNumber and Guid. \r | |
368 | If Guid is NULL, then ASSERT(). \r | |
369 | \r | |
370 | @param[in] Guid Pointer to a 128-bit unique value that designates \r | |
371 | which namespace to retrieve a value from.\r | |
372 | @param[in] TokenNumber The PCD token number to retrieve a current value for.\r | |
373 | \r | |
374 | @retval UINTN Return the size.\r | |
375 | \r | |
376 | **/\r | |
377 | UINTN\r | |
378 | EFIAPI\r | |
379 | LibPcdGetExSize (\r | |
380 | IN CONST GUID *Guid,\r | |
381 | IN UINTN TokenNumber\r | |
382 | )\r | |
383 | {\r | |
384 | ASSERT (Guid != NULL);\r | |
385 | \r | |
386 | return mPcd->GetSizeEx (Guid, TokenNumber);\r | |
387 | }\r | |
388 | \r | |
389 | \r | |
390 | \r | |
391 | /**\r | |
392 | Sets the 8-bit value for the token specified by TokenNumber \r | |
393 | to the value specified by Value. Value is returned.\r | |
394 | \r | |
395 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
396 | @param[in] Value The 8-bit value to set.\r | |
397 | \r | |
398 | @retval UINT8 Return the value been set.\r | |
399 | \r | |
400 | **/\r | |
401 | UINT8\r | |
402 | EFIAPI\r | |
403 | LibPcdSet8 (\r | |
404 | IN UINTN TokenNumber,\r | |
405 | IN UINT8 Value\r | |
406 | )\r | |
407 | {\r | |
408 | EFI_STATUS Status;\r | |
409 | \r | |
410 | Status = mPcd->Set8 (TokenNumber, Value);\r | |
411 | \r | |
412 | ASSERT_EFI_ERROR (Status);\r | |
413 | \r | |
414 | return Value;\r | |
415 | }\r | |
416 | \r | |
417 | \r | |
418 | \r | |
419 | /**\r | |
420 | Sets the 16-bit value for the token specified by TokenNumber \r | |
421 | to the value specified by Value. Value is returned.\r | |
422 | \r | |
423 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
424 | @param[in] Value The 16-bit value to set.\r | |
425 | \r | |
426 | @retval UINT16 Return the value been set.\r | |
427 | \r | |
428 | **/\r | |
429 | UINT16\r | |
430 | EFIAPI\r | |
431 | LibPcdSet16 (\r | |
432 | IN UINTN TokenNumber,\r | |
433 | IN UINT16 Value\r | |
434 | )\r | |
435 | {\r | |
436 | EFI_STATUS Status;\r | |
437 | \r | |
438 | Status = mPcd->Set16 (TokenNumber, Value);\r | |
439 | \r | |
440 | ASSERT_EFI_ERROR (Status);\r | |
441 | \r | |
442 | return Value;\r | |
443 | }\r | |
444 | \r | |
445 | \r | |
446 | \r | |
447 | /**\r | |
448 | Sets the 32-bit value for the token specified by TokenNumber \r | |
449 | to the value specified by Value. Value is returned.\r | |
450 | \r | |
451 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
452 | @param[in] Value The 32-bit value to set.\r | |
453 | \r | |
454 | @retval UINT32 Return the value been set.\r | |
455 | \r | |
456 | **/\r | |
457 | UINT32\r | |
458 | EFIAPI\r | |
459 | LibPcdSet32 (\r | |
460 | IN UINTN TokenNumber,\r | |
461 | IN UINT32 Value\r | |
462 | )\r | |
463 | {\r | |
464 | EFI_STATUS Status;\r | |
465 | Status = mPcd->Set32 (TokenNumber, Value);\r | |
466 | \r | |
467 | ASSERT_EFI_ERROR (Status);\r | |
468 | \r | |
469 | return Value;\r | |
470 | }\r | |
471 | \r | |
472 | \r | |
473 | \r | |
474 | /**\r | |
475 | Sets the 64-bit value for the token specified by TokenNumber \r | |
476 | to the value specified by Value. Value is returned.\r | |
477 | \r | |
478 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
479 | @param[in] Value The 64-bit value to set.\r | |
480 | \r | |
481 | @retval UINT64 Return the value been set.\r | |
482 | \r | |
483 | **/\r | |
484 | UINT64\r | |
485 | EFIAPI\r | |
486 | LibPcdSet64 (\r | |
487 | IN UINTN TokenNumber,\r | |
488 | IN UINT64 Value\r | |
489 | )\r | |
490 | {\r | |
491 | EFI_STATUS Status;\r | |
492 | \r | |
493 | Status = mPcd->Set64 (TokenNumber, Value);\r | |
494 | \r | |
495 | ASSERT_EFI_ERROR (Status);\r | |
496 | \r | |
497 | return Value;\r | |
498 | }\r | |
499 | \r | |
500 | \r | |
501 | \r | |
502 | /**\r | |
503 | Sets a buffer for the token specified by TokenNumber to \r | |
504 | the value specified by Buffer and SizeOfValue. Buffer to\r | |
505 | be set is returned. The content of the buffer could be \r | |
506 | overwritten if a Callback on SET is registered with this\r | |
507 | TokenNumber.\r | |
508 | \r | |
509 | If SizeOfValue is greater than the maximum \r | |
510 | size support by TokenNumber, then set SizeOfValue to the \r | |
511 | maximum size supported by TokenNumber and return NULL to \r | |
512 | indicate that the set operation was not actually performed. \r | |
513 | \r | |
514 | If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r | |
515 | \r | |
516 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
517 | @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.\r | |
518 | @param[in] Value A pointer to the buffer to set.\r | |
519 | \r | |
520 | @retval VOID* Return the pointer for the buffer been set.\r | |
521 | \r | |
522 | **/\r | |
523 | \r | |
524 | VOID *\r | |
525 | EFIAPI\r | |
526 | LibPcdSetPtr (\r | |
527 | IN UINTN TokenNumber,\r | |
528 | IN OUT UINTN *SizeOfBuffer,\r | |
529 | IN VOID *Buffer\r | |
530 | )\r | |
531 | {\r | |
532 | EFI_STATUS Status;\r | |
533 | \r | |
534 | ASSERT (SizeOfBuffer != NULL);\r | |
535 | \r | |
536 | if (*SizeOfBuffer > 0) {\r | |
537 | ASSERT (Buffer != NULL);\r | |
538 | }\r | |
539 | \r | |
540 | Status = mPcd->SetPtr (TokenNumber, SizeOfBuffer, Buffer);\r | |
541 | \r | |
542 | if (EFI_ERROR (Status)) {\r | |
543 | return NULL;\r | |
544 | }\r | |
545 | \r | |
546 | return Buffer;\r | |
547 | }\r | |
548 | \r | |
549 | \r | |
550 | \r | |
551 | /**\r | |
552 | Sets the Boolean value for the token specified by TokenNumber \r | |
553 | to the value specified by Value. Value is returned.\r | |
554 | \r | |
555 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
556 | @param[in] Value The boolean value to set.\r | |
557 | \r | |
558 | @retval BOOLEAN Return the value been set.\r | |
559 | \r | |
560 | **/\r | |
561 | BOOLEAN\r | |
562 | EFIAPI\r | |
563 | LibPcdSetBool (\r | |
564 | IN UINTN TokenNumber,\r | |
565 | IN BOOLEAN Value\r | |
566 | )\r | |
567 | {\r | |
568 | EFI_STATUS Status;\r | |
569 | \r | |
570 | Status = mPcd->SetBool (TokenNumber, Value);\r | |
571 | \r | |
572 | ASSERT_EFI_ERROR (Status);\r | |
573 | \r | |
574 | return Value;\r | |
575 | }\r | |
576 | \r | |
577 | \r | |
578 | \r | |
579 | /**\r | |
580 | Sets the 8-bit value for the token specified by TokenNumber and \r | |
581 | Guid to the value specified by Value. Value is returned.\r | |
582 | If Guid is NULL, then ASSERT().\r | |
583 | \r | |
584 | @param[in] Guid Pointer to a 128-bit unique value that \r | |
585 | designates which namespace to set a value from.\r | |
586 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
587 | @param[in] Value The 8-bit value to set.\r | |
588 | \r | |
589 | @retval UINT8 Return the value been set.\r | |
590 | \r | |
591 | **/\r | |
592 | UINT8\r | |
593 | EFIAPI\r | |
594 | LibPcdSetEx8 (\r | |
595 | IN CONST GUID *Guid,\r | |
596 | IN UINTN TokenNumber,\r | |
597 | IN UINT8 Value\r | |
598 | )\r | |
599 | {\r | |
600 | EFI_STATUS Status;\r | |
601 | \r | |
602 | ASSERT (Guid != NULL);\r | |
603 | \r | |
604 | Status = mPcd->Set8Ex (Guid, TokenNumber, Value);\r | |
605 | \r | |
606 | ASSERT_EFI_ERROR (Status);\r | |
607 | \r | |
608 | return Value;\r | |
609 | }\r | |
610 | \r | |
611 | \r | |
612 | \r | |
613 | /**\r | |
614 | Sets the 16-bit value for the token specified by TokenNumber and \r | |
615 | Guid to the value specified by Value. Value is returned.\r | |
616 | If Guid is NULL, then ASSERT().\r | |
617 | \r | |
618 | @param[in] Guid Pointer to a 128-bit unique value that \r | |
619 | designates which namespace to set a value from.\r | |
620 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
621 | @param[in] Value The 16-bit value to set.\r | |
622 | \r | |
623 | @retval UINT8 Return the value been set.\r | |
624 | \r | |
625 | **/\r | |
626 | UINT16\r | |
627 | EFIAPI\r | |
628 | LibPcdSetEx16 (\r | |
629 | IN CONST GUID *Guid,\r | |
630 | IN UINTN TokenNumber,\r | |
631 | IN UINT16 Value\r | |
632 | )\r | |
633 | {\r | |
634 | EFI_STATUS Status;\r | |
635 | \r | |
636 | ASSERT (Guid != NULL);\r | |
637 | \r | |
638 | Status = mPcd->Set16Ex (Guid, TokenNumber, Value);\r | |
639 | \r | |
640 | ASSERT_EFI_ERROR (Status);\r | |
641 | \r | |
642 | return Value;\r | |
643 | }\r | |
644 | \r | |
645 | \r | |
646 | \r | |
647 | /**\r | |
648 | Sets the 32-bit value for the token specified by TokenNumber and \r | |
649 | Guid to the value specified by Value. Value is returned.\r | |
650 | If Guid is NULL, then ASSERT().\r | |
651 | \r | |
652 | @param[in] Guid Pointer to a 128-bit unique value that \r | |
653 | designates which namespace to set a value from.\r | |
654 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
655 | @param[in] Value The 32-bit value to set.\r | |
656 | \r | |
657 | @retval UINT32 Return the value been set.\r | |
658 | \r | |
659 | **/\r | |
660 | UINT32\r | |
661 | EFIAPI\r | |
662 | LibPcdSetEx32 (\r | |
663 | IN CONST GUID *Guid,\r | |
664 | IN UINTN TokenNumber,\r | |
665 | IN UINT32 Value\r | |
666 | )\r | |
667 | {\r | |
668 | EFI_STATUS Status;\r | |
669 | \r | |
670 | ASSERT (Guid != NULL);\r | |
671 | \r | |
672 | Status = mPcd->Set32Ex (Guid, TokenNumber, Value);\r | |
673 | \r | |
674 | ASSERT_EFI_ERROR (Status);\r | |
675 | \r | |
676 | return Value;\r | |
677 | }\r | |
678 | \r | |
679 | \r | |
680 | \r | |
681 | /**\r | |
682 | Sets the 64-bit value for the token specified by TokenNumber and \r | |
683 | Guid to the value specified by Value. Value is returned.\r | |
684 | If Guid is NULL, then ASSERT().\r | |
685 | \r | |
686 | @param[in] Guid Pointer to a 128-bit unique value that \r | |
687 | designates which namespace to set a value from.\r | |
688 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
689 | @param[in] Value The 64-bit value to set.\r | |
690 | \r | |
691 | @retval UINT64 Return the value been set.\r | |
692 | \r | |
693 | **/\r | |
694 | UINT64\r | |
695 | EFIAPI\r | |
696 | LibPcdSetEx64 (\r | |
697 | IN CONST GUID *Guid,\r | |
698 | IN UINTN TokenNumber,\r | |
699 | IN UINT64 Value\r | |
700 | )\r | |
701 | {\r | |
702 | EFI_STATUS Status;\r | |
703 | \r | |
704 | ASSERT (Guid != NULL);\r | |
705 | \r | |
706 | Status = mPcd->Set64Ex (Guid, TokenNumber, Value);\r | |
707 | \r | |
708 | ASSERT_EFI_ERROR (Status);\r | |
709 | \r | |
710 | return Value;\r | |
711 | }\r | |
712 | \r | |
713 | \r | |
714 | \r | |
715 | /**\r | |
716 | Sets a buffer for the token specified by TokenNumber to the value specified by \r | |
717 | Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r | |
718 | the maximum size support by TokenNumber, then set SizeOfValue to the maximum size \r | |
719 | supported by TokenNumber and return NULL to indicate that the set operation \r | |
720 | was not actually performed. \r | |
721 | \r | |
722 | If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r | |
723 | \r | |
724 | @param[in] Guid Pointer to a 128-bit unique value that \r | |
725 | designates which namespace to set a value from.\r | |
726 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
727 | @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r | |
728 | @param[in] Buffer A pointer to the buffer to set.\r | |
729 | \r | |
730 | @retval VOID * Return the pinter to the buffer been set.\r | |
731 | \r | |
732 | **/\r | |
733 | VOID *\r | |
734 | EFIAPI\r | |
735 | LibPcdSetExPtr (\r | |
736 | IN CONST GUID *Guid,\r | |
737 | IN UINTN TokenNumber,\r | |
738 | IN OUT UINTN *SizeOfBuffer,\r | |
739 | IN VOID *Buffer\r | |
740 | )\r | |
741 | {\r | |
742 | EFI_STATUS Status;\r | |
743 | \r | |
744 | ASSERT (Guid != NULL);\r | |
745 | \r | |
746 | ASSERT (SizeOfBuffer != NULL);\r | |
747 | \r | |
748 | if (*SizeOfBuffer > 0) {\r | |
749 | ASSERT (Buffer != NULL);\r | |
750 | }\r | |
751 | \r | |
752 | Status = mPcd->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);\r | |
753 | \r | |
754 | if (EFI_ERROR (Status)) {\r | |
755 | return NULL;\r | |
756 | }\r | |
757 | \r | |
758 | return Buffer;\r | |
759 | }\r | |
760 | \r | |
761 | \r | |
762 | \r | |
763 | /**\r | |
764 | Sets the Boolean value for the token specified by TokenNumber and \r | |
765 | Guid to the value specified by Value. Value is returned.\r | |
766 | If Guid is NULL, then ASSERT().\r | |
767 | \r | |
768 | @param[in] Guid Pointer to a 128-bit unique value that \r | |
769 | designates which namespace to set a value from.\r | |
770 | @param[in] TokenNumber The PCD token number to set a current value for.\r | |
771 | @param[in] Value The Boolean value to set.\r | |
772 | \r | |
773 | @retval Boolean Return the value been set.\r | |
774 | \r | |
775 | **/\r | |
776 | BOOLEAN\r | |
777 | EFIAPI\r | |
778 | LibPcdSetExBool (\r | |
779 | IN CONST GUID *Guid,\r | |
780 | IN UINTN TokenNumber,\r | |
781 | IN BOOLEAN Value\r | |
782 | )\r | |
783 | {\r | |
784 | EFI_STATUS Status;\r | |
785 | \r | |
786 | ASSERT (Guid != NULL);\r | |
787 | \r | |
788 | Status = mPcd->SetBoolEx (Guid, TokenNumber, Value);\r | |
789 | \r | |
790 | ASSERT_EFI_ERROR (Status);\r | |
791 | \r | |
792 | return Value;\r | |
793 | }\r | |
794 | \r | |
795 | \r | |
796 | \r | |
797 | /**\r | |
798 | When the token specified by TokenNumber and Guid is set, \r | |
799 | then notification function specified by NotificationFunction is called. \r | |
800 | If Guid is NULL, then the default token space is used. \r | |
801 | If NotificationFunction is NULL, then ASSERT().\r | |
802 | \r | |
803 | @param[in] Guid Pointer to a 128-bit unique value that designates which \r | |
804 | namespace to set a value from. If NULL, then the default \r | |
805 | token space is used.\r | |
806 | @param[in] TokenNumber The PCD token number to monitor.\r | |
807 | @param[in] NotificationFunction The function to call when the token \r | |
808 | specified by Guid and TokenNumber is set.\r | |
809 | \r | |
810 | @retval VOID\r | |
811 | \r | |
812 | **/\r | |
813 | VOID\r | |
814 | EFIAPI\r | |
815 | LibPcdCallbackOnSet (\r | |
816 | IN CONST GUID *Guid, OPTIONAL\r | |
817 | IN UINTN TokenNumber,\r | |
818 | IN PCD_CALLBACK NotificationFunction\r | |
819 | )\r | |
820 | {\r | |
821 | EFI_STATUS Status;\r | |
822 | \r | |
823 | ASSERT (NotificationFunction != NULL);\r | |
824 | \r | |
825 | Status = mPcd->CallbackOnSet (Guid, TokenNumber, NotificationFunction);\r | |
826 | \r | |
827 | ASSERT_EFI_ERROR (Status);\r | |
828 | \r | |
829 | return;\r | |
830 | }\r | |
831 | \r | |
832 | \r | |
833 | \r | |
834 | /**\r | |
835 | Disable a notification function that was established with LibPcdCallbackonSet().\r | |
836 | If NotificationFunction is NULL, then ASSERT().\r | |
837 | \r | |
838 | @param[in] Guid Specify the GUID token space.\r | |
839 | @param[in] TokenNumber Specify the token number.\r | |
840 | @param[in] NotificationFunction The callback function to be unregistered.\r | |
841 | \r | |
842 | @retval VOID\r | |
843 | \r | |
844 | **/\r | |
845 | VOID\r | |
846 | EFIAPI\r | |
847 | LibPcdCancelCallback (\r | |
848 | IN CONST GUID *Guid, OPTIONAL\r | |
849 | IN UINTN TokenNumber,\r | |
850 | IN PCD_CALLBACK NotificationFunction\r | |
851 | )\r | |
852 | {\r | |
853 | EFI_STATUS Status;\r | |
854 | \r | |
855 | ASSERT (NotificationFunction != NULL);\r | |
856 | \r | |
857 | Status = mPcd->CancelCallback (Guid, TokenNumber, NotificationFunction);\r | |
858 | \r | |
859 | ASSERT_EFI_ERROR (Status);\r | |
860 | \r | |
861 | return;\r | |
862 | }\r | |
863 | \r | |
864 | \r | |
865 | \r | |
866 | /**\r | |
867 | Retrieves the next PCD token number from the token space specified by Guid. \r | |
868 | If Guid is NULL, then the default token space is used. If TokenNumber is 0, \r | |
869 | then the first token number is returned. Otherwise, the token number that \r | |
870 | follows TokenNumber in the token space is returned. If TokenNumber is the last \r | |
871 | token number in the token space, then 0 is returned. If TokenNumber is not 0 and \r | |
872 | is not in the token space specified by Guid, then ASSERT().\r | |
873 | \r | |
874 | @param[in] Pointer to a 128-bit unique value that designates which namespace \r | |
875 | to set a value from. If NULL, then the default token space is used.\r | |
876 | @param[in] The previous PCD token number. If 0, then retrieves the first PCD \r | |
877 | token number.\r | |
878 | \r | |
879 | @retval UINTN The next valid token number.\r | |
880 | \r | |
881 | **/\r | |
882 | UINTN \r | |
883 | EFIAPI\r | |
884 | LibPcdGetNextToken (\r | |
885 | IN CONST GUID *Guid, OPTIONAL\r | |
886 | IN UINTN TokenNumber\r | |
887 | )\r | |
888 | {\r | |
889 | EFI_STATUS Status;\r | |
890 | \r | |
891 | Status = mPcd->GetNextToken (Guid, &TokenNumber);\r | |
892 | \r | |
893 | ASSERT_EFI_ERROR (Status);\r | |
894 | \r | |
895 | return TokenNumber;\r | |
896 | }\r | |
897 | \r | |
898 | \r | |
899 | \r | |
900 | /**\r | |
901 | Retrieves the next PCD token space from a token space specified by Guid.\r | |
902 | Guid of NULL is reserved to mark the default local token namespace on the current\r | |
903 | platform. If Guid is NULL, then the GUID of the first non-local token space of the \r | |
904 | current platform is returned. If Guid is the last non-local token space, \r | |
905 | then NULL is returned. \r | |
906 | \r | |
907 | If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().\r | |
908 | \r | |
909 | \r | |
910 | \r | |
911 | @param[in] Pointer to a 128-bit unique value that designates from which namespace \r | |
912 | to start the search.\r | |
913 | \r | |
914 | @retval CONST GUID * The next valid token namespace.\r | |
915 | \r | |
916 | **/\r | |
917 | GUID * \r | |
918 | EFIAPI\r | |
919 | LibPcdGetNextTokenSpace (\r | |
920 | IN CONST GUID *Guid\r | |
921 | )\r | |
922 | {\r | |
923 | EFI_STATUS Status;\r | |
924 | \r | |
925 | Status = mPcd->GetNextTokenSpace (&Guid);\r | |
926 | \r | |
927 | ASSERT_EFI_ERROR (Status);\r | |
928 | \r | |
929 | return (GUID *) Guid;\r | |
930 | }\r | |
931 | \r | |
932 | \r | |
933 | /**\r | |
934 | Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r | |
935 | and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r | |
936 | MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return \r | |
937 | NULL to indicate that the set operation was not actually performed. \r | |
938 | If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to \r | |
939 | MaximumDatumSize and NULL must be returned.\r | |
940 | \r | |
941 | If PatchVariable is NULL, then ASSERT().\r | |
942 | If SizeOfValue is NULL, then ASSERT().\r | |
943 | If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r | |
944 | \r | |
945 | @param[in] PatchVariable A pointer to the global variable in a module that is \r | |
946 | the target of the set operation.\r | |
947 | @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r | |
948 | @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r | |
949 | @param[in] Buffer A pointer to the buffer to used to set the target variable.\r | |
950 | \r | |
951 | **/\r | |
952 | VOID *\r | |
953 | EFIAPI\r | |
954 | LibPatchPcdSetPtr (\r | |
955 | IN VOID *PatchVariable,\r | |
956 | IN UINTN MaximumDatumSize,\r | |
957 | IN OUT UINTN *SizeOfBuffer,\r | |
958 | IN CONST VOID *Buffer\r | |
959 | )\r | |
960 | {\r | |
961 | ASSERT (PatchVariable != NULL);\r | |
962 | ASSERT (SizeOfBuffer != NULL);\r | |
963 | \r | |
964 | if (*SizeOfBuffer > 0) {\r | |
965 | ASSERT (Buffer != NULL);\r | |
966 | }\r | |
967 | \r | |
968 | if ((*SizeOfBuffer > MaximumDatumSize) ||\r | |
969 | (*SizeOfBuffer == MAX_ADDRESS)) {\r | |
970 | *SizeOfBuffer = MaximumDatumSize;\r | |
971 | return NULL;\r | |
972 | }\r | |
973 | \r | |
974 | CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r | |
975 | \r | |
976 | return (VOID *) Buffer;\r | |
977 | }\r | |
978 | \r | |
979 | \r | |
980 | \r |