summaryrefslogtreecommitdiff
path: root/sys/arch/alpha/include/disklabel.h
blob: 64037920c1974c2d06c5a086a456cc5499ddeeb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*	$OpenBSD: disklabel.h,v 1.6 1997/08/08 22:01:09 niklas Exp $	*/
/*	$NetBSD: disklabel.h,v 1.1 1995/02/13 23:07:34 cgd Exp $	*/

/*
 * Copyright (c) 1994 Christopher G. Demetriou
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by Christopher G. Demetriou.
 * 4. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef _MACHINE_DISKLABEL_H_
#define _MACHINE_DISKLABEL_H_

enum disklabel_tag { DLT_ALPHA, DLT_I386, DLT_AMIGA };

/*
 * What disklabels are we probing for, and in which order?
 */
#ifndef LABELPROBES
#define LABELPROBES		DLT_ALPHA, DLT_I386, DLT_AMIGA
#endif

#define	ALPHA_LABELSECTOR	0		/* sector containing label */
#define	ALPHA_LABELOFFSET	64		/* offset of label in sector */
#define	I386_LABELSECTOR	1		/* sector containing label */
#define	I386_LABELOFFSET	0		/* offset of label in sector */
#define	AMIGA_LABELSECTOR	0		/* sector containing label */
#define	AMIGA_LABELOFFSET	64		/* offset of label in sector */

#define LABELSECTOR		ALPHA_LABELSECTOR
#define LABELOFFSET		ALPHA_LABELOFFSET

#define	MAXPARTITIONS		16		/* number of partitions */
#define	RAW_PART		2		/* raw partition: xx?c */

/* DOS partition table -- located in boot block */
#define	DOSBBSECTOR	0		/* DOS boot block relative sector # */
#define	DOSPARTOFF	446
#define	NDOSPART	4

struct dos_partition {
	u_int8_t	dp_flag;	/* bootstrap flags */
	u_int8_t	dp_shd;		/* starting head */
	u_int8_t	dp_ssect;	/* starting sector */
	u_int8_t	dp_scyl;	/* starting cylinder */
	u_int8_t	dp_typ;		/* partition type (see below) */
	u_int8_t	dp_ehd;		/* end head */
	u_int8_t	dp_esect;	/* end sector */
	u_int8_t	dp_ecyl;	/* end cylinder */
	u_int32_t	dp_start;	/* absolute starting sector number */
	u_int32_t	dp_size;	/* partition size in sectors */
};

/* Known DOS partition types. */
#define	DOSPTYP_UNUSED	0x00		/* Unused partition */
#define DOSPTYP_FAT12	0x01		/* 12-bit FAT */
#define DOSPTYP_FAT16S	0x04		/* 16-bit FAT, less than 32M */
#define DOSPTYP_EXTEND	0x05		/* Extended; contains sub-partitions */
#define DOSPTYP_FAT16B	0x06		/* 16-bit FAT, more than 32M */
#define DOSPTYP_FAT16C	0x0e		/* 16-bit FAT, CHS-mapped */
#define DOSPTYP_ONTRACK	0x54
#define	DOSPTYP_LINUX	0x83		/* That other thing */
#define DOSPTYP_386BSD	0xa5		/* 386BSD partition type */
#define DOSPTYP_NETBSD	DOSPTYP_386BSD	/* NetBSD partition type (XXX) */
#define DOSPTYP_OPENBSD	0xa6		/* OpenBSD partition type */

/* Isolate the relevant bits to get sector and cylinder. */
#define	DPSECT(s)	((s) & 0x3f)
#define	DPCYL(c, s)	((c) + (((s) & 0xc0) << 2))

/*
 * describes ados Rigid Disk Blocks
 * which are used to partition a drive
 */
#define RDBNULL ((u_int32_t)0xffffffff)

/*
 * you will find rdblock somewhere in [0, RDBMAXBLOCKS)
 */
#define RDB_MAXBLOCKS	16

struct rdblock {
	u_int32_t id;		/* 'RDSK' */
	u_int32_t nsumlong;	/* number of longs in check sum */
	u_int32_t chksum;	/* simple additive with wrap checksum */
	u_int32_t hostid;	/* scsi target of host */
	u_int32_t nbytes;	/* size of disk blocks */
	u_int32_t flags;
	u_int32_t badbhead;	/* linked list of badblocks */
	u_int32_t partbhead;	/* linked list of partblocks */
	u_int32_t fsbhead;	/*   "     "   of fsblocks */
	u_int32_t driveinit;
	u_int32_t resv1[6];	/* RDBNULL */
	u_int32_t ncylinders;	/* number of cylinders on drive */
	u_int32_t nsectors;	/* number of sectors per track */
	u_int32_t nheads;	/* number of tracks per cylinder */
	u_int32_t interleave;
	u_int32_t park;		/* only used with st506 i.e. not */
	u_int32_t resv2[3];
	u_int32_t wprecomp;	/* start cyl for write precomp */
	u_int32_t reducedwrite;	/* start cyl for reduced write current */
	u_int32_t steprate;	/* driver step rate in ?s */
	u_int32_t resv3[5];
	u_int32_t rdblowb;	/* lowblock of range for rdb's */
	u_int32_t rdbhighb;	/* high block of range for rdb's */
	u_int32_t lowcyl;	/* low cylinder of partition area */
	u_int32_t highcyl;	/* upper cylinder of partition area */
	u_int32_t secpercyl;	/* number of sectors per cylinder */
	u_int32_t parkseconds;	/* zero if no park needed */
	u_int32_t resv4[2];
	char   diskvendor[8];	/* inquiry stuff */
	char   diskproduct[16];	/* inquiry stuff */
	char   diskrevision[4];	/* inquiry stuff */
	char   contvendor[8];	/* inquiry stuff */
	char   contproduct[16];	/* inquiry stuff */
	char   contrevision[4];	/* inquiry stuff */
#if never_use_secsize
	u_int32_t resv5[0];
#endif
};


#define RDBF_LAST	0x1	/* last drive available */
#define RDBF_LASTLUN	0x2	/* last LUN available */
#define RDBF_LASTUNIT	0x4	/* last target available */
#define RDBF_NORESELECT	0x8	/* do not use reselect */
#define RDBF_DISKID	0x10	/* disk id is valid ?? */
#define RDBF_CTRLID	0x20	/* ctrl id is valid ?? */
#define RDBF_SYNC	0x40	/* drive supports SCSI synchronous mode */
	
struct ados_environ {
	u_int32_t tabsize;	/* 0: environ table size */
	u_int32_t sizeblock;	/* 1: n long words in a block */
	u_int32_t secorg;	/* 2: not used must be zero */
	u_int32_t numheads;	/* 3: number of surfaces */
	u_int32_t secperblk;	/* 4: must be 1 */
	u_int32_t secpertrk;	/* 5: blocks per track */
	u_int32_t resvblocks;	/* 6: reserved blocks at start */
	u_int32_t prefac;	/* 7: must be 0 */
	u_int32_t interleave;	/* 8: normally 1 */
	u_int32_t lowcyl;	/* 9: low cylinder of partition */
	u_int32_t highcyl;	/* 10: upper cylinder of partition */
	u_int32_t numbufs;	/* 11: ados: number of buffers */
	u_int32_t membuftype;	/* 12: ados: type of bufmem */
	u_int32_t maxtrans;	/* 13: maxtrans the ctrlr supports */
	u_int32_t mask;		/* 14: mask for valid address */
	u_int32_t bootpri;	/* 15: boot priority for autoboot */
	u_int32_t dostype;	/* 16: filesystem type */
	u_int32_t baud;		/* 17: serial handler baud rate */
	u_int32_t control;	/* 18: control word for fs */
	u_int32_t bootblocks;	/* 19: blocks containing boot code */
	u_int32_t fsize;	/* 20: file system block size */
	u_int32_t frag;		/* 21: allowable frags per block */
	u_int32_t cpg;		/* 22: cylinders per group */
};

struct partblock {
	u_int32_t id;		/* 'PART' */
	u_int32_t nsumlong;	/* number of longs in check sum */
	u_int32_t chksum;	/* simple additive with wrap checksum */
	u_int32_t hostid;	/* scsi target of host */
	u_int32_t next;		/* next in chain */
	u_int32_t flags;	/* see below */
	u_int32_t resv1[3];
	u_char partname[32];	/* (BCPL) part name (may not be unique) */
	u_int32_t resv2[15];
	struct ados_environ e;
#if never_use_secsize
	u_int32_t extra[9];	/* 8 for extra added to environ */
#endif
};

#define PBF_BOOTABLE	0x1	/* partition is bootable */
#define PBF_NOMOUNT	0x2	/* partition should be mounted */

struct badblock {
	u_int32_t id;		/* 'BADB' */
	u_int32_t nsumlong;	/* number of longs in check sum */
	u_int32_t chksum;	/* simple additive with wrap checksum */
	u_int32_t hostid;	/* scsi target of host */
	u_int32_t next;		/* next in chain */
	u_int32_t resv;
	struct badblockent {
		u_int32_t badblock;
		u_int32_t goodblock;
	} badtab[0];		/* 61 for secsize == 512 */
};

struct fsblock {
	u_int32_t id;		/* 'FSHD' */
	u_int32_t nsumlong;	/* number of longs in check sum */
	u_int32_t chksum;	/* simple additive with wrap checksum */
	u_int32_t hostid;	/* scsi target of host */
	u_int32_t next;		/* next in chain */
	u_int32_t flags;
	u_int32_t resv1[2];
	u_int32_t dostype;	/* this is a file system for this type */
	u_int32_t version;	/* version of this fs */
	u_int32_t patchflags;	/* describes which functions to replace */
	u_int32_t type;		/* zero */
	u_int32_t task;		/* zero */
	u_int32_t lock;		/* zero */
	u_int32_t handler;	/* zero */
	u_int32_t stacksize;	/* to use when loading handler */
	u_int32_t priority;	/* to run the fs at. */
	u_int32_t startup;	/* zero */
	u_int32_t lsegblocks;	/* linked list of lsegblocks of fs code */
	u_int32_t globalvec;	/* bcpl vector not used mostly */
#if never_use_secsize
	u_int32_t resv2[44];
#endif
};

struct lsegblock {
	u_int32_t id;		/* 'LSEG' */
	u_int32_t nsumlong;	/* number of longs in check sum */
	u_int32_t chksum;	/* simple additive with wrap checksum */
	u_int32_t hostid;	/* scsi target of host */
	u_int32_t next;		/* next in chain */
	u_int32_t loaddata[0];	/* load segment data, 123 for secsize == 512 */
};

#define RDBLOCK_ID	0x5244534b	/* 'RDSK' */
#define PARTBLOCK_ID	0x50415254	/* 'PART' */
#define BADBLOCK_ID	0x42414442	/* 'BADB' */
#define FSBLOCK_ID	0x46534844	/* 'FSHD' */
#define LSEGBLOCK_ID	0x4c534547	/* 'LSEG' */

#include <sys/dkbad.h>
struct cpu_disklabel {
	enum disklabel_tag labeltag;
	int labelsector;
	union {
		struct {
		} _alpha;
		struct {
			struct dos_partition dosparts[NDOSPART];
			struct dkbad bad;
		} _i386;
		struct {
			u_int32_t rdblock;		/* RDBNULL -> inval. */
			u_int32_t pblist[MAXPARTITIONS];/* pblock number */
			int pbindex[MAXPARTITIONS];	/* index of pblock */
			int valid;			/* valid? */
		} _amiga;
	} u;
};

#define DKBAD(x) ((x)->u._i386.bad)

#endif /* _MACHINE_DISKLABEL_H_ */