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