1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Networks (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * * Neither the name of Cavium Networks nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
23 * This Software, including technical data, may be subject to U.S. export control
24 * laws, including the U.S. Export Administration Act and its associated
25 * regulations, and may be subject to export or import regulations in other
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
43 #ifndef __CVMX_BOOTLOADER__
44 #define __CVMX_BOOTLOADER__
51 * Bootloader definitions that are shared with other programs
53 * <hr>$Revision: 49448 $<hr>
57 /* The bootloader_header_t structure defines the header that is present
58 ** at the start of binary u-boot images. This header is used to locate the bootloader
59 ** image in NAND, and also to allow verification of images for normal NOR booting.
60 ** This structure is placed at the beginning of a bootloader binary image, and remains
61 ** in the executable code.
63 #define BOOTLOADER_HEADER_MAGIC 0x424f4f54 /* "BOOT" in ASCII */
65 #define BOOTLOADER_HEADER_COMMENT_LEN 64
66 #define BOOTLOADER_HEADER_VERSION_LEN 64
67 #define BOOTLOADER_HEADER_MAX_SIZE 0x200 /* limited by the space to the next exception handler */
69 #define BOOTLOADER_HEADER_CURRENT_MAJOR_REV 1
70 #define BOOTLOADER_HEADER_CURRENT_MINOR_REV 2
72 * 1.1 Initial released revision. (SDK 1.9)
73 * 1.2 TLB based relocatable image (SDK 2.0)
78 /* offsets to struct bootloader_header fields for assembly use */
79 #define GOT_ADDRESS_OFFSET 48
81 #define LOOKUP_STEP (64*1024)
84 typedef struct bootloader_header
86 uint32_t jump_instr; /* Jump to executable code following the
87 ** header. This allows this header to
88 ** be (and remain) part of the executable image)
90 uint32_t nop_instr; /* Must be 0x0 */
91 uint32_t magic; /* Magic number to identify header */
92 uint32_t hcrc; /* CRC of all of header excluding this field */
94 uint16_t hlen; /* Length of header in bytes */
95 uint16_t maj_rev; /* Major revision */
96 uint16_t min_rev; /* Minor revision */
97 uint16_t board_type; /* Board type that the image is for */
99 uint32_t dlen; /* Length of data (immediately following header) in bytes */
100 uint32_t dcrc; /* CRC of data */
101 uint64_t address; /* Mips virtual address */
103 uint16_t image_type; /* Defined in bootloader_image_t enum */
104 uint16_t resv0; /* pad */
111 char comment_string[BOOTLOADER_HEADER_COMMENT_LEN]; /* Optional, for descriptive purposes */
112 char version_string[BOOTLOADER_HEADER_VERSION_LEN]; /* Optional, for descriptive purposes */
113 } __attribute__((packed)) bootloader_header_t;
117 /* Defines for flag field */
118 #define BL_HEADER_FLAG_FAILSAFE (1)
123 BL_HEADER_IMAGE_UNKNOWN = 0x0,
124 BL_HEADER_IMAGE_STAGE2, /* Binary bootloader stage2 image (NAND boot) */
125 BL_HEADER_IMAGE_STAGE3, /* Binary bootloader stage3 image (NAND boot)*/
126 BL_HEADER_IMAGE_NOR, /* Binary bootloader for NOR boot */
127 BL_HEADER_IMAGE_PCIBOOT, /* Binary bootloader for PCI boot */
128 BL_HEADER_IMAGE_UBOOT_ENV, /* Environment for u-boot */
130 /* Range for customer private use. Will not be used by Cavium Networks */
131 BL_HEADER_IMAGE_CUST_RESERVED_MIN = 0x1000,
132 BL_HEADER_IMAGE_CUST_RESERVED_MAX = 0x1fff,
133 } bootloader_image_t;
135 #endif /* __ASSEMBLY__ */
137 /* Maximum address searched for NAND boot images and environments. This is used
138 ** by stage1 and stage2. */
139 #define MAX_NAND_SEARCH_ADDR 0x400000
141 /* Maximum address to look for start of normal bootloader */
142 #define MAX_NOR_SEARCH_ADDR 0x100000
144 /* Defines for RAM based environment set by the host or the previous bootloader
145 ** in a chain boot configuration. */
147 #define U_BOOT_RAM_ENV_ADDR (0x1000)
148 #define U_BOOT_RAM_ENV_SIZE (0x1000)
149 #define U_BOOT_RAM_ENV_CRC_SIZE (0x4)
151 #endif /* __CVMX_BOOTLOADER__ */