cvmx-bootloader.h revision 256281
117680Spst/***********************license start***************
217680Spst * Copyright (c) 2003-2010  Cavium Inc. (support@cavium.com). All rights
317680Spst * reserved.
417680Spst *
517680Spst *
617680Spst * Redistribution and use in source and binary forms, with or without
717680Spst * modification, are permitted provided that the following conditions are
817680Spst * met:
917680Spst *
1017680Spst *   * Redistributions of source code must retain the above copyright
1117680Spst *     notice, this list of conditions and the following disclaimer.
1217680Spst *
1317680Spst *   * Redistributions in binary form must reproduce the above
1417680Spst *     copyright notice, this list of conditions and the following
1517680Spst *     disclaimer in the documentation and/or other materials provided
1617680Spst *     with the distribution.
1717680Spst
1817680Spst *   * Neither the name of Cavium Inc. nor the names of
1917680Spst *     its contributors may be used to endorse or promote products
2017680Spst *     derived from this software without specific prior written
21214478Srpaulo *     permission.
2253146Sbrian
2317680Spst * This Software, including technical data, may be subject to U.S. export  control
2417680Spst * laws, including the U.S. Export Administration Act and its  associated
2575118Sfenner * regulations, and may be subject to export or import  regulations in other
2675118Sfenner * countries.
2775118Sfenner
2875118Sfenner * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
2975118Sfenner * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
3075118Sfenner * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
3175118Sfenner * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
3275118Sfenner * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
3375118Sfenner * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
3475118Sfenner * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
3575118Sfenner * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
3617680Spst * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37146778Ssam * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38146778Ssam ***********************license end**************************************/
39146778Ssam
40146778Ssam
41146778Ssam
42146778Ssam
43146778Ssam#ifndef __CVMX_BOOTLOADER__
4475118Sfenner#define __CVMX_BOOTLOADER__
4575118Sfenner
4675118Sfenner
4775118Sfenner
4875118Sfenner/**
4975118Sfenner * @file
5075118Sfenner *
5175118Sfenner * Bootloader definitions that are shared with other programs
5275118Sfenner *
5375118Sfenner * <hr>$Revision: 70030 $<hr>
5475118Sfenner */
5575118Sfenner
5617680Spst
5717680Spst/* The bootloader_header_t structure defines the header that is present
5817680Spst** at the start of binary u-boot images.  This header is used to locate the bootloader
5917680Spst** image in NAND, and also to allow verification of images for normal NOR booting.
6017680Spst** This structure is placed at the beginning of a bootloader binary image, and remains
6117680Spst** in the executable code.
6217680Spst*/
6317680Spst#define BOOTLOADER_HEADER_MAGIC 0x424f4f54  /* "BOOT" in ASCII */
6417680Spst
6517680Spst#define BOOTLOADER_HEADER_COMMENT_LEN  64
6617680Spst#define BOOTLOADER_HEADER_VERSION_LEN  64
6717680Spst#define BOOTLOADER_HEADER_MAX_SIZE      0x200 /* limited by the space to the next exception handler */
6817680Spst
6917680Spst#define BOOTLOADER_HEADER_CURRENT_MAJOR_REV 1
7017680Spst#define BOOTLOADER_HEADER_CURRENT_MINOR_REV 2
7117680Spst/* Revision history
7217680Spst* 1.1  Initial released revision. (SDK 1.9)
7317680Spst* 1.2  TLB based relocatable image (SDK 2.0)
7417680Spst*
7517680Spst*
7617680Spst*/
7717680Spst
7817680Spst/* offsets to struct bootloader_header fields for assembly use */
7917680Spst#define GOT_ADDRESS_OFFSET       48
80214478Srpaulo
81214478Srpaulo#define LOOKUP_STEP (64*1024)
82214478Srpaulo
8317680Spst#ifndef __ASSEMBLY__
8417680Spsttypedef struct bootloader_header
8517680Spst{
8617680Spst    uint32_t    jump_instr; /* Jump to executable code following the
8717680Spst                            ** header.  This allows this header to
8817680Spst                            ** be (and remain) part of the executable image)
8917680Spst                            */
9017680Spst    uint32_t    nop_instr;  /* Must be 0x0 */
9117680Spst    uint32_t    magic; /* Magic number to identify header */
9217680Spst    uint32_t    hcrc;  /* CRC of all of header excluding this field */
9317680Spst
9417680Spst    uint16_t    hlen;  /* Length of header in bytes */
9517680Spst    uint16_t    maj_rev;  /* Major revision */
9617680Spst    uint16_t    min_rev;  /* Minor revision */
9717680Spst    uint16_t    board_type;  /* Board type that the image is for */
9817680Spst
9917680Spst    uint32_t    dlen;  /* Length of data (immediately following header) in bytes */
10017680Spst    uint32_t    dcrc;  /* CRC of data */
10117680Spst    uint64_t    address;  /* Mips virtual address */
10217680Spst    uint32_t    flags;
10317680Spst    uint16_t    image_type;  /* Defined in bootloader_image_t enum */
104241235Sdelphij    uint16_t    resv0;       /* pad */
105241235Sdelphij
106241235Sdelphij    uint32_t    reserved1;
10756896Sfenner    uint32_t    reserved2;
10856896Sfenner    uint32_t    reserved3;
10956896Sfenner    uint32_t    reserved4;
110235530Sdelphij
111235530Sdelphij    char        comment_string[BOOTLOADER_HEADER_COMMENT_LEN];  /* Optional, for descriptive purposes */
112235530Sdelphij    char        version_string[BOOTLOADER_HEADER_VERSION_LEN];  /* Optional, for descriptive purposes */
113235530Sdelphij} __attribute__((packed)) bootloader_header_t;
114235530Sdelphij
115235530Sdelphij
116235530Sdelphij
117235530Sdelphij/* Defines for flag field */
118235530Sdelphij#define BL_HEADER_FLAG_FAILSAFE         (1)
119235530Sdelphij
120235530Sdelphij
121235530Sdelphijtypedef enum
122235530Sdelphij{
123235530Sdelphij    BL_HEADER_IMAGE_UNKNOWN = 0x0,
12417692Spst    BL_HEADER_IMAGE_STAGE2,  /* Binary bootloader stage2 image (NAND boot) */
12598527Sfenner    BL_HEADER_IMAGE_STAGE3,  /* Binary bootloader stage3 image (NAND boot)*/
12617692Spst    BL_HEADER_IMAGE_NOR,     /* Binary bootloader for NOR boot */
12756896Sfenner    BL_HEADER_IMAGE_PCIBOOT,     /* Binary bootloader for PCI boot */
12856896Sfenner    BL_HEADER_IMAGE_UBOOT_ENV,  /* Environment for u-boot */
12953146Sbrian    BL_HEADER_IMAGE_MAX,
13098527Sfenner    /* Range for customer private use.  Will not be used by Cavium Inc. */
13198527Sfenner    BL_HEADER_IMAGE_CUST_RESERVED_MIN = 0x1000,
13298527Sfenner    BL_HEADER_IMAGE_CUST_RESERVED_MAX = 0x1fff
133190207Srpaulo} bootloader_image_t;
134190207Srpaulo
135190207Srpaulo#endif /* __ASSEMBLY__ */
136162021Ssam
137162021Ssam/* Maximum address searched for NAND boot images and environments.  This is used
138162021Ssam** by stage1 and stage2. */
13998527Sfenner#define MAX_NAND_SEARCH_ADDR   0x400000
14098527Sfenner
14198527Sfenner/* Maximum address to look for start of normal bootloader */
14298527Sfenner#define MAX_NOR_SEARCH_ADDR   0x200000
14398527Sfenner
14498527Sfenner/* Defines for RAM based environment set by the host or the previous bootloader
14556896Sfenner** in a chain boot configuration. */
14656896Sfenner
14753146Sbrian#define U_BOOT_RAM_ENV_ADDR     (0x1000)
14856896Sfenner#define U_BOOT_RAM_ENV_SIZE     (0x1000)
14956896Sfenner#define U_BOOT_RAM_ENV_CRC_SIZE (0x4)
15056896Sfenner#define U_BOOT_RAM_ENV_ADDR_2	(U_BOOT_RAM_ENV_ADDR + U_BOOT_RAM_ENV_SIZE)
15184019Sjulian
15284019Sjulian#endif /* __CVMX_BOOTLOADER__ */
15384019Sjulian