xref: /netbsd/sys/arch/mipsco/include/disklabel.h (revision 509fd41b)
1 /*	$NetBSD: disklabel.h,v 1.8 2011/08/30 12:39:56 bouyer Exp $	*/
2 
3 /*
4  * Copyright (c) 2000 Wayne Knowles.     All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *      This product includes software developed by Christopher G. Demetriou.
17  * 4. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _MACHINE_DISKLABEL_H_
33 #define _MACHINE_DISKLABEL_H_
34 
35 /*
36  * MIPS partition conventions:
37  *
38  * Partition 0 - root
39  * Partition 1 - swap
40  * Partition 6 - usr
41  * Partition 7 - volume body
42  * Partition 8 - volume header
43  * Partition 10 - whole disk
44  */
45 
46 #define LABELUSESMBR	0	/* no MBR partitionning */
47 #define LABELSECTOR	1
48 #define LABELOFFSET	0
49 #define MAXPARTITIONS	8	/* XXX - NetBSD Compatibility */
50 #define RAW_PART	2
51 
52 #define MIPS_PARTITIONS	16	/* Number or partitions for Mips */
53 #define MIPS_NVOLDIR	15	/* Number of volume directory files */
54 #define MIPS_VDIRSZ	8	/* File name size in volume directory */
55 #define MIPS_BFSIZE	16	/* Boot filename size */
56 #define	MIPS_VHSECTOR	0	/* Sector number for MIPS volume header */
57 
58 /*
59  * Devices parameters that RISC/os uses for mapping logical block numbers
60  * to physical device addresses.
61  */
62 struct mips_devparams {
63 	u_int8_t	dp_skew;	/* spiral addressing skew */
64 	u_int8_t	dp_gap1;	/* words of 0 before header */
65 	u_int8_t	dp_gap2;	/* words of 0 between hdr and data */
66 	u_int8_t	dp_spare0;	/* spare space */
67 	u_int16_t	dp_cyls;	/* number of cylinders */
68 	u_int16_t	dp_shd0;	/* starting head vol 0 */
69 	u_int16_t	dp_trks0;	/* number of tracks vol 0 */
70 	u_int16_t	dp_shd1;	/* starting head vol 1 */
71 	u_int16_t	dp_trks1;	/* number of tracks vol 1 */
72 	u_int16_t	dp_secs;	/* number of sectors/track */
73 	u_int16_t	dp_secbytes;	/* length of sector in bytes */
74 	u_int16_t	dp_interleave;	/* sector interleave */
75 	int32_t		dp_flags;	/* controller characteristics */
76 	int32_t		dp_datarate;	/* bytes/sec for kernel stats */
77 	int32_t		dp_nretries;	/* max num retries on data error */
78 	int32_t		dp_spare1;	/* spare entries */
79 	int32_t		dp_spare2;
80 	int32_t		dp_spare3;
81 	int32_t		dp_spare4;
82 } __attribute__((__packed__));
83 
84 /*
85  * Volume directory is used as a shortcut to find bootstraps etc
86  */
87 struct mips_voldir {			/* Disk volume directory */
88 	char 		vd_name[MIPS_VDIRSZ];
89 	int32_t		vd_lba;
90 	int32_t		vd_len;
91 };
92 
93 struct mips_partitions {
94 	int32_t 	pt_size;	/* # of logical blocks in partition */
95 	int32_t 	pt_offset;	/* first logical block of partition */
96 	int32_t 	pt_fstype;
97 };
98 
99 /*
100  * Mips RISC/os compatible volume header and partition table
101  *
102  * 1 sector (512 bytes) in size, and normally copied to the first sector
103  * and cylinder of every track on a disk.
104  */
105 struct mips_volheader {
106 	u_int32_t	vh_magic;
107 #define MIPS_VHMAGIC	0xbe5a941
108 	int16_t		vh_root;		/* Root partition number */
109 	int16_t		vh_swap;		/* Swap partition number */
110 	char		bootfile[MIPS_BFSIZE];	/* default file to boot */
111 	struct mips_devparams	vh_dp;		/* disk device parameters */
112 	struct mips_voldir 	vh_voldir[MIPS_NVOLDIR];
113 	struct mips_partitions	vh_part[MIPS_PARTITIONS];
114 	int32_t		vh_cksum;
115 	int32_t		vh_pad;
116 } __attribute__((__packed__));
117 
118 #define MIPS_FS_VOLHDR	0
119 #define MIPS_FS_TRKREPL 1
120 #define MIPS_FS_SECREPL	2
121 #define MIPS_FS_RAW	3
122 #define MIPS_FS_BSD     4
123 #define MIPS_FS_BSD42   4
124 #define MIPS_FS_SYSV    5
125 #define MIPS_FS_VOLUME	6 /* Entire volume */
126 
127 /* Just a dummy */
128 struct cpu_disklabel {
129 	int	cd_dummy;			/* must have one element. */
130 };
131 
132 #endif /* _MACHINE_DISKLABEL_H_ */
133