1) Fix bug reported on the PcdSetEx* Macro.
[mirror_edk2.git] / EdkModulePkg / Universal / PCD / Dxe / Pcd.c
CommitLineData
878ddf1f 1/** @file\r
2PCD DXE driver\r
3\r
4Copyright (c) 2006, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13\r
14Module Name: Pcd.c\r
15\r
16**/\r
17\r
18#include "../Common/PcdCommon.h"\r
19#include "Service.h"\r
20\r
21\r
22PCD_PROTOCOL mPcdInstance = {\r
23 DxePcdSetSku,\r
24\r
25 DxePcdGet8,\r
26 DxePcdGet16,\r
27 DxePcdGet32,\r
28 DxePcdGet64,\r
29 DxePcdGetPtr,\r
30 DxePcdGetBool,\r
31 DxePcdGetSize,\r
32\r
33 DxePcdGet8Ex,\r
34 DxePcdGet16Ex,\r
35 DxePcdGet32Ex,\r
36 DxePcdGet64Ex,\r
37 DxePcdGetPtrEx,\r
38 DxePcdGetBoolEx,\r
39 DxePcdGetSizeEx,\r
40\r
41 DxePcdSet8,\r
42 DxePcdSet16,\r
43 DxePcdSet32,\r
44 DxePcdSet64,\r
45 DxePcdSetPtr,\r
46 DxePcdSetBool,\r
47\r
48 DxePcdSet8Ex,\r
49 DxePcdSet16Ex,\r
50 DxePcdSet32Ex,\r
51 DxePcdSet64Ex,\r
52 DxePcdSetPtrEx,\r
53 DxePcdSetBoolEx,\r
54\r
55 PcdRegisterCallBackOnSet,\r
56 PcdUnRegisterCallBackOnSet,\r
57 DxePcdGetNextToken\r
58};\r
59\r
60\r
61//\r
62// Static global to reduce the code size\r
63//\r
64static EFI_HANDLE NewHandle = NULL;\r
65\r
66EFI_STATUS\r
67EFIAPI\r
68PcdDxeInit (\r
69 IN EFI_HANDLE ImageHandle,\r
70 IN EFI_SYSTEM_TABLE *SystemTable\r
71 )\r
72{\r
73 EFI_STATUS Status;\r
74 \r
75 InitPcdDxeDataBase ();\r
76 \r
77 Status = gBS->InstallProtocolInterface (\r
78 &NewHandle,\r
79 &gPcdProtocolGuid,\r
80 EFI_NATIVE_INTERFACE,\r
81 &mPcdInstance\r
82 );\r
83\r
84 ASSERT_EFI_ERROR (Status);\r
85\r
86 return EFI_SUCCESS;\r
87\r
88}\r
89\r
90\r
91EFI_STATUS\r
92EFIAPI\r
93DxePcdSetSku (\r
94 IN UINTN SkuId\r
95 )\r
96{\r
97 return DxeSetSku(SkuId);\r
98}\r
99\r
100\r
101\r
102UINT8\r
103EFIAPI\r
104DxePcdGet8 (\r
105 IN UINTN TokenNumber\r
106 )\r
107{\r
108 return DxePcdGet8Ex (NULL, TokenNumber);\r
109}\r
110\r
111\r
112\r
113UINT16\r
114EFIAPI\r
115DxePcdGet16 (\r
116 IN UINTN TokenNumber\r
117 )\r
118{\r
119 return DxePcdGet16Ex (NULL, TokenNumber);\r
120}\r
121\r
122\r
123\r
124UINT32\r
125EFIAPI\r
126DxePcdGet32 (\r
127 IN UINTN TokenNumber\r
128 )\r
129{\r
130 return DxePcdGet32Ex (NULL, TokenNumber);\r
131}\r
132\r
133\r
134\r
135UINT64\r
136EFIAPI\r
137DxePcdGet64 (\r
138 IN UINTN TokenNumber\r
139 )\r
140{\r
141 return DxePcdGet32Ex (NULL, TokenNumber);\r
142}\r
143\r
144\r
145\r
146VOID *\r
147EFIAPI\r
148DxePcdGetPtr (\r
149 IN UINTN TokenNumber\r
150 )\r
151{\r
152 return DxePcdGetPtrEx (NULL, TokenNumber);\r
153}\r
154\r
155\r
156\r
157BOOLEAN\r
158EFIAPI\r
159DxePcdGetBool (\r
160 IN UINTN TokenNumber\r
161 )\r
162{\r
163 return DxePcdGetBoolEx (NULL, TokenNumber);\r
164}\r
165\r
166\r
167\r
168UINTN\r
169EFIAPI\r
170DxePcdGetSize (\r
171 IN UINTN TokenNumber\r
172 )\r
173{\r
174 return DxePcdGetSizeEx (NULL, TokenNumber);\r
175}\r
176\r
177\r
178\r
179UINT8\r
180EFIAPI\r
181DxePcdGet8Ex (\r
182 IN CONST EFI_GUID *Guid,\r
183 IN UINTN TokenNumber\r
184 )\r
185{\r
186 UINT8 Data;\r
187\r
188 DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte8, &Data);\r
189\r
190 return Data;\r
191}\r
192\r
193\r
194\r
195UINT16\r
196EFIAPI\r
197DxePcdGet16Ex (\r
198 IN CONST EFI_GUID *Guid,\r
199 IN UINTN TokenNumber\r
200 )\r
201{\r
202 UINT16 Data;\r
203\r
204 DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte16, &Data);\r
205\r
206 return Data;\r
207}\r
208\r
209\r
210\r
211UINT32\r
212EFIAPI\r
213DxePcdGet32Ex (\r
214 IN CONST EFI_GUID *Guid,\r
215 IN UINTN TokenNumber\r
216 )\r
217{\r
218 UINT32 Data;\r
219\r
220 DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte32, &Data);\r
221\r
222 return Data;\r
223}\r
224\r
225\r
226\r
227UINT64\r
228EFIAPI\r
229DxePcdGet64Ex (\r
230 IN CONST EFI_GUID *Guid,\r
231 IN UINTN TokenNumber\r
232 )\r
233{\r
234 UINT64 Data;\r
235\r
236 DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte64, &Data);\r
237\r
238 return Data;\r
239}\r
240\r
241\r
242\r
243VOID *\r
244EFIAPI\r
245DxePcdGetPtrEx (\r
246 IN CONST EFI_GUID *Guid,\r
247 IN UINTN TokenNumber\r
248 )\r
249{\r
250 VOID *Data;\r
251\r
252 DxeGetPcdEntryWorker (TokenNumber, Guid, PcdPointer, &Data);\r
253\r
254 return Data;\r
255}\r
256\r
257\r
258\r
259BOOLEAN\r
260EFIAPI\r
261DxePcdGetBoolEx (\r
262 IN CONST EFI_GUID *Guid,\r
263 IN UINTN TokenNumber\r
264 )\r
265{\r
266 BOOLEAN Data;\r
267 DxeGetPcdEntryWorker (TokenNumber, Guid, PcdBoolean, &Data);\r
268 return Data;\r
269}\r
270\r
271\r
272\r
273UINTN\r
274EFIAPI\r
275DxePcdGetSizeEx (\r
276 IN CONST EFI_GUID *Guid,\r
277 IN UINTN TokenNumber\r
278 )\r
279{\r
280 return DxeGetPcdEntrySizeWorker (TokenNumber, Guid);\r
281}\r
282\r
283\r
284\r
285EFI_STATUS\r
286EFIAPI\r
287DxePcdSet8 (\r
288 IN UINTN TokenNumber,\r
289 IN UINT8 Value\r
290 )\r
291{\r
292 return DxePcdSet8Ex (NULL, TokenNumber, Value);\r
293}\r
294\r
295\r
296\r
297EFI_STATUS\r
298EFIAPI\r
299DxePcdSet16 (\r
300 IN UINTN TokenNumber,\r
301 IN UINT16 Value\r
302 )\r
303{\r
304 return DxePcdSet16Ex (NULL, TokenNumber, Value);\r
305}\r
306\r
307\r
308\r
309EFI_STATUS\r
310EFIAPI\r
311DxePcdSet32 (\r
312 IN UINTN TokenNumber,\r
313 IN UINT32 Value\r
314 )\r
315{\r
316 return DxePcdSet32Ex (NULL, TokenNumber, Value);\r
317}\r
318\r
319\r
320\r
321EFI_STATUS\r
322EFIAPI\r
323DxePcdSet64 (\r
324 IN UINTN TokenNumber,\r
325 IN UINT64 Value\r
326 )\r
327{\r
328 return DxePcdSet64Ex (NULL, TokenNumber, Value);\r
329}\r
330\r
331\r
332\r
333EFI_STATUS\r
334EFIAPI\r
335DxePcdSetPtr (\r
336 IN UINTN TokenNumber,\r
337 IN CONST VOID *Value\r
338 )\r
339{\r
340 return DxePcdSetPtrEx (NULL, TokenNumber, Value);\r
341}\r
342\r
343\r
344\r
345EFI_STATUS\r
346EFIAPI\r
347DxePcdSetBool (\r
348 IN UINTN TokenNumber,\r
349 IN BOOLEAN Value\r
350 )\r
351{\r
352 return DxePcdSetBoolEx (NULL, TokenNumber, Value);\r
353}\r
354\r
355\r
356\r
357EFI_STATUS\r
358EFIAPI\r
359DxePcdSet8Ex (\r
360 IN CONST EFI_GUID *Guid,\r
361 IN UINTN TokenNumber,\r
362 IN UINT8 Value\r
363 )\r
364{\r
365 return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte8, &Value);\r
366}\r
367\r
368\r
369\r
370EFI_STATUS\r
371EFIAPI\r
372DxePcdSet16Ex (\r
373 IN CONST EFI_GUID *Guid,\r
374 IN UINTN TokenNumber,\r
375 IN UINT16 Value\r
376 )\r
377{\r
378 return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte16, &Value);\r
379}\r
380\r
381\r
382\r
383EFI_STATUS\r
384EFIAPI\r
385DxePcdSet32Ex (\r
386 IN CONST EFI_GUID *Guid,\r
387 IN UINTN TokenNumber,\r
388 IN UINT32 Value\r
389 )\r
390{\r
391 return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte32, &Value);\r
392}\r
393\r
394\r
395\r
396EFI_STATUS\r
397EFIAPI\r
398DxePcdSet64Ex (\r
399 IN CONST EFI_GUID *Guid,\r
400 IN UINTN TokenNumber,\r
401 IN UINT64 Value\r
402 )\r
403{\r
404 return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte64, &Value);\r
405}\r
406\r
407\r
408\r
409EFI_STATUS\r
410EFIAPI\r
411DxePcdSetPtrEx (\r
412 IN CONST EFI_GUID *Guid,\r
413 IN UINTN TokenNumber,\r
414 IN CONST VOID *Value\r
415 )\r
416{\r
417 return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdPointer, Value);\r
418}\r
419\r
420\r
421\r
422EFI_STATUS\r
423EFIAPI\r
424DxePcdSetBoolEx (\r
425 IN CONST EFI_GUID *Guid,\r
426 IN UINTN TokenNumber,\r
427 IN BOOLEAN Value\r
428 )\r
429{\r
430 return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdBoolean, &Value);\r
431\r
432}\r
433\r
434\r
435\r
436\r
437EFI_STATUS\r
438EFIAPI\r
439PcdRegisterCallBackOnSet (\r
440 IN UINTN TokenNumber,\r
441 IN CONST EFI_GUID *Guid, OPTIONAL\r
442 IN PCD_PROTOCOL_CALLBACK CallBackFunction\r
443 )\r
444{\r
445 return DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction, TRUE);\r
446}\r
447\r
448\r
449\r
450EFI_STATUS\r
451EFIAPI\r
452PcdUnRegisterCallBackOnSet (\r
453 IN UINTN TokenNumber,\r
454 IN CONST EFI_GUID *Guid, OPTIONAL\r
455 IN PCD_PROTOCOL_CALLBACK CallBackFunction\r
456 )\r
457{\r
458 return DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction, FALSE);\r
459}\r
460\r
461\r
462\r
463EFI_STATUS\r
464EFIAPI\r
465DxePcdGetNextToken (\r
466 IN CONST EFI_GUID *Guid, OPTIONAL\r
467 IN OUT UINTN *TokenNumber\r
468 )\r
469{\r
470 return DxeGetNextTokenWorker (TokenNumber, Guid);\r
471}\r
472\r