dec_boot.h revision 1.4 1 /* $NetBSD: dec_boot.h,v 1.4 2002/04/03 04:05:05 lukem Exp $ */
2
3 /*
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Ralph Campbell.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)dec_boot.h 8.1 (Berkeley) 6/10/93
39 *
40 * from: Header: /sprite/src/kernel/dev/RCS/devDiskLabel.h,
41 * v 9.4 90/03/01 12:22:36 jhh Exp SPRITE (Berkeley)
42 */
43
44 /*
45 * Copyright (c) 1994, 1999 Christopher G. Demetriou
46 * All rights reserved.
47 *
48 * Redistribution and use in source and binary forms, with or without
49 * modification, are permitted provided that the following conditions
50 * are met:
51 * 1. Redistributions of source code must retain the above copyright
52 * notice, this list of conditions and the following disclaimer.
53 * 2. Redistributions in binary form must reproduce the above copyright
54 * notice, this list of conditions and the following disclaimer in the
55 * documentation and/or other materials provided with the distribution.
56 * 3. All advertising materials mentioning features or use of this software
57 * must display the following acknowledgement:
58 * This product includes software developed by Christopher G. Demetriou
59 * for the NetBSD Project.
60 * 4. The name of the author may not be used to endorse or promote products
61 * derived from this software without specific prior written permission
62 *
63 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
64 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
65 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
66 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
67 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
68 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
69 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
70 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
71 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
72 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73 */
74
75 #ifndef _DEV_DEC_DEC_BOOT_H_
76 #define _DEV_DEC_DEC_BOOT_H_
77
78 /*
79 * Boot block information on the 0th sector.
80 * The boot program is stored in sequences of contiguous blocks.
81 *
82 * NOTE: The standard disk label offset is 64 which is
83 * after the boot information expected by the PROM boot loader.
84 */
85
86 /*
87 * Alpha (disk, but also tape) Boot Block.
88 *
89 * See Section (III) 3.6.1 of the Alpha Architecture Reference Manual.
90 */
91
92 struct alpha_boot_block {
93 u_int64_t bb_data[63]; /* data (disklabel, also as below) */
94 u_int64_t bb_cksum; /* checksum of the boot block,
95 * taken as u_int64_t's
96 */
97 };
98 #define bb_secsize bb_data[60] /* secondary size (blocks) */
99 #define bb_secstart bb_data[61] /* secondary start (blocks) */
100 #define bb_flags bb_data[62] /* unknown flags (set to zero) */
101
102 #define ALPHA_BOOT_BLOCK_OFFSET 0 /* offset of boot block. */
103 #define ALPHA_BOOT_BLOCK_BLOCKSIZE 512 /* block size for sector
104 * size/start, and for boot
105 * block itself.
106 */
107
108 #define ALPHA_BOOT_BLOCK_CKSUM(bb,cksum) \
109 do { \
110 const struct alpha_boot_block *_bb = (bb); \
111 u_int64_t _cksum; \
112 int _i; \
113 \
114 _cksum = 0; \
115 for (_i = 0; \
116 _i < (sizeof _bb->bb_data / sizeof _bb->bb_data[0]); \
117 _i++) \
118 _cksum += _bb->bb_data[_i]; \
119 *(cksum) = _cksum; \
120 } while (0)
121
122
123 /*
124 * PMAX (DECstation / MIPS) boot block information
125 */
126
127 /*
128 * If mode is 0, there is just one sequence of blocks and one Dec_BootMap
129 * is used. If mode is 1, there are multiple sequences of blocks
130 * and multiple Dec_BootMaps are used, the last with numBlocks = 0.
131 */
132 struct pmax_boot_map {
133 int32_t num_blocks; /* Number of blocks to read. */
134 int32_t start_block; /* Starting block on disk. */
135 };
136
137 /*
138 * This is the structure of a disk or tape boot block. The boot_map
139 * can either be a single boot count and start block (contiguous mode)
140 * or a list of up to 61 (to fill a 512 byte sector) block count and
141 * start block pairs. Under NetBSD, contiguous mode is always used.
142 */
143 struct pmax_boot_block {
144 u_int8_t pad[8];
145 int32_t magic; /* PMAX_BOOT_MAGIC */
146 int32_t mode; /* Mode for boot info. */
147 u_int32_t load_addr; /* Address to start loading. */
148 u_int32_t exec_addr; /* Address to start execing. */
149 struct pmax_boot_map map[61]; /* boot program section(s). */
150 } __attribute__((__packed__));
151
152 #define PMAX_BOOT_MAGIC 0x0002757a
153 #define PMAX_BOOTMODE_CONTIGUOUS 0
154 #define PMAX_BOOTMODE_SCATTERED 1
155
156 #define PMAX_BOOT_BLOCK_OFFSET 0
157 #define PMAX_BOOT_BLOCK_BLOCKSIZE 512
158
159
160 /*
161 * VAX boot block information
162 */
163 struct vax_boot_block {
164 /* Note that these don't overlap any of the pmax boot block
165 */
166 u_int8_t pad0[2];
167 u_int8_t bb_id_offset; /* offset in words to id (magic1)*/
168 u_int8_t bb_mbone; /* must be one */
169 u_int16_t bb_lbn_hi; /* lbn (hi word) of bootstrap */
170 u_int16_t bb_lbn_low; /* lbn (low word) of bootstrap */
171 u_int8_t pad1[332];
172
173 /* The rest of these fields are identification area and describe
174 * the secondary block for uVAX VMB.
175 */
176 u_int8_t bb_magic1; /* magic number */
177 u_int8_t bb_mbz1; /* must be zero */
178 u_int8_t bb_pad1; /* any value */
179 u_int8_t bb_sum1; /* ~(magic1 + mbz1 + pad1) */
180
181 u_int8_t bb_mbz2; /* must be zero */
182 u_int8_t bb_volinfo; /* volinfo */
183 u_int8_t bb_pad2a; /* any value */
184 u_int8_t bb_pad2b; /* any value */
185
186 u_int32_t bb_size; /* size in blocks of bootstrap */
187 u_int32_t bb_load; /* load offset to bootstrap */
188 u_int32_t bb_entry; /* byte offset in bootstrap */
189 u_int32_t bb_sum3; /* sum of previous 3 fields */
190
191 /* The rest is unused.
192 */
193 u_int8_t pad2[148];
194 } __attribute__((__packed__));
195
196 #define VAX_BOOT_MAGIC1 0x18 /* size of BB info? */
197 #define VAX_BOOT_VOLINFO_NONE 0x00 /* no special info */
198 #define VAX_BOOT_VOLINFO_SS 0x01 /* single sided */
199 #define VAX_BOOT_VOLINFO_DS 0x81 /* double sided */
200
201 #define VAX_BOOT_SIZE 15 /* 15 blocks */
202 #define VAX_BOOT_LOAD 0 /* no load offset */
203 #define VAX_BOOT_ENTRY 0x200 /* one block in */
204
205 #define VAX_BOOT_BLOCK_OFFSET 0
206 #define VAX_BOOT_BLOCK_BLOCKSIZE 512
207
208 /* The following describes the ULTRIX partition tables.
209 */
210 /*
211 * DEC_NUM_DISK_PARTS is the number of partitions that are recorded in
212 * the label information. The size of the padding in the Dec_DiskLabel
213 * type is dependent on this number...
214 */
215 #define DEC_NUM_DISK_PARTS 8
216
217 /*
218 * A disk is divided into partitions and this type specifies where a
219 * partition starts and how many bytes it contains.
220 */
221 typedef struct dec_disk_map {
222 int32_t num_blocks; /* Number of 512 byte blocks in partition. */
223 int32_t start_block; /* Start of partition in blocks. */
224 } dec_disk_map;
225
226 /*
227 * Label information on the 31st (DEC_LABEL_SECTOR) sector.
228 */
229 typedef struct dec_disklabel {
230 u_int8_t pad0[440]; /* DIFFERENT from sprite!!! */
231 int32_t magic; /* DEC_LABEL_MAGIC */
232 int32_t is_partitioned; /* 1 if disk is partitioned. */
233 dec_disk_map map[DEC_NUM_DISK_PARTS]; /* Indicates disk partitions. */
234 } dec_disklabel;
235
236 #define DEC_LABEL_MAGIC 0x00032957
237 #define DEC_LABEL_SECTOR 31
238
239 #endif /* !_DEV_DEC_DEC_BOOT_H_ */
240