2 Common functions used by PCD PEIM and PCD DXE.
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
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.
14 Module Name: PcdCommon.h
18 #ifndef __PCD_COMMON_H__
19 #define __PCD_COMMON_H__
22 // Enumeration for PCD_DATA_TYPE
35 // The definitions for Global PCD Length Fields
37 #define PCD_LENGTH_BIT8 0x01
38 #define PCD_LENGTH_BIT16 0x02
39 #define PCD_LENGTH_BIT24 0x03
40 #define PCD_LENGTH_BIT32 0x04
45 * This data structure is used in <PCD_IMAGE> transverse
49 UINTN GlobalOffsetLength
;
50 UINTN GlobalTokenLength
;
51 UINTN GlobalGuidTabIdxLength
;
52 UINTN GlobalDatumLength
;
53 UINTN GlobalStrTabIdxLength
;
55 CONST UINT8
*DataDefaultStart
;
56 UINTN DataDefaultLength
;
57 UINTN WholeDataDefaultLength
;
58 CONST UINT8
*IndexStart
;
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
68 CONST UINT8
*ImageStart
;
78 BOOLEAN SkuDataArrayEnable
;
79 PCD_DATA_TYPE DataType
;
80 BOOLEAN ExtendedGuidPresent
;
87 // All Pointer's Offset in byte
90 PCD_STATEBYTE StateByte
;
92 UINT32 SkuIdArray
; //Pointer
93 UINT32 ExtendedDataOffset
;
95 UINT16 DynamicExGuid
; //Pointer
102 * PCD Image Definition according PCD Specification 0.51.
107 UINT8 ImageLength
[3];
109 // The length of PCD_FFS_ENCODING is included
112 UINT8 DataBufferLength
[3];
113 UINT8 WholeDataBufferLength
[3];
114 UINT8 PcdIndexLength
[3];
115 UINT8 GuidTableLength
[3];
117 // The StringTable can be computed using:
118 // ImageLength, DataBufferLength, PcdIndexLength, GuidTableLength,
119 // and length of PCD_FFS_ENCODING
122 UINT8 GlobalOffsetLength
[1];
123 UINT8 GlobalTokenLength
[1];
125 UINT8 GlobalDatumLength
[1];
126 UINT8 GlobalStrTabIdxLength
[1];
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
;
148 } PCD_DATABASE_HEADER
;
153 PCD_DATABASE_HEADER Info
;
154 EFI_GUID GuidTable
[1];
157 extern EFI_GUID gPcdDataBaseHobGuid
;
161 The function returns the actual address of item in the PCD
162 database according to its Segment and Offset.
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.
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.
176 IN UINTN SegmentStart
,
184 The function return the number of Unicode Character in a NULL terminated string.
185 The NULL is NOT counted.
187 @param[in] String The unicode string starts from an unaligned address.
189 @retval UINTN The number of Unicode characters.
198 The function retrieves the PCD data value according to
199 TokenNumber and Guid space given.
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.
212 IN CONST PCD_DATABASE_HEADER
*Info
,
213 IN UINTN TokenNumber
,
214 IN CONST GUID
*Guid
, OPTIONAL
215 IN PCD_DATA_TYPE Type
,
223 The function retrieves the PCD data value according to
224 TokenNumber and Guid space given.
226 @param[in] Info The PCD Database info.
227 @param[in] TokenNumber The token number.
228 @param[in] Guid The Guid space.
230 @retval UINTN The size of the PCD Entry.
234 GetPcdEntrySizeWorker (
235 IN CONST PCD_DATABASE_HEADER
*Info
,
236 IN UINTN TokenNumber
,
237 IN CONST GUID
*Guid OPTIONAL
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.
250 @param[in] Info The PCD Database info.
251 @param[in,out] TokenNumber The token number.
252 @param[in] Guid The Guid space.
254 @retval EFI_NOT_FOUND Can't find the PCD_ENTRY.
255 @retval EFI_SUCCESS Operation succesful.
260 IN CONST PCD_DATABASE_HEADER
*Info
,
261 IN OUT UINTN
*TokenNumber
,
262 IN CONST GUID
*Guid OPTIONAL
269 The function is the worker function to set the data of a PCD entry.
271 @param[in] PcdIndex The PCD Index.
272 @param[in] Info The attributes of the PCD database.
273 @param[in] Data The input data.
279 IN CONST PCD_INDEX
*PcdIndex
,
280 IN CONST PCD_DATABASE_HEADER
*Info
,
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.
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.
295 @retval EFI_SUCCESS Operation successful.
296 @retval EFI_SUCCESS Variablel not found.
300 IN EFI_GUID
*VariableGuid
,
301 IN UINT16
*VariableName
,
302 OUT VOID
**VariableData
,
303 OUT UINTN
*VariableSize
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.
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.
319 @retval EFI_SUCCESS Operation successful.
320 @retval EFI_SUCCESS Variablel not found.
324 IN EFI_GUID
*VariableGuid
,
325 IN UINT16
*VariableName
,
327 IN UINTN VariableSize
,
333 The function locates the PCD_INDEX according to TokeNumber and GUID space given.
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.
339 @retval PCD_INDEX* The PCD_INDEX found.
343 IN UINTN TokenNumber
,
345 IN CONST PCD_DATABASE_HEADER
*Info
,
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.
354 @param[in] PcdIndex The PCD Index.
355 @param[in] Info The attributes of the PCD database.
356 @param[out] Data The output data.
362 IN CONST PCD_INDEX
*PcdIndex
,
363 IN CONST PCD_DATABASE_HEADER
*Info
368 The function retrieves the PCD data value according to
369 the PCD_DATA_TYPE specified.
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.
380 IN PCD_DATA_TYPE Type
,