xref: /netbsd/sys/arch/atari/include/ahdilabel.h (revision bf9ec67e)
1 /*	$NetBSD: ahdilabel.h,v 1.3 2001/07/26 23:07:57 wiz Exp $	*/
2 
3 /*
4  * Copyright (c) 1995 Leo Weppelman.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by Leo Weppelman.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _MACHINE_AHDILABEL_H_
34 #define _MACHINE_AHDILABEL_H_
35 
36 #define	AHDI_BSIZE	512		/* AHDI blocksize		*/
37 #define	AHDI_BBLOCK	0		/* AHDI bootblock (root sector)	*/
38 #define AHDI_MAXROOTS	(MAXAUXROOTS)	/* max. # of AHDI rootsectors	*/
39 #define	AHDI_MAXPARTS	(AHDI_MAXROOTS+3) /* max. # of AHDI partitions	*/
40 
41 /*
42  * Various `well known' AHDI partition identifiers.
43  */
44 #define AHDI_MKPID(x,y,z)	(   ((u_int32_t)(x) << 16)	\
45 				  | ((u_int32_t)(y) << 8)	\
46 				  | ((u_int32_t)(z))		\
47 				)
48 #define	AHDI_PID_XGM	AHDI_MKPID('X','G','M')
49 #define	AHDI_PID_GEM	AHDI_MKPID('G','E','M')
50 #define	AHDI_PID_BGM	AHDI_MKPID('B','G','M')
51 #define	AHDI_PID_RAW	AHDI_MKPID('R','A','W')
52 #define	AHDI_PID_SWP	AHDI_MKPID('S','W','P')
53 #define	AHDI_PID_NBD	AHDI_MKPID('N','B','D')
54 #define	AHDI_PID_NBR	AHDI_MKPID('N','B','R')
55 #define	AHDI_PID_NBS	AHDI_MKPID('N','B','S')
56 #define	AHDI_PID_NBU	AHDI_MKPID('N','B','U')
57 
58 /*
59  * Format of AHDI boot block.
60  */
61 #define	AHDI_MAXRPD	4		/* max. # of partition descriptors */
62 					/* in an AHDI bootblock (aka root) */
63 #define	AHDI_MAXARPD	2		/* max. # of partition descriptors */
64 					/* in an AHDI auxiliary root sector */
65 struct ahdi_part {
66 	u_int8_t	ap_flg;		/* bit 0 is in-use flag            */
67 	u_int8_t	ap_id[3];	/* id: GEM, BGM, XGM, UNX, MIX     */
68 	u_int32_t	ap_st;		/* block where partition starts    */
69 	u_int32_t	ap_size;	/* partition size in blocks        */
70 } __attribute__((__packed__));
71 #define	ap_end	ap_size /* in the in-core copy, store end instead of size  */
72 
73 struct ahdi_root {
74 	u_int8_t	 ar_fill[0x1c2];/* filler, can be boot code        */
75 	u_int32_t	 ar_hdsize;	/* size of entire volume in blocks */
76 	struct ahdi_part ar_parts[AHDI_MAXRPD]; /* root partition table    */
77 	u_int32_t	 ar_bslst;	/* start of bad-sector list        */
78 	u_int32_t	 ar_bslsize;	/* # of blocks in bad-sector list  */
79 	u_int16_t	 ar_checksum;
80 } __attribute__((__packed__));
81 
82 /*
83  * AHDI partition table.
84  */
85 #ifdef _KERNEL
86 struct ahdi_ptbl {
87 	struct cpu_disklabel	*at_cdl;
88 	u_int			at_hdsize;   /* size of volume in blocks   */
89 	u_int			at_nroots;   /* # of auxiliary root sectors */
90 	u_int			at_nparts;   /* # of AHDI partitions       */
91 	struct ahdi_part	at_parts[AHDI_MAXPARTS];
92 };
93 #define at_bblock	at_cdl->cd_bblock
94 #define at_label	at_cdl->cd_label
95 #define at_bslst	at_cdl->cd_bslst
96 #define at_bslend	at_cdl->cd_bslend
97 #define at_roots	at_cdl->cd_roots
98 #endif /* _KERNEL */
99 
100 #endif /* _MACHINE_AHDILABEL_H_ */
101