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