sb_file_format.h
/*
* Copyright (c) 2013, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(_SB_FILE_FORMAT_H_)
#define _SB_FILE_FORMAT_H_
#include "bootloader_common.h"
// Definitions
#pragma pack(push)
#pragma pack(1)
enum
{
ROM_DISPLAY_PROGRESS = (1 << 0),
ROM_VERBOSE_PROGRESS = (1 << 1)
};
typedef struct _sb_version
{
uint16_t m_major;
uint16_t m_pad0;
uint16_t m_minor;
uint16_t m_pad1;
uint16_t m_revision;
uint16_t m_pad2;
} sb_version_t;
typedef struct _sb_image_header
{
uint8_t m_digest[20]; // !< SHA-1 digest of image header. Also used as the crypto IV.
uint32_t m_signature; // !< 'STMP', see #BOOT_SIGNATURE.
uint8_t m_majorVersion; // !< Major version for the image format, see #SB_FILE_MAJOR_VERSION.
uint8_t m_minorVersion; // !< Minor version of the boot image format.
uint16_t m_flags; // !< Flags or options associated with the entire image.
uint32_t m_imageBlocks; // !< Size of entire image in blocks.
uint32_t m_firstBootTagBlock; // !< Offset from start of file to the first boot tag, in blocks.
uint32_t m_firstBootableSectionID; // !< ID of section to start booting from.
uint16_t m_keyCount; // !< Number of entries in DEK dictionary.
uint16_t m_keyDictionaryBlock; // !< Starting block number for the key dictionary.
uint16_t m_headerBlocks; // !< Size of this header, including this size word, in blocks.
uint16_t m_sectionCount; // !< Number of section headers in this table.
uint16_t m_sectionHeaderSize; // !< Size in blocks of a section header.
uint8_t m_padding0[2]; // !< Padding to align #m_timestamp to long word.
uint32_t
m_signature2; // !< Second signature to distinguish this .sb format from the 36xx format, see #BOOT_SIGNATURE2.
uint64_t m_timestamp; // !< Timestamp when image was generated in microseconds since 1-1-2000.
sb_version_t m_productVersion; // !< Product version.
sb_version_t m_componentVersion; // !< Component version.
uint16_t m_driveTag; // !< Drive tag for the system drive which this boot image belongs to.
uint8_t m_padding1[6]; // !< Padding to round up to next cipher block.
} sb_image_header_t;
typedef struct _sb_dek_dictionary_entry
{
uint8_t m_mac[16];
uint8_t m_dek[16];
} sb_dek_dictionary_entry_t;
typedef struct _sb_dek_dictionary
{
sb_dek_dictionary_entry_t m_entries[1];
} sb_dek_dictionary_t;
enum
{
ROM_SECTION_BOOTABLE = (1 << 0),
ROM_SECTION_CLEARTEXT =
(1 << 1)
};
typedef struct _sb_section_header
{
uint32_t m_tag;
uint32_t m_offset;
uint32_t m_length;
uint32_t m_flags;
} sb_section_header_t;
typedef struct _sb_section_table
{
sb_section_header_t m_sections[1];
} sb_section_table_t;
#pragma pack(pop)
#endif // _SB_FILE_FORMAT_H_
// EOF
ROM_DISPLAY_PROGRESS
Print progress reports.
Definition: sb_file_format.h:48
sb_section_table_t
An index of all sections within the boot image.
Definition: sb_file_format.h:157
sb_section_header_t::m_flags
uint32_t m_flags
Section flags.
Definition: sb_file_format.h:138
ROM_VERBOSE_PROGRESS
Progress reports are verbose.
Definition: sb_file_format.h:49
sb_section_header_t::m_length
uint32_t m_length
Size of section data in blocks.
Definition: sb_file_format.h:137
ROM_SECTION_BOOTABLE
The section contains bootloader commands.
Definition: sb_file_format.h:126
sb_section_header_t::m_tag
uint32_t m_tag
Unique identifier for this section. High bit must be zero.
Definition: sb_file_format.h:135
sb_section_header_t::m_offset
uint32_t m_offset
Offset to section data from start of image in blocks.
Definition: sb_file_format.h:136
sb_image_header_t
Header for the entire boot image.
Definition: sb_file_format.h:82
sb_dek_dictionary_entry_t
Entry in sb_dek_dictionary_t.
Definition: sb_file_format.h:111
sb_section_header_t
Information about each section, held in the section table.
Definition: sb_file_format.h:133
ROM_SECTION_CLEARTEXT
The section is unencrypted. Applies only if the rest of the boot image is encrypted.
Definition: sb_file_format.h:127
sb_version_t
Version struct used in SB files.
Definition: sb_file_format.h:53
sb_dek_dictionary_t
The DEK dictionary always follows the image header, in the next cipher block.
Definition: sb_file_format.h:118