1/*	$NetBSD: ahdilbl.h,v 1.4 2009/10/20 19:10:11 snj 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 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef AHDILABEL_H
29#define AHDILABEL_H
30
31/***** from src/sys/arch/atari/include/disklabel.h *************************/
32
33/*
34 * On a volume, exclusively used by NetBSD, the boot block starts at
35 * sector 0. To allow shared use of a volume between two or more OS's
36 * the vendor specific AHDI format is supported. In this case the boot
37 * block is located at the start of an AHDI partition. In any case the
38 * size of the boot block must be at least 8KB.
39 */
40#define	BBMINSIZE	8192		/* minimum size of boot block      */
41#define	LABELSECTOR	0		/* `natural' start of boot block   */
42#define	LABELOFFSET	516		/* offset of disk label in bytes,
43					   relative to start of boot block */
44#define	LABELMAXSIZE	1020		/* maximum size of disk label      */
45
46#define	MAXPARTITIONS	16		/* max. # of NetBSD partitions     */
47#define	RAW_PART	2		/* xx?c is raw partition	   */
48
49#define	NO_BOOT_BLOCK	((u_int)-1)
50#define	MAXAUXROOTS	29		/* max. # of auxiliary root sectors */
51
52struct bootblock {
53	u_int8_t	bb_xxboot[LABELOFFSET - sizeof(u_int32_t)];
54						/* first-stage boot loader */
55	u_int32_t	bb_magic;		/* boot block magic number */
56#define	NBDAMAGIC	0x4e424441
57#define	AHDIMAGIC	0x41484449
58	u_int8_t	bb_label[LABELMAXSIZE];	/* disk pack label         */
59	u_int8_t	bb_bootxx[BBMINSIZE - (LABELOFFSET + LABELMAXSIZE)];
60						/* second-stage boot loader*/
61};
62
63#define BBGETLABEL(bb, dl)	memcpy((dl), (bb)->bb_label, sizeof (struct disklabel))
64#define BBSETLABEL(bb, dl)	memcpy((bb)->bb_label, (dl), sizeof (struct disklabel))
65
66/***** from src/sys/arch/atari/include/ahdilabel.h *************************/
67
68#define	AHDI_BSIZE	512		/* AHDI blocksize		*/
69#define	AHDI_BBLOCK	0		/* AHDI bootblock (root sector)	*/
70#define	AHDI_MAXROOTS	(MAXAUXROOTS)	/* max. # of AHDI rootsectors	*/
71#define	AHDI_MAXPARTS	(AHDI_MAXROOTS+3) /* max. # of AHDI partitions	*/
72
73/*
74 * Various `well known' AHDI partition identifiers.
75 */
76#define	AHDI_MKPID(x,y,z)	(   ((u_int32_t)(x) << 16)	\
77				  | ((u_int32_t)(y) << 8)	\
78				  | ((u_int32_t)(z))		\
79				)
80#define	AHDI_PID_XGM	AHDI_MKPID('X','G','M')
81#define	AHDI_PID_GEM	AHDI_MKPID('G','E','M')
82#define	AHDI_PID_BGM	AHDI_MKPID('B','G','M')
83#define	AHDI_PID_RAW	AHDI_MKPID('R','A','W')
84#define	AHDI_PID_SWP	AHDI_MKPID('S','W','P')
85#define	AHDI_PID_NBD	AHDI_MKPID('N','B','D')
86#define	AHDI_PID_NBR	AHDI_MKPID('N','B','R')
87#define	AHDI_PID_NBS	AHDI_MKPID('N','B','S')
88#define	AHDI_PID_NBU	AHDI_MKPID('N','B','U')
89
90/*
91 * Format of AHDI boot block.
92 */
93#define	AHDI_MAXRPD	4		/* max. # of partition descriptors */
94					/* in the AHDI bootblock (aka root)*/
95#define	AHDI_MAXARPD	2		/* max. # of partition descriptors */
96					/* in an AHDI auxiliary root sector */
97
98struct ahdi_part {
99	u_int8_t	ap_flg;		/* bit 0 is in-use flag            */
100	u_int8_t	ap_id[3];	/* id: GEM, BGM, XGM, UNX, MIX     */
101	u_int32_t	ap_offs;	/* block where partition starts    */
102	u_int32_t	ap_size;	/* partition size in blocks        */
103#define	ap_end	ap_size /* in the in-core copy, store end instead of size  */
104};
105
106struct ahdi_root {
107	u_int8_t	 ar_fill[0x1c2];/* filler, can be boot code        */
108	u_int32_t	 ar_hdsize;	/* size of entire volume in blocks */
109	struct ahdi_part ar_parts[AHDI_MAXRPD]; /* root partition table    */
110	u_int32_t	 ar_bslst;	/* start of bad-sector list        */
111	u_int32_t	 ar_bslsize;	/* # of blocks in bad-sector list  */
112	u_int16_t	 ar_cksum;
113};
114
115#endif /* AHDILABEL_H */
116