647a0068e1e98dd557c456dac782053eb5a36af0
[mirror_edk2.git] / EdkModulePkg / Universal / PCD / Pei / Service.h
1 /** @file
2 Private functions used by PCD PEIM.
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 that is shared by PEI and DXE PCD database
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
78 //
79 // C Structure generate for PEI PCD Database
80 //
81 #define PEI_EXMAPPING_TABLE_SIZE 1
82 #define PEI_GUID_TABLE_SIZE 1
83 #define PEI_LOCAL_TOKEN_NUMBER 1
84 #define PEI_STRING_TABLE_SIZE 2
85 #define PEI_SKUID_TABLE_SIZE 3
86
87
88 #define PEI_DATABASE_EMPTRY FALSE
89 #define PEI_EXMAP_TABLE_EMPTY FALSE
90 #define PEI_GUID_TABLE_EMPTY FALSE
91 #define PEI_STRINGTABLE_EMPTY FALSE
92 #define PEI_SIZETABLE_EMPTY FALSE
93 #define PEI_SKUID_TABLE_EMPTY FALSE
94
95
96 typedef struct {
97
98 DYNAMICEX_MAPPING ExMapTable[PEI_EXMAPPING_TABLE_SIZE];
99 EFI_GUID GuidTable[PEI_GUID_TABLE_SIZE];
100
101 UINT32 LocalTokenNumberTable[PEI_LOCAL_TOKEN_NUMBER];
102
103
104 UINT16 StringTable[PEI_STRING_TABLE_SIZE];
105 UINT16 SizeTable[PEI_LOCAL_TOKEN_NUMBER];
106
107 UINT8 SkuIdTable[PEI_SKUID_TABLE_SIZE];
108
109 SKU_ID SystemSkuId;
110
111 } PEI_PCD_DATABASE_INIT;
112
113 typedef struct {
114 UINT8 Dummy;
115 } PEI_PCD_DATABASE_UNINIT;
116
117 #define PEI_PCD_DB_INIT_VALUE \
118 /* ExMapTable */ \
119 { \
120 { /* ExTokenNumber */ 0x00000001, /* LocalTokenNumberIndex */ 0, /* ExGuidIndex */ 0} \
121 }, \
122 \
123 /* GuidTable */ \
124 { \
125 { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD }} \
126 }, \
127 \
128 /* LocalTokenNumberTable */ \
129 { \
130 0 \
131 }, \
132 \
133 /* StringTable */ \
134 { \
135 L"\0" \
136 }, \
137 \
138 /* SizeTable */ \
139 { \
140 4 \
141 }, \
142 \
143 /* SkuIdTable */ \
144 { \
145 /*MaxSku*/ 2, /*SkuId*/ 100, /*SkuId*/200 \
146 },\
147 \
148 /* SystemSkuId */ \
149 0 \
150
151
152 //
153 // End of Autogen Code
154 //
155 #endif
156
157 /*
158 typedef struct {
159 PEI_PCD_DATABASE_INIT Init;
160 PEI_PCD_DATABASE_UNINIT Uninit;
161 } PEI_PCD_DATABASE;
162 */
163
164 /* Internal Function definitions */
165
166 PEI_PCD_DATABASE *
167 GetPcdDatabase (
168 VOID
169 )
170 ;
171
172 EFI_STATUS
173 SetWorker (
174 IN UINTN TokenNumber,
175 IN VOID *Data,
176 IN UINTN Size,
177 IN BOOLEAN PtrType
178 )
179 ;
180
181 EFI_STATUS
182 SetWorkerByLocalTokenNumber (
183 UINT32 LocalTokenNumber,
184 VOID *Data,
185 UINTN Size,
186 BOOLEAN PtrType
187 )
188 ;
189
190 EFI_STATUS
191 ExSetWorker (
192 IN UINT32 ExTokenNumber,
193 IN CONST EFI_GUID *Guid,
194 VOID *Data,
195 UINTN Size,
196 BOOLEAN PtrType
197 )
198 ;
199
200 VOID *
201 GetWorker (
202 UINTN TokenNumber,
203 UINTN GetSize
204 )
205 ;
206
207 VOID *
208 ExGetWorker (
209 IN CONST EFI_GUID *Guid,
210 IN UINT32 ExTokenNumber,
211 IN UINTN GetSize
212 )
213 ;
214
215 typedef struct {
216 UINTN TokenNumber;
217 UINTN Size;
218 UINT32 LocalTokenNumberAlias;
219 } EX_PCD_ENTRY_ATTRIBUTE;
220
221 VOID
222 GetExPcdTokenAttributes (
223 IN CONST EFI_GUID *Guid,
224 IN UINT32 ExTokenNumber,
225 OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
226 )
227 ;
228
229 EFI_STATUS
230 PeiRegisterCallBackWorker (
231 IN UINTN TokenNumber,
232 IN CONST GUID *Guid, OPTIONAL
233 IN PCD_PPI_CALLBACK CallBackFunction,
234 IN BOOLEAN Register
235 );
236
237 VOID
238 BuildPcdDatabase (
239 VOID
240 )
241 ;
242
243
244 extern EFI_GUID gPcdImageFileGuid;
245
246 //
247 // PPI Interface Implementation Declaration.
248 //
249 EFI_STATUS
250 EFIAPI
251 PeiPcdSetSku (
252 IN UINTN SkuId
253 )
254 ;
255
256
257 UINT8
258 EFIAPI
259 PeiPcdGet8 (
260 IN UINTN TokenNumber
261 )
262 ;
263
264
265 UINT16
266 EFIAPI
267 PeiPcdGet16 (
268 IN UINTN TokenNumber
269 )
270 ;
271
272
273 UINT32
274 EFIAPI
275 PeiPcdGet32 (
276 IN UINTN TokenNumber
277 )
278 ;
279
280
281 UINT64
282 EFIAPI
283 PeiPcdGet64 (
284 IN UINTN TokenNumber
285 )
286 ;
287
288
289 VOID *
290 EFIAPI
291 PeiPcdGetPtr (
292 IN UINTN TokenNumber
293 )
294 ;
295
296
297 BOOLEAN
298 EFIAPI
299 PeiPcdGetBool (
300 IN UINTN TokenNumber
301 )
302 ;
303
304
305 UINTN
306 EFIAPI
307 PeiPcdGetSize (
308 IN UINTN TokenNumber
309 )
310 ;
311
312
313 UINT8
314 EFIAPI
315 PeiPcdGet8Ex (
316 IN CONST EFI_GUID *Guid,
317 IN UINTN TokenNumber
318 )
319 ;
320
321
322 UINT16
323 EFIAPI
324 PeiPcdGet16Ex (
325 IN CONST EFI_GUID *Guid,
326 IN UINTN TokenNumber
327 )
328 ;
329
330 UINT32
331 EFIAPI
332 PeiPcdGet32Ex (
333 IN CONST EFI_GUID *Guid,
334 IN UINTN TokenNumber
335 )
336 ;
337
338
339 UINT64
340 EFIAPI
341 PeiPcdGet64Ex (
342 IN CONST EFI_GUID *Guid,
343 IN UINTN TokenNumber
344 )
345 ;
346
347
348 VOID *
349 EFIAPI
350 PeiPcdGetPtrEx (
351 IN CONST EFI_GUID *Guid,
352 IN UINTN TokenNumber
353 )
354 ;
355
356
357 BOOLEAN
358 EFIAPI
359 PeiPcdGetBoolEx (
360 IN CONST EFI_GUID *Guid,
361 IN UINTN TokenNumber
362 )
363 ;
364
365
366 UINTN
367 EFIAPI
368 PeiPcdGetSizeEx (
369 IN CONST EFI_GUID *Guid,
370 IN UINTN TokenNumber
371 )
372 ;
373
374
375 EFI_STATUS
376 EFIAPI
377 PeiPcdSet8 (
378 IN UINTN TokenNumber,
379 IN UINT8 Value
380 )
381 ;
382
383
384 EFI_STATUS
385 EFIAPI
386 PeiPcdSet16 (
387 IN UINTN TokenNumber,
388 IN UINT16 Value
389 )
390 ;
391
392
393 EFI_STATUS
394 EFIAPI
395 PeiPcdSet32 (
396 IN UINTN TokenNumber,
397 IN UINT32 Value
398 )
399 ;
400
401
402 EFI_STATUS
403 EFIAPI
404 PeiPcdSet64 (
405 IN UINTN TokenNumber,
406 IN UINT64 Value
407 )
408 ;
409
410 EFI_STATUS
411 EFIAPI
412 PeiPcdSetPtr (
413 IN UINTN TokenNumber,
414 IN CONST VOID *Value
415 )
416 ;
417
418
419 EFI_STATUS
420 EFIAPI
421 PeiPcdSetBool (
422 IN UINTN TokenNumber,
423 IN BOOLEAN Value
424 )
425 ;
426
427
428 EFI_STATUS
429 EFIAPI
430 PeiPcdSet8Ex (
431 IN CONST EFI_GUID *Guid,
432 IN UINTN TokenNumber,
433 IN UINT8 Value
434 )
435 ;
436
437 EFI_STATUS
438 EFIAPI
439 PeiPcdSet16Ex (
440 IN CONST EFI_GUID *Guid,
441 IN UINTN TokenNumber,
442 IN UINT16 Value
443 )
444 ;
445
446
447 EFI_STATUS
448 EFIAPI
449 PeiPcdSet32Ex (
450 IN CONST EFI_GUID *Guid,
451 IN UINTN TokenNumber,
452 IN UINT32 Value
453 )
454 ;
455
456
457 EFI_STATUS
458 EFIAPI
459 PeiPcdSet64Ex (
460 IN CONST EFI_GUID *Guid,
461 IN UINTN TokenNumber,
462 IN UINT64 Value
463 )
464 ;
465
466
467 EFI_STATUS
468 EFIAPI
469 PeiPcdSetPtrEx (
470 IN CONST EFI_GUID *Guid,
471 IN UINTN TokenNumber,
472 IN CONST VOID *Value
473 )
474 ;
475
476
477 EFI_STATUS
478 EFIAPI
479 PeiPcdSetBoolEx (
480 IN CONST EFI_GUID *Guid,
481 IN UINTN TokenNumber,
482 IN BOOLEAN Value
483 )
484 ;
485
486
487
488 EFI_STATUS
489 EFIAPI
490 PcdRegisterCallBackOnSet (
491 IN UINTN TokenNumber,
492 IN CONST EFI_GUID *Guid, OPTIONAL
493 IN PCD_PPI_CALLBACK CallBackFunction
494 )
495 ;
496
497
498 EFI_STATUS
499 EFIAPI
500 PcdUnRegisterCallBackOnSet (
501 IN UINTN TokenNumber,
502 IN CONST EFI_GUID *Guid, OPTIONAL
503 IN PCD_PPI_CALLBACK CallBackFunction
504 )
505 ;
506
507
508 EFI_STATUS
509 EFIAPI
510 PeiPcdGetNextToken (
511 IN CONST EFI_GUID *Guid, OPTIONAL
512 IN OUT UINTN *TokenNumber
513 )
514 ;
515
516 extern EFI_GUID gPcdDataBaseHobGuid;
517
518 extern EFI_GUID gPcdPeiCallbackFnTableHobGuid;
519
520 extern PEI_PCD_DATABASE_INIT gPEIPcdDbInit;
521
522 #endif