1 /* 2 * TRX image file header format. 3 * 4 * Copyright (C) 1999-2013, Broadcom Corporation 5 * 6 * Permission to use, copy, modify, and/or distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * 18 * $Id: trxhdr.h 349211 2012-08-07 09:45:24Z $ 19 */ 20 21 #ifndef _TRX_HDR_H 22 #define _TRX_HDR_H 23 24 #include <typedefs.h> 25 26 #define TRX_MAGIC 0x30524448 /* "HDR0" */ 27 #define TRX_MAX_LEN 0x3B0000 /* Max length */ 28 #define TRX_NO_HEADER 1 /* Do not write TRX header */ 29 #define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */ 30 #define TRX_EMBED_UCODE 0x8 /* Trx contains embedded ucode image */ 31 #define TRX_ROMSIM_IMAGE 0x10 /* Trx contains ROM simulation image */ 32 #define TRX_UNCOMP_IMAGE 0x20 /* Trx contains uncompressed rtecdc.bin image */ 33 #define TRX_BOOTLOADER 0x40 /* the image is a bootloader */ 34 35 #define TRX_V1 1 36 #define TRX_V1_MAX_OFFSETS 3 /* V1: Max number of individual files */ 37 38 #ifndef BCMTRXV2 39 #define TRX_VERSION TRX_V1 /* Version 1 */ 40 #define TRX_MAX_OFFSET TRX_V1_MAX_OFFSETS 41 #endif 42 43 /* BMAC Host driver/application like bcmdl need to support both Ver 1 as well as 44 * Ver 2 of trx header. To make it generic, trx_header is structure is modified 45 * as below where size of "offsets" field will vary as per the TRX version. 46 * Currently, BMAC host driver and bcmdl are modified to support TRXV2 as well. 47 * To make sure, other applications like "dhdl" which are yet to be enhanced to support 48 * TRXV2 are not broken, new macro and structure defintion take effect only when BCMTRXV2 49 * is defined. 50 */ 51 struct trx_header { 52 uint32 magic; /* "HDR0" */ 53 uint32 len; /* Length of file including header */ 54 uint32 crc32; /* 32-bit CRC from flag_version to end of file */ 55 uint32 flag_version; /* 0:15 flags, 16:31 version */ 56 #ifndef BCMTRXV2 57 uint32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */ 58 #else 59 uint32 offsets[1]; /* Offsets of partitions from start of header */ 60 #endif 61 }; 62 63 #ifdef BCMTRXV2 64 #define TRX_VERSION TRX_V2 /* Version 2 */ 65 #define TRX_MAX_OFFSET TRX_V2_MAX_OFFSETS 66 67 #define TRX_V2 2 68 /* V2: Max number of individual files 69 * To support SDR signature + Config data region 70 */ 71 #define TRX_V2_MAX_OFFSETS 5 72 #define SIZEOF_TRXHDR_V1 (sizeof(struct trx_header)+(TRX_V1_MAX_OFFSETS-1)*sizeof(uint32)) 73 #define SIZEOF_TRXHDR_V2 (sizeof(struct trx_header)+(TRX_V2_MAX_OFFSETS-1)*sizeof(uint32)) 74 #define TRX_VER(trx) (trx->flag_version>>16) 75 #define ISTRX_V1(trx) (TRX_VER(trx) == TRX_V1) 76 #define ISTRX_V2(trx) (TRX_VER(trx) == TRX_V2) 77 /* For V2, return size of V2 size: others, return V1 size */ 78 #define SIZEOF_TRX(trx) (ISTRX_V2(trx) ? SIZEOF_TRXHDR_V2: SIZEOF_TRXHDR_V1) 79 #else 80 #define SIZEOF_TRX(trx) (sizeof(struct trx_header)) 81 #endif /* BCMTRXV2 */ 82 83 /* Compatibility */ 84 typedef struct trx_header TRXHDR, *PTRXHDR; 85 86 #endif /* _TRX_HDR_H */ 87