Sync up Pcd Library Instances and PCD Driver/PEIM with Pcd spec 0.51 and Mde 0.51
[mirror_edk2.git] / EdkModulePkg / Universal / PCD / Dxe / Service.h
1 /** @file
2 Private functions used by 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: Service.h
15
16 **/
17
18 #ifndef _SERVICE_H
19 #define _SERVICE_H
20
21 #define USE_AUTOGEN
22
23 #ifndef USE_AUTOGEN
24 //
25 // The following definition will be generated by build tool
26 //
27
28 //
29 // Common definitions
30 //
31 #define PCD_TYPE_SHIFT 24
32
33
34 #define PCD_TYPE_DATA (0x00 << PCD_TYPE_SHIFT)
35 #define PCD_TYPE_HII (0x80 << PCD_TYPE_SHIFT)
36 #define PCD_TYPE_VPD (0x40 << PCD_TYPE_SHIFT)
37 #define PCD_TYPE_SKU_ENABLED (0x20 << PCD_TYPE_SHIFT)
38
39
40 #define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED))
41
42 typedef struct {
43 UINT32 ExTokenNumber;
44 UINT32 LocalTokenNumber; // PCD Number of this particular platform build
45 UINT16 ExGuidIndex; // Index of GuidTable
46 } DYNAMICEX_MAPPING;
47
48
49 typedef struct {
50 UINT32 SkuDataStartOffset; //We have to use offsetof MACRO as we don't know padding done by compiler
51 UINT32 SkuIdTableOffset; //Offset from the PCD_DB
52 } SKU_HEAD;
53
54
55 typedef struct {
56 UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
57 UINT16 StringIndex; // Offset in String Table in units of UINT16.
58 UINT16 Offset; // Offset in Variable
59 } VARIABLE_HEAD ;
60
61
62 typedef struct {
63 UINT32 Offset;
64 } VPD_HEAD;
65
66 typedef struct {
67 UINT32 LocalTokenNumber;
68 UINT16 TokenNumber;
69 UINT16 Size;
70 } SIZEINFO;
71
72 #define offsetof(s,m) (UINT32)&(((s *)0)->m)
73
74
75
76 //
77 // C Structure generate for PEI PCD Database
78 //
79 #define PEI_EXMAPPING_TABLE_SIZE 1
80 #define PEI_GUID_TABLE_SIZE 1
81 #define PEI_LOCAL_TOKEN_NUMBER 1
82 #define PEI_EXTOKEN_NUMBER 1
83 #define PEI_STRING_TABLE_SIZE 2
84 #define PEI_SKUID_TABLE_SIZE 3
85 #define PEI_SIZE_TABLE_SIZE 1
86
87 #define PEI_DATABASE_EMPTRY FALSE
88 #define PEI_DYNAMICEX_MAPPING_EMPTY FALSE
89 #define PEI_GUID_TABLE_EMPTY FALSE
90 #define PEI_STRINGTABLE_EMPTY FALSE
91 #define PEI_SIZETABLE_EMPTY FALSE
92 #define PEI_SKUID_TABLE_EMPTY FALSE
93
94
95 typedef struct {
96
97 DYNAMICEX_MAPPING ExMapTable[PEI_EXMAPPING_TABLE_SIZE];
98 EFI_GUID GuidTable[PEI_GUID_TABLE_SIZE];
99
100 UINT32 LocalTokenNumberTable[PEI_LOCAL_TOKEN_NUMBER];
101
102
103 UINT16 StringTable[PEI_STRING_TABLE_SIZE];
104 UINT16 SizeTable[PEI_LOCAL_TOKEN_NUMBER];
105
106 SKU_ID SkuIdTable[PEI_SKUID_TABLE_SIZE];
107
108 SKU_ID SystemSkuId;
109
110 } PEI_PCD_DATABASE_INIT;
111
112 typedef struct {
113 UINT8 Dummy;
114 } PEI_PCD_DATABASE_UNINIT;
115
116 //
117 // Following code should be generated for PCD DXE driver
118 //
119
120 #define DXE_EXMAPPING_TABLE_SIZE 1
121 #define DXE_GUID_TABLE_SIZE 1
122 #define DXE_TOKEN_NUMBER 1
123 #define DXE_EXTOKEN_NUMBER 1
124 #define DXE_STRING_TABLE_SIZE 2
125 #define DXE_SKUID_TABLE_SIZE 3
126 #define DXE_SIZE_TABLE_SIZE 1
127
128 #define DXE_DATABASE_EMPTRY FALSE
129 #define DXE_DYNAMICEX_MAPPING_EMPTY FALSE
130 #define DXE_GUID_TABLE_EMPTY FALSE
131 #define DXE_STRINGTABLE_EMPTY FALSE
132 #define DXE_SIZETABLE_EMPTY FALSE
133 #define DXE_SKUID_TABLE_EMPTY FALSE
134
135 typedef struct {
136 DYNAMICEX_MAPPING ExMapTable[DXE_EXMAPPING_TABLE_SIZE];
137 EFI_GUID GuidTable[DXE_GUID_TABLE_SIZE];
138
139 UINT32 LocalTokenNumberTable[DXE_TOKEN_NUMBER];
140
141
142 UINT16 StringTable[DXE_STRING_TABLE_SIZE];
143 UINT16 SizeTable[DXE_TOKEN_NUMBER];
144
145 SKU_ID SkuIdTable[DXE_SKUID_TABLE_SIZE];
146
147 } DXE_PCD_DATABASE_INIT;
148
149 typedef struct {
150 UINT8 Dummy;
151 } DXE_PCD_DATABASE_UNINIT;
152
153
154 #define DXE_PCD_DB_INIT_VALUE \
155 /* ExMapTable */ \
156 { \
157 { /* ExTokenNumber */ 0x00000001, /* LocalTokenNumberIndex */ 0, /* ExGuidIndex */ 0} \
158 }, \
159 \
160 /* GuidTable */ \
161 { \
162 { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD }} \
163 }, \
164 \
165 /* LocalTokenNumberTable */ \
166 { \
167 0 \
168 }, \
169 \
170 /* StringTable */ \
171 { \
172 L"\0" \
173 }, \
174 \
175 /* SizeTable */ \
176 { \
177 4 \
178 }, \
179 \
180 /* SkuIdTable */ \
181 { \
182 /*MaxSku*/ 2, /*SkuId*/ 100, /*SkuId*/200 \
183 },\
184 \
185
186 //
187 // End of Autogen Code
188 //
189 #endif
190
191 /*
192 typedef struct {
193 PEI_PCD_DATABASE_INIT Init;
194 PEI_PCD_DATABASE_UNINIT Uninit;
195 } PEI_PCD_DATABASE;
196
197
198
199 typedef struct {
200 DXE_PCD_DATABASE_INIT Init;
201 DXE_PCD_DATABASE_UNINIT Uninit;
202 } DXE_PCD_DATABASE;
203
204
205 typedef struct {
206 PEI_PCD_DATABASE PeiDb;
207 DXE_PCD_DATABASE DxeDb;
208 } PCD_DATABASE;
209 */
210
211
212 //
213 // Internal Functions
214 //
215
216 EFI_STATUS
217 SetWorker (
218 UINTN TokenNumber,
219 VOID *Data,
220 UINTN Size,
221 BOOLEAN PtrType
222 )
223 ;
224
225 EFI_STATUS
226 ExSetWorker (
227 IN UINT32 ExTokenNumber,
228 IN CONST EFI_GUID *Guid,
229 VOID *Data,
230 UINTN Size,
231 BOOLEAN PtrType
232 )
233 ;
234
235
236 VOID *
237 GetWorker (
238 UINTN TokenNumber
239 )
240 ;
241
242 VOID *
243 ExGetWorker (
244 IN CONST EFI_GUID *Guid,
245 IN UINTN ExTokenNumber,
246 IN UINTN GetSize
247 )
248 ;
249
250 UINT32
251 GetSkuEnabledTokenNumber (
252 UINT32 LocalTokenNumber,
253 UINTN Size,
254 BOOLEAN IsPeiDb
255 )
256 ;
257
258 EFI_STATUS
259 GetHiiVariable (
260 IN EFI_GUID *VariableGuid,
261 IN UINT16 *VariableName,
262 OUT VOID ** VariableData,
263 OUT UINTN *VariableSize
264 )
265 ;
266
267 EFI_STATUS
268 DxeRegisterCallBackWorker (
269 IN UINTN TokenNumber,
270 IN CONST EFI_GUID *Guid, OPTIONAL
271 IN PCD_PROTOCOL_CALLBACK CallBackFunction,
272 IN BOOLEAN Reigster
273 );
274
275 EFI_STATUS
276 DxeGetNextTokenWorker (
277 IN OUT UINTN *Token,
278 IN CONST EFI_GUID *Guid OPTIONAL
279 );
280
281 VOID
282 BuildPcdDxeDataBase (
283 VOID
284 );
285
286
287 typedef struct {
288 UINTN TokenNumber;
289 UINTN Size;
290 UINT32 LocalTokenNumberAlias;
291 BOOLEAN IsPeiDb;
292 } EX_PCD_ENTRY_ATTRIBUTE;
293
294 VOID
295 GetExPcdTokenAttributes (
296 IN CONST EFI_GUID *Guid,
297 IN UINT32 ExTokenNumber,
298 OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
299 )
300 ;
301
302 //
303 // Protocol Interface function declaration.
304 //
305 VOID
306 EFIAPI
307 DxePcdSetSku (
308 IN SKU_ID SkuId
309 )
310 ;
311
312
313 UINT8
314 EFIAPI
315 DxePcdGet8 (
316 IN PCD_TOKEN_NUMBER TokenNumber
317 )
318 ;
319
320
321 UINT16
322 EFIAPI
323 DxePcdGet16 (
324 IN PCD_TOKEN_NUMBER TokenNumber
325 )
326 ;
327
328
329 UINT32
330 EFIAPI
331 DxePcdGet32 (
332 IN PCD_TOKEN_NUMBER TokenNumber
333 )
334 ;
335
336
337 UINT64
338 EFIAPI
339 DxePcdGet64 (
340 IN PCD_TOKEN_NUMBER TokenNumber
341 )
342 ;
343
344
345 VOID *
346 EFIAPI
347 DxePcdGetPtr (
348 IN PCD_TOKEN_NUMBER TokenNumber
349 )
350 ;
351
352
353 BOOLEAN
354 EFIAPI
355 DxePcdGetBool (
356 IN PCD_TOKEN_NUMBER TokenNumber
357 )
358 ;
359
360
361 UINTN
362 EFIAPI
363 DxePcdGetSize (
364 IN PCD_TOKEN_NUMBER TokenNumber
365 )
366 ;
367
368
369 UINT8
370 EFIAPI
371 DxePcdGet8Ex (
372 IN CONST EFI_GUID *Guid,
373 IN PCD_TOKEN_NUMBER TokenNumber
374 )
375 ;
376
377
378 UINT16
379 EFIAPI
380 DxePcdGet16Ex (
381 IN CONST EFI_GUID *Guid,
382 IN PCD_TOKEN_NUMBER TokenNumber
383 )
384 ;
385
386
387 UINT32
388 EFIAPI
389 DxePcdGet32Ex (
390 IN CONST EFI_GUID *Guid,
391 IN PCD_TOKEN_NUMBER TokenNumber
392 )
393 ;
394
395
396
397 UINT64
398 EFIAPI
399 DxePcdGet64Ex (
400 IN CONST EFI_GUID *Guid,
401 IN PCD_TOKEN_NUMBER TokenNumber
402 )
403 ;
404
405
406
407 VOID *
408 EFIAPI
409 DxePcdGetPtrEx (
410 IN CONST EFI_GUID *Guid,
411 IN PCD_TOKEN_NUMBER TokenNumber
412 )
413 ;
414
415
416 BOOLEAN
417 EFIAPI
418 DxePcdGetBoolEx (
419 IN CONST EFI_GUID *Guid,
420 IN PCD_TOKEN_NUMBER TokenNumber
421 )
422 ;
423
424
425 UINTN
426 EFIAPI
427 DxePcdGetSizeEx (
428 IN CONST EFI_GUID *Guid,
429 IN PCD_TOKEN_NUMBER TokenNumber
430 )
431 ;
432
433
434 EFI_STATUS
435 EFIAPI
436 DxePcdSet8 (
437 IN PCD_TOKEN_NUMBER TokenNumber,
438 IN UINT8 Value
439 )
440 ;
441
442
443 EFI_STATUS
444 EFIAPI
445 DxePcdSet16 (
446 IN PCD_TOKEN_NUMBER TokenNumber,
447 IN UINT16 Value
448 )
449 ;
450
451
452 EFI_STATUS
453 EFIAPI
454 DxePcdSet32 (
455 IN PCD_TOKEN_NUMBER TokenNumber,
456 IN UINT32 Value
457 )
458 ;
459
460
461 EFI_STATUS
462 EFIAPI
463 DxePcdSet64 (
464 IN PCD_TOKEN_NUMBER TokenNumber,
465 IN UINT64 Value
466 )
467 ;
468
469
470 EFI_STATUS
471 EFIAPI
472 DxePcdSetPtr (
473 IN PCD_TOKEN_NUMBER TokenNumber,
474 IN UINTN SizeOfBuffer,
475 IN VOID *Buffer
476 )
477 ;
478
479
480 EFI_STATUS
481 EFIAPI
482 DxePcdSetBool (
483 IN PCD_TOKEN_NUMBER TokenNumber,
484 IN BOOLEAN Value
485 )
486 ;
487
488
489 EFI_STATUS
490 EFIAPI
491 DxePcdSet8Ex (
492 IN CONST EFI_GUID *Guid,
493 IN PCD_TOKEN_NUMBER TokenNumber,
494 IN UINT8 Value
495 )
496 ;
497
498
499 EFI_STATUS
500 EFIAPI
501 DxePcdSet16Ex (
502 IN CONST EFI_GUID *Guid,
503 IN PCD_TOKEN_NUMBER TokenNumber,
504 IN UINT16 Value
505 )
506 ;
507
508
509 EFI_STATUS
510 EFIAPI
511 DxePcdSet32Ex (
512 IN CONST EFI_GUID *Guid,
513 IN PCD_TOKEN_NUMBER TokenNumber,
514 IN UINT32 Value
515 )
516 ;
517
518
519 EFI_STATUS
520 EFIAPI
521 DxePcdSet64Ex (
522 IN CONST EFI_GUID *Guid,
523 IN PCD_TOKEN_NUMBER TokenNumber,
524 IN UINT64 Value
525 )
526 ;
527
528
529 EFI_STATUS
530 EFIAPI
531 DxePcdSetPtrEx (
532 IN CONST EFI_GUID *Guid,
533 IN PCD_TOKEN_NUMBER TokenNumber,
534 IN UINTN SizeOfBuffer,
535 IN VOID *Buffer
536 )
537 ;
538
539
540 EFI_STATUS
541 EFIAPI
542 DxePcdSetBoolEx (
543 IN CONST EFI_GUID *Guid,
544 IN PCD_TOKEN_NUMBER TokenNumber,
545 IN BOOLEAN Value
546 )
547 ;
548
549
550
551 EFI_STATUS
552 EFIAPI
553 PcdRegisterCallBackOnSet (
554 IN PCD_TOKEN_NUMBER TokenNumber,
555 IN CONST EFI_GUID *Guid, OPTIONAL
556 IN PCD_PROTOCOL_CALLBACK CallBackFunction
557 )
558 ;
559
560
561 EFI_STATUS
562 EFIAPI
563 PcdUnRegisterCallBackOnSet (
564 IN PCD_TOKEN_NUMBER TokenNumber,
565 IN CONST EFI_GUID *Guid, OPTIONAL
566 IN PCD_PROTOCOL_CALLBACK CallBackFunction
567 )
568 ;
569
570
571 EFI_STATUS
572 EFIAPI
573 DxePcdGetNextToken (
574 IN CONST EFI_GUID *Guid, OPTIONAL
575 IN OUT PCD_TOKEN_NUMBER *TokenNumber
576 )
577 ;
578
579 EFI_STATUS
580 SetWorkerByLocalTokenNumber (
581 UINT32 LocalTokenNumber,
582 VOID *Data,
583 UINTN Size,
584 BOOLEAN PtrType,
585 BOOLEAN IsPeiDb
586 )
587 ;
588
589 extern EFI_GUID gPcdDataBaseHobGuid;
590
591 extern PCD_DATABASE * gPcdDatabase;
592
593 extern DXE_PCD_DATABASE_INIT gDXEPcdDbInit;
594
595 #endif