1 /*******************************************************************************
2 Copyright (C) Marvell International Ltd. and its affiliates
4 Marvell GPL License Option
6 If you received this File from Marvell, you may opt to use, redistribute and/or
7 modify this File in accordance with the terms and conditions of the General
8 Public License Version 2, June 1991 (the "GPL License"), a copy of which is
9 available along with the File in the license.txt file or by writing to the Free
10 Software Foundation, Inc.
12 THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED
13 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY
14 DISCLAIMED. The GPL License provides additional details about this warranty
17 *******************************************************************************/
18 #ifndef _INC_DOIMAGE_H
19 #define _INC_DOIMAGE_H
21 #include <sys/types.h>
23 /* use the same version as in "bootrom.inc" file */
24 #define VERSION_NUMBER "2.20"
25 #define PRODUCT_SUPPORT "Marvell Armada-3xx series"
27 #define RSA_KEY_SIZE 2048
28 #define RSA_EXPONENT 65537
30 #define T_OPTION_MASK 0x1 /* image type */
31 #define D_OPTION_MASK 0x2 /* image destination */
32 #define E_OPTION_MASK 0x4 /* image execution address */
33 #define S_OPTION_MASK 0x8 /* starting sector */
34 #define R_OPTION_MASK 0x10 /* DRAM file */
35 #define C_OPTION_MASK 0x20 /* headers definition file */
36 #define P_OPTION_MASK 0x40 /* NAND Page size */
37 #define M_OPTION_MASK 0x80 /* TWSI serial init file */
38 #define W_OPTION_MASK 0x100 /* HEX file width */
39 #define H_OPTION_MASK 0x200 /* Header mode */
40 #define X_OPTION_MASK 0x400 /* Pre padding */
41 #define Y_OPTION_MASK 0x800 /* Post padding */
42 #define J_OPTION_MASK 0x1000 /* JTAG Enabled */
43 #define B_OPTION_MASK 0x2000 /* Box ID */
44 #define Z_OPTION_MASK 0x4000 /* secure boot mode - KAK private key */
45 #define F_OPTION_MASK 0x8000 /* Flash ID */
46 #define A_OPTION_MASK 0x10000 /* secure boot mode - CSK private key */
47 #define G_OPTION_MASK 0x20000 /* binary file */
48 #define K_OPTION_MASK 0x40000 /* secure boot mode - CSK private key index */
49 #define L_OPTION_MASK 0x80000 /* NAND block size (in 64K chunks) */
50 #define N_OPTION_MASK 0x100000 /* NAND cell technology MLC/SLC */
51 #define p_OPTION_MASK 0x200000 /* Print enable */
52 #define b_OPTION_MASK 0x400000 /* Baudrate */
53 #define u_OPTION_MASK 0x800000 /* debug serial port number */
54 #define m_OPTION_MASK 0x1000000 /* debug serial port MPP configuration */
56 #ifndef O_BINARY /* should be defined on __WIN32__ */
60 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
76 #define REGULAR_IMAGE(opt) \
77 (((opt)->image_type != IMG_BOOTROM) && \
78 ((opt)->image_type != IMG_HEX) && ((opt)->image_type != IMG_BIN))
81 IMG_TYPE img_type
; /* image type */
82 char *img_name
; /* image name string */
83 unsigned int img_opt
; /* mandatory options for this image type */
94 HDR_IMG_ONE_FILE
= 1, /* Create one file with header and image */
95 HDR_IMG_TWO_FILES
= 2, /* Create separate header and image files */
96 HDR_ONLY
= 3, /* Create only header */
97 IMG_ONLY
= 4, /* Create only image */
103 char *fname_dram
; /* DRAM init file for "register" header */
104 char *fname_twsi
; /* TWSI serial init file */
105 char *fname_bin
; /* binary code file for "binary" header */
106 char *fname_prkey
; /* KAK RSA Private key file */
107 char *fname_prkeyCsk
; /* CSK RSA Private key file */
108 char *fname_list
; /* headers definition file */
109 u32 flags
; /* user-defined flags */
110 u32 req_flags
; /* mandatory flags */
111 u32 image_source
; /* starting sector */
112 u32 image_dest
; /* image destination */
113 u32 image_exec
; /* image execution */
114 unsigned int hex_width
; /* HEX file width */
115 unsigned int header_mode
; /* Header file mode */
120 int postpadding_size
;
121 unsigned int bytesToAlign
;
122 unsigned int nandPageSize
;
123 unsigned int nandBlkSize
;
128 char *image_buf
; /* image buffer for image pre-load */
129 u32 image_sz
; /* total size of pre-loaded image buffer including
131 u32 img_gap
; /* gap between header and image start point */
132 u32 baudRate
; /* debug print port baudrate */
133 u32 debugPortNum
; /* debug print port number */
134 u32 debugPortMpp
; /* debug print port MPP configuration */
147 /* Function declaration */
148 void print_usage(void);
150 /* 32 bit checksum */
151 MV_U32
checksum32(void *start
, MV_U32 len
, MV_U32 csum
);
152 MV_U8
checksum8(void *start
, MV_U32 len
, MV_U8 csum
);
153 MV_U32
crc32(MV_U32 crc
, volatile MV_U32
*buf
, MV_U32 len
);
155 #endif /* _INC_DOIMAGE_H */