]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/PCD/Common/PcdCommon.h
Initial import.
[mirror_edk2.git] / EdkModulePkg / Universal / PCD / Common / PcdCommon.h
1 /** @file
2 Common functions used by PCD PEIM and PCD DXE.
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: PcdCommon.h
15
16 **/
17
18 #ifndef __PCD_COMMON_H__
19 #define __PCD_COMMON_H__
20
21 //
22 // Enumeration for PCD_DATA_TYPE
23 //
24 typedef enum {
25 PcdByte8,
26 PcdByte16,
27 PcdByte32,
28 PcdByte64,
29 PcdPointer,
30 PcdBoolean
31 } PCD_DATA_TYPE;
32
33
34 //
35 // The definitions for Global PCD Length Fields
36 //
37 #define PCD_LENGTH_BIT8 0x01
38 #define PCD_LENGTH_BIT16 0x02
39 #define PCD_LENGTH_BIT24 0x03
40 #define PCD_LENGTH_BIT32 0x04
41
42
43
44 /*
45 * This data structure is used in <PCD_IMAGE> transverse
46 */
47 typedef struct {
48 UINTN EntryCount;
49 UINTN GlobalOffsetLength;
50 UINTN GlobalTokenLength;
51 UINTN GlobalGuidTabIdxLength;
52 UINTN GlobalDatumLength;
53 UINTN GlobalStrTabIdxLength;
54
55 CONST UINT8 *DataDefaultStart;
56 UINTN DataDefaultLength;
57 UINTN WholeDataDefaultLength;
58 CONST UINT8 *IndexStart;
59 UINTN IndexLength;
60 CONST GUID *GuidTableStart;
61 UINTN GuidTableLength;
62 CONST UINT16 *StringTableStart;
63 UINTN StringTableLength;
64 /* Length of the <PCD_IMAGE> in byte.
65 This info is from Section header
66 in FFS */
67 UINTN ImageLength;
68 CONST UINT8 *ImageStart;
69
70 } PCD_IMAGE_RECORD;
71
72
73
74 typedef struct {
75 BOOLEAN HiiEnable;
76 BOOLEAN SkuEnable;
77 BOOLEAN VpdEnable;
78 BOOLEAN SkuDataArrayEnable;
79 PCD_DATA_TYPE DataType;
80 BOOLEAN ExtendedGuidPresent;
81 } PCD_STATEBYTE;
82
83
84
85 typedef struct {
86 //
87 // All Pointer's Offset in byte
88 //
89 UINT32 TokenNumber;
90 PCD_STATEBYTE StateByte;
91 UINT32 HiiData;
92 UINT32 SkuIdArray; //Pointer
93 UINT32 ExtendedDataOffset;
94 UINT32 DatumSize;
95 UINT16 DynamicExGuid; //Pointer
96 UINT8 SkuCount;
97 } PCD_INDEX;
98
99
100
101 /*
102 * PCD Image Definition according PCD Specification 0.51.
103 *
104 */
105 #pragma pack(1)
106 typedef struct {
107 UINT8 ImageLength[3];
108 //
109 // The length of PCD_FFS_ENCODING is included
110 // in ImageLength
111 //
112 UINT8 DataBufferLength[3];
113 UINT8 WholeDataBufferLength[3];
114 UINT8 PcdIndexLength[3];
115 UINT8 GuidTableLength[3];
116 //
117 // The StringTable can be computed using:
118 // ImageLength, DataBufferLength, PcdIndexLength, GuidTableLength,
119 // and length of PCD_FFS_ENCODING
120 //
121 UINT8 EntryCount[3];
122 UINT8 GlobalOffsetLength[1];
123 UINT8 GlobalTokenLength[1];
124 UINT8 GuidLength[1];
125 UINT8 GlobalDatumLength[1];
126 UINT8 GlobalStrTabIdxLength[1];
127 } PCD_FFS_ENCODING;
128 #pragma pack()
129
130
131
132 typedef struct {
133 UINTN DatabaseLen;
134 UINTN EntryCount;
135 UINTN InfoLength;
136 UINTN GuidTableOffset;
137 UINTN PcdIndexOffset;
138 UINTN StringTableOffset;
139 UINTN CallbackTableOffset;
140 UINTN ImageIndexOffset;
141 UINTN DataBufferOffset;
142 UINTN MaxCallbackNum;
143 UINTN HiiVariableOffsetLength;
144 UINTN HiiGuidOffsetLength;
145 UINTN ExtendedOffsetLength;
146 UINT8 *VpdStart;
147 UINTN SkuId;
148 } PCD_DATABASE_HEADER;
149
150
151
152 typedef struct {
153 PCD_DATABASE_HEADER Info;
154 EFI_GUID GuidTable[1];
155 } PCD_DATABASE;
156
157 extern EFI_GUID gPcdDataBaseHobGuid;
158
159
160 /**
161 The function returns the actual address of item in the PCD
162 database according to its Segment and Offset.
163
164 @param[out] Offset The offset within the segment.
165 @param[in] SegmentStart The starting address of the segment.
166 @param[in] DatabaseStart The base address of the PCD DataBase.
167
168
169 @retval EFI_SUCESS If data value is found according to SKU_ID.
170 @retval EFI_NOT_FOUND If not such a value is found.
171
172 --*/
173 UINT8 *
174 GetAbsoluteAddress (
175 IN UINTN Offset,
176 IN UINTN SegmentStart,
177 IN CONST VOID *Base
178 )
179 ;
180
181
182
183 /**
184 The function return the number of Unicode Character in a NULL terminated string.
185 The NULL is NOT counted.
186
187 @param[in] String The unicode string starts from an unaligned address.
188
189 @retval UINTN The number of Unicode characters.
190 --*/
191 UINTN
192 GetUnalignedStrLen (
193 UINT16 *String
194 );
195
196
197 /**
198 The function retrieves the PCD data value according to
199 TokenNumber and Guid space given.
200
201 @param[in] Info The PCD Database Info.
202 @param[in] TokenNumber The token number.
203 @param[in] Guid The Guid space.
204 @param[in] Type The storage type.
205 @param[out] Data The output data.
206
207 @retval VOID
208
209 --*/
210 VOID
211 GetPcdEntryWorker (
212 IN CONST PCD_DATABASE_HEADER *Info,
213 IN UINTN TokenNumber,
214 IN CONST GUID *Guid, OPTIONAL
215 IN PCD_DATA_TYPE Type,
216 OUT VOID *Data
217 )
218 ;
219
220
221
222 /**
223 The function retrieves the PCD data value according to
224 TokenNumber and Guid space given.
225
226 @param[in] Info The PCD Database info.
227 @param[in] TokenNumber The token number.
228 @param[in] Guid The Guid space.
229
230 @retval UINTN The size of the PCD Entry.
231
232 --*/
233 UINTN
234 GetPcdEntrySizeWorker (
235 IN CONST PCD_DATABASE_HEADER *Info,
236 IN UINTN TokenNumber,
237 IN CONST GUID *Guid OPTIONAL
238 )
239 ;
240
241
242
243 /**
244 The function looks for the next PCD ENTRY.
245 If *TokenNumber is 0, the first TokenNumber in
246 the GUID token space is return.
247 If there is no next TokenNumber found,
248 *TokenNumber will be 0.
249
250 @param[in] Info The PCD Database info.
251 @param[in,out] TokenNumber The token number.
252 @param[in] Guid The Guid space.
253
254 @retval EFI_NOT_FOUND Can't find the PCD_ENTRY.
255 @retval EFI_SUCCESS Operation succesful.
256
257 --*/
258 EFI_STATUS
259 GetNextTokenWorker (
260 IN CONST PCD_DATABASE_HEADER *Info,
261 IN OUT UINTN *TokenNumber,
262 IN CONST GUID *Guid OPTIONAL
263 )
264 ;
265
266
267
268 /**
269 The function is the worker function to set the data of a PCD entry.
270
271 @param[in] PcdIndex The PCD Index.
272 @param[in] Info The attributes of the PCD database.
273 @param[in] Data The input data.
274
275 @retval VOID
276 --*/
277 EFI_STATUS
278 SetPcdData (
279 IN CONST PCD_INDEX *PcdIndex,
280 IN CONST PCD_DATABASE_HEADER *Info,
281 IN CONST VOID *Data
282 )
283 ;
284
285
286 /**
287 The function is provided by PCD PEIM and PCD DXE driver to
288 do the work of reading a HII variable from variable service.
289
290 @param[in] VariableGuid The Variable GUID.
291 @param[in] VariableName The Variable Name.
292 @param[out] VariableData The output data.
293 @param[out] VariableSize The size of the variable.
294
295 @retval EFI_SUCCESS Operation successful.
296 @retval EFI_SUCCESS Variablel not found.
297 --*/
298 EFI_STATUS
299 GetHiiVariable (
300 IN EFI_GUID *VariableGuid,
301 IN UINT16 *VariableName,
302 OUT VOID **VariableData,
303 OUT UINTN *VariableSize
304 )
305 ;
306
307
308
309 /**
310 The function is provided by PCD PEIM and PCD DXE driver to
311 do the work of reading a HII variable from variable service.
312
313 @param[in] VariableGuid The Variable GUID.
314 @param[in] VariableName The Variable Name.
315 @param[in] Data The input data.
316 @param[out] VariableSize The size of the variable.
317 @param[in] Offset The offset of the variable data that a PCD entry will starts from.
318
319 @retval EFI_SUCCESS Operation successful.
320 @retval EFI_SUCCESS Variablel not found.
321 --*/
322 EFI_STATUS
323 SetHiiVariable (
324 IN EFI_GUID *VariableGuid,
325 IN UINT16 *VariableName,
326 IN CONST VOID *Data,
327 IN UINTN VariableSize,
328 IN UINTN Offset
329 )
330 ;
331
332 /**
333 The function locates the PCD_INDEX according to TokeNumber and GUID space given.
334
335 @param[in] TokenNumber The token number.
336 @param[in] Guid The GUID token space.
337 @param[out] Info The attributes of the PCD database.
338
339 @retval PCD_INDEX* The PCD_INDEX found.
340 --*/
341 PCD_INDEX *
342 FindPcdIndex (
343 IN UINTN TokenNumber,
344 IN CONST GUID *Guid,
345 IN CONST PCD_DATABASE_HEADER *Info,
346 OUT UINTN *Index
347 )
348 ;
349
350 /**
351 (WQBUGBUG: You must handle the new SKU_ID encoding.
352 The function is the worker function to get the data of a PCD entry.
353
354 @param[in] PcdIndex The PCD Index.
355 @param[in] Info The attributes of the PCD database.
356 @param[out] Data The output data.
357
358 @retval VOID
359 --*/
360 UINT8*
361 GetPcdDataPtr (
362 IN CONST PCD_INDEX *PcdIndex,
363 IN CONST PCD_DATABASE_HEADER *Info
364 )
365 ;
366
367 /**
368 The function retrieves the PCD data value according to
369 the PCD_DATA_TYPE specified.
370
371 @param[in] Type The PCD_DATA_TYPE used to interpret the data.
372 @param[in] InData The input data.
373 @param[in] OutData The output data.
374 @param[in] Len The length of the data; it is mainly used for PcdPointer type.
375
376 @retval VOID
377 --*/
378 VOID
379 GetDataBasedOnType (
380 IN PCD_DATA_TYPE Type,
381 IN VOID *InData,
382 OUT VOID *OutData,
383 IN UINTN Len
384 )
385 ;
386 #endif