3 Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
19 This file contains the relevant declarations required
20 to generate Boot Strap File
25 // Module Coded to EFI 2.0 Coding Conventions
27 #ifndef _EFI_GEN_BSF_IMAGE_H
28 #define _EFI_GEN_BSF_IMAGE_H
31 // External Files Referenced
38 // #include "TianoCommon.h"
39 #include "Common/FirmwareFileSystem.h"
40 #include "Common/FirmwareVolumeHeader.h"
46 #define EFI_IPF_VTF1_GUID \
48 0xfa371c9b, 0x5a86, 0x4198, 0xab, 0xc2, 0xed, 0x3f, 0xaa, 0xce, 0xb0, 0x8b \
51 #define EFI_IPF_VTF2_GUID \
53 0x624a0d5a, 0x315f, 0x40b6, 0xa6, 0x33, 0xe5, 0xf7, 0xde, 0x58, 0x20, 0xa0 \
56 #define EFI_IA32_BOOT_STRAP_GUID \
58 0xd4260a8d, 0x356, 0x4f45, 0x85, 0xe9, 0xad, 0x1d, 0x79, 0x22, 0x79, 0xf0 \
61 #define CV_N_TYPE(a,b) (UINT8)(((UINT8)a << 7) + (UINT8)b) // Keeps the CV and Type in same byte field
62 #define MAKE_VERSION(a,b) (UINT16)(((UINT16)a << 8) + (UINT16)b)
64 #define FILE_NAME_SIZE 256
65 #define COMPONENT_NAME_SIZE 128
66 #define BSF_INPUT_FILE "BSF.INF"
67 #define BSF_OUTPUT_FILE "Bsf.RAW"
68 #define BSF_SYM_FILE "Bsf.SYM"
69 #define FIT_SIGNATURE "_FIT_ "
72 // This is IA32 seccore
74 #define COMP_TYPE_SECCORE 0x0F
79 #define COMP_TYPE_FIT_HEADER 0x00
80 #define COMP_TYPE_FIT_PAL_B 0x01
83 // This is generic PAL_A
85 #define COMP_TYPE_FIT_PAL_A 0x0F
86 #define COMP_TYPE_FIT_PEICORE 0x10
87 #define COMP_TYPE_FIT_AUTOSCAN 0x30
88 #define COMP_TYPE_FIT_FV_BOOT 0x7E
91 //This is processor Specific PAL_A
93 #define COMP_TYPE_FIT_PAL_A_SPECIFIC 0x0E
94 #define COMP_TYPE_FIT_UNUSED 0x7F
96 #define FIT_TYPE_MASK 0x7F
97 #define CHECKSUM_BIT_MASK 0x80
100 // IPF processor address is cached bit
102 #define IPF_CACHE_BIT 0x8000000000000000
105 // Size definition to calculate the location from top of address for
108 #define SIZE_IA32_RESET_VECT 0x10 // 16 Bytes
109 #define SIZE_SALE_ENTRY_POINT 0x08 // 8 Byte
110 #define SIZE_FIT_TABLE_ADD 0x08 // 8 Byte
111 #define SIZE_FIT_TABLE_PAL_A 0x10
112 #define SIZE_RESERVED 0x10
115 #define SIZE_TO_OFFSET_PAL_A_END (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT + \
116 SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PAL_A + \
118 #define SIZE_TO_PAL_A_FIT (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT + \
119 SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PAL_A)
121 #define SIZE_OF_PAL_HEADER 0x40 //PAL has 64 byte header
126 #define UTILITY_NAME "GenBsfImage"
129 // Utility version information
131 #define UTILITY_MAJOR_VERSION 0
132 #define UTILITY_MINOR_VERSION 0
133 #define UTILITY_DATE __DATE__
136 // The maximum number of arguments accepted from the command line.
138 #define ONE_BSF_ARGS 5
139 #define TWO_BSF_ARGS 9
142 // The number of IA32 bsf arguments accepted from the command line.
146 #define IA32_SOFT_FIT "IA32BsfAddress.inf"
149 // Internal Data Structure
151 typedef enum _LOC_TYPE
153 NONE
, // In case there is - INF file
154 FIRST_VTF
, // First VTF
155 SECOND_VTF
, // Outside BSF
158 typedef struct _PARSED_BSF_INFO
{
159 CHAR8 CompName
[COMPONENT_NAME_SIZE
];
160 LOC_TYPE LocationType
;
164 UINT8 CheckSumRequired
;
165 BOOLEAN VersionPresent
; // If it is TRUE, then, Version is in INF file
166 BOOLEAN PreferredSize
;
167 BOOLEAN PreferredAddress
;
168 CHAR8 CompBinName
[FILE_NAME_SIZE
];
169 CHAR8 CompSymName
[FILE_NAME_SIZE
];
171 UINT64 CompPreferredAddress
;
175 // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedBsfInfo *' to 'struct _PARSED_BSF_INFO *'
176 // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedBsfInfo *' to 'struct _PARSED_BSF_INFO *'
177 // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedBsfInfo *' to 'struct _PARSED_BSF_INFO *'
178 // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedBsfInfo *' to 'struct _PARSED_BSF_INFO *'
180 struct _PARSED_BSF_INFO
*NextBsfInfo
;
194 // The function that displays general utility information
204 Displays the standard utility information to SDTOUT
218 // The function that displays the utility usage message.
228 Displays the utility usage syntax to STDOUT
242 // Other Function Prototype Declarations
247 IN UINT64 StartAddress
,
256 Update the Firmware Volume Buffer with requested buffer data
260 StartAddress - StartAddress in buffer. This number will automatically
261 point to right address in buffer where data needed
263 Buffer - Buffer pointer from data will be copied to memory mapped buffer.
264 DataSize - Size of the data needed to be copied.
265 LocType - The type of the BSF
269 EFI_ABORTED - The input parameter is error
270 EFI_SUCCESS - The function completed successfully
277 IN UINT64 BaseAddress
,
278 IN CHAR8
*DestFileName
,
279 IN CHAR8
*SourceFileName
285 This function adds the SYM tokens in the source file to the destination file.
286 The SYM tokens are updated to reflect the base address.
290 BaseAddress - The base address for the new SYM tokens.
291 DestFileName - The destination file.
292 SourceFileName - The source file.
296 EFI_SUCCESS - The function completed successfully.
297 EFI_INVALID_PARAMETER - One of the input parameters was invalid.
298 EFI_ABORTED - An error occurred.
304 CalculateFitTableChecksum (
311 This function will perform byte checksum on the FIT table, if the the checksum required
312 field is set to CheckSum required. If the checksum is not required then checksum byte
313 will have value as 0;.
321 Status - Value returned by call to CalculateChecksum8 ()
322 EFI_SUCCESS - The function completed successfully
329 IN UINT64 StartAddress1
,
331 IN UINT64 StartAddress2
,
338 This is the main function which will be called from application.
342 StartAddress1 - The start address of the first BSF
343 Size1 - The size of the first BSF
344 StartAddress2 - The start address of the second BSF
345 Size2 - The size of the second BSF
349 EFI_OUT_OF_RESOURCES - Can not allocate memory
350 The return value can be any of the values
351 returned by the calls to following functions:
352 GetBsfRelatedInfoFromInfFile
354 UpdateIA32ResetVector
362 PeimFixupInFitTable (
363 IN UINT64 StartAddress
369 This function is an entry point to fixup SAL-E entry point.
373 StartAddress - StartAddress for PEIM.....
377 EFI_SUCCESS - The function completed successfully
378 EFI_ABORTED - Error Opening File
385 IN UINT64 BootFileStartAddress
391 This is the main IA32 function which will be called from application.
392 (Now this tool is not used for IA32 platform, if it will be used in future,
393 the relative functions need to be updated, the updating can refer to IPF
398 BootFileStartAddress - Top Address of Boot File
402 The return value can be any of the values
403 returned by the calls to following functions:
404 Get32BsfRelatedInfoFromInfFile
406 ProcessAndCreate32Bsf
421 This function calculates total size for IA32 BSF which would be needed to create
422 the buffer. This will be done using Passed Info link list and looking for the
423 size of the components which belong to BSF. The addtional file header is accounted.
427 BSFSize - Pointer to the size of IA32 BSF
431 EFI_ABORTED - Returned due to one of the following resons:
432 (a) Error Opening File
433 EFI_SUCCESS - The fuction completes successfully
439 ProcessAndCreate32Bsf (
446 This function process the link list created during INF file parsing
447 and create component in IA32 BSF
451 Size - Size of the Firmware Volume of which, this BSF belongs to.
455 EFI_UNSUPPORTED - Unknown component type
456 EFI_SUCCESS - The function completed successfully
462 CreateAndUpdateSeccore (
463 IN PARSED_BSF_INFO
*BsfInfo
469 This function reads the binary file for seccore and update them
474 BsfInfo - Pointer to Parsed Info
478 EFI_ABORTED - Due to one of the following reasons:
479 (a)Error Opening File
480 (b)The PAL_A Size is more than specified size status
481 One of the values mentioned below returned from
482 call to UpdateSymFile
483 EFI_SUCCESS - The function completed successfully.
484 EFI_INVALID_PARAMETER - One of the input parameters was invalid.
485 EFI_ABORTED - An error occurred.UpdateSymFile
491 CreateAndUpdate32Component (
492 IN PARSED_BSF_INFO
*BsfInfo
498 This function reads the binary file for each components. Add it at aligned address.
502 BsfInfo - Pointer to Parsed Info
506 EFI_SUCCESS - The function completed successful
507 EFI_ABORTED - Aborted due to one of the many reasons like:
508 (a) Component Size greater than the specified size.
509 (b) Error opening files.
510 EFI_INVALID_PARAMETER - Value returned from call to UpdateEntryPoint()
523 Update the Firmware Volume Buffer with requested buffer data
527 BsfSize - Size of the IA32 BSF
531 EFI_SUCCESS - The function completed successfully
532 EFI_INVALID_PARAMETER - The Ffs File Header Pointer is NULL
538 Get32BsfRelatedInfoFromInfFile (
545 This function reads the input file, parse it and create a list of tokens
546 which is parsed and used, to intialize the data related to IA32 BSF
550 FileName FileName which needed to be read to parse data
554 EFI_ABORTED Error in opening file
555 EFI_INVALID_PARAMETER File doesn't contain any valid informations
556 EFI_OUT_OF_RESOURCES Malloc Failed
557 EFI_SUCCESS The function completed successfully
563 Initialize32InFileInfo (
570 This function intializes the relevant global variable which is being
571 used to store the information retrieved from IA32 INF file.
585 ParseAndUpdate32Components (
586 IN PARSED_BSF_INFO
*BsfInfo
592 This function intializes the relevant global variable which is being
593 used to store the information retrieved from INF file.
597 BsfInfo - A pointer to the BSF Info Structure
610 IN PARSED_BSF_INFO
*BsfInfo
616 Write IA32 Firmware Volume component address from memory to a file.
620 FileName Output File Name which needed to be created/
621 BsfInfo Parsed info link
625 EFI_ABORTED - Returned due to one of the following resons:
626 (a) Error Opening File
627 (b) Failing to copy buffers
628 EFI_SUCCESS - The fuction completes successfully