AppleDiskPartitions.pas 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. {
  2. File: AppleDiskPartitions.p
  3. Contains: The Apple disk partition scheme as defined in Inside Macintosh: Volume V.
  4. Version: Technology: Mac OS 9
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 2000-2002 by Apple Computer, Inc., all rights reserved
  7. Bugs?: For bug reports, consult the following page on
  8. the World Wide Web:
  9. http://www.freepascal.org/bugs.html
  10. }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit AppleDiskPartitions;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes;
  92. {$ALIGN MAC68K}
  93. { Block 0 Definitions }
  94. const
  95. sbSIGWord = $4552; { signature word for Block 0 ('ER') }
  96. sbMac = 1; { system type for Mac }
  97. { Partition Map Signatures }
  98. pMapSIG = $504D; { partition map signature ('PM') }
  99. pdSigWord = $5453; { partition map signature ('TS') }
  100. oldPMSigWord = $5453;
  101. newPMSigWord = $504D;
  102. { Driver Descriptor Map }
  103. type
  104. Block0Ptr = ^Block0;
  105. Block0 = packed record
  106. sbSig: UInt16; { unique value for SCSI block 0 }
  107. sbBlkSize: UInt16; { block size of device }
  108. sbBlkCount: UInt32; { number of blocks on device }
  109. sbDevType: UInt16; { device type }
  110. sbDevId: UInt16; { device id }
  111. sbData: UInt32; { not used }
  112. sbDrvrCount: UInt16; { driver descriptor count }
  113. ddBlock: UInt32; { 1st driver's starting block }
  114. ddSize: UInt16; { size of 1st driver (512-byte blks) }
  115. ddType: UInt16; { system type (1 for Mac+) }
  116. ddPad: array [0..242] of UInt16; { array[0..242] of SInt16; not used }
  117. end;
  118. { Driver descriptor }
  119. DDMapPtr = ^DDMap;
  120. DDMap = record
  121. ddBlock: UInt32; { 1st driver's starting block }
  122. ddSize: UInt16; { size of 1st driver (512-byte blks) }
  123. ddType: UInt16; { system type (1 for Mac+) }
  124. end;
  125. { Constants for the ddType field of the DDMap structure. }
  126. const
  127. kDriverTypeMacSCSI = $0001;
  128. kDriverTypeMacATA = $0701;
  129. kDriverTypeMacSCSIChained = $FFFF;
  130. kDriverTypeMacATAChained = $F8FF;
  131. { Partition Map Entry }
  132. type
  133. PartitionPtr = ^Partition;
  134. Partition = packed record
  135. pmSig: UInt16; { unique value for map entry blk }
  136. pmSigPad: UInt16; { currently unused }
  137. pmMapBlkCnt: UInt32; { # of blks in partition map }
  138. pmPyPartStart: UInt32; { physical start blk of partition }
  139. pmPartBlkCnt: UInt32; { # of blks in this partition }
  140. pmPartName: packed array [0..31] of UInt8; { ASCII partition name }
  141. pmParType: packed array [0..31] of UInt8; { ASCII partition type }
  142. pmLgDataStart: UInt32; { log. # of partition's 1st data blk }
  143. pmDataCnt: UInt32; { # of blks in partition's data area }
  144. pmPartStatus: UInt32; { bit field for partition status }
  145. pmLgBootStart: UInt32; { log. blk of partition's boot code }
  146. pmBootSize: UInt32; { number of bytes in boot code }
  147. pmBootAddr: UInt32; { memory load address of boot code }
  148. pmBootAddr2: UInt32; { currently unused }
  149. pmBootEntry: UInt32; { entry point of boot code }
  150. pmBootEntry2: UInt32; { currently unused }
  151. pmBootCksum: UInt32; { checksum of boot code }
  152. pmProcessor: packed array [0..15] of UInt8; { ASCII for the processor type }
  153. pmPad: array [0..187] of UInt16; { array[0..187] of SInt16; not used }
  154. end;
  155. { Flags for the pmPartStatus field of the Partition data structure. }
  156. const
  157. kPartitionAUXIsValid = $00000001;
  158. kPartitionAUXIsAllocated = $00000002;
  159. kPartitionAUXIsInUse = $00000004;
  160. kPartitionAUXIsBootValid = $00000008;
  161. kPartitionAUXIsReadable = $00000010;
  162. kPartitionAUXIsWriteable = $00000020;
  163. kPartitionAUXIsBootCodePositionIndependent = $00000040;
  164. kPartitionIsWriteable = $00000020;
  165. kPartitionIsMountedAtStartup = $40000000;
  166. kPartitionIsStartup = $80000000;
  167. kPartitionIsChainCompatible = $00000100;
  168. kPartitionIsRealDeviceDriver = $00000200;
  169. kPartitionCanChainToNext = $00000400;
  170. { Well known driver signatures, stored in the first four byte of pmPad. }
  171. kPatchDriverSignature = $70744452 (* 'ptDR' *); { SCSI and ATA[PI] patch driver }
  172. kSCSIDriverSignature = $00010600; { SCSI hard disk driver }
  173. kATADriverSignature = $77696B69 (* 'wiki' *); { ATA hard disk driver }
  174. kSCSICDDriverSignature = $43447672 (* 'CDvr' *); { SCSI CD-ROM driver }
  175. kATAPIDriverSignature = $41545049 (* 'ATPI' *); { ATAPI CD-ROM driver }
  176. kDriveSetupHFSSignature = $44535531 (* 'DSU1' *); { Drive Setup HFS partition }
  177. {$ALIGN MAC68K}
  178. end.