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