123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- #ifndef __MXSSB_H__
- #define __MXSSB_H__
- #include <stdint.h>
- #include <arpa/inet.h>
- #define SB_BLOCK_SIZE 16
- #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
- #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
- struct sb_boot_image_version {
- uint16_t major;
- uint16_t pad0;
- uint16_t minor;
- uint16_t pad1;
- uint16_t revision;
- uint16_t pad2;
- };
- struct sb_boot_image_header {
- union {
-
- uint8_t digest[20];
- struct {
-
- uint8_t iv[16];
- uint8_t extra[4];
- };
- };
-
- uint8_t signature1[4];
-
- uint8_t major_version;
-
- uint8_t minor_version;
-
- uint16_t flags;
-
- uint32_t image_blocks;
-
- uint32_t first_boot_tag_block;
-
- uint32_t first_boot_section_id;
-
- uint16_t key_count;
-
- uint16_t key_dictionary_block;
-
- uint16_t header_blocks;
-
- uint16_t section_count;
-
- uint16_t section_header_size;
-
- uint8_t padding0[2];
-
- uint8_t signature2[4];
-
- uint64_t timestamp_us;
-
- struct sb_boot_image_version
- product_version;
-
- struct sb_boot_image_version
- component_version;
-
- uint16_t drive_tag;
-
- uint8_t padding1[6];
- };
- #define SB_VERSION_MAJOR 1
- #define SB_VERSION_MINOR 1
- #define SB_IMAGE_FLAG_DISPLAY_PROGRESS (1 << 0)
- #define SB_IMAGE_FLAGS_MASK SB_IMAGE_FLAG_DISPLAY_PROGRESS
- struct sb_key_dictionary_key {
-
- uint8_t cbc_mac[SB_BLOCK_SIZE];
-
- uint8_t key[SB_BLOCK_SIZE];
- };
- struct sb_ivt_header {
- uint32_t header;
- uint32_t entry;
- uint32_t reserved1;
- uint32_t dcd;
- uint32_t boot_data;
- uint32_t self;
- uint32_t csf;
- uint32_t reserved2;
- };
- #define SB_HAB_IVT_TAG 0xd1UL
- #define SB_HAB_DCD_TAG 0xd2UL
- #define SB_HAB_VERSION 0x40UL
- static inline uint32_t sb_hab_ivt_header(void)
- {
- uint32_t ret = 0;
- ret |= SB_HAB_IVT_TAG << 24;
- ret |= sizeof(struct sb_ivt_header) << 16;
- ret |= SB_HAB_VERSION;
- return htonl(ret);
- }
- struct sb_sections_header {
-
- uint32_t section_number;
-
- uint32_t section_offset;
-
- uint32_t section_size;
-
- uint32_t section_flags;
- };
- #define SB_SECTION_FLAG_BOOTABLE (1 << 0)
- struct sb_command {
- struct {
- uint8_t checksum;
- uint8_t tag;
- uint16_t flags;
- #define ROM_TAG_CMD_FLAG_ROM_LAST_TAG 0x1
- #define ROM_LOAD_CMD_FLAG_DCD_LOAD 0x1
- #define ROM_JUMP_CMD_FLAG_HAB 0x1
- #define ROM_CALL_CMD_FLAG_HAB 0x1
- } header;
- union {
- struct {
- uint32_t reserved[3];
- } nop;
- struct {
- uint32_t section_number;
- uint32_t section_length;
- uint32_t section_flags;
- } tag;
- struct {
- uint32_t address;
- uint32_t count;
- uint32_t crc32;
- } load;
- struct {
- uint32_t address;
- uint32_t count;
- uint32_t pattern;
- } fill;
- struct {
- uint32_t address;
- uint32_t reserved;
-
- uint32_t argument;
- } jump;
- struct {
- uint32_t address;
- uint32_t reserved;
-
- uint32_t argument;
- } call;
- struct {
- uint32_t reserved1;
- uint32_t reserved2;
- uint32_t mode;
- } mode;
- };
- };
- static const struct {
- const char *name;
- const char *altname;
- const uint8_t mode;
- } modetable[] = {
- { "USB", NULL, 0x00 },
- { "I2C", NULL, 0x01 },
- { "SPI2_FLASH", "SPI1_FLASH", 0x02 },
- { "SPI3_FLASH", "SPI2_FLASH", 0x03 },
- { "NAND_BCH", NULL, 0x04 },
- { "JTAG", NULL, 0x06 },
- { "SPI3_EEPROM", "SPI2_EEPROM", 0x08 },
- { "SD_SSP0", NULL, 0x09 },
- { "SD_SSP1", NULL, 0x0A }
- };
- enum sb_tag {
- ROM_NOP_CMD = 0x00,
- ROM_TAG_CMD = 0x01,
- ROM_LOAD_CMD = 0x02,
- ROM_FILL_CMD = 0x03,
- ROM_JUMP_CMD = 0x04,
- ROM_CALL_CMD = 0x05,
- ROM_MODE_CMD = 0x06
- };
- struct sb_source_entry {
- uint8_t tag;
- uint32_t address;
- uint32_t flags;
- char *filename;
- };
- #endif
|