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