disklabel.h revision 1.5.46.1 1 1.5.46.1 martin /* $NetBSD: disklabel.h,v 1.5.46.1 2017/08/30 15:45:03 martin Exp $ */
2 1.1 simonb
3 1.1 simonb /*
4 1.1 simonb * Copyright (c) 1994 Christopher G. Demetriou
5 1.1 simonb * All rights reserved.
6 1.1 simonb *
7 1.1 simonb * Redistribution and use in source and binary forms, with or without
8 1.1 simonb * modification, are permitted provided that the following conditions
9 1.1 simonb * are met:
10 1.1 simonb * 1. Redistributions of source code must retain the above copyright
11 1.1 simonb * notice, this list of conditions and the following disclaimer.
12 1.1 simonb * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 simonb * notice, this list of conditions and the following disclaimer in the
14 1.1 simonb * documentation and/or other materials provided with the distribution.
15 1.1 simonb * 3. All advertising materials mentioning features or use of this software
16 1.1 simonb * must display the following acknowledgement:
17 1.1 simonb * This product includes software developed by Christopher G. Demetriou.
18 1.1 simonb * 4. The name of the author may not be used to endorse or promote products
19 1.1 simonb * derived from this software without specific prior written permission
20 1.1 simonb *
21 1.1 simonb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 simonb * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 simonb * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 simonb * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 simonb * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 simonb * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 simonb * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 simonb * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 simonb * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 simonb * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 simonb */
32 1.1 simonb
33 1.5.46.1 martin /*
34 1.5.46.1 martin * Copyright 2000, 2001
35 1.5.46.1 martin * Broadcom Corporation. All rights reserved.
36 1.5.46.1 martin *
37 1.5.46.1 martin * This software is furnished under license and may be used and copied only
38 1.5.46.1 martin * in accordance with the following terms and conditions. Subject to these
39 1.5.46.1 martin * conditions, you may download, copy, install, use, modify and distribute
40 1.5.46.1 martin * modified or unmodified copies of this software in source and/or binary
41 1.5.46.1 martin * form. No title or ownership is transferred hereby.
42 1.5.46.1 martin *
43 1.5.46.1 martin * 1) Any source code used, modified or distributed must reproduce and
44 1.5.46.1 martin * retain this copyright notice and list of conditions as they appear in
45 1.5.46.1 martin * the source file.
46 1.5.46.1 martin *
47 1.5.46.1 martin * 2) No right is granted to use any trade name, trademark, or logo of
48 1.5.46.1 martin * Broadcom Corporation. The "Broadcom Corporation" name may not be
49 1.5.46.1 martin * used to endorse or promote products derived from this software
50 1.5.46.1 martin * without the prior written permission of Broadcom Corporation.
51 1.5.46.1 martin *
52 1.5.46.1 martin * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
53 1.5.46.1 martin * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
54 1.5.46.1 martin * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
55 1.5.46.1 martin * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
56 1.5.46.1 martin * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
57 1.5.46.1 martin * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
58 1.5.46.1 martin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
59 1.5.46.1 martin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
60 1.5.46.1 martin * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
61 1.5.46.1 martin * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
62 1.5.46.1 martin * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 1.5.46.1 martin */
64 1.5.46.1 martin
65 1.1 simonb #ifndef _EVBMIPS_DISKLABEL_H_
66 1.1 simonb #define _EVBMIPS_DISKLABEL_H_
67 1.5.46.1 martin
68 1.5 bouyer #ifdef _KERNEL_OPT
69 1.5 bouyer #include "opt_pmon.h"
70 1.5.46.1 martin #include "opt_cputype.h"
71 1.5.46.1 martin #endif
72 1.5.46.1 martin
73 1.5.46.1 martin #ifdef MIPS64_SB1
74 1.5.46.1 martin
75 1.5.46.1 martin #define LABELUSESMBR 0 /* no MBR partitionning */
76 1.5.46.1 martin #define LABELSECTOR 1 /* sector containing label */
77 1.5.46.1 martin #define LABELOFFSET 0 /* offset of label in sector */
78 1.5.46.1 martin #define MAXPARTITIONS 16
79 1.5.46.1 martin #define RAW_PART 3
80 1.5.46.1 martin
81 1.5.46.1 martin #ifdef __NetBSD__
82 1.5.46.1 martin /* Pull in MBR partition definitions. */
83 1.5.46.1 martin #if HAVE_NBTOOL_CONFIG_H
84 1.5.46.1 martin #include <nbinclude/sys/bootblock.h>
85 1.5.46.1 martin #else
86 1.5.46.1 martin #include <sys/bootblock.h>
87 1.5.46.1 martin #endif /* HAVE_NBTOOL_CONFIG_H */
88 1.5.46.1 martin
89 1.5.46.1 martin #ifndef __ASSEMBLER__
90 1.5.46.1 martin #if HAVE_NBTOOL_CONFIG_H
91 1.5.46.1 martin #include <nbinclude/sys/dkbad.h>
92 1.5.46.1 martin #else
93 1.5.46.1 martin #include <sys/dkbad.h>
94 1.5.46.1 martin #endif /* HAVE_NBTOOL_CONFIG_H */
95 1.5.46.1 martin struct cpu_disklabel {
96 1.5.46.1 martin struct mbr_partition mbrparts[MBR_PART_COUNT];
97 1.5.46.1 martin #define __HAVE_DISKLABEL_DKBAD
98 1.5.46.1 martin struct dkbad bad;
99 1.5.46.1 martin };
100 1.5 bouyer #endif
101 1.5.46.1 martin #endif
102 1.5.46.1 martin
103 1.5.46.1 martin /*
104 1.5.46.1 martin * CFE boot block, modeled loosely on Alpha.
105 1.5.46.1 martin *
106 1.5.46.1 martin * It consists of:
107 1.5.46.1 martin *
108 1.5.46.1 martin * BSD disk label
109 1.5.46.1 martin * <blank space>
110 1.5.46.1 martin * Boot block info (5 uint_64s)
111 1.5.46.1 martin *
112 1.5.46.1 martin * The boot block portion looks like:
113 1.5.46.1 martin *
114 1.5.46.1 martin *
115 1.5.46.1 martin * +-------+-------+-------+-------+-------+-------+-------+-------+
116 1.5.46.1 martin * | BOOT_MAGIC_NUMBER |
117 1.5.46.1 martin * +-------+-------+-------+-------+-------+-------+-------+-------+
118 1.5.46.1 martin * | Flags | Reserved | Vers | Header Checksum |
119 1.5.46.1 martin * +-------+-------+-------+-------+-------+-------+-------+-------+
120 1.5.46.1 martin * | Secondary Loader Location (bytes) |
121 1.5.46.1 martin * +-------+-------+-------+-------+-------+-------+-------+-------+
122 1.5.46.1 martin * | Loader Checksum | Size of loader (bytes) |
123 1.5.46.1 martin * +-------+-------+-------+-------+-------+-------+-------+-------+
124 1.5.46.1 martin * | Reserved | Architecture Information |
125 1.5.46.1 martin * +-------+-------+-------+-------+-------+-------+-------+-------+
126 1.5.46.1 martin *
127 1.5.46.1 martin * Boot block fields should always be read as 64-bit numbers.
128 1.5.46.1 martin *
129 1.5.46.1 martin */
130 1.5.46.1 martin
131 1.5.46.1 martin
132 1.5.46.1 martin struct boot_block {
133 1.5.46.1 martin uint64_t cfe_bb_data[64]; /* data (disklabel, also as below) */
134 1.5.46.1 martin };
135 1.5.46.1 martin #define cfe_bb_magic cfe_bb_data[59] /* magic number */
136 1.5.46.1 martin #define cfe_bb_hdrinfo cfe_bb_data[60] /* header checksum, ver, flags */
137 1.5.46.1 martin #define cfe_bb_secstart cfe_bb_data[61] /* secondary start (bytes) */
138 1.5.46.1 martin #define cfe_bb_secsize cfe_bb_data[62] /* secondary size (bytes) */
139 1.5.46.1 martin #define cfe_bb_archinfo cfe_bb_data[63] /* architecture info */
140 1.5.46.1 martin
141 1.5.46.1 martin #define BOOT_BLOCK_OFFSET 0 /* offset of boot block. */
142 1.5.46.1 martin #define BOOT_BLOCK_BLOCKSIZE 512 /* block size for sec. size/start,
143 1.5.46.1 martin * and for boot block itself
144 1.5.46.1 martin */
145 1.5.46.1 martin #define BOOT_BLOCK_SIZE 40 /* 5 64-bit words */
146 1.5.46.1 martin
147 1.5.46.1 martin #define BOOT_MAGIC_NUMBER 0x43465631424f4f54
148 1.5.46.1 martin #define BOOT_HDR_CHECKSUM_MASK 0x00000000FFFFFFFF
149 1.5.46.1 martin #define BOOT_HDR_VER_MASK 0x000000FF00000000
150 1.5.46.1 martin #define BOOT_HDR_VER_SHIFT 32
151 1.5.46.1 martin #define BOOT_HDR_FLAGS_MASK 0xFF00000000000000
152 1.5.46.1 martin #define BOOT_SECSIZE_MASK 0x00000000FFFFFFFF
153 1.5.46.1 martin #define BOOT_DATA_CHECKSUM_MASK 0xFFFFFFFF00000000
154 1.5.46.1 martin #define BOOT_DATA_CHECKSUM_SHIFT 32
155 1.5.46.1 martin #define BOOT_ARCHINFO_MASK 0x00000000FFFFFFFF
156 1.5.46.1 martin
157 1.5.46.1 martin #define BOOT_HDR_VERSION 1
158 1.5.46.1 martin
159 1.5.46.1 martin #define CHECKSUM_BOOT_BLOCK(bb,cksum) \
160 1.5.46.1 martin do { \
161 1.5.46.1 martin uint32_t *_ptr = (uint32_t *) (bb); \
162 1.5.46.1 martin uint32_t _cksum; \
163 1.5.46.1 martin int _i; \
164 1.5.46.1 martin \
165 1.5.46.1 martin _cksum = 0; \
166 1.5.46.1 martin for (_i = 0; \
167 1.5.46.1 martin _i < (BOOT_BLOCK_SIZE / sizeof (uint32_t)); \
168 1.5.46.1 martin _i++) \
169 1.5.46.1 martin _cksum += _ptr[_i]; \
170 1.5.46.1 martin *(cksum) = _cksum; \
171 1.5.46.1 martin } while (0)
172 1.5.46.1 martin
173 1.5.46.1 martin
174 1.5.46.1 martin #define CHECKSUM_BOOT_DATA(data,len,cksum) \
175 1.5.46.1 martin do { \
176 1.5.46.1 martin uint32_t *_ptr = (uint32_t *) (data); \
177 1.5.46.1 martin uint32_t _cksum; \
178 1.5.46.1 martin int _i; \
179 1.5.46.1 martin \
180 1.5.46.1 martin _cksum = 0; \
181 1.5.46.1 martin for (_i = 0; \
182 1.5.46.1 martin _i < ((len) / sizeof (uint32_t)); \
183 1.5.46.1 martin _i++) \
184 1.5.46.1 martin _cksum += _ptr[_i]; \
185 1.5.46.1 martin *(cksum) = _cksum; \
186 1.5.46.1 martin } while (0)
187 1.5.46.1 martin
188 1.5.46.1 martin #else /* MIPS64_SB1 */
189 1.5.46.1 martin
190 1.5 bouyer #ifdef PMON
191 1.5 bouyer #define LABELUSESMBR 1 /* use MBR partitionning */
192 1.5 bouyer #else
193 1.5 bouyer #define LABELUSESMBR 0 /* no MBR partitionning */
194 1.5 bouyer #endif
195 1.1 simonb #define LABELSECTOR 0 /* sector containing label */
196 1.1 simonb #define LABELOFFSET 64 /* offset of label in sector */
197 1.1 simonb #define MAXPARTITIONS 16 /* number of partitions */
198 1.1 simonb #define RAW_PART 2 /* raw partition: xx?c */
199 1.1 simonb
200 1.2 dyoung #if HAVE_NBTOOL_CONFIG_H
201 1.2 dyoung #include <nbinclude/sys/dkbad.h>
202 1.2 dyoung #else
203 1.1 simonb #include <sys/dkbad.h>
204 1.2 dyoung #endif /* HAVE_NBTOOL_CONFIG_H */
205 1.1 simonb
206 1.1 simonb /* Just a dummy */
207 1.1 simonb struct cpu_disklabel {
208 1.4 pooka #define __HAVE_DISKLABEL_DKBAD
209 1.1 simonb struct dkbad bad; /* must have one element. */
210 1.1 simonb };
211 1.1 simonb
212 1.5.46.1 martin #endif /* MIPS64_SB1 */
213 1.5.46.1 martin
214 1.1 simonb #endif /* !_EVBMIPS_DISKLABEL_H_ */
215