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