2
File: AppleDiskPartitions.p
4
Contains: The Apple disk partition scheme as defined in Inside Macintosh: Volume V.
6
Version: Technology: Mac OS 9
7
Release: Universal Interfaces 3.4.2
9
Copyright: � 2000-2002 by Apple Computer, Inc., all rights reserved
11
Bugs?: For bug reports, consult the following page on
14
http://www.freepascal.org/bugs.html
20
Modified for use with Free Pascal
22
Please report any bugs to <gpc@microbizz.nl>
31
unit AppleDiskPartitions;
33
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
34
{$setc GAP_INTERFACES_VERSION := $0210}
36
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
37
{$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
40
{$ifc defined CPUPOWERPC and defined CPUI386}
41
{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
43
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
44
{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
47
{$ifc not defined __ppc__ and defined CPUPOWERPC}
52
{$ifc not defined __i386__ and defined CPUI386}
58
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
59
{$error Conflicting definitions for __ppc__ and __i386__}
62
{$ifc defined __ppc__ and __ppc__}
63
{$setc TARGET_CPU_PPC := TRUE}
64
{$setc TARGET_CPU_X86 := FALSE}
65
{$elifc defined __i386__ and __i386__}
66
{$setc TARGET_CPU_PPC := FALSE}
67
{$setc TARGET_CPU_X86 := TRUE}
69
{$error Neither __ppc__ nor __i386__ is defined.}
71
{$setc TARGET_CPU_PPC_64 := FALSE}
73
{$ifc defined FPC_BIG_ENDIAN}
74
{$setc TARGET_RT_BIG_ENDIAN := TRUE}
75
{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
76
{$elifc defined FPC_LITTLE_ENDIAN}
77
{$setc TARGET_RT_BIG_ENDIAN := FALSE}
78
{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
80
{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
82
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
83
{$setc CALL_NOT_IN_CARBON := FALSE}
84
{$setc OLDROUTINENAMES := FALSE}
85
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
86
{$setc OPAQUE_UPP_TYPES := TRUE}
87
{$setc OTCARBONAPPLICATION := TRUE}
88
{$setc OTKERNEL := FALSE}
89
{$setc PM_USE_SESSION_APIS := TRUE}
90
{$setc TARGET_API_MAC_CARBON := TRUE}
91
{$setc TARGET_API_MAC_OS8 := FALSE}
92
{$setc TARGET_API_MAC_OSX := TRUE}
93
{$setc TARGET_CARBON := TRUE}
94
{$setc TARGET_CPU_68K := FALSE}
95
{$setc TARGET_CPU_MIPS := FALSE}
96
{$setc TARGET_CPU_SPARC := FALSE}
97
{$setc TARGET_OS_MAC := TRUE}
98
{$setc TARGET_OS_UNIX := FALSE}
99
{$setc TARGET_OS_WIN32 := FALSE}
100
{$setc TARGET_RT_MAC_68881 := FALSE}
101
{$setc TARGET_RT_MAC_CFM := FALSE}
102
{$setc TARGET_RT_MAC_MACHO := TRUE}
103
{$setc TYPED_FUNCTION_POINTERS := TRUE}
104
{$setc TYPE_BOOL := FALSE}
105
{$setc TYPE_EXTENDED := FALSE}
106
{$setc TYPE_LONGLONG := TRUE}
112
{ Block 0 Definitions }
115
sbSIGWord = $4552; { signature word for Block 0 ('ER') }
116
sbMac = 1; { system type for Mac }
118
{ Partition Map Signatures }
119
pMapSIG = $504D; { partition map signature ('PM') }
120
pdSigWord = $5453; { partition map signature ('TS') }
121
oldPMSigWord = $5453;
122
newPMSigWord = $504D;
125
{ Driver Descriptor Map }
129
Block0 = packed record
130
sbSig: UInt16; { unique value for SCSI block 0 }
131
sbBlkSize: UInt16; { block size of device }
132
sbBlkCount: UInt32; { number of blocks on device }
133
sbDevType: UInt16; { device type }
134
sbDevId: UInt16; { device id }
135
sbData: UInt32; { not used }
136
sbDrvrCount: UInt16; { driver descriptor count }
137
ddBlock: UInt32; { 1st driver's starting block }
138
ddSize: UInt16; { size of 1st driver (512-byte blks) }
139
ddType: UInt16; { system type (1 for Mac+) }
140
ddPad: array [0..242] of UInt16; { array[0..242] of SInt16; not used }
143
{ Driver descriptor }
146
ddBlock: UInt32; { 1st driver's starting block }
147
ddSize: UInt16; { size of 1st driver (512-byte blks) }
148
ddType: UInt16; { system type (1 for Mac+) }
151
{ Constants for the ddType field of the DDMap structure. }
154
kDriverTypeMacSCSI = $0001;
155
kDriverTypeMacATA = $0701;
156
kDriverTypeMacSCSIChained = $FFFF;
157
kDriverTypeMacATAChained = $F8FF;
159
{ Partition Map Entry }
162
PartitionPtr = ^Partition;
163
Partition = packed record
164
pmSig: UInt16; { unique value for map entry blk }
165
pmSigPad: UInt16; { currently unused }
166
pmMapBlkCnt: UInt32; { # of blks in partition map }
167
pmPyPartStart: UInt32; { physical start blk of partition }
168
pmPartBlkCnt: UInt32; { # of blks in this partition }
169
pmPartName: packed array [0..31] of UInt8; { ASCII partition name }
170
pmParType: packed array [0..31] of UInt8; { ASCII partition type }
171
pmLgDataStart: UInt32; { log. # of partition's 1st data blk }
172
pmDataCnt: UInt32; { # of blks in partition's data area }
173
pmPartStatus: UInt32; { bit field for partition status }
174
pmLgBootStart: UInt32; { log. blk of partition's boot code }
175
pmBootSize: UInt32; { number of bytes in boot code }
176
pmBootAddr: UInt32; { memory load address of boot code }
177
pmBootAddr2: UInt32; { currently unused }
178
pmBootEntry: UInt32; { entry point of boot code }
179
pmBootEntry2: UInt32; { currently unused }
180
pmBootCksum: UInt32; { checksum of boot code }
181
pmProcessor: packed array [0..15] of UInt8; { ASCII for the processor type }
182
pmPad: array [0..187] of UInt16; { array[0..187] of SInt16; not used }
186
{ Flags for the pmPartStatus field of the Partition data structure. }
189
kPartitionAUXIsValid = $00000001;
190
kPartitionAUXIsAllocated = $00000002;
191
kPartitionAUXIsInUse = $00000004;
192
kPartitionAUXIsBootValid = $00000008;
193
kPartitionAUXIsReadable = $00000010;
194
kPartitionAUXIsWriteable = $00000020;
195
kPartitionAUXIsBootCodePositionIndependent = $00000040;
196
kPartitionIsWriteable = $00000020;
197
kPartitionIsMountedAtStartup = $40000000;
198
kPartitionIsStartup = $80000000;
199
kPartitionIsChainCompatible = $00000100;
200
kPartitionIsRealDeviceDriver = $00000200;
201
kPartitionCanChainToNext = $00000400;
204
{ Well known driver signatures, stored in the first four byte of pmPad. }
205
kPatchDriverSignature = FourCharCode('ptDR'); { SCSI and ATA[PI] patch driver }
206
kSCSIDriverSignature = $00010600; { SCSI hard disk driver }
207
kATADriverSignature = FourCharCode('wiki'); { ATA hard disk driver }
208
kSCSICDDriverSignature = FourCharCode('CDvr'); { SCSI CD-ROM driver }
209
kATAPIDriverSignature = FourCharCode('ATPI'); { ATAPI CD-ROM driver }
210
kDriveSetupHFSSignature = FourCharCode('DSU1'); { Drive Setup HFS partition }