1 { 2 File: OSServices/AppleDiskPartitions.h 3 4 Contains: The Apple disk partition scheme as defined in Inside Macintosh: Volume V. 5 6 Version: OSServices-352~2 7 8 Copyright: � 2000-2008 by Apple Computer, Inc., all rights reserved 9 10 Bugs?: For bug reports, consult the following page on 11 the World Wide Web: 12 13 http://bugs.freepascal.org 14 15 } 16 { Translation Updated: Jonas Maebe, <jonas@freepascal.org>, October 2009 (only changes in C header were layout, so not updated since deprecated) } 17 { 18 Modified for use with Free Pascal 19 Version 308 20 Please report any bugs to <gpc@microbizz.nl> 21 } 22 23 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE} 24 {$mode macpas} 25 {$modeswitch cblocks} 26 {$packenum 1} 27 {$macro on} 28 {$inline on} 29 {$calling mwpascal} 30 31 unit AppleDiskPartitions; 32 interface 33 {$setc UNIVERSAL_INTERFACES_VERSION := $0400} 34 {$setc GAP_INTERFACES_VERSION := $0308} 35 36 {$ifc not defined USE_CFSTR_CONSTANT_MACROS} 37 {$setc USE_CFSTR_CONSTANT_MACROS := TRUE} 38 {$endc} 39 40 {$ifc defined CPUPOWERPC and defined CPUI386} 41 {$error Conflicting initial definitions for CPUPOWERPC and CPUI386} 42 {$endc} 43 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN} 44 {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN} 45 {$endc} 46 47 {$ifc not defined __ppc__ and defined CPUPOWERPC32} 48 {$setc __ppc__ := 1} 49 {$elsec} 50 {$setc __ppc__ := 0} 51 {$endc} 52 {$ifc not defined __ppc64__ and defined CPUPOWERPC64} 53 {$setc __ppc64__ := 1} 54 {$elsec} 55 {$setc __ppc64__ := 0} 56 {$endc} 57 {$ifc not defined __i386__ and defined CPUI386} 58 {$setc __i386__ := 1} 59 {$elsec} 60 {$setc __i386__ := 0} 61 {$endc} 62 {$ifc not defined __x86_64__ and defined CPUX86_64} 63 {$setc __x86_64__ := 1} 64 {$elsec} 65 {$setc __x86_64__ := 0} 66 {$endc} 67 {$ifc not defined __arm__ and defined CPUARM} 68 {$setc __arm__ := 1} 69 {$elsec} 70 {$setc __arm__ := 0} 71 {$endc} 72 {$ifc not defined __arm64__ and defined CPUAARCH64} 73 {$setc __arm64__ := 1} 74 {$elsec} 75 {$setc __arm64__ := 0} 76 {$endc} 77 78 {$ifc defined cpu64} 79 {$setc __LP64__ := 1} 80 {$elsec} 81 {$setc __LP64__ := 0} 82 {$endc} 83 84 85 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__} 86 {$error Conflicting definitions for __ppc__ and __i386__} 87 {$endc} 88 89 {$ifc defined __ppc__ and __ppc__} 90 {$setc TARGET_CPU_PPC := TRUE} 91 {$setc TARGET_CPU_PPC64 := FALSE} 92 {$setc TARGET_CPU_X86 := FALSE} 93 {$setc TARGET_CPU_X86_64 := FALSE} 94 {$setc TARGET_CPU_ARM := FALSE} 95 {$setc TARGET_CPU_ARM64 := FALSE} 96 {$setc TARGET_OS_MAC := TRUE} 97 {$setc TARGET_OS_IPHONE := FALSE} 98 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 99 {$setc TARGET_OS_EMBEDDED := FALSE} 100 {$elifc defined __ppc64__ and __ppc64__} 101 {$setc TARGET_CPU_PPC := FALSE} 102 {$setc TARGET_CPU_PPC64 := TRUE} 103 {$setc TARGET_CPU_X86 := FALSE} 104 {$setc TARGET_CPU_X86_64 := FALSE} 105 {$setc TARGET_CPU_ARM := FALSE} 106 {$setc TARGET_CPU_ARM64 := FALSE} 107 {$setc TARGET_OS_MAC := TRUE} 108 {$setc TARGET_OS_IPHONE := FALSE} 109 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 110 {$setc TARGET_OS_EMBEDDED := FALSE} 111 {$elifc defined __i386__ and __i386__} 112 {$setc TARGET_CPU_PPC := FALSE} 113 {$setc TARGET_CPU_PPC64 := FALSE} 114 {$setc TARGET_CPU_X86 := TRUE} 115 {$setc TARGET_CPU_X86_64 := FALSE} 116 {$setc TARGET_CPU_ARM := FALSE} 117 {$setc TARGET_CPU_ARM64 := FALSE} 118 {$ifc defined iphonesim} 119 {$setc TARGET_OS_MAC := FALSE} 120 {$setc TARGET_OS_IPHONE := TRUE} 121 {$setc TARGET_IPHONE_SIMULATOR := TRUE} 122 {$elsec} 123 {$setc TARGET_OS_MAC := TRUE} 124 {$setc TARGET_OS_IPHONE := FALSE} 125 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 126 {$endc} 127 {$setc TARGET_OS_EMBEDDED := FALSE} 128 {$elifc defined __x86_64__ and __x86_64__} 129 {$setc TARGET_CPU_PPC := FALSE} 130 {$setc TARGET_CPU_PPC64 := FALSE} 131 {$setc TARGET_CPU_X86 := FALSE} 132 {$setc TARGET_CPU_X86_64 := TRUE} 133 {$setc TARGET_CPU_ARM := FALSE} 134 {$setc TARGET_CPU_ARM64 := FALSE} 135 {$ifc defined iphonesim} 136 {$setc TARGET_OS_MAC := FALSE} 137 {$setc TARGET_OS_IPHONE := TRUE} 138 {$setc TARGET_IPHONE_SIMULATOR := TRUE} 139 {$elsec} 140 {$setc TARGET_OS_MAC := TRUE} 141 {$setc TARGET_OS_IPHONE := FALSE} 142 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 143 {$endc} 144 {$setc TARGET_OS_EMBEDDED := FALSE} 145 {$elifc defined __arm__ and __arm__} 146 {$setc TARGET_CPU_PPC := FALSE} 147 {$setc TARGET_CPU_PPC64 := FALSE} 148 {$setc TARGET_CPU_X86 := FALSE} 149 {$setc TARGET_CPU_X86_64 := FALSE} 150 {$setc TARGET_CPU_ARM := TRUE} 151 {$setc TARGET_CPU_ARM64 := FALSE} 152 {$setc TARGET_OS_MAC := FALSE} 153 {$setc TARGET_OS_IPHONE := TRUE} 154 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 155 {$setc TARGET_OS_EMBEDDED := TRUE} 156 {$elifc defined __arm64__ and __arm64__} 157 {$setc TARGET_CPU_PPC := FALSE} 158 {$setc TARGET_CPU_PPC64 := FALSE} 159 {$setc TARGET_CPU_X86 := FALSE} 160 {$setc TARGET_CPU_X86_64 := FALSE} 161 {$setc TARGET_CPU_ARM := FALSE} 162 {$setc TARGET_CPU_ARM64 := TRUE} 163 {$ifc defined ios} 164 {$setc TARGET_OS_MAC := FALSE} 165 {$setc TARGET_OS_IPHONE := TRUE} 166 {$setc TARGET_OS_EMBEDDED := TRUE} 167 {$elsec} 168 {$setc TARGET_OS_MAC := TRUE} 169 {$setc TARGET_OS_IPHONE := FALSE} 170 {$setc TARGET_OS_EMBEDDED := FALSE} 171 {$endc} 172 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 173 {$elsec} 174 {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.} 175 {$endc} 176 177 {$ifc defined __LP64__ and __LP64__ } 178 {$setc TARGET_CPU_64 := TRUE} 179 {$elsec} 180 {$setc TARGET_CPU_64 := FALSE} 181 {$endc} 182 183 {$ifc defined FPC_BIG_ENDIAN} 184 {$setc TARGET_RT_BIG_ENDIAN := TRUE} 185 {$setc TARGET_RT_LITTLE_ENDIAN := FALSE} 186 {$elifc defined FPC_LITTLE_ENDIAN} 187 {$setc TARGET_RT_BIG_ENDIAN := FALSE} 188 {$setc TARGET_RT_LITTLE_ENDIAN := TRUE} 189 {$elsec} 190 {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.} 191 {$endc} 192 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE} 193 {$setc CALL_NOT_IN_CARBON := FALSE} 194 {$setc OLDROUTINENAMES := FALSE} 195 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE} 196 {$setc OPAQUE_UPP_TYPES := TRUE} 197 {$setc OTCARBONAPPLICATION := TRUE} 198 {$setc OTKERNEL := FALSE} 199 {$setc PM_USE_SESSION_APIS := TRUE} 200 {$setc TARGET_API_MAC_CARBON := TRUE} 201 {$setc TARGET_API_MAC_OS8 := FALSE} 202 {$setc TARGET_API_MAC_OSX := TRUE} 203 {$setc TARGET_CARBON := TRUE} 204 {$setc TARGET_CPU_68K := FALSE} 205 {$setc TARGET_CPU_MIPS := FALSE} 206 {$setc TARGET_CPU_SPARC := FALSE} 207 {$setc TARGET_OS_UNIX := FALSE} 208 {$setc TARGET_OS_WIN32 := FALSE} 209 {$setc TARGET_RT_MAC_68881 := FALSE} 210 {$setc TARGET_RT_MAC_CFM := FALSE} 211 {$setc TARGET_RT_MAC_MACHO := TRUE} 212 {$setc TYPED_FUNCTION_POINTERS := TRUE} 213 {$setc TYPE_BOOL := FALSE} 214 {$setc TYPE_EXTENDED := FALSE} 215 {$setc TYPE_LONGLONG := TRUE} 216 uses MacTypes; 217 {$endc} {not MACOSALLINCLUDE} 218 219 220 {$ifc TARGET_OS_MAC} 221 222 // warning AppleDiskPartitions.h is no longer maintained. You should switch to IOApplePartitionScheme.h 223 224 {$ALIGN MAC68K} 225 226 { Block 0 Definitions } 227 228 const 229 sbSIGWord = $4552; { signature word for Block 0 ('ER') } 230 sbMac = 1; { system type for Mac } 231 232 { Partition Map Signatures } 233 pMapSIG = $504D; { partition map signature ('PM') } 234 pdSigWord = $5453; { partition map signature ('TS') } 235 oldPMSigWord = $5453; 236 newPMSigWord = $504D; 237 238 239 { Driver Descriptor Map } 240 241 type 242 Block0Ptr = ^Block0; 243 Block0 = packed record 244 sbSig: UInt16; { unique value for SCSI block 0 } 245 sbBlkSize: UInt16; { block size of device } 246 sbBlkCount: UInt32; { number of blocks on device } 247 sbDevType: UInt16; { device type } 248 sbDevId: UInt16; { device id } 249 sbData: UInt32; { not used } 250 sbDrvrCount: UInt16; { driver descriptor count } 251 ddBlock: UInt32; { 1st driver's starting block } 252 ddSize: UInt16; { size of 1st driver (512-byte blks) } 253 ddType: UInt16; { system type (1 for Mac+) } 254 ddPad: array [0..242] of UInt16; { array[0..242] of SInt16; not used } 255 end; 256 257 { Driver descriptor } 258 DDMapPtr = ^DDMap; 259 DDMap = record 260 ddBlock: UInt32; { 1st driver's starting block } 261 ddSize: UInt16; { size of 1st driver (512-byte blks) } 262 ddType: UInt16; { system type (1 for Mac+) } 263 end; 264 265 { Constants for the ddType field of the DDMap structure. } 266 267 const 268 kDriverTypeMacSCSI = $0001; 269 kDriverTypeMacATA = $0701; 270 kDriverTypeMacSCSIChained = $FFFF; 271 kDriverTypeMacATAChained = $F8FF; 272 273 { Partition Map Entry } 274 275 type 276 PartitionPtr = ^Partition; 277 Partition = packed record 278 pmSig: UInt16; { unique value for map entry blk } 279 pmSigPad: UInt16; { currently unused } 280 pmMapBlkCnt: UInt32; { # of blks in partition map } 281 pmPyPartStart: UInt32; { physical start blk of partition } 282 pmPartBlkCnt: UInt32; { # of blks in this partition } 283 pmPartName: packed array [0..31] of UInt8; { ASCII partition name } 284 pmParType: packed array [0..31] of UInt8; { ASCII partition type } 285 pmLgDataStart: UInt32; { log. # of partition's 1st data blk } 286 pmDataCnt: UInt32; { # of blks in partition's data area } 287 pmPartStatus: UInt32; { bit field for partition status } 288 pmLgBootStart: UInt32; { log. blk of partition's boot code } 289 pmBootSize: UInt32; { number of bytes in boot code } 290 pmBootAddr: UInt32; { memory load address of boot code } 291 pmBootAddr2: UInt32; { currently unused } 292 pmBootEntry: UInt32; { entry point of boot code } 293 pmBootEntry2: UInt32; { currently unused } 294 pmBootCksum: UInt32; { checksum of boot code } 295 pmProcessor: packed array [0..15] of UInt8; { ASCII for the processor type } 296 pmPad: array [0..187] of UInt16; { array[0..187] of SInt16; not used } 297 end; 298 299 300 { Flags for the pmPartStatus field of the Partition data structure. } 301 302 const 303 kPartitionAUXIsValid = $00000001; 304 kPartitionAUXIsAllocated = $00000002; 305 kPartitionAUXIsInUse = $00000004; 306 kPartitionAUXIsBootValid = $00000008; 307 kPartitionAUXIsReadable = $00000010; 308 kPartitionAUXIsWriteable = $00000020; 309 kPartitionAUXIsBootCodePositionIndependent = $00000040; 310 kPartitionIsWriteable = $00000020; 311 kPartitionIsMountedAtStartup = $40000000; 312 kPartitionIsStartup = $80000000; 313 kPartitionIsChainCompatible = $00000100; 314 kPartitionIsRealDeviceDriver = $00000200; 315 kPartitionCanChainToNext = $00000400; 316 317 318 { Well known driver signatures, stored in the first four byte of pmPad. } 319 kPatchDriverSignature = FourCharCode('ptDR'); { SCSI and ATA[PI] patch driver } 320 kSCSIDriverSignature = $00010600; { SCSI hard disk driver } 321 kATADriverSignature = FourCharCode('wiki'); { ATA hard disk driver } 322 kSCSICDDriverSignature = FourCharCode('CDvr'); { SCSI CD-ROM driver } 323 kATAPIDriverSignature = FourCharCode('ATPI'); { ATAPI CD-ROM driver } 324 kDriveSetupHFSSignature = FourCharCode('DSU1'); { Drive Setup HFS partition } 325 326 327 {$endc} {TARGET_OS_MAC} 328 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE} 329 330 end. 331 {$endc} {not MACOSALLINCLUDE} 332