ahdilbl.h revision 1.1.2.2 1 1.1.2.2 nathanw /* $NetBSD: ahdilbl.h,v 1.1.2.2 2002/02/28 04:08:32 nathanw Exp $ */
2 1.1.2.2 nathanw
3 1.1.2.2 nathanw /*
4 1.1.2.2 nathanw * Copyright (c) 1995 Leo Weppelman.
5 1.1.2.2 nathanw * All rights reserved.
6 1.1.2.2 nathanw *
7 1.1.2.2 nathanw * Redistribution and use in source and binary forms, with or without
8 1.1.2.2 nathanw * modification, are permitted provided that the following conditions
9 1.1.2.2 nathanw * are met:
10 1.1.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
11 1.1.2.2 nathanw * notice, this list of conditions and the following disclaimer.
12 1.1.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
14 1.1.2.2 nathanw * documentation and/or other materials provided with the distribution.
15 1.1.2.2 nathanw * 3. All advertising materials mentioning features or use of this software
16 1.1.2.2 nathanw * must display the following acknowledgement:
17 1.1.2.2 nathanw * This product includes software developed by Leo Weppelman.
18 1.1.2.2 nathanw * 4. The name of the author may not be used to endorse or promote products
19 1.1.2.2 nathanw * derived from this software without specific prior written permission
20 1.1.2.2 nathanw *
21 1.1.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1.2.2 nathanw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1.2.2 nathanw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1.2.2 nathanw * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1.2.2 nathanw * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1.2.2 nathanw * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1.2.2 nathanw * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1.2.2 nathanw * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1.2.2 nathanw * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1.2.2 nathanw * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1.2.2 nathanw */
32 1.1.2.2 nathanw
33 1.1.2.2 nathanw #ifndef AHDILABEL_H
34 1.1.2.2 nathanw #define AHDILABEL_H
35 1.1.2.2 nathanw
36 1.1.2.2 nathanw /***** from src/sys/arch/atari/include/disklabel.h *************************/
37 1.1.2.2 nathanw
38 1.1.2.2 nathanw /*
39 1.1.2.2 nathanw * On a volume, exclusively used by NetBSD, the boot block starts at
40 1.1.2.2 nathanw * sector 0. To allow shared use of a volume between two or more OS's
41 1.1.2.2 nathanw * the vendor specific AHDI format is supported. In this case the boot
42 1.1.2.2 nathanw * block is located at the start of an AHDI partition. In any case the
43 1.1.2.2 nathanw * size of the boot block must be at least 8KB.
44 1.1.2.2 nathanw */
45 1.1.2.2 nathanw #define BBMINSIZE 8192 /* minimum size of boot block */
46 1.1.2.2 nathanw #define LABELSECTOR 0 /* `natural' start of boot block */
47 1.1.2.2 nathanw #define LABELOFFSET 516 /* offset of disk label in bytes,
48 1.1.2.2 nathanw relative to start of boot block */
49 1.1.2.2 nathanw #define LABELMAXSIZE 1020 /* maximum size of disk label */
50 1.1.2.2 nathanw
51 1.1.2.2 nathanw #define MAXPARTITIONS 16 /* max. # of NetBSD partitions */
52 1.1.2.2 nathanw #define RAW_PART 2 /* xx?c is raw partition */
53 1.1.2.2 nathanw
54 1.1.2.2 nathanw #define NO_BOOT_BLOCK ((u_int)-1)
55 1.1.2.2 nathanw #define MAXAUXROOTS 29 /* max. # of auxiliary root sectors */
56 1.1.2.2 nathanw
57 1.1.2.2 nathanw struct bootblock {
58 1.1.2.2 nathanw u_int8_t bb_xxboot[LABELOFFSET - sizeof(u_int32_t)];
59 1.1.2.2 nathanw /* first-stage boot loader */
60 1.1.2.2 nathanw u_int32_t bb_magic; /* boot block magic number */
61 1.1.2.2 nathanw #define NBDAMAGIC 0x4e424441
62 1.1.2.2 nathanw #define AHDIMAGIC 0x41484449
63 1.1.2.2 nathanw u_int8_t bb_label[LABELMAXSIZE]; /* disk pack label */
64 1.1.2.2 nathanw u_int8_t bb_bootxx[BBMINSIZE - (LABELOFFSET + LABELMAXSIZE)];
65 1.1.2.2 nathanw /* second-stage boot loader*/
66 1.1.2.2 nathanw };
67 1.1.2.2 nathanw
68 1.1.2.2 nathanw #define BBGETLABEL(bb, dl) *(dl) = *((struct disklabel *)(bb)->bb_label)
69 1.1.2.2 nathanw #define BBSETLABEL(bb, dl) *((struct disklabel *)(bb)->bb_label) = *(dl)
70 1.1.2.2 nathanw
71 1.1.2.2 nathanw /***** from src/sys/arch/atari/include/ahdilabel.h *************************/
72 1.1.2.2 nathanw
73 1.1.2.2 nathanw #define AHDI_BSIZE 512 /* AHDI blocksize */
74 1.1.2.2 nathanw #define AHDI_BBLOCK 0 /* AHDI bootblock (root sector) */
75 1.1.2.2 nathanw #define AHDI_MAXROOTS (MAXAUXROOTS) /* max. # of AHDI rootsectors */
76 1.1.2.2 nathanw #define AHDI_MAXPARTS (AHDI_MAXROOTS+3) /* max. # of AHDI partitions */
77 1.1.2.2 nathanw
78 1.1.2.2 nathanw /*
79 1.1.2.2 nathanw * Various `well known' AHDI partition identifiers.
80 1.1.2.2 nathanw */
81 1.1.2.2 nathanw #define AHDI_MKPID(x,y,z) ( ((u_int32_t)(x) << 16) \
82 1.1.2.2 nathanw | ((u_int32_t)(y) << 8) \
83 1.1.2.2 nathanw | ((u_int32_t)(z)) \
84 1.1.2.2 nathanw )
85 1.1.2.2 nathanw #define AHDI_PID_XGM AHDI_MKPID('X','G','M')
86 1.1.2.2 nathanw #define AHDI_PID_GEM AHDI_MKPID('G','E','M')
87 1.1.2.2 nathanw #define AHDI_PID_BGM AHDI_MKPID('B','G','M')
88 1.1.2.2 nathanw #define AHDI_PID_RAW AHDI_MKPID('R','A','W')
89 1.1.2.2 nathanw #define AHDI_PID_SWP AHDI_MKPID('S','W','P')
90 1.1.2.2 nathanw #define AHDI_PID_NBD AHDI_MKPID('N','B','D')
91 1.1.2.2 nathanw #define AHDI_PID_NBR AHDI_MKPID('N','B','R')
92 1.1.2.2 nathanw #define AHDI_PID_NBS AHDI_MKPID('N','B','S')
93 1.1.2.2 nathanw #define AHDI_PID_NBU AHDI_MKPID('N','B','U')
94 1.1.2.2 nathanw
95 1.1.2.2 nathanw /*
96 1.1.2.2 nathanw * Format of AHDI boot block.
97 1.1.2.2 nathanw */
98 1.1.2.2 nathanw #define AHDI_MAXRPD 4 /* max. # of partition descriptors */
99 1.1.2.2 nathanw /* in the AHDI bootblock (aka root)*/
100 1.1.2.2 nathanw #define AHDI_MAXARPD 2 /* max. # of partition descriptors */
101 1.1.2.2 nathanw /* in an AHDI auxiliary root sector */
102 1.1.2.2 nathanw
103 1.1.2.2 nathanw struct ahdi_part {
104 1.1.2.2 nathanw u_int8_t ap_flg; /* bit 0 is in-use flag */
105 1.1.2.2 nathanw u_int8_t ap_id[3]; /* id: GEM, BGM, XGM, UNX, MIX */
106 1.1.2.2 nathanw u_int32_t ap_st; /* block where partition starts */
107 1.1.2.2 nathanw u_int32_t ap_size; /* partition size in blocks */
108 1.1.2.2 nathanw #define ap_end ap_size /* in the in-core copy, store end instead of size */
109 1.1.2.2 nathanw };
110 1.1.2.2 nathanw
111 1.1.2.2 nathanw struct ahdi_root {
112 1.1.2.2 nathanw u_int8_t ar_fill[0x1c2];/* filler, can be boot code */
113 1.1.2.2 nathanw u_int32_t ar_hdsize; /* size of entire volume in blocks */
114 1.1.2.2 nathanw struct ahdi_part ar_parts[AHDI_MAXRPD]; /* root partition table */
115 1.1.2.2 nathanw u_int32_t ar_bslst; /* start of bad-sector list */
116 1.1.2.2 nathanw u_int32_t ar_bslsize; /* # of blocks in bad-sector list */
117 1.1.2.2 nathanw u_int16_t ar_cksum;
118 1.1.2.2 nathanw };
119 1.1.2.2 nathanw
120 1.1.2.2 nathanw /*
121 1.1.2.2 nathanw * Partition table representation as generated by ahdi_getparts():
122 1.1.2.2 nathanw */
123 1.1.2.2 nathanw typedef struct {
124 1.1.2.2 nathanw char id[4];
125 1.1.2.2 nathanw u_int start;
126 1.1.2.2 nathanw u_int end;
127 1.1.2.2 nathanw u_int rsec;
128 1.1.2.2 nathanw u_int rent;
129 1.1.2.2 nathanw int mod;
130 1.1.2.2 nathanw } part_t;
131 1.1.2.2 nathanw
132 1.1.2.2 nathanw typedef struct {
133 1.1.2.2 nathanw int nparts;
134 1.1.2.2 nathanw part_t *parts;
135 1.1.2.2 nathanw } ptable_t;
136 1.1.2.2 nathanw
137 1.1.2.2 nathanw EXTERN u_int ahdi_getparts PROTO((disk_t *, ptable_t *, u_int, u_int));
138 1.1.2.2 nathanw #endif /* AHDILABEL_H */
139