]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sys/contrib/octeon-sdk/cvmx-bootloader.h
MFC: 217169
[FreeBSD/releng/8.2.git] / sys / contrib / octeon-sdk / cvmx-bootloader.h
1 /***********************license start***************
2  *  Copyright (c) 2008 Cavium Networks (support@cavium.com). All rights
3  *  reserved.
4  *
5  *
6  *  Redistribution and use in source and binary forms, with or without
7  *  modification, are permitted provided that the following conditions are
8  *  met:
9  *
10  *      * Redistributions of source code must retain the above copyright
11  *        notice, this list of conditions and the following disclaimer.
12  *
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.
17  *
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
21  *        permission.
22  *
23  *  TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24  *  AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25  *  OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26  *  RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27  *  REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28  *  DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29  *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30  *  PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31  *  POSSESSION OR CORRESPONDENCE TO DESCRIPTION.  THE ENTIRE RISK ARISING OUT
32  *  OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
33  *
34  *
35  *  For any questions regarding licensing please contact marketing@caviumnetworks.com
36  *
37  ***********************license end**************************************/
38
39
40
41 #ifndef __CVMX_BOOTLOADER__
42 #define __CVMX_BOOTLOADER__
43
44
45
46 /**
47  * @file
48  *
49  * Bootloader definitions that are shared with other programs
50  *
51  * <hr>$Revision: 41586 $<hr>
52  */
53
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__
81 typedef 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
119 typedef 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__ */