3 Copyright (c) 2004 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 This file contains describes the public interfaces to the GenFvImage Library.
19 The basic purpose of the library is to create Firmware Volume images.
23 #ifndef _EFI_GEN_FV_INTERNAL_LIB_H
24 #define _EFI_GEN_FV_INTERNAL_LIB_H
31 #include <Common/UefiBaseTypes.h>
32 #include <Common/UefiCapsule.h>
34 #include <Common/PiFirmwareFile.h>
35 #include <Common/PiFirmwareVolume.h>
36 #include <Guid/PiFirmwareFileSystem.h>
37 #include <IndustryStandard/PeImage.h>
39 #include "CommonLib.h"
41 #include "EfiUtilityMsgs.h"
44 // Different file separater for Linux and Windows
46 #define FILE_SEP_CHAR '/'
49 // The maximum number of Pad file guid entries.
51 #define MAX_NUMBER_OF_PAD_FILE_GUIDS 1024
54 // The maximum number of block map entries supported by the library
56 #define MAX_NUMBER_OF_FV_BLOCKS 100
59 // The maximum number of files in the FV supported by the library
61 #define MAX_NUMBER_OF_FILES_IN_FV 1000
62 #define MAX_NUMBER_OF_FILES_IN_CAP 1000
63 #define EFI_FFS_FILE_HEADER_ALIGNMENT 8
67 #define OPTIONS_SECTION_STRING "[options]"
68 #define ATTRIBUTES_SECTION_STRING "[attributes]"
69 #define FILES_SECTION_STRING "[files]"
74 #define EFI_FV_BASE_ADDRESS_STRING "EFI_BASE_ADDRESS"
75 #define EFI_FV_FILE_NAME_STRING "EFI_FILE_NAME"
76 #define EFI_NUM_BLOCKS_STRING "EFI_NUM_BLOCKS"
77 #define EFI_BLOCK_SIZE_STRING "EFI_BLOCK_SIZE"
78 #define EFI_GUID_STRING "EFI_GUID"
79 #define EFI_FV_FILESYSTEMGUID_STRING "EFI_FV_GUID"
80 #define EFI_FV_NAMEGUID_STRING "EFI_FVNAME_GUID"
81 #define EFI_CAPSULE_GUID_STRING "EFI_CAPSULE_GUID"
82 #define EFI_CAPSULE_HEADER_SIZE_STRING "EFI_CAPSULE_HEADER_SIZE"
83 #define EFI_CAPSULE_FLAGS_STRING "EFI_CAPSULE_FLAGS"
84 #define EFI_CAPSULE_VERSION_STRING "EFI_CAPSULE_VERSION"
85 #define EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING "EFI_BOOT_DRIVER_BASE_ADDRESS"
86 #define EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING "EFI_RUNTIME_DRIVER_BASE_ADDRESS"
88 #define EFI_FV_TOTAL_SIZE_STRING "EFI_FV_TOTAL_SIZE"
89 #define EFI_FV_TAKEN_SIZE_STRING "EFI_FV_TAKEN_SIZE"
90 #define EFI_FV_SPACE_SIZE_STRING "EFI_FV_SPACE_SIZE"
95 #define EFI_FVB2_READ_DISABLED_CAP_STRING "EFI_READ_DISABLED_CAP"
96 #define EFI_FVB2_READ_ENABLED_CAP_STRING "EFI_READ_ENABLED_CAP"
97 #define EFI_FVB2_READ_STATUS_STRING "EFI_READ_STATUS"
99 #define EFI_FVB2_WRITE_DISABLED_CAP_STRING "EFI_WRITE_DISABLED_CAP"
100 #define EFI_FVB2_WRITE_ENABLED_CAP_STRING "EFI_WRITE_ENABLED_CAP"
101 #define EFI_FVB2_WRITE_STATUS_STRING "EFI_WRITE_STATUS"
103 #define EFI_FVB2_LOCK_CAP_STRING "EFI_LOCK_CAP"
104 #define EFI_FVB2_LOCK_STATUS_STRING "EFI_LOCK_STATUS"
106 #define EFI_FVB2_STICKY_WRITE_STRING "EFI_STICKY_WRITE"
107 #define EFI_FVB2_MEMORY_MAPPED_STRING "EFI_MEMORY_MAPPED"
108 #define EFI_FVB2_ERASE_POLARITY_STRING "EFI_ERASE_POLARITY"
110 #define EFI_FVB2_READ_LOCK_CAP_STRING "EFI_READ_LOCK_CAP"
111 #define EFI_FVB2_READ_LOCK_STATUS_STRING "EFI_READ_LOCK_STATUS"
112 #define EFI_FVB2_WRITE_LOCK_CAP_STRING "EFI_WRITE_LOCK_CAP"
113 #define EFI_FVB2_WRITE_LOCK_STATUS_STRING "EFI_WRITE_LOCK_STATUS"
115 #define EFI_FVB2_ALIGNMENT_1_STRING "EFI_FVB2_ALIGNMENT_1"
116 #define EFI_FVB2_ALIGNMENT_2_STRING "EFI_FVB2_ALIGNMENT_2"
117 #define EFI_FVB2_ALIGNMENT_4_STRING "EFI_FVB2_ALIGNMENT_4"
118 #define EFI_FVB2_ALIGNMENT_8_STRING "EFI_FVB2_ALIGNMENT_8"
119 #define EFI_FVB2_ALIGNMENT_16_STRING "EFI_FVB2_ALIGNMENT_16"
120 #define EFI_FVB2_ALIGNMENT_32_STRING "EFI_FVB2_ALIGNMENT_32"
121 #define EFI_FVB2_ALIGNMENT_64_STRING "EFI_FVB2_ALIGNMENT_64"
122 #define EFI_FVB2_ALIGNMENT_128_STRING "EFI_FVB2_ALIGNMENT_128"
123 #define EFI_FVB2_ALIGNMENT_256_STRING "EFI_FVB2_ALIGNMENT_256"
124 #define EFI_FVB2_ALIGNMENT_512_STRING "EFI_FVB2_ALIGNMENT_512"
125 #define EFI_FVB2_ALIGNMENT_1K_STRING "EFI_FVB2_ALIGNMENT_1K"
126 #define EFI_FVB2_ALIGNMENT_2K_STRING "EFI_FVB2_ALIGNMENT_2K"
127 #define EFI_FVB2_ALIGNMENT_4K_STRING "EFI_FVB2_ALIGNMENT_4K"
128 #define EFI_FVB2_ALIGNMENT_8K_STRING "EFI_FVB2_ALIGNMENT_8K"
129 #define EFI_FVB2_ALIGNMENT_16K_STRING "EFI_FVB2_ALIGNMENT_16K"
130 #define EFI_FVB2_ALIGNMENT_32K_STRING "EFI_FVB2_ALIGNMENT_32K"
131 #define EFI_FVB2_ALIGNMENT_64K_STRING "EFI_FVB2_ALIGNMENT_64K"
132 #define EFI_FVB2_ALIGNMENT_128K_STRING "EFI_FVB2_ALIGNMENT_128K"
133 #define EFI_FVB2_ALIGNMENT_256K_STRING "EFI_FVB2_ALIGNMENT_256K"
134 #define EFI_FVB2_ALIGNMNET_512K_STRING "EFI_FVB2_ALIGNMENT_512K"
135 #define EFI_FVB2_ALIGNMENT_1M_STRING "EFI_FVB2_ALIGNMENT_1M"
136 #define EFI_FVB2_ALIGNMENT_2M_STRING "EFI_FVB2_ALIGNMENT_2M"
137 #define EFI_FVB2_ALIGNMENT_4M_STRING "EFI_FVB2_ALIGNMENT_4M"
138 #define EFI_FVB2_ALIGNMENT_8M_STRING "EFI_FVB2_ALIGNMENT_8M"
139 #define EFI_FVB2_ALIGNMENT_16M_STRING "EFI_FVB2_ALIGNMENT_16M"
140 #define EFI_FVB2_ALIGNMENT_32M_STRING "EFI_FVB2_ALIGNMENT_32M"
141 #define EFI_FVB2_ALIGNMENT_64M_STRING "EFI_FVB2_ALIGNMENT_64M"
142 #define EFI_FVB2_ALIGNMENT_128M_STRING "EFI_FVB2_ALIGNMENT_128M"
143 #define EFI_FVB2_ALIGNMENT_256M_STRING "EFI_FVB2_ALIGNMENT_256M"
144 #define EFI_FVB2_ALIGNMENT_512M_STRING "EFI_FVB2_ALIGNMENT_512M"
145 #define EFI_FVB2_ALIGNMENT_1G_STRING "EFI_FVB2_ALIGNMENT_1G"
146 #define EFI_FVB2_ALIGNMENT_2G_STRING "EFI_FVB2_ALIGNMENT_2G"
151 #define EFI_FILE_NAME_STRING "EFI_FILE_NAME"
153 #define ONE_STRING "1"
154 #define ZERO_STRING "0"
155 #define TRUE_STRING "TRUE"
156 #define FALSE_STRING "FALSE"
157 #define NULL_STRING "NULL"
162 #define EFI_FV_EXT_HEADER_FILE_NAME "EFI_FV_EXT_HEADER_FILE_NAME"
166 // VTF (Firmware Volume Top File) signatures
168 #define IA32_X64_VTF_SIGNATURE_OFFSET 0x14
169 #define IA32_X64_VTF0_SIGNATURE EFI_SIGNATURE_32('V','T','F',0)
172 // Defines to calculate the offset for PEI CORE entry points
174 #define IA32_PEI_CORE_ENTRY_OFFSET 0x20
177 // Defines to calculate the offset for IA32 SEC CORE entry point
179 #define IA32_SEC_CORE_ENTRY_OFFSET 0xD
182 // Defines to calculate the FIT table
184 #define IPF_FIT_ADDRESS_OFFSET 0x20
187 // Defines to calculate the offset for SALE_ENTRY
189 #define IPF_SALE_ENTRY_ADDRESS_OFFSET 0x18
192 // Symbol file definitions, current max size if 512K
194 #define SYMBOL_FILE_SIZE 0x80000
196 #define FV_IMAGES_TOP_ADDRESS 0x100000000ULL
199 // Following definition is used for FIT in IPF
201 #define COMP_TYPE_FIT_PEICORE 0x10
202 #define COMP_TYPE_FIT_UNUSED 0x7F
204 #define FIT_TYPE_MASK 0x7F
205 #define CHECKSUM_BIT_MASK 0x80
210 #define REBASE_XIP_FILE 0x1
211 #define REBASE_BOOTTIME_FILE 0x2
212 #define REBASE_RUNTIME_FILE 0x4
215 // Private data types
218 // Component information
222 CHAR8 ComponentName
[_MAX_PATH
];
226 // FV and capsule information holder
229 BOOLEAN BaseAddressSet
;
230 EFI_PHYSICAL_ADDRESS BaseAddress
;
231 EFI_PHYSICAL_ADDRESS BootBaseAddress
;
232 EFI_PHYSICAL_ADDRESS RuntimeBaseAddress
;
233 EFI_GUID FvFileSystemGuid
;
234 BOOLEAN FvFileSystemGuidSet
;
236 BOOLEAN FvNameGuidSet
;
237 CHAR8 FvExtHeaderFile
[_MAX_PATH
];
239 EFI_FVB_ATTRIBUTES FvAttributes
;
240 CHAR8 FvName
[_MAX_PATH
];
241 EFI_FV_BLOCK_MAP_ENTRY FvBlocks
[MAX_NUMBER_OF_FV_BLOCKS
];
242 CHAR8 FvFiles
[MAX_NUMBER_OF_FILES_IN_FV
][_MAX_PATH
];
243 UINT32 SizeofFvFiles
[MAX_NUMBER_OF_FILES_IN_FV
];
251 CHAR8 CapName
[_MAX_PATH
];
252 CHAR8 CapFiles
[MAX_NUMBER_OF_FILES_IN_CAP
][_MAX_PATH
];
267 #define FV_DEFAULT_ATTRIBUTE 0x0004FEFF
268 extern FV_INFO mFvDataInfo
;
269 extern CAP_INFO mCapDataInfo
;
270 extern EFI_GUID mEfiFirmwareFileSystem2Guid
;
271 extern UINT32 mFvTotalSize
;
272 extern UINT32 mFvTakenSize
;
274 // Local function prototypes
278 IN MEMORY_FILE
*InfFile
,
284 UpdatePeiCoreEntryInFit (
285 IN FIT_TABLE
*FitTablePtr
,
286 IN UINT64 PeiCorePhysicalAddress
292 This function is used to update the Pei Core address in FIT, this can be used by Sec core to pass control from
297 FitTablePtr - The pointer of FIT_TABLE.
298 PeiCorePhysicalAddress - The address of Pei Core entry.
302 EFI_SUCCESS - The PEI_CORE FIT entry was updated successfully.
303 EFI_NOT_FOUND - Not found the PEI_CORE FIT entry.
310 IN FIT_TABLE
*FitTablePtr
316 This function is used to update the checksum for FIT.
321 FitTablePtr - The pointer of FIT_TABLE.
333 OUT UINT32
*EntryPoint
,
334 OUT UINT32
*BaseOfCode
,
335 OUT UINT16
*MachineType
340 IN MEMORY_FILE
*InfFile
,
341 OUT CAP_INFO
*CapInfo
345 FindApResetVectorPosition (
346 IN MEMORY_FILE
*FvImage
,
357 IN OUT FV_INFO
*FvInfo
,
359 IN OUT EFI_FFS_FILE_HEADER
*FfsFile
,
365 // Exported function prototypes
369 IN CHAR8
*InfFileImage
,
370 IN UINTN InfFileSize
,
371 IN CHAR8
*CapFileName
377 This is the main function which will be called from application to
378 generate UEFI Capsule image.
382 InfFileImage Buffer containing the INF file contents.
383 InfFileSize Size of the contents of the InfFileImage buffer.
384 CapFileName Requested name for the Cap file.
388 EFI_SUCCESS Function completed successfully.
389 EFI_OUT_OF_RESOURCES Could not allocate required resources.
390 EFI_ABORTED Error encountered.
391 EFI_INVALID_PARAMETER A required parameter was NULL.
398 IN CHAR8
*InfFileImage
,
399 IN UINTN InfFileSize
,
400 IN CHAR8
*FvFileName
,
401 IN CHAR8
*MapFileName
407 This is the main function which will be called from application to
408 generate Firmware Image conforms to PI spec.
412 InfFileImage Buffer containing the INF file contents.
413 InfFileSize Size of the contents of the InfFileImage buffer.
414 FvFileName Requested name for the FV file.
415 MapFileName Fv map file to log fv driver information.
419 EFI_SUCCESS Function completed successfully.
420 EFI_OUT_OF_RESOURCES Could not allocate required resources.
421 EFI_ABORTED Error encountered.
422 EFI_INVALID_PARAMETER A required parameter was NULL.