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