2 // dpme.h - Disk Partition Map Entry (dpme)
4 // Written by Eryk Vershen
6 // This file describes structures and values related to the standard
7 // Apple SCSI disk partitioning scheme.
9 // Each entry is (and shall remain) 512 bytes long.
11 // For more information see:
12 // "Inside Macintosh: Devices" pages 3-12 to 3-15.
13 // "Inside Macintosh - Volume V" pages V-576 to V-582
14 // "Inside Macintosh - Volume IV" page IV-292
16 // There is a kernel file with much of the same info (under different names):
17 // /usr/src/mklinux-1.0DR2/osfmk/src/mach_kernel/ppc/POWERMAC/mac_label.h
21 * Copyright 1996 by Apple Computer, Inc.
24 * Permission to use, copy, modify, and distribute this software and
25 * its documentation for any purpose and without fee is hereby granted,
26 * provided that the above copyright notice appears in all copies and
27 * that both the copyright notice and this permission notice appear in
28 * supporting documentation.
30 * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
31 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32 * FOR A PARTICULAR PURPOSE.
34 * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
35 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
36 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
37 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
38 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
48 #define BLOCK0_SIGNATURE 0x4552 /* i.e. 'ER' */
51 #define DPME_SIGNATURE 0x504D /* i.e. 'PM' */
53 // A/UX only stuff (tradition!)
54 #define dpme_bzb dpme_boot_args
55 #define BZBMAGIC 0xABADBABE /* BZB magic number */
56 #define FST ((u8) 0x1) /* standard UNIX FS */
57 #define FSTEFS ((u8) 0x2) /* Autorecovery FS */
58 #define FSTSFS ((u8) 0x3) /* Swap FS */
64 typedef unsigned char u8
;
65 typedef unsigned short u16
;
66 typedef unsigned long u32
;
69 // Physical block zero of the disk has this format
71 u16 sbSig
; /* unique value for SCSI block 0 */
72 u16 sbBlkSize
; /* block size of device */
73 u32 sbBlkCount
; /* number of blocks on device */
74 u16 sbDevType
; /* device type */
75 u16 sbDevId
; /* device id */
76 u32 sbData
; /* not used */
77 u16 sbDrvrCount
; /* driver descriptor count */
78 u16 sbMap
[247]; /* descriptor map */
80 typedef struct Block0 Block0
;
82 // Where &sbMap[0] is actually an array DDMap[sbDrvrCount]
83 // kludge to get around alignment junk
85 u32 ddBlock
; /* 1st driver's starting block (in sbBlkSize blocks!) */
86 u16 ddSize
; /* size of 1st driver (512-byte blks) */
87 u16 ddType
; /* system type (1 for Mac+) */
89 typedef struct DDMap DDMap
;
92 // Each partition map entry (blocks 1 through n) has this format
96 u32 dpme_map_entries
;
97 u32 dpme_pblock_start
;
99 char dpme_name
[DPISTRLEN
] ; /* name of partition */
100 char dpme_type
[DPISTRLEN
] ; /* type of partition */
101 u32 dpme_lblock_start
;
105 u32 dpme_reserved_2
: 23 ; /* Bit 9 through 31. */
106 u32 dpme_os_specific_1
: 1 ; /* Bit 8. */
107 u32 dpme_os_specific_2
: 1 ; /* Bit 7. */
108 u32 dpme_os_pic_code
: 1 ; /* Bit 6. */
109 u32 dpme_writable
: 1 ; /* Bit 5. */
110 u32 dpme_readable
: 1 ; /* Bit 4. */
111 u32 dpme_bootable
: 1 ; /* Bit 3. */
112 u32 dpme_in_use
: 1 ; /* Bit 2. */
113 u32 dpme_allocated
: 1 ; /* Bit 1. */
114 u32 dpme_valid
: 1 ; /* Bit 0. */
116 u32 dpme_boot_block
;
117 u32 dpme_boot_bytes
;
119 u8
*dpme_load_addr_2
;
121 u8
*dpme_goto_addr_2
;
123 char dpme_process_id
[16] ;
124 u32 dpme_boot_args
[32] ;
125 u32 dpme_reserved_3
[62] ;
127 typedef struct dpme DPME
;
129 #define dpme_diskdriver_set(p, v) bitfield_set(&p->dpme_flags, 9, 1, v)
130 #define dpme_chainable_set(p, v) bitfield_set(&p->dpme_flags, 8, 1, v)
132 #define dpme_os_specific_1_set(p, v) bitfield_set(&p->dpme_flags, 8, 1, v)
133 #define dpme_os_specific_2_set(p, v) bitfield_set(&p->dpme_flags, 7, 1, v)
134 #define dpme_os_pic_code_set(p, v) bitfield_set(&p->dpme_flags, 6, 1, v)
135 #define dpme_writable_set(p, v) bitfield_set(&p->dpme_flags, 5, 1, v)
136 #define dpme_readable_set(p, v) bitfield_set(&p->dpme_flags, 4, 1, v)
137 #define dpme_bootable_set(p, v) bitfield_set(&p->dpme_flags, 3, 1, v)
138 #define dpme_in_use_set(p, v) bitfield_set(&p->dpme_flags, 2, 1, v)
139 #define dpme_allocated_set(p, v) bitfield_set(&p->dpme_flags, 1, 1, v)
140 #define dpme_valid_set(p, v) bitfield_set(&p->dpme_flags, 0, 1, v)
142 #define dpme_diskdriver_get(p) bitfield_get(p->dpme_flags, 9, 1)
143 #define dpme_chainable_get(p) bitfield_get(p->dpme_flags, 8, 1)
145 #define dpme_os_specific_1_get(p) bitfield_get(p->dpme_flags, 8, 1)
146 #define dpme_os_specific_2_get(p) bitfield_get(p->dpme_flags, 7, 1)
147 #define dpme_os_pic_code_get(p) bitfield_get(p->dpme_flags, 6, 1)
148 #define dpme_writable_get(p) bitfield_get(p->dpme_flags, 5, 1)
149 #define dpme_readable_get(p) bitfield_get(p->dpme_flags, 4, 1)
150 #define dpme_bootable_get(p) bitfield_get(p->dpme_flags, 3, 1)
151 #define dpme_in_use_get(p) bitfield_get(p->dpme_flags, 2, 1)
152 #define dpme_allocated_get(p) bitfield_get(p->dpme_flags, 1, 1)
153 #define dpme_valid_get(p) bitfield_get(p->dpme_flags, 0, 1)
156 // A/UX only data structures (sentimental reasons?)
158 // Alternate block map (aka bad block remaping) [Never really used]
159 struct abm
/* altblk map info stored in bzb */
161 u32 abm_size
; /* size of map in bytes */
162 u32 abm_ents
; /* number of used entries */
163 u32 abm_start
; /* start of altblk map */
165 typedef struct abm ABM
;
167 // BZB (Block Zero Block, but I can't remember the etymology)
168 // Where &dpme_boot_args[0] is actually the address of a struct bzb
169 // kludge to get around alignment junk
170 struct bzb
/* block zero block format */
172 u32 bzb_magic
; /* magic number */
173 u8 bzb_cluster
; /* Autorecovery cluster grouping */
174 u8 bzb_type
; /* FS type */
175 u16 bzb_inode
; /* bad block inode number */
178 u16 bzb_root
:1, /* FS is a root FS */
179 bzb_usr
:1, /* FS is a usr FS */
180 bzb_crit
:1, /* FS is a critical FS */
181 bzb_rsrvd
:8, /* reserved for later use */
182 bzb_slice
:5; /* slice number to associate with plus one */
183 u16 bzb_filler
; /* pad bitfield to 32 bits */
185 u32 bzb_tmade
; /* time of FS creation */
186 u32 bzb_tmount
; /* time of last mount */
187 u32 bzb_tumount
; /* time of last umount */
188 ABM bzb_abm
; /* altblk map info */
189 u32 bzb_fill2
[7]; /* for expansion of ABM (ha!ha!) */
190 u8 bzb_mount_point
[64]; /* default mount point name */
192 typedef struct bzb BZB
;
194 #define bzb_root_set(p, v) bitfield_set(&p->bzb_flags, 31, 1, v)
195 #define bzb_usr_set(p, v) bitfield_set(&p->bzb_flags, 30, 1, v)
196 #define bzb_crit_set(p, v) bitfield_set(&p->bzb_flags, 29, 1, v)
197 #define bzb_slice_set(p, v) bitfield_set(&p->bzb_flags, 20, 5, v)
199 #define bzb_root_get(p) bitfield_get(p->bzb_flags, 31, 1)
200 #define bzb_usr_get(p) bitfield_get(p->bzb_flags, 30, 1)
201 #define bzb_crit_get(p) bitfield_get(p->bzb_flags, 29, 1)
202 #define bzb_slice_get(p) bitfield_get(p->bzb_flags, 20, 5)
216 // Forward declarations
219 #endif /* __dpme__ */