DriverGestalt.pas 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. {
  2. File: DriverGestalt.p
  3. Contains: Driver Gestalt interfaces
  4. Version: Technology: Mac OS 9
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 1995-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 DriverGestalt;
  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,OSUtils,NameRegistry,SCSI,USB;
  92. {$ALIGN MAC68K}
  93. {__________________________________________________________________________________}
  94. { The Driver Gestalt bit in the dCtlFlags }
  95. const
  96. kbDriverGestaltEnable = 2;
  97. kmDriverGestaltEnableMask = $04;
  98. { __________________________________________________________________________________ }
  99. { Driver Gestalt related csCodes }
  100. kDriverGestaltCode = 43; { various uses }
  101. kDriverConfigureCode = 43; { various uses }
  102. kcsSetBootPartitionCode = 44; { Set Startup Partition Control Call }
  103. kcsGetBootPartitionStatus = 44; { Get Startup Partition Status Call }
  104. kdgLowPowerMode = 70; { Sets/Returns the current energy consumption level }
  105. kdgReturnDeviceID = 120; { returns SCSI DevID in csParam[0] }
  106. kdgGetCDDeviceInfo = 121; { returns CDDeviceCharacteristics in csParam[0] }
  107. { __________________________________________________________________________________ }
  108. { Driver Gestalt selectors }
  109. kdgVersion = $76657273 (* 'vers' *); { Version number of the driver in standard Apple format }
  110. kdgDeviceType = $64657674 (* 'devt' *); { The type of device the driver is driving. }
  111. kdgInterface = $696E7466 (* 'intf' *); { The underlying interface that the driver is using (if any) }
  112. kdgSync = $73796E63 (* 'sync' *); { True if driver only behaves synchronously. }
  113. kdgBoot = $626F6F74 (* 'boot' *); { value to place in PRAM for this drive (long) }
  114. kdgWide = $77696465 (* 'wide' *); { True if driver supports ioWPosOffset }
  115. kdgPurge = $70757267 (* 'purg' *); { Driver purge permission (True = purge; False = no purge) }
  116. kdgSupportsSwitching = $6C707772 (* 'lpwr' *); { True if driver supports power switching }
  117. kdgMin3VPower = $706D6E33 (* 'pmn3' *); { Minimum 3.3V power consumption in microWatts }
  118. kdgMin5VPower = $706D6E35 (* 'pmn5' *); { Minimum 5V power consumption in microWatts }
  119. kdgMax3VPower = $706D7833 (* 'pmx3' *); { Maximum 3.3V power consumption in microWatts }
  120. kdgMax5VPower = $706D7835 (* 'pmx5' *); { Maximum 5V power consumption in microWatts }
  121. kdgInHighPower = $70737461 (* 'psta' *); { True if device is currently in high power mode }
  122. kdgSupportsPowerCtl = $70737570 (* 'psup' *); { True if driver supports following five calls }
  123. kdgAPI = $64415049 (* 'dAPI' *); { API support for PC Exchange }
  124. kdgEject = $656A6563 (* 'ejec' *); { Eject options for shutdown/restart (Shutdown Mgr) }
  125. kdgFlush = $666C7573 (* 'flus' *); { Determine if disk driver supports flush and if it needs a flush }
  126. kdgVMOptions = $766D6F70 (* 'vmop' *); { Disk drive's Virtual Memory options }
  127. kdgMediaInfo = $6D696E66 (* 'minf' *); { return media specific information }
  128. kdgPhysDriveIconSuite = $64696373 (* 'dics' *); { Return a pointer to a IconFamily ('icns') data structure for }
  129. { Disk Driver physical drive (formerly in csCode 21) in driverGestaltResponse. }
  130. kdgMediaIconSuite = $6D696373 (* 'mics' *); { Return a pointer to a IconFamily ('icns') data structure for }
  131. { Disk Driver media (formerly in csCode 22) in driverGestaltResponse. }
  132. { See IconServices.r for information detailing the 'icns' resource data format }
  133. kdgMediaName = $6D6E616D (* 'mnam' *); { Return a pointer to a pascal string describing the Disk Driver (formerly in csCode 21) in driverGestaltResponse. }
  134. kdgGetDriveAddInfo = $64696774 (* 'digt' *); { Get a disk driver's add-drive information record }
  135. kdcAddDriveWithInfo = $64696164 (* 'diad' *); { Tell disk driver to add the drive specified with the drive information record }
  136. { DriverGestalt selector for ATA drivers to signify that they are device 0/1 compliant. }
  137. { see http://developer.apple.com/techpubs/hardware/Developer_Notes/System_Software/ATA_Device_Zero_One.pdf }
  138. kdgATADev1 = $64657631 (* 'dev1' *);
  139. kdgDeviceReference = $64767266 (* 'dvrf' *); { Returns a 32-bit reference number for the device, format is interface specific }
  140. kdgNameRegistryEntry = $6E6D7267 (* 'nmrg' *); { Returns a pointer to the Name Registry ID for the device }
  141. kdgDeviceModelInfo = $696E666F (* 'info' *); { Returns a pointer to a Device Model Info structure }
  142. kdgSupportedMediaTypes = $6D647479 (* 'mdty' *); { Returns a count and a pointer to list of all media types supported by the device }
  143. kdgOpenFirmwareBootSupport = $6F667074 (* 'ofpt' *); { Returns information that Open Firmware needs to support booting from the device }
  144. kdgOpenFirmwareBootingSupport = $6F666274 (* 'ofbt' *); { Returns same information as kdgOpenFirmwareBootSupport, but is only used during booting }
  145. { __________________________________________________________________________________ }
  146. { Driver Configure selectors }
  147. kdcFlush = $666C7573 (* 'flus' *); { Tell a disk driver to flush its cache and any hardware caches }
  148. kdcVMOptions = $766D6F70 (* 'vmop' *); { Change the disk driver's Virtual Memory options }
  149. { __________________________________________________________________________________ }
  150. { control parameter block for Driver Configure calls }
  151. type
  152. DriverConfigParamPtr = ^DriverConfigParam;
  153. DriverConfigParam = record
  154. qLink: QElemPtr;
  155. qType: SInt16;
  156. ioTrap: SInt16;
  157. ioCmdAddr: Ptr;
  158. ioCompletion: ProcPtr;
  159. ioResult: OSErr;
  160. ioNamePtr: StringPtr;
  161. ioVRefNum: SInt16;
  162. ioCRefNum: SInt16; { refNum for I/O operation }
  163. csCode: SInt16; { == kDriverConfigureCode }
  164. driverConfigureSelector: OSType;
  165. driverConfigureParameter: UInt32;
  166. end;
  167. { __________________________________________________________________________________ }
  168. { status parameter block for Driver Gestalt calls }
  169. DriverGestaltParamPtr = ^DriverGestaltParam;
  170. DriverGestaltParam = record
  171. qLink: QElemPtr;
  172. qType: SInt16;
  173. ioTrap: SInt16;
  174. ioCmdAddr: Ptr;
  175. ioCompletion: ProcPtr;
  176. ioResult: OSErr;
  177. ioNamePtr: StringPtr;
  178. ioVRefNum: SInt16;
  179. ioCRefNum: SInt16; { refNum for I/O operation }
  180. csCode: SInt16; { == kDriverGestaltCode }
  181. driverGestaltSelector: OSType; { 'sync', 'vers', etc. }
  182. driverGestaltResponse: UInt32; { Could be a pointer, bit field or other format }
  183. driverGestaltResponse1: UInt32; { Could be a pointer, bit field or other format }
  184. driverGestaltResponse2: UInt32; { Could be a pointer, bit field or other format }
  185. driverGestaltResponse3: UInt32; { Could be a pointer, bit field or other format }
  186. driverGestaltfiller: UInt16; { To pad out to the size of a controlPB }
  187. end;
  188. { __________________________________________________________________________________ }
  189. { Device Types response }
  190. DriverGestaltDevTResponsePtr = ^DriverGestaltDevTResponse;
  191. DriverGestaltDevTResponse = record
  192. deviceType: OSType;
  193. end;
  194. const
  195. kdgDiskType = $6469736B (* 'disk' *); { standard r/w disk drive }
  196. kdgTapeType = $74617065 (* 'tape' *); { tape drive }
  197. kdgPrinterType = $70726E74 (* 'prnt' *); { printer }
  198. kdgProcessorType = $70726F63 (* 'proc' *); { processor }
  199. kdgWormType = $776F726D (* 'worm' *); { write-once }
  200. kdgCDType = $6364726D (* 'cdrm' *); { cd-rom drive }
  201. kdgFloppyType = $666C6F70 (* 'flop' *); { floppy disk drive }
  202. kdgScannerType = $7363616E (* 'scan' *); { scanner }
  203. kdgFileType = $66696C65 (* 'file' *); { Logical Partition type based on a file (Drive Container) }
  204. kdgRemovableType = $7264736B (* 'rdsk' *); { A removable media hard disk drive ie. Syquest, Bernioulli }
  205. { __________________________________________________________________________________ }
  206. { Device Interfaces response }
  207. type
  208. DriverGestaltIntfResponsePtr = ^DriverGestaltIntfResponse;
  209. DriverGestaltIntfResponse = record
  210. interfaceType: OSType;
  211. end;
  212. const
  213. kdgScsiIntf = $73637369 (* 'scsi' *);
  214. kdgPcmciaIntf = $70636D63 (* 'pcmc' *);
  215. kdgATAIntf = $61746120 (* 'ata ' *);
  216. kdgUSBIntf = $75736220 (* 'usb ' *);
  217. kdgFireWireIntf = $66697265 (* 'fire' *);
  218. kdgExtBus = $63617264 (* 'card' *);
  219. kdgNetworkIntf = $6E657420 (* 'net ' *);
  220. { __________________________________________________________________________________ }
  221. { Power Saving }
  222. type
  223. DriverGestaltPowerResponsePtr = ^DriverGestaltPowerResponse;
  224. DriverGestaltPowerResponse = record
  225. powerValue: UInt32; { Power consumed in µWatts }
  226. end;
  227. { __________________________________________________________________________________ }
  228. { Disk Specific }
  229. DriverGestaltSyncResponsePtr = ^DriverGestaltSyncResponse;
  230. DriverGestaltSyncResponse = record
  231. behavesSynchronously: boolean;
  232. pad1,pad2,pad3: SInt8;
  233. end;
  234. DriverGestaltBootResponsePtr = ^DriverGestaltBootResponse;
  235. DriverGestaltBootResponse = record
  236. extDev: SInt8; { Packed target (upper 5 bits) LUN (lower 3 bits) }
  237. partition: SInt8; { Unused }
  238. SIMSlot: SInt8; { Slot }
  239. SIMsRSRC: SInt8; { sRsrcID }
  240. end;
  241. DriverGestaltAPIResponsePtr = ^DriverGestaltAPIResponse;
  242. DriverGestaltAPIResponse = record
  243. partitionCmds: SInt16; { if bit 0 is nonzero, supports partition control and status calls }
  244. { prohibitMounting (control, kProhibitMounting) }
  245. { partitionToVRef (status, kGetPartitionStatus) }
  246. { getPartitionInfo (status, kGetPartInfo) }
  247. unused1: SInt16; { all the unused fields should be zero }
  248. unused2: SInt16;
  249. unused3: SInt16;
  250. unused4: SInt16;
  251. unused5: SInt16;
  252. unused6: SInt16;
  253. unused7: SInt16;
  254. unused8: SInt16;
  255. unused9: SInt16;
  256. unused10: SInt16;
  257. end;
  258. DriverGestaltFlushResponsePtr = ^DriverGestaltFlushResponse;
  259. DriverGestaltFlushResponse = record
  260. canFlush: boolean; { Return true if driver supports the }
  261. { kdcFlush Driver Configure _Control call }
  262. needsFlush: boolean; { Return true if driver/device has data cached }
  263. { and needs to be flushed when the disk volume }
  264. { is flushed by the File Manager }
  265. pad: packed array [0..1] of UInt8;
  266. end;
  267. { Flags for purge permissions }
  268. const
  269. kbCloseOk = 0; { Ok to call Close }
  270. kbRemoveOk = 1; { Ok to call RemoveDrvr }
  271. kbPurgeOk = 2; { Ok to call DisposePtr }
  272. kmNoCloseNoPurge = 0;
  273. kmOkCloseNoPurge = $03;
  274. kmOkCloseOkPurge = $07;
  275. { Driver purge permission structure }
  276. type
  277. DriverGestaltPurgeResponsePtr = ^DriverGestaltPurgeResponse;
  278. DriverGestaltPurgeResponse = record
  279. purgePermission: UInt16; { 0 = Do not change the state of the driver }
  280. { 3 = Do Close() and DrvrRemove() this driver }
  281. { but don't deallocate driver code }
  282. { 7 = Do Close(), DrvrRemove(), and DisposePtr() }
  283. purgeReserved: UInt16;
  284. purgeDriverPointer: Ptr; { pointer to the start of the driver block (valid }
  285. { only of DisposePtr permission is given }
  286. end;
  287. DriverGestaltEjectResponsePtr = ^DriverGestaltEjectResponse;
  288. DriverGestaltEjectResponse = record
  289. ejectFeatures: UInt32; { }
  290. end;
  291. { Flags for Ejection Features field }
  292. const
  293. kRestartDontEject = 0; { Dont Want eject during Restart }
  294. kShutDownDontEject = 1; { Dont Want eject during Shutdown }
  295. kRestartDontEject_Mask = $01;
  296. kShutDownDontEject_Mask = $02;
  297. {
  298. The DriverGestaltVMOptionsResponse is returned by a disk driver in response to a
  299. kdgVMOptions Driver Gestalt request. This allows a disk driver to tell VM a few
  300. things about a disk drive. For example:
  301. ¥ A drive that should never be in the page fault path should return kAllowVMNoneMask.
  302. Examples of this are drives that have manual eject buttons that are not disabled by
  303. software, drives with very slow throughput, or drives that depend on
  304. a network connection.
  305. ¥ A drive that should never be written to but is safe for read-only file mapping
  306. should return kAllowVMReadOnlyMask. Examples of this are WORM drives where each write
  307. eats write-once space on the disk and CD-ROM drives which are read-only media.
  308. ¥ A drive that should allow VM to create its main backing store file should return
  309. kAllowVMReadWriteMask. Examples of this are fast read/write drives that don't allow
  310. manual eject and don't use a network connection.
  311. A disk driver must look at the ioVRefNum field of the DriverGestaltParam to determine
  312. what disk drive this call is for. This is a per-drive call, not a per-driver call.
  313. The only three valid responses to kdgVMOptions at this time are kAllowVMNoneMask,
  314. kAllowVMReadOnlyMask, and kAllowVMReadWriteMask (i.e., setting only kAllowVMWriteBit
  315. is not valid).
  316. Important: All bits not defined here are reserved and should be set to zero until
  317. they are defined for a specific purpose.
  318. The kdcVMOptions Driver Configure _Control call provides the ability to change a driver's
  319. response to kdgVMOptions Driver Gestalt requests. A driver should return controlErr if
  320. it doesn't want to provide the ability to change the kdgVMOptions response. If a driver
  321. supports the kdcVMOptions Driver Configure _Control call, but is asked to set an option bit
  322. that it doesn't support (for example, if a read-only device is asked to set the kAllowVMWriteBit),
  323. it should return paramErr.
  324. }
  325. type
  326. DriverGestaltVMOptionsResponsePtr = ^DriverGestaltVMOptionsResponse;
  327. DriverGestaltVMOptionsResponse = record
  328. vmOptions: UInt32;
  329. end;
  330. { Bits and masks for DriverGestaltVMOptionsResponse.vmOptions field }
  331. const
  332. kAllowVMReadBit = 0; { Allow VM to use this drive for read access }
  333. kAllowVMWriteBit = 1; { Allow VM to use this drive for write access }
  334. kAllowVMNoneMask = 0;
  335. kAllowVMReadOnlyMask = $01;
  336. kAllowVMReadWriteMask = $03;
  337. {
  338. kdgGetDriveAddInfo/kdcAddDriveWithInfo is used by the Alias Manager to
  339. assist in the remounting of container files. eg DiskCopy. The driver
  340. can use it to store whatever information it needs to remount a drive
  341. For example the Volume name and FileID.. What is in here is entirely
  342. dependant on the driver, we never interpret it.
  343. This extension to the Alias Manager works as such:
  344. When creating an alias
  345. ----------------------
  346. If driver supports Driver Gestalt, the Alias Mgr calls the driver with a
  347. kdgGetDriveAddInfo DriverGestalt request.
  348. Inputs to DriverGestalt:
  349. ioVRefNum = drive number
  350. ioCRefNum = driver refNum
  351. csCode = kDriverGestaltCode
  352. driverGestaltSelector = kdgGetDriveAddInfo
  353. If the driver supports kdgGetDriveAddInfo, it returns a pointer to the drive's
  354. drive information record (DriverGestaltDriveAddInfoResponse*) in the
  355. driverGestaltResponse field and returns noErr.
  356. The memory used by the DriverGestaltDriveAddInfoResponse and it's pointed
  357. to data, must be previously held by the disk driver with HoldMemory.
  358. If the driver doesn't support kdgGetDriveAddInfo, it returns statusErr.
  359. If noErr, the Alias Mgr stores the drive information record in the alias record
  360. (the length of the drive information record data is in the length field).
  361. When resolving an alias:
  362. ------------------------
  363. If driver supports Driver Gestalt, the Alias Mgr holds the drive information record
  364. in the alias with HoldMemory and then calls the driver with a kdcAddDriveWithInfo
  365. DriverConfigure request.
  366. Inputs to DriverConfigure:
  367. ioCRefNum = driver refNum
  368. csCode = kDriverConfigureCode
  369. driverGestaltSelector = pointer to DriverGestaltDriveAddInfoResponse
  370. If the driver supports kdcAddDriveWithInfo, it uses the information in the drive
  371. information record to add a drive to the drive queue. If the drive is added,
  372. the driver returns noErr and returns the drive number in the ioVRefNum field of
  373. the parameter block.
  374. If the drive cannot be added (but kdcAddDriveWithInfo is supported), the driver
  375. returns nsDrvErr.
  376. If the driver doesn't support kdcAddDriveWithInfo, it returns controlErr.
  377. If noErr is returned, but the data in the drive information record is not
  378. up-to-date, the driver should set driveInfoChangedBit in the options field of the
  379. drive information record.
  380. If driveInfoInteractBit in the options field is set at input, the driver
  381. may perform user interaction to mount the drive.
  382. If noErr, the Alias Mgr tries to resolve the alias the rest of the way.
  383. }
  384. { drive info option flags }
  385. driveInfoInteractBit = 31; { Input to kdcAddDriveWithInfo: If set, it's OK for the driver }
  386. driveInfoInteractMask = $80000000; { to perform user interaction to add the drive }
  387. driveInfoChangedBit = 30; { Output from kdgGetDriveInfo: If set, the drive was mounted, but }
  388. driveInfoChangedMask = $40000000; { the drive information record needs to be updated. }
  389. driveInfoDriverReservedMask = $0000FFFF; { bits 0-15 are defined by each driver for its own use }
  390. driveInfoSystemReservedMask = $FFFF0000; { bits 16-31 are reserved for Apple system use }
  391. type
  392. DriverGestaltDriveAddInfoResponsePtr = ^DriverGestaltDriveAddInfoResponse;
  393. DriverGestaltDriveAddInfoResponse = record
  394. options: OptionBits; { option flags. }
  395. length: ByteCount; { length of data }
  396. data: Ptr; { this data must be held with HoldMemory }
  397. end;
  398. {
  399. The DriverGestaltMediaInfoResponse is returned by a disk driver in response to a
  400. kdgMediaInfo DriverGestalt request. This allows a disk driver to tell callers the
  401. physical block size, the number of blocks that are of that size, and the media type
  402. for a given device.
  403. A disk driver must look at the ioVRefNum field of the DriverGestaltParam to determine
  404. what disk drive this call is for. This is a per-drive call, not a per-driver call.
  405. On drives that support ejectable media, the response can change depending on what
  406. media is currently in the drive.
  407. }
  408. DriverGestaltMediaInfoResponsePtr = ^DriverGestaltMediaInfoResponse;
  409. DriverGestaltMediaInfoResponse = record
  410. numberBlocks: UInt32; { number of blocks }
  411. blockSize: UInt32; { physical size of blocks }
  412. mediaType: SInt16; { media type identifier }
  413. end;
  414. { DriverGestaltMediaInfoResponse.mediaType constants }
  415. const
  416. kMediaTypeUnknown = 128; { media type is unknown }
  417. kMediaTypeCDROM = 129; { media type is a CD-ROM }
  418. kMediaTypeDVDROM = 130; { media type is a DVD-ROM }
  419. kMediaTypeDVDRAM = 131; { media type is a DVD-RAM }
  420. kMediaTypeDVDR = 132; { media type is a DVD-RW }
  421. kMediaTypeReadOnly = 133; { basic read only type }
  422. kMediaTypeWriteOnce = 134; { basic write once type }
  423. kMediaTypeRewritable = 135; { rewritable media, i.e CD-RW }
  424. kMediaTypeOverwritable = 136; { random access read write media }
  425. kMediaTypeNoMedia = -1; { no media is present }
  426. type
  427. DriverGestaltATADev1ResponsePtr = ^DriverGestaltATADev1Response;
  428. DriverGestaltATADev1Response = record
  429. dev1Support: UInt32; { 1 = supports devices 0 and 1 }
  430. end;
  431. { __________________________________________________________________________________ }
  432. { Device Reference }
  433. {
  434. The driver will return a 32-bit device reference number in the driverGestaltResponse
  435. field of the DriverGestaltParam structure. The device refernce number will be interpreted
  436. differently depending on the interface retrieved by using the 'intf' Driver Gestalt call.
  437. }
  438. { The union for the kdgDeviceReference Gestalt }
  439. DriverGestaltDeviceReferenceResponsePtr = ^DriverGestaltDeviceReferenceResponse;
  440. DriverGestaltDeviceReferenceResponse = record
  441. case SInt16 of
  442. 0: (
  443. devRef: UInt32; { Generic reference number for interfaces not specified }
  444. );
  445. 1: (
  446. scsiID: DeviceIdent; { kdgScsiIntf devices will return a DeviceIdent }
  447. );
  448. 2: (
  449. ataID: DeviceIdent; { kdgATAIntf devices will return a DeviceIdent }
  450. );
  451. 3: (
  452. usbRef: USBDeviceRef; { kdgUSBIntf devices will return a USBDeviceRef }
  453. );
  454. end;
  455. { __________________________________________________________________________________ }
  456. { Name Registry ID }
  457. {
  458. The driver will pass back in the driverGestaltResponse field of the DriverGestaltParam
  459. a pointer to the Name Registry Entry ID for the device that it controls
  460. }
  461. { The structure for the kdgNameRegistryEntry Gestalt }
  462. DriverGestaltNameRegistryResponsePtr = ^DriverGestaltNameRegistryResponse;
  463. DriverGestaltNameRegistryResponse = record
  464. entryID: RegEntryIDPtr;
  465. end;
  466. { __________________________________________________________________________________ }
  467. { Device Model Information }
  468. {
  469. The driver will pass a pointer to the DriverGestaltDeviceModelInfoResponse in the
  470. driverGestaltResponse field of the DriverGestaltParam structure
  471. The structure for the kdgDeviceModelInfo Gestalt
  472. If any of theses pointers are nil, that means that the device doesn't provide that information
  473. }
  474. DriverGestaltDeviceModelInfoResponsePtr = ^DriverGestaltDeviceModelInfoResponse;
  475. DriverGestaltDeviceModelInfoResponse = record
  476. infoStructVersion: UInt32;
  477. vendorName: StringPtr;
  478. productName: StringPtr;
  479. revisionNumber: StringPtr;
  480. subRevisionNumber: StringPtr;
  481. serialNumber: StringPtr;
  482. end;
  483. { infoStructVersion field values }
  484. { NOTE: May need/want to add a UniCode version of the InfoStruct at some point }
  485. const
  486. kInfoStructStringPtrsVers1 = 1;
  487. { __________________________________________________________________________________ }
  488. { Supported Media Types }
  489. {
  490. The driver will return the number of media types supported by the device in the
  491. driverGestaltResponse field of the DriverGestaltParam structure and an array of
  492. 'devt' values for the supported media types will be returned in the driverGestaltResponse1
  493. field of the DriverGestaltParam.
  494. This call will return the number of media types supported by the device, and an array
  495. of 'devt' values for the media types (i.e. if a device supports floppy disks
  496. and large capacity removables, the driver would return that 2 media types are supported,
  497. and the array would contain kdgFloppyType ('flop') and kdgRemovableType ('rdsk')).
  498. }
  499. { The structure for the kdgSupportedMediaTypes Gestalt }
  500. type
  501. DriverGestaltSupportedMediaTypesResponsePtr = ^DriverGestaltSupportedMediaTypesResponse;
  502. DriverGestaltSupportedMediaTypesResponse = record
  503. supportTypesCount: UInt32; { The number of Media Types in the array }
  504. supportedTypesArray: array [0..0] of OSType; { Array of supported media types }
  505. end;
  506. { __________________________________________________________________________________ }
  507. { Open Firmware Boot support and Open Firmware Booting support }
  508. {
  509. The kdgOpenFirmwareBootSupport selector is used to get information about boot support
  510. for the driver/device. The kdgOpenFirmwareBootingSupport is used during the boot
  511. process to allow booting from partitions that Open Firmware may not be able to read
  512. directly (i.e. Disk Array partitions, encrypted partitions, compressed partitions, etc..)
  513. The driver will return the bootPartitionQualifier value in the driverGestaltResponse
  514. field of the DriverGestaltParam and will return the exact partition map entry for
  515. the boot partition in the driverGestaltResponse1 field of the DriverGestaltParam if
  516. kOFBootSpecifiedPartition is returned in the driverGestaltResponse.
  517. The number that is returned for the bootPartitionMapEntry field if the kOFBootSpecifiedPartition
  518. is returned is the partition map entry number for the partition. (i.e. If the partition map entry
  519. for the boot partition is the 2nd partition entry in the partition map, the bootPartitionMapEntry
  520. field would be set to 2. If the partition map entry for the boot partition is the 3rd partition
  521. map, the bootPartitionMapEntry field would be set to 3 and etc.)
  522. }
  523. DriverGestaltOFBootSupportResponsePtr = ^DriverGestaltOFBootSupportResponse;
  524. DriverGestaltOFBootSupportResponse = record
  525. bootPartitionQualifier: UInt32; { The exact level of booting that the driver and device supports }
  526. bootPartitionMapEntry: UInt32; { The Partition Map entry for the boot partition if applicable }
  527. end;
  528. { Levels of boot support that the driver/device supports }
  529. { These values are used in the bootPartitionQualifier field of the DriverGestaltOFBootSupportResponse }
  530. const
  531. kOFBootAnyPartition = 1;
  532. kOFBootSpecifiedPartition = 2;
  533. kOFBootNotBootable = 3;
  534. kOFBootNotPartitioned = 4;
  535. { __________________________________________________________________________________ }
  536. { CD-ROM Specific }
  537. { The CDDeviceCharacteristics result is returned in csParam[0..2] of a
  538. standard CntrlParam parameter block called with csCode kdgGetCDDeviceInfo.
  539. }
  540. type
  541. CDDeviceCharacteristicsPtr = ^CDDeviceCharacteristics;
  542. CDDeviceCharacteristics = record
  543. speedMajor: SInt8; { High byte of fixed point number containing drive speed }
  544. speedMinor: SInt8; { Low byte of "" CD 300 == 2.2, CD_SC == 1.0 etc. }
  545. cdFeatures: UInt16; { Flags field for features and transport type of this CD-ROM }
  546. extendedCdFeatures: UInt16; { extended flags to support new DVD-ROM/DVD-R etc. }
  547. end;
  548. const
  549. cdFeatureFlagsMask = $FFFC; { The Flags are in the first 14 bits of the cdFeatures field }
  550. cdTransportMask = $0003; { The transport type is in the last 2 bits of the cdFeatures field }
  551. { Flags for cdFeatures field }
  552. cdPowerInject = 0; { device supports power inject of media }
  553. cdNotPowerEject = 1; { device does not support power eject of media }
  554. cdMute = 2; { device supports audio channels muting }
  555. cdLeftToChannel = 3; { device supports left channel only mono audio }
  556. cdRightToChannel = 4; { device supports right channel only mono audio }
  557. cdLeftPlusRight = 5; { device supports left + right channels mono audio }
  558. cdSCSI_2 = 10; { device supports SCSI2 command set (SCSI only) }
  559. cdStereoVolume = 11; { device supports independent volume per channel }
  560. cdDisconnect = 12; { device supports disconnect / reconnect (SCSI only) }
  561. cdWriteOnce = 13; { device is a write-once type of drive }
  562. cdLockableButton = 14; { device drawer/tray can be locked }
  563. cdExtendedFeatures = 15; { extendedCdFeatures field is used }
  564. cdPowerInject_Mask = $01;
  565. cdNotPowerEject_Mask = $02;
  566. cdMute_Mask = $04;
  567. cdLeftToChannel_Mask = $08;
  568. cdRightToChannel_Mask = $10;
  569. cdLeftPlusRight_Mask = $20;
  570. cdSCSI_2_Mask = $0400;
  571. cdStereoVolume_Mask = $0800;
  572. cdDisconnect_Mask = $1000;
  573. cdWriteOnce_Mask = $2000;
  574. cdLockableButton_Mask = $4000;
  575. cdExtendedFeatures_Mask = $8000;
  576. { Transport types }
  577. cdCaddy = 0; { CD_SC,CD_SC_PLUS,CD-300 etc. - power eject only }
  578. cdTray = $01; { CD_300_PLUS etc. - power inject only }
  579. cdLid = $02; { Power CD - no power inject/no power eject }
  580. {
  581. Flags for extendedCdFeatures field
  582. Only valid when cdExtendedFeatures_Mask bit of cdFeatures field is set
  583. }
  584. cdDVDROM = 0; { device reads DVD-ROM media }
  585. cdDVDR = 1; { device writes DVD-R media }
  586. cdDVDRAM = 2; { device writes DVD-RAM media }
  587. cdDVDAudio = 3; { device reads DVD-Audio media }
  588. cdDVDRW = 4; { device writes DVD-RW media }
  589. cdCDRom = 5; { device reads CD-ROM media }
  590. cdCDR = 6; { device writes CD-R media }
  591. cdCDRW = 7; { device writes CD-RW media }
  592. cdDVDROM_Mask = $01;
  593. cdDVDR_Mask = $02;
  594. cdDVDRAM_Mask = $04;
  595. cdDVDAudio_Mask = $08;
  596. cdDVDRW_Mask = $10;
  597. cdCDRom_Mask = $20;
  598. cdCDR_Mask = $40;
  599. cdCDRW_Mask = $80;
  600. { the following are used by PC Exchange (and Apple DOS/PC Compatibility Card) }
  601. { Control Codes }
  602. kRegisterPartition = 50; { PCX needs a new Drive (for a non-macintosh partition found on the disk) }
  603. OLD_REGISTER_PARTITION = 301; { left in for compatibility with shipping Apple DOS/PC Compatibility Card }
  604. THE_DRIVE = 0; { DrvQElPtr for the partition to register }
  605. THE_PHYS_START = 1; { The start of the partition in logical blocks }
  606. THE_PHYS_SIZE = 2; { The size of the partition in logical blocks }
  607. kGetADrive = 51; { control call to ask the driver to create a drive }
  608. OLD_GET_A_DRIVE = 302; { left in for compatibility with shipping Apple DOS/PC Compatibility Card }
  609. THE_VAR_QUEL = 0; { a var parameter for the returned DrvQElPtr }
  610. kProhibitMounting = 52; { Dont allow mounting of the following drives }
  611. kOldProhibitMounting = 2100; { left in for compatibility with shipping Apple DOS/PC Compatibility Card }
  612. kProhibitDevice = 0; { CS Param 0 and 1 (partInfoRecPtr) }
  613. kIsContainerMounted = 53;
  614. kOldIsContainerMounted = 2201; { left in for compatibility with shipping Apple DOS/PC Compatibility Card }
  615. kContainerVRef = 0; { CS Param 0 and 1 (VRefNum) }
  616. kContainerParID = 1; { CS Param 2 and 3 (Parent ID) }
  617. kContainerName = 2; { CS Param 4 and 5 (File Name) }
  618. kContainerResponse = 3; { CS Param 6 and 7 (var pointer to short result) }
  619. kMountVolumeImg = 54;
  620. OLD_MOUNT_VOLUME_IMG = 2000;
  621. MV_HOST_VREFNUM = 0;
  622. MV_HOST_PAR_ID = 1;
  623. MV_HOST_NAME = 2;
  624. MV_REQ_PERM = 3;
  625. { Status Codes }
  626. kGetPartitionStatus = 50; { what is the status of this partition? }
  627. kOldGetPartitionStatus = 2200; { left in for compatibility with shipping Apple DOS/PC Compatibility Card }
  628. kDeviceToQuery = 0; { CS Param 0 and 1 (partInfoRecPtr) }
  629. kDeviceResponse = 1; { CS Param 2 and 3 (var pointer to short result) }
  630. kGetPartInfo = 51; { Get a partition info record based on the provided vrefnum }
  631. kOldGetPartInfo = 2300; { left in for compatibility with shipping Apple DOS/PC Compatibility Card }
  632. kPartInfoResponse = 0; { var parameter (pointer to partInfoRec) CSParam [0-1] }
  633. kGetContainerAlias = 52; { Get the alias that describes the file this drive was mounted from. }
  634. kOldGetContainerAlias = 2400; { left in for compatibility with shipping Apple DOS/PC Compatibility Card }
  635. kGetAliasResponse = 0; { var parameter (pointer to a Handle) CSParam [0-1] }
  636. { the result codes to come from the driver interface }
  637. DRIVER_NOT_INSTALLED = -1;
  638. DRIVER_BUSY = -2;
  639. CANT_MOUNT_WITHIN_THIS_FS = -3; { can only mount container within residing on HFS volume }
  640. VOLUME_ALREADY_MOUNTED = -4; { Already Mounted }
  641. { requisite structures for PCX control and status calls }
  642. kMaxProhibted = 2; { the max number of volumes the PC can possibly have mounted }
  643. { GestaltSelector for Finding Driver information }
  644. kGetDriverInfo = $76647263 (* 'vdrc' *);
  645. { VerifyCmd, FormatCmd and EjectCmd are now defined in Disks.h/p/a }
  646. { Partition information passed back and forth between PCX and the driver }
  647. type
  648. partInfoRecPtr = ^partInfoRec;
  649. partInfoRec = record
  650. SCSIID: DeviceIdent; { DeviceIdent for the device }
  651. physPartitionLoc: UInt32; { physical block number of beginning of partition }
  652. partitionNumber: UInt32; { the partition number of this partition }
  653. end;
  654. vPartInfoRecPtr = ^vPartInfoRec;
  655. vPartInfoRec = record
  656. VPRTVers: SInt8; { Virtual partition version number }
  657. VPRTType: SInt8; { virtual partition type (DOS, HFS, etc) }
  658. drvrRefNum: SInt16; { Driver Reference number of partition driver }
  659. end;
  660. { Information related to DOS partitions }
  661. const
  662. kDOSSigLow = $01FE; { offset into boot block for DOS signature }
  663. kDOSSigHi = $01FF; { offset into boot block for DOS signature }
  664. kDOSSigValLo = $55; { DOS signature value in low byte }
  665. kDOSSigValHi = $AA; { DOS signature value in high byte }
  666. {$ALIGN MAC68K}
  667. end.