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
37 // #include "TianoCommon.h"
38 #include "Common/FirmwareFileSystem.h"
39 #include "Common/FirmwareVolumeHeader.h"
45 #define EFI_IPF_VTF1_GUID \
47 0xfa371c9b, 0x5a86, 0x4198, 0xab, 0xc2, 0xed, 0x3f, 0xaa, 0xce, 0xb0, 0x8b \
50 #define EFI_IPF_VTF2_GUID \
52 0x624a0d5a, 0x315f, 0x40b6, 0xa6, 0x33, 0xe5, 0xf7, 0xde, 0x58, 0x20, 0xa0 \
55 #define EFI_IA32_BOOT_STRAP_GUID \
57 0xd4260a8d, 0x356, 0x4f45, 0x85, 0xe9, 0xad, 0x1d, 0x79, 0x22, 0x79, 0xf0 \
60 #define CV_N_TYPE(a,b) (UINT8)(((UINT8)a << 7) + (UINT8)b) // Keeps the CV and Type in same byte field
61 #define MAKE_VERSION(a,b) (UINT16)(((UINT16)a << 8) + (UINT16)b)
63 #define FILE_NAME_SIZE 256
64 #define COMPONENT_NAME_SIZE 128
65 #define BSF_INPUT_FILE "BSF.INF"
66 #define BSF_OUTPUT_FILE "Bsf.RAW"
67 #define BSF_SYM_FILE "Bsf.SYM"
68 #define FIT_SIGNATURE "_FIT_ "
71 // This is IA32 seccore
73 #define COMP_TYPE_SECCORE 0x0F
78 #define COMP_TYPE_FIT_HEADER 0x00
79 #define COMP_TYPE_FIT_PAL_B 0x01
82 // This is generic PAL_A
84 #define COMP_TYPE_FIT_PAL_A 0x0F
85 #define COMP_TYPE_FIT_PEICORE 0x10
86 #define COMP_TYPE_FIT_AUTOSCAN 0x30
87 #define COMP_TYPE_FIT_FV_BOOT 0x7E
90 //This is processor Specific PAL_A
92 #define COMP_TYPE_FIT_PAL_A_SPECIFIC 0x0E
93 #define COMP_TYPE_FIT_UNUSED 0x7F
95 #define FIT_TYPE_MASK 0x7F
96 #define CHECKSUM_BIT_MASK 0x80
99 // IPF processor address is cached bit
101 #define IPF_CACHE_BIT 0x8000000000000000
104 // Size definition to calculate the location from top of address for
107 #define SIZE_IA32_RESET_VECT 0x10 // 16 Bytes
108 #define SIZE_SALE_ENTRY_POINT 0x08 // 8 Byte
109 #define SIZE_FIT_TABLE_ADD 0x08 // 8 Byte
110 #define SIZE_FIT_TABLE_PAL_A 0x10
111 #define SIZE_RESERVED 0x10
114 #define SIZE_TO_OFFSET_PAL_A_END (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT + \
115 SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PAL_A + \
117 #define SIZE_TO_PAL_A_FIT (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT + \
118 SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PAL_A)
120 #define SIZE_OF_PAL_HEADER 0x40 //PAL has 64 byte header
125 #define UTILITY_NAME "GenBsfImage"
128 // Utility version information
130 #define UTILITY_MAJOR_VERSION 0
131 #define UTILITY_MINOR_VERSION 1
132 #define UTILITY_DATE __DATE__
135 // The maximum number of arguments accepted from the command line.
137 #define ONE_BSF_ARGS 5
138 #define TWO_BSF_ARGS 9
141 // The number of IA32 bsf arguments accepted from the command line.
145 #define IA32_SOFT_FIT "IA32BsfAddress.inf"
148 // Internal Data Structure
150 typedef enum _LOC_TYPE
152 NONE
, // In case there is - INF file
153 FIRST_VTF
, // First VTF
154 SECOND_VTF
, // Outside BSF
157 typedef struct _PARSED_BSF_INFO
{
158 CHAR8 CompName
[COMPONENT_NAME_SIZE
];
159 LOC_TYPE LocationType
;
163 UINT8 CheckSumRequired
;
164 BOOLEAN VersionPresent
; // If it is TRUE, then, Version is in INF file
165 BOOLEAN PreferredSize
;
166 BOOLEAN PreferredAddress
;
167 CHAR8 CompBinName
[FILE_NAME_SIZE
];
168 CHAR8 CompSymName
[FILE_NAME_SIZE
];
170 UINT64 CompPreferredAddress
;
174 // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedBsfInfo *' to 'struct _PARSED_BSF_INFO *'
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 *'
179 struct _PARSED_BSF_INFO
*NextBsfInfo
;
193 // The function that displays general utility information
203 Displays the standard utility information to SDTOUT
217 // The function that displays the utility usage message.
227 Displays the utility usage syntax to STDOUT
241 // Other Function Prototype Declarations
246 IN UINT64 StartAddress
,
255 Update the Firmware Volume Buffer with requested buffer data
259 StartAddress - StartAddress in buffer. This number will automatically
260 point to right address in buffer where data needed
262 Buffer - Buffer pointer from data will be copied to memory mapped buffer.
263 DataSize - Size of the data needed to be copied.
264 LocType - The type of the BSF
268 EFI_ABORTED - The input parameter is error
269 EFI_SUCCESS - The function completed successfully
276 IN UINT64 BaseAddress
,
277 IN CHAR8
*DestFileName
,
278 IN CHAR8
*SourceFileName
284 This function adds the SYM tokens in the source file to the destination file.
285 The SYM tokens are updated to reflect the base address.
289 BaseAddress - The base address for the new SYM tokens.
290 DestFileName - The destination file.
291 SourceFileName - The source file.
295 EFI_SUCCESS - The function completed successfully.
296 EFI_INVALID_PARAMETER - One of the input parameters was invalid.
297 EFI_ABORTED - An error occurred.
303 CalculateFitTableChecksum (
310 This function will perform byte checksum on the FIT table, if the the checksum required
311 field is set to CheckSum required. If the checksum is not required then checksum byte
312 will have value as 0;.
320 Status - Value returned by call to CalculateChecksum8 ()
321 EFI_SUCCESS - The function completed successfully
328 IN UINT64 StartAddress1
,
330 IN UINT64 StartAddress2
,
337 This is the main function which will be called from application.
341 StartAddress1 - The start address of the first BSF
342 Size1 - The size of the first BSF
343 StartAddress2 - The start address of the second BSF
344 Size2 - The size of the second BSF
348 EFI_OUT_OF_RESOURCES - Can not allocate memory
349 The return value can be any of the values
350 returned by the calls to following functions:
351 GetBsfRelatedInfoFromInfFile
353 UpdateIA32ResetVector
361 PeimFixupInFitTable (
362 IN UINT64 StartAddress
368 This function is an entry point to fixup SAL-E entry point.
372 StartAddress - StartAddress for PEIM.....
376 EFI_SUCCESS - The function completed successfully
377 EFI_ABORTED - Error Opening File
384 IN UINT64 BootFileStartAddress
390 This is the main IA32 function which will be called from application.
391 (Now this tool is not used for IA32 platform, if it will be used in future,
392 the relative functions need to be updated, the updating can refer to IPF
397 BootFileStartAddress - Top Address of Boot File
401 The return value can be any of the values
402 returned by the calls to following functions:
403 Get32BsfRelatedInfoFromInfFile
405 ProcessAndCreate32Bsf
420 This function calculates total size for IA32 BSF which would be needed to create
421 the buffer. This will be done using Passed Info link list and looking for the
422 size of the components which belong to BSF. The addtional file header is accounted.
426 BSFSize - Pointer to the size of IA32 BSF
430 EFI_ABORTED - Returned due to one of the following resons:
431 (a) Error Opening File
432 EFI_SUCCESS - The fuction completes successfully
438 ProcessAndCreate32Bsf (
445 This function process the link list created during INF file parsing
446 and create component in IA32 BSF
450 Size - Size of the Firmware Volume of which, this BSF belongs to.
454 EFI_UNSUPPORTED - Unknown component type
455 EFI_SUCCESS - The function completed successfully
461 CreateAndUpdateSeccore (
462 IN PARSED_BSF_INFO
*BsfInfo
468 This function reads the binary file for seccore and update them
473 BsfInfo - Pointer to Parsed Info
477 EFI_ABORTED - Due to one of the following reasons:
478 (a)Error Opening File
479 (b)The PAL_A Size is more than specified size status
480 One of the values mentioned below returned from
481 call to UpdateSymFile
482 EFI_SUCCESS - The function completed successfully.
483 EFI_INVALID_PARAMETER - One of the input parameters was invalid.
484 EFI_ABORTED - An error occurred.UpdateSymFile
490 CreateAndUpdate32Component (
491 IN PARSED_BSF_INFO
*BsfInfo
497 This function reads the binary file for each components. Add it at aligned address.
501 BsfInfo - Pointer to Parsed Info
505 EFI_SUCCESS - The function completed successful
506 EFI_ABORTED - Aborted due to one of the many reasons like:
507 (a) Component Size greater than the specified size.
508 (b) Error opening files.
509 EFI_INVALID_PARAMETER - Value returned from call to UpdateEntryPoint()
522 Update the Firmware Volume Buffer with requested buffer data
526 BsfSize - Size of the IA32 BSF
530 EFI_SUCCESS - The function completed successfully
531 EFI_INVALID_PARAMETER - The Ffs File Header Pointer is NULL
537 Get32BsfRelatedInfoFromInfFile (
544 This function reads the input file, parse it and create a list of tokens
545 which is parsed and used, to intialize the data related to IA32 BSF
549 FileName FileName which needed to be read to parse data
553 EFI_ABORTED Error in opening file
554 EFI_INVALID_PARAMETER File doesn't contain any valid informations
555 EFI_OUT_OF_RESOURCES Malloc Failed
556 EFI_SUCCESS The function completed successfully
562 Initialize32InFileInfo (
569 This function intializes the relevant global variable which is being
570 used to store the information retrieved from IA32 INF file.
584 ParseAndUpdate32Components (
585 IN PARSED_BSF_INFO
*BsfInfo
591 This function intializes the relevant global variable which is being
592 used to store the information retrieved from INF file.
596 BsfInfo - A pointer to the BSF Info Structure
609 IN PARSED_BSF_INFO
*BsfInfo
615 Write IA32 Firmware Volume component address from memory to a file.
619 FileName Output File Name which needed to be created/
620 BsfInfo Parsed info link
624 EFI_ABORTED - Returned due to one of the following resons:
625 (a) Error Opening File
626 (b) Failing to copy buffers
627 EFI_SUCCESS - The fuction completes successfully