GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / include / cfe_bootblock.h
blob497e024cfa9baa484d025f88acd1c0d58adc1701
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * Boot Block File: cfe_bootblock.h
5 *
6 * The structure of the boot block used on block-style devices
7 * like disks and CDROMs
8 *
9 * Author: Mitch Lichtenberg (mpl@broadcom.com)
11 *********************************************************************
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
16 * This software is furnished under license and may be used and
17 * copied only in accordance with the following terms and
18 * conditions. Subject to these conditions, you may download,
19 * copy, install, use, modify and distribute modified or unmodified
20 * copies of this software in source and/or binary form. No title
21 * or ownership is transferred hereby.
23 * 1) Any source code used, modified or distributed must reproduce
24 * and retain this copyright notice and list of conditions
25 * as they appear in the source file.
27 * 2) No right is granted to use any trade name, trademark, or
28 * logo of Broadcom Corporation. The "Broadcom Corporation"
29 * name may not be used to endorse or promote products derived
30 * from this software without the prior written permission of
31 * Broadcom Corporation.
33 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
34 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
35 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
37 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
38 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
39 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
41 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
43 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
45 * THE POSSIBILITY OF SUCH DAMAGE.
46 ********************************************************************* */
50 * CFE boot block, modeled loosely on Alpha.
52 * It consists of:
54 * BSD disk label
55 * <blank space>
56 * Boot block info (5 u_int_64s)
58 * The boot block portion looks like:
61 * +-------+-------+-------+-------+-------+-------+-------+-------+
62 * | BOOT_MAGIC_NUMBER |
63 * +-------+-------+-------+-------+-------+-------+-------+-------+
64 * | Flags | Reserved | Vers | Header Checksum |
65 * +-------+-------+-------+-------+-------+-------+-------+-------+
66 * | Secondary Loader Location (bytes) |
67 * +-------+-------+-------+-------+-------+-------+-------+-------+
68 * | Loader Checksum | Size of loader (bytes) |
69 * +-------+-------+-------+-------+-------+-------+-------+-------+
70 * | Reserved | Architecture Information |
71 * +-------+-------+-------+-------+-------+-------+-------+-------+
73 * Boot block fields should always be read as 64-bit numbers.
78 struct boot_block {
79 uint64_t bb_data[64]; /* data (disklabel, also as below) */
81 #define bb_magic bb_data[59] /* magic number */
82 #define bb_hdrinfo bb_data[60] /* header checksum, ver, flags */
83 #define bb_secstart bb_data[61] /* secondary start (bytes) */
84 #define bb_secsize bb_data[62] /* secondary size (bytes) */
85 #define bb_archinfo bb_data[63] /* architecture info */
87 #define BOOT_BLOCK_OFFSET 0 /* offset of boot block. */
88 #define BOOT_BLOCK_BLOCKSIZE 512 /* block size for sec. size/start,
89 * and for boot block itself
91 #define BOOT_BLOCK_SIZE 40 /* 5 64-bit words */
93 /*
94 * This is the highest block number that we look at when
95 * searching for a valid boot block
97 #define BOOT_BLOCK_MAXLOC 16
100 * Fields within the boot block
102 #define _U64(x) ((uint64_t) x##LL)
103 #define BOOT_MAGIC_NUMBER _U64(0x43465631424f4f54)
104 #define BOOT_HDR_CHECKSUM_MASK _U64(0x00000000FFFFFFFF)
105 #define BOOT_HDR_VER_MASK _U64(0x000000FF00000000)
106 #define BOOT_HDR_VER_SHIFT 32
107 #define BOOT_HDR_FLAGS_MASK _U64(0xFF00000000000000)
108 #define BOOT_SECSIZE_MASK _U64(0x00000000FFFFFFFF)
109 #define BOOT_DATA_CHECKSUM_MASK _U64(0xFFFFFFFF00000000)
110 #define BOOT_DATA_CHECKSUM_SHIFT 32
111 #define BOOT_ARCHINFO_MASK _U64(0x00000000FFFFFFFF)
113 #define BOOT_HDR_VERSION 1
115 #define CHECKSUM_BOOT_DATA(data,len,cksum) \
116 do { \
117 uint32_t *_ptr = (uint32_t *) (data); \
118 uint32_t _cksum; \
119 int _i; \
121 _cksum = 0; \
122 for (_i = 0; \
123 _i < ((len) / sizeof (uint32_t)); \
124 _i++) \
125 _cksum += _ptr[_i]; \
126 *(cksum) = _cksum; \
127 } while (0)