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