1 /* @(#)mac_label.h	1.3 04/03/01 joerg, Copyright 1997, 1998, 1999, 2000 James Pearson */
2 /*
3  *      Copyright (c) 1997, 1998, 1999, 2000 James Pearson
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; see the file COPYING.  If not, write to
17  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 /*
21  *	mac_label.h: defines Macintosh partition maps and label
22  *
23  *	Taken from "mkisofs 1.05 PLUS" by Andy Polyakov <appro@fy.chalmers.se>
24  *	(see http://fy.chalmers.se/~appro/mkisofs_plus.html for details)
25  *
26  *	Much of this is already defined in the libhfs code, but to keep
27  *	things simple we stick with these.
28  */
29 
30 #ifndef	_MAC_LABEL_H
31 #define	_MAC_LABEL_H
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #ifdef PREP_BOOT
38 struct fdiskPartition {
39 #define	prepPartType 0x41
40 #define	chrpPartType 0x96
41 	unsigned char	boot;		/* bootable flag; not used */
42 	unsigned char	CHSstart[3];	/* start CHS; not used */
43 	unsigned char	type;		/* Partition type, = 0x41 (PReP bootable) */
44 	unsigned char	CHSend[3];	/* end CHS; not used */
45 	unsigned char	startSect[4];	/* start sector (really start of boot image on CD */
46 	unsigned char	size[4];	/* size of partition (or boot image ;) ) */
47 };
48 typedef struct fdiskPartition fdiskPartition;
49 #endif
50 
51 /* Driver Descriptor Map */
52 #define	sbSigMagic	"ER"
53 struct MacLabel {
54 	unsigned char	sbSig[2];	/* unique value for SCSI block 0 */
55 	unsigned char	sbBlkSize[2];	/* block size of device */
56 	unsigned char	sbBlkCount[4];	/* number of blocks on device */
57 	unsigned char	sbDevType[2];	/* device type */
58 	unsigned char	sbDevId[2];	/* device id */
59 	unsigned char	sbData[4];	/* not used */
60 	unsigned char	sbDrvrCount[2];	/* driver descriptor count */
61 	unsigned char	ddBlock[4];	/* 1st driver's starting block */
62 	unsigned char	ddSize[2];	/* size of 1st driver (512-byte blks) */
63 	unsigned char	ddType[2];	/* system type (1 for Mac+) */
64 #ifndef PREP_BOOT
65 	unsigned char	ddPad[486];	/* ARRAY[0..242] OF INTEGER; not used */
66 #else
67 #define	fdiskMagic0 0x55
68 #define	fdiskMagic1 0xAA
69 	unsigned char   pad1[420];	/* not used */
70 	fdiskPartition	image[4];	/* heh heh heh, we can have up to 4 */
71 					/* different boot images */
72 	unsigned char	fdiskMagic[2];	/* PReP uses fdisk partition map */
73 #endif /* PREP_BOOT */
74 };
75 typedef struct MacLabel MacLabel;
76 
77 #define	IS_MAC_LABEL(d)		(((MacLabel*)(d))->sbSig[0] == 'E' && \
78 				((MacLabel*)(d))->sbSig[1] == 'R')
79 
80 /* Partition Map Entry */
81 #define	pmSigMagic	"PM"
82 
83 #define	pmPartType_1	"Apple_partition_map"
84 #define	pmPartName_11	"Apple"
85 
86 #define	pmPartType_2	"Apple_Driver"
87 #define	pmPartType_21	"Apple_Driver43"
88 
89 #define	pmPartType_3	"Apple_UNIX_SVR2"
90 #define	pmPartName_31	"A/UX Root"
91 #define	pmPartName_32	"A/UX Usr"
92 #define	pmPartName_33	"Random A/UX fs"
93 #define	pmPartName_34	"Swap"
94 
95 #define	pmPartType_4	"Apple_HFS"
96 #define	pmPartName_41	"MacOS"
97 
98 #define	pmPartType_5	"Apple_Free"
99 #define	pmPartName_51	"Extra"
100 
101 #define	PM2	2
102 #define	PM4	4
103 
104 struct MacPart {
105 	unsigned char	pmSig[2];	/* unique value for map entry blk */
106 	unsigned char	pmSigPad[2];	/* currently unused */
107 	unsigned char	pmMapBlkCnt[4];	/* # of blks in partition map */
108 	unsigned char	pmPyPartStart[4]; /* physical start blk of partition */
109 	unsigned char	pmPartBlkCnt[4];  /* # of blks in this partition */
110 	unsigned char	pmPartName[32];	  /* ASCII partition name */
111 	unsigned char	pmPartType[32];	  /* ASCII partition type */
112 	unsigned char	pmLgDataStart[4]; /* log. # of partition's 1st data blk */
113 	unsigned char	pmDataCnt[4];	  /* # of blks in partition's data area */
114 	unsigned char	pmPartStatus[4];  /* bit field for partition status */
115 	unsigned char	pmLgBootStart[4]; /* log. blk of partition's boot code */
116 	unsigned char	pmBootSize[4];	/* number of bytes in boot code */
117 	unsigned char	pmBootAddr[4];	/* memory load address of boot code */
118 	unsigned char	pmBootAddr2[4];	/* currently unused */
119 	unsigned char	pmBootEntry[4];	/* entry point of boot code */
120 	unsigned char	pmBootEntry2[4]; /* currently unused */
121 	unsigned char	pmBootCksum[4];	 /* checksum of boot code */
122 	unsigned char	pmProcessor[16]; /* ASCII for the processor type */
123 	unsigned char	pmPad[376];	 /* ARRAY[0..187] OF INTEGER; not used */
124 };
125 typedef struct MacPart MacPart;
126 
127 #define	IS_MAC_PART(d)		(((MacPart*)(d))->pmSig[0] == 'P' && \
128 				((MacPart*)(d))->pmSig[1] == 'M')
129 
130 #define	PM_STAT_VALID		0x01	/* Set if a valid partition map entry */
131 #define	PM_STAT_ALLOC		0x02	/* Set if partition is already allocated; clear if available */
132 #define	PM_STAT_INUSE		0x04	/* Set if partition is in use; may be cleared after a system reset */
133 #define	PM_STAT_BOOTABLE	0x08	/* Set if partition contains valid boot information */
134 #define	PM_STAT_READABLE	0x10	/* Set if partition allows reading */
135 #define	PM_STAT_WRITABLE	0x20	/* Set if partition allows writing */
136 #define	PM_STAT_BOOT_PIC	0x40	/* Set if boot code is position-independent */
137 #define	PM_STAT_UNUSED		0x80	/* Unused */
138 #define	PM_STAT_DEFAULT		PM_STAT_VALID|PM_STAT_ALLOC|PM_STAT_READABLE|PM_STAT_WRITABLE
139 
140 typedef struct {
141 	char *name;			/* Partition name */
142 	char *type;			/* Partition type */
143 	int   ntype;			/* Partition type (numeric) */
144 	int   start;			/* start extent (SECTOR_SIZE blocks) */
145 	int   size;			/* extents (SECTOR_SIZE blocks) */
146 } mac_partition_table;
147 
148 /* from libhfs */
149 #define	HFS_BB_SIGWORD		0x4c4b
150 
151 typedef struct deferred_write defer;
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #endif /* _MAC_LABEL_H */
158