xref: /netbsd-src/sys/sys/disklabel_rdb.h (revision 55b56938ed6d4b41323615770c1cafc2658becd9)
1*55b56938Srin /*	$NetBSD: disklabel_rdb.h,v 1.5 2021/02/20 09:51:20 rin Exp $	*/
2e628320bSphx 
3e628320bSphx /*
4e628320bSphx  * Copyright (c) 1994 Christian E. Hopps
5e628320bSphx  * All rights reserved.
6e628320bSphx  *
7e628320bSphx  * Redistribution and use in source and binary forms, with or without
8e628320bSphx  * modification, are permitted provided that the following conditions
9e628320bSphx  * are met:
10e628320bSphx  * 1. Redistributions of source code must retain the above copyright
11e628320bSphx  *    notice, this list of conditions and the following disclaimer.
12e628320bSphx  * 2. Redistributions in binary form must reproduce the above copyright
13e628320bSphx  *    notice, this list of conditions and the following disclaimer in the
14e628320bSphx  *    documentation and/or other materials provided with the distribution.
15e628320bSphx  * 3. All advertising materials mentioning features or use of this software
16e628320bSphx  *    must display the following acknowledgement:
17e628320bSphx  *      This product includes software developed by Christian E. Hopps.
18e628320bSphx  * 4. The name of the author may not be used to endorse or promote products
19e628320bSphx  *    derived from this software without specific prior written permission
20e628320bSphx  *
21e628320bSphx  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22e628320bSphx  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23e628320bSphx  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24e628320bSphx  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25e628320bSphx  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26e628320bSphx  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27e628320bSphx  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28e628320bSphx  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29e628320bSphx  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30e628320bSphx  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31e628320bSphx  */
32*55b56938Srin 
33e628320bSphx #ifndef _SYS_DISKLABEL_RDB_H_
34e628320bSphx #define _SYS_DISKLABEL_RDB_H_
35e628320bSphx 
3638399309Srin #include <sys/types.h>
3738399309Srin 
38e628320bSphx /*
39e628320bSphx  * describes ados Rigid Disk Blocks
40e628320bSphx  * which are used to partition a drive
41e628320bSphx  */
4238399309Srin #define RDBNULL ((uint32_t)0xffffffff)
43e628320bSphx 
44e628320bSphx /*
45e628320bSphx  * you will find rdblock somewhere in [0, RDBMAXBLOCKS)
46e628320bSphx  */
47e628320bSphx #define RDB_MAXBLOCKS	16
48e628320bSphx 
49e628320bSphx struct rdblock {
5038399309Srin 	uint32_t id;		/* 'RDSK' */
5138399309Srin 	uint32_t nsumlong;	/* number of long words in check sum */
5238399309Srin 	uint32_t chksum;	/* simple additive with wrap checksum */
5338399309Srin 	uint32_t hostid;	/* scsi target of host */
5438399309Srin 	uint32_t nbytes;	/* size of disk blocks */
5538399309Srin 	uint32_t flags;
5638399309Srin 	uint32_t badbhead;	/* linked list of badblocks */
5738399309Srin 	uint32_t partbhead;	/* linked list of partblocks */
5838399309Srin 	uint32_t fsbhead;	/*   "     "   of fsblocks */
5938399309Srin 	uint32_t driveinit;
6038399309Srin 	uint32_t resv1[6];	/* RDBNULL */
6138399309Srin 	uint32_t ncylinders;	/* number of cylinders on drive */
6238399309Srin 	uint32_t nsectors;	/* number of sectors per track */
6338399309Srin 	uint32_t nheads;	/* number of tracks per cylinder */
6438399309Srin 	uint32_t interleave;
6538399309Srin 	uint32_t park;		/* only used with st506 i.e. not */
6638399309Srin 	uint32_t resv2[3];
6738399309Srin 	uint32_t wprecomp;	/* start cyl for write precomp */
6838399309Srin 	uint32_t reducedwrite;	/* start cyl for reduced write current */
6938399309Srin 	uint32_t steprate;	/* driver step rate in ?s */
7038399309Srin 	uint32_t resv3[5];
7138399309Srin 	uint32_t rdblowb;	/* lowblock of range for rdb's */
7238399309Srin 	uint32_t rdbhighb;	/* high block of range for rdb's */
7338399309Srin 	uint32_t lowcyl;	/* low cylinder of partition area */
7438399309Srin 	uint32_t highcyl;	/* upper cylinder of partition area */
7538399309Srin 	uint32_t secpercyl;	/* number of sectors per cylinder */
7638399309Srin 	uint32_t parkseconds;	/* zero if no park needed */
7738399309Srin 	uint32_t resv4[2];
78e628320bSphx 	char   diskvendor[8];	/* inquiry stuff */
79e628320bSphx 	char   diskproduct[16];	/* inquiry stuff */
80e628320bSphx 	char   diskrevision[4];	/* inquiry stuff */
81e628320bSphx 	char   contvendor[8];	/* inquiry stuff */
82e628320bSphx 	char   contproduct[16];	/* inquiry stuff */
83e628320bSphx 	char   contrevision[4];	/* inquiry stuff */
84e628320bSphx #if never_use_secsize
8538399309Srin 	uint32_t resv5[0];
86e628320bSphx #endif
87e628320bSphx };
88e628320bSphx 
89e628320bSphx 
90e628320bSphx #define RDBF_LAST	0x1	/* last drive available */
91e628320bSphx #define RDBF_LASTLUN	0x2	/* last LUN available */
92e628320bSphx #define RDBF_LASTUNIT	0x4	/* last target available */
93e628320bSphx #define RDBF_NORESELECT	0x8	/* do not use reselect */
94e628320bSphx #define RDBF_DISKID	0x10	/* disk id is valid ?? */
95e628320bSphx #define RDBF_CTRLID	0x20	/* ctrl id is valid ?? */
96e628320bSphx #define RDBF_SYNC	0x40	/* drive supports SCSI synchronous mode */
97e628320bSphx 
98e628320bSphx struct ados_environ {
9938399309Srin 	uint32_t tabsize;	/* 0: environ table size */
10038399309Srin 	uint32_t sizeblock;	/* 1: n long words in a block */
10138399309Srin 	uint32_t secorg;	/* 2: not used must be zero */
10238399309Srin 	uint32_t numheads;	/* 3: number of surfaces */
10338399309Srin 	uint32_t secperblk;	/* 4: must be 1 */
10438399309Srin 	uint32_t secpertrk;	/* 5: blocks per track */
10538399309Srin 	uint32_t resvblocks;	/* 6: reserved blocks at start */
10638399309Srin 	uint32_t prefac;	/* 7: must be 0 */
10738399309Srin 	uint32_t interleave;	/* 8: normally 1 */
10838399309Srin 	uint32_t lowcyl;	/* 9: low cylinder of partition */
10938399309Srin 	uint32_t highcyl;	/* 10: upper cylinder of partition */
11038399309Srin 	uint32_t numbufs;	/* 11: ados: number of buffers */
11138399309Srin 	uint32_t membuftype;	/* 12: ados: type of bufmem */
11238399309Srin 	uint32_t maxtrans;	/* 13: maxtrans the ctrlr supports */
11338399309Srin 	uint32_t mask;		/* 14: mask for valid address */
11438399309Srin 	uint32_t bootpri;	/* 15: boot priority for autoboot */
11538399309Srin 	uint32_t dostype;	/* 16: filesystem type */
11638399309Srin 	uint32_t baud;		/* 17: serial handler baud rate */
11738399309Srin 	uint32_t control;	/* 18: control word for fs */
11838399309Srin 	uint32_t bootblocks;	/* 19: blocks containing boot code */
11938399309Srin 	uint32_t fsize;		/* 20: file system block size */
12038399309Srin 	uint32_t frag;		/* 21: allowable frags per block */
12138399309Srin 	uint32_t cpg;		/* 22: cylinders per group */
122e628320bSphx };
123e628320bSphx 
124e628320bSphx struct partblock {
12538399309Srin 	uint32_t id;		/* 'PART' */
12638399309Srin 	uint32_t nsumlong;	/* number of long words in check sum */
12738399309Srin 	uint32_t chksum;	/* simple additive with wrap checksum */
12838399309Srin 	uint32_t hostid;	/* scsi target of host */
12938399309Srin 	uint32_t next;		/* next in chain */
13038399309Srin 	uint32_t flags;		/* see below */
13138399309Srin 	uint32_t resv1[3];
13214ce3d3fSrin 	unsigned char partname[32]; /* (BCPL) part name (may not be unique) */
13338399309Srin 	uint32_t resv2[15];
134e628320bSphx 	struct ados_environ e;
135e628320bSphx #if never_use_secsize
13638399309Srin 	uint32_t extra[9];	/* 8 for extra added to environ */
137e628320bSphx #endif
138e628320bSphx };
139e628320bSphx 
140e628320bSphx #define PBF_BOOTABLE	0x1	/* partition is bootable */
141e628320bSphx #define PBF_NOMOUNT	0x2	/* partition should be mounted */
142e628320bSphx 
143e628320bSphx struct badblock {
14438399309Srin 	uint32_t id;		/* 'BADB' */
14538399309Srin 	uint32_t nsumlong;	/* number of long words in check sum */
14638399309Srin 	uint32_t chksum;	/* simple additive with wrap checksum */
14738399309Srin 	uint32_t hostid;	/* scsi target of host */
14838399309Srin 	uint32_t next;		/* next in chain */
14938399309Srin 	uint32_t resv;
150e628320bSphx 	struct badblockent {
15138399309Srin 		uint32_t badblock;
15238399309Srin 		uint32_t goodblock;
153e628320bSphx 	} badtab[0];		/* 61 for secsize == 512 */
154e628320bSphx };
155e628320bSphx 
156e628320bSphx struct fsblock {
15738399309Srin 	uint32_t id;		/* 'FSHD' */
15838399309Srin 	uint32_t nsumlong;	/* number of long words in check sum */
15938399309Srin 	uint32_t chksum;	/* simple additive with wrap checksum */
16038399309Srin 	uint32_t hostid;	/* scsi target of host */
16138399309Srin 	uint32_t next;		/* next in chain */
16238399309Srin 	uint32_t flags;
16338399309Srin 	uint32_t resv1[2];
16438399309Srin 	uint32_t dostype;	/* this is a file system for this type */
16538399309Srin 	uint32_t version;	/* version of this fs */
16638399309Srin 	uint32_t patchflags;	/* describes which functions to replace */
16738399309Srin 	uint32_t type;		/* zero */
16838399309Srin 	uint32_t task;		/* zero */
16938399309Srin 	uint32_t lock;		/* zero */
17038399309Srin 	uint32_t handler;	/* zero */
17138399309Srin 	uint32_t stacksize;	/* to use when loading handler */
17238399309Srin 	uint32_t priority;	/* to run the fs at. */
17338399309Srin 	uint32_t startup;	/* zero */
17438399309Srin 	uint32_t lsegblocks;	/* linked list of lsegblocks of fs code */
17538399309Srin 	uint32_t globalvec;	/* bcpl vector not used mostly */
176e628320bSphx #if never_use_secsize
17738399309Srin 	uint32_t resv2[44];
178e628320bSphx #endif
179e628320bSphx };
180e628320bSphx 
181e628320bSphx struct lsegblock {
18238399309Srin 	uint32_t id;		/* 'LSEG' */
18338399309Srin 	uint32_t nsumlong;	/* number of long words in check sum */
18438399309Srin 	uint32_t chksum;	/* simple additive with wrap checksum */
18538399309Srin 	uint32_t hostid;	/* scsi target of host */
18638399309Srin 	uint32_t next;		/* next in chain */
18738399309Srin 	uint32_t loaddata[0];	/* load segment data, 123 for secsize == 512 */
188e628320bSphx };
189e628320bSphx 
190e628320bSphx #define RDBLOCK_ID	0x5244534b	/* 'RDSK' */
191e628320bSphx #define PARTBLOCK_ID	0x50415254	/* 'PART' */
192e628320bSphx #define BADBLOCK_ID	0x42414442	/* 'BADB' */
193e628320bSphx #define FSBLOCK_ID	0x46534844	/* 'FSHD' */
194e628320bSphx #define LSEGBLOCK_ID	0x4c534547	/* 'LSEG' */
195e628320bSphx 
196e628320bSphx /*
197e628320bSphx  * Dos types for identifying file systems
198e628320bSphx  * bsd file systems will be 'N','B',x,y where y is the fstype found in
199e628320bSphx  * disklabel.h (for DOST_DOS it will be the version number)
200e628320bSphx  */
201e628320bSphx #define DOST_XXXBSD	0x42534400	/* Old type back compat*/
202e628320bSphx #define DOST_NBR	0x4e425200	/* 'NBRx' NetBSD root partition */
203e628320bSphx #define DOST_NBS	0x4e425300	/* 'NBS0' NetBSD swap partition */
204e628320bSphx #define DOST_NBU	0x4e425500	/* 'NBUx' NetBSD user partition */
205e628320bSphx #define DOST_DOS	0x444f5300	/* 'DOSx' AmigaDos partition */
206e628320bSphx #define DOST_AMIX	0x554e4900	/* 'UNIx' AmigaDos partition */
207e628320bSphx #define DOST_MUFS	0x6d754600	/* 'muFx' AmigaDos partition (muFS) */
208e628320bSphx #define DOST_EXT2	0x4c4e5800	/* 'LNX0' Linux fs partition (ext2fs) */
209e628320bSphx #define DOST_LNXSWP	0x53575000	/* 'SWP0' Linux swap partition */
210e628320bSphx #define DOST_RAID	0x52414900	/* 'RAID' Raidframe partition */
2115289a292Skiyohara #define DOST_MSD	0x4d534400	/* 'MSDx' MSDOS partition */
2125289a292Skiyohara #define DOST_SFS	0x53465300	/* 'SFSx' Smart fs partition */
213e628320bSphx 
214e628320bSphx struct adostype {
215*55b56938Srin 	uint8_t archtype;	/* see ADT_xxx below */
216*55b56938Srin 	uint8_t fstype;		/* byte 3 from amiga dostype */
217e628320bSphx };
218e628320bSphx 
219e628320bSphx /* archtypes */
220e628320bSphx #define ADT_UNKNOWN	0
221e628320bSphx #define ADT_AMIGADOS	1
222e628320bSphx #define ADT_NETBSDROOT	2
223e628320bSphx #define ADT_NETBSDSWAP	3
224e628320bSphx #define ADT_NETBSDUSER	4
225e628320bSphx #define ADT_AMIX	5
226e628320bSphx #define ADT_EXT2	6
227e628320bSphx #define ADT_RAID	7
2285289a292Skiyohara #define ADT_MSD		8
2295289a292Skiyohara #define ADT_SFS		9
230e628320bSphx 
231e628320bSphx #define ISFSARCH_NETBSD(adt) \
232e628320bSphx 	((adt).archtype >= ADT_NETBSDROOT && (adt).archtype <= ADT_NETBSDUSER)
233e628320bSphx 
234e628320bSphx #endif /* _SYS_DISKLABEL_RDB_H_ */
235