cvmx-bootloader.h revision 210286
1231200Smm/***********************license start*************** 2231200Smm * Copyright (c) 2008 Cavium Networks (support@cavium.com). All rights 3231200Smm * reserved. 4231200Smm * 5231200Smm * 6231200Smm * Redistribution and use in source and binary forms, with or without 7231200Smm * modification, are permitted provided that the following conditions are 8231200Smm * met: 9231200Smm * 10231200Smm * * Redistributions of source code must retain the above copyright 11231200Smm * notice, this list of conditions and the following disclaimer. 12231200Smm * 13231200Smm * * Redistributions in binary form must reproduce the above 14231200Smm * copyright notice, this list of conditions and the following 15231200Smm * disclaimer in the documentation and/or other materials provided 16231200Smm * with the distribution. 17231200Smm * 18231200Smm * * Neither the name of Cavium Networks nor the names of 19231200Smm * its contributors may be used to endorse or promote products 20231200Smm * derived from this software without specific prior written 21231200Smm * permission. 22231200Smm * 23231200Smm * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 24231200Smm * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS 25231200Smm * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH 26231200Smm * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY 27231200Smm * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT 28231200Smm * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES 29231200Smm * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR 30231200Smm * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET 31231200Smm * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT 32231200Smm * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 33231200Smm * 34231200Smm * 35231200Smm * For any questions regarding licensing please contact marketing@caviumnetworks.com 36231200Smm * 37231200Smm ***********************license end**************************************/ 38231200Smm 39231200Smm 40231200Smm 41231200Smm#ifndef __CVMX_BOOTLOADER__ 42231200Smm#define __CVMX_BOOTLOADER__ 43231200Smm 44231200Smm 45231200Smm 46231200Smm/** 47231200Smm * @file 48231200Smm * 49231200Smm * Bootloader definitions that are shared with other programs 50231200Smm * 51231200Smm * <hr>$Revision: 41586 $<hr> 52231200Smm */ 53231200Smm 54 55/* The bootloader_header_t structure defines the header that is present 56** at the start of binary u-boot images. This header is used to locate the bootloader 57** image in NAND, and also to allow verification of images for normal NOR booting. 58** This structure is placed at the beginning of a bootloader binary image, and remains 59** in the executable code. 60*/ 61#define BOOTLOADER_HEADER_MAGIC 0x424f4f54 /* "BOOT" in ASCII */ 62 63#define BOOTLOADER_HEADER_COMMENT_LEN 64 64#define BOOTLOADER_HEADER_VERSION_LEN 64 65#define BOOTLOADER_HEADER_MAX_SIZE 0x200 /* limited by the space to the next exception handler */ 66 67#define BOOTLOADER_HEADER_CURRENT_MAJOR_REV 1 68#define BOOTLOADER_HEADER_CURRENT_MINOR_REV 1 69 70/* offsets to struct bootloader_header fields for assembly use */ 71#define MAGIC_OFFST 8 72#define HCRC_OFFST 12 73#define HLEN_OFFST 16 74#define DLEN_OFFST 24 75#define DCRC_OFFST 28 76#define GOT_OFFST 48 77 78#define LOOKUP_STEP 8192 79 80#ifndef __ASSEMBLY__ 81typedef struct bootloader_header 82{ 83 uint32_t jump_instr; /* Jump to executable code following the 84 ** header. This allows this header to 85 ** be (and remain) part of the executable image) 86 */ 87 uint32_t nop_instr; /* Must be 0x0 */ 88 uint32_t magic; /* Magic number to identify header */ 89 uint32_t hcrc; /* CRC of all of header excluding this field */ 90 91 uint16_t hlen; /* Length of header in bytes */ 92 uint16_t maj_rev; /* Major revision */ 93 uint16_t min_rev; /* Minor revision */ 94 uint16_t board_type; /* Board type that the image is for */ 95 96 uint32_t dlen; /* Length of data (immediately following header) in bytes */ 97 uint32_t dcrc; /* CRC of data */ 98 uint64_t address; /* Mips virtual address */ 99 uint32_t flags; 100 uint16_t image_type; /* Defined in bootloader_image_t enum */ 101 uint16_t resv0; /* pad */ 102 103 /* The next 4 fields are placed in compile-time, not by the utility */ 104 uint32_t got_address; /* compiled got address position in the image */ 105 uint32_t got_num_entries; /* number of got entries */ 106 uint32_t compiled_start; /* compaled start of the image address */ 107 uint32_t image_start; /* relocated start of image address */ 108 109 char comment_string[BOOTLOADER_HEADER_COMMENT_LEN]; /* Optional, for descriptive purposes */ 110 char version_string[BOOTLOADER_HEADER_VERSION_LEN]; /* Optional, for descriptive purposes */ 111} __attribute__((packed)) bootloader_header_t; 112 113 114 115/* Defines for flag field */ 116#define BL_HEADER_FLAG_FAILSAFE (1) 117 118 119typedef enum 120{ 121 BL_HEADER_IMAGE_UKNOWN = 0x0, 122 BL_HEADER_IMAGE_STAGE2, /* Binary bootloader stage2 image (NAND boot) */ 123 BL_HEADER_IMAGE_STAGE3, /* Binary bootloader stage3 image (NAND boot)*/ 124 BL_HEADER_IMAGE_NOR, /* Binary bootloader for NOR boot */ 125 BL_HEADER_IMAGE_PCIBOOT, /* Binary bootloader for PCI boot */ 126 BL_HEADER_IMAGE_UBOOT_ENV, /* Environment for u-boot */ 127 BL_HEADER_IMAGE_MAX, 128 /* Range for customer private use. Will not be used by Cavium Networks */ 129 BL_HEADER_IMAGE_CUST_RESERVED_MIN = 0x1000, 130 BL_HEADER_IMAGE_CUST_RESERVED_MAX = 0x1fff, 131} bootloader_image_t; 132 133#endif /* __ASSEMBLY__ */ 134 135/* Maximum address searched for NAND boot images and environments. This is used 136** by stage1 and stage2. */ 137#define MAX_NAND_SEARCH_ADDR 0x400000 138 139 140/* Defines for RAM based environment set by the host or the previous bootloader 141** in a chain boot configuration. */ 142 143#define U_BOOT_RAM_ENV_ADDR (0x1000) 144#define U_BOOT_RAM_ENV_SIZE (0x1000) 145#define U_BOOT_RAM_ENV_CRC_SIZE (0x4) 146 147#endif /* __CVMX_BOOTLOADER__ */ 148