USB.pas 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862
  1. {
  2. File: USB.p
  3. Contains: Public API for USB Services Library (and associated components)
  4. Version: Technology: USB 1.4
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 1998-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 USB;
  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,Files,NameRegistry,CodeFragments,Devices,MacErrors;
  92. {$ALIGN MAC68K}
  93. { ************* Constants ************* }
  94. const
  95. { Flags }
  96. kUSBTaskTimeFlag = 1;
  97. kUSBHubPower = 2;
  98. kUSBPowerReset = 4;
  99. kUSBHubReaddress = 8;
  100. kUSBAddressRequest = 16;
  101. kUSBReturnOnException = 32;
  102. kUSBNo5SecTimeout = 64;
  103. kUSBTimeout = 128;
  104. kUSBNoDataTimeout = 256;
  105. kUSBDebugAwareFlag = 512;
  106. kUSBResetDescriptorCache = 1024;
  107. kUSBHighSpeedFlag = 2048;
  108. kUSBDevZeroDetatch = 4096;
  109. kUSBLowSpeedFlag = 8192;
  110. kUSBTaskTimeSetAddressFlag = 16384;
  111. { Hub messages }
  112. kUSBHubPortResetRequest = 1;
  113. kUSBHubPortSuspendRequest = 2;
  114. kUSBHubPortStatusRequest = 3;
  115. kVendorID_AppleComputer = $05AC;
  116. { ************* types ************* }
  117. type
  118. USBReference = SInt32;
  119. USBReference_fix = USBReference; { used as field type when a record declaration contains a USBReference field identifier }
  120. USBDeviceRef = USBReference;
  121. USBDeviceRef_fix = USBDeviceRef; { used as field type when a record declaration contains a USBDeviceRef field identifier }
  122. USBDeviceRefPtr = ^USBDeviceRef;
  123. USBInterfaceRef = USBReference;
  124. USBPipeRef = USBReference;
  125. USBBusRef = USBReference;
  126. USBPipeState = UInt32;
  127. USBCount = UInt32;
  128. USBFlags = UInt32;
  129. USBFlags_fix = USBFlags; { used as field type when a record declaration contains a USBFlags field identifier }
  130. USBRequest = UInt8;
  131. USBDirection = UInt8;
  132. USBRqRecipient = UInt8;
  133. USBRqType = UInt8;
  134. USBRqIndex = UInt16;
  135. USBRqValue = UInt16;
  136. usbControlBitsPtr = ^usbControlBits;
  137. usbControlBits = record
  138. BMRequestType: SInt8;
  139. BRequest: SInt8;
  140. WValue: USBRqValue;
  141. WIndex: USBRqIndex;
  142. reserved4: UInt16;
  143. end;
  144. USBIsocFramePtr = ^USBIsocFrame;
  145. USBIsocFrame = record
  146. frStatus: OSStatus;
  147. frReqCount: UInt16;
  148. frActCount: UInt16;
  149. end;
  150. const
  151. kUSBMaxIsocFrameReqCount = 1023; { maximum size (bytes) of any one Isoc frame }
  152. type
  153. usbIsocBitsPtr = ^usbIsocBits;
  154. usbIsocBits = record
  155. FrameList: USBIsocFramePtr;
  156. NumFrames: UInt32;
  157. end;
  158. usbHubBitsPtr = ^usbHubBits;
  159. usbHubBits = record
  160. Request: UInt32;
  161. Spare: UInt32;
  162. end;
  163. USBPBPtr = ^USBPB;
  164. {$ifc TYPED_FUNCTION_POINTERS}
  165. USBCompletion = procedure(pb: USBPBPtr);
  166. USBCompletion_fix = USBCompletion; { used as field type when a record declaration contains a USBCompletion field identifier }
  167. {$elsec}
  168. USBCompletion = ProcPtr;
  169. USBCompletion_fix = USBCompletion; { used as field type when a record declaration contains a USBCompletion field identifier }
  170. {$endc}
  171. USBVariantBitsPtr = ^USBVariantBits;
  172. USBVariantBits = record
  173. case SInt16 of
  174. 0: (
  175. cntl: usbControlBits;
  176. );
  177. 1: (
  178. isoc: usbIsocBits;
  179. );
  180. 2: (
  181. hub: usbHubBits;
  182. );
  183. end;
  184. USBPB = packed record
  185. qlink: Ptr;
  186. qType: UInt16;
  187. pbLength: UInt16;
  188. pbVersion: UInt16;
  189. reserved1: UInt16;
  190. reserved2: UInt32;
  191. usbStatus: OSStatus;
  192. usbCompletion: USBCompletion_fix;
  193. usbRefcon: UInt32;
  194. usbReference: USBReference_fix;
  195. usbBuffer: Ptr;
  196. usbReqCount: USBCount;
  197. usbActCount: USBCount;
  198. usbFlags: USBFlags_fix;
  199. usb: USBVariantBits;
  200. usbFrame: UInt32;
  201. usbClassType: UInt8;
  202. usbSubclass: UInt8;
  203. usbProtocol: UInt8;
  204. usbOther: UInt8;
  205. reserved6: UInt32;
  206. reserved7: UInt16;
  207. reserved8: UInt16;
  208. end;
  209. uslReqPtr = ^uslReq;
  210. uslReq = record
  211. usbDirection: SInt8;
  212. usbType: SInt8;
  213. usbRecipient: SInt8;
  214. usbRequest: SInt8;
  215. end;
  216. const
  217. { BT 19Aug98, bump up to v1.10 for Isoc }
  218. kUSBCurrentPBVersion = $0100; { v1.00 }
  219. kUSBIsocPBVersion = $0109; { v1.10 }
  220. kUSBCurrentHubPB = $0109;
  221. kUSBNoCallBack = -1;
  222. type
  223. bcdUSB = UInt8;
  224. const
  225. kUSBControl = 0;
  226. kUSBIsoc = 1;
  227. kUSBBulk = 2;
  228. kUSBInterrupt = 3;
  229. kUSBAnyType = $FF;
  230. { endpoint type }
  231. kUSBOut = 0;
  232. kUSBIn = 1;
  233. kUSBNone = 2;
  234. kUSBAnyDirn = 3;
  235. { USBDirection }
  236. kUSBStandard = 0;
  237. kUSBClass = 1;
  238. kUSBVendor = 2;
  239. { USBRqType }
  240. kUSBDevice = 0;
  241. kUSBInterface = 1;
  242. kUSBEndpoint = 2;
  243. kUSBOther = 3;
  244. { USBRqRecipient }
  245. kUSBRqGetStatus = 0;
  246. kUSBRqClearFeature = 1;
  247. kUSBRqReserved1 = 2;
  248. kUSBRqSetFeature = 3;
  249. kUSBRqReserved2 = 4;
  250. kUSBRqSetAddress = 5;
  251. kUSBRqGetDescriptor = 6;
  252. kUSBRqSetDescriptor = 7;
  253. kUSBRqGetConfig = 8;
  254. kUSBRqSetConfig = 9;
  255. kUSBRqGetInterface = 10;
  256. kUSBRqSetInterface = 11;
  257. kUSBRqSyncFrame = 12;
  258. { USBRequest }
  259. kUSBDeviceDesc = 1;
  260. kUSBConfDesc = 2;
  261. kUSBStringDesc = 3;
  262. kUSBInterfaceDesc = 4;
  263. kUSBEndpointDesc = 5;
  264. kUSBHIDDesc = $21;
  265. kUSBReportDesc = $22;
  266. kUSBPhysicalDesc = $23;
  267. kUSBHUBDesc = $29;
  268. { descriptorType }
  269. kUSBFeatureDeviceRemoteWakeup = 1;
  270. kUSBFeatureEndpointStall = 0;
  271. { Feature selectors }
  272. kUSBActive = 0; { Pipe can accept new transactions }
  273. kUSBIdle = 1; { Pipe will not accept new transactions }
  274. kUSBStalled = 2; { An error occured on the pipe }
  275. kUSBSuspended = 4; { Device is suspended }
  276. kUSBNoBandwidth = 8; { (Isoc or Int) Pipe could not be initialised due to bandwidth constraint }
  277. kUSB100mAAvailable = 50;
  278. kUSB500mAAvailable = 250;
  279. kUSB100mA = 50;
  280. kUSBAtrBusPowered = $80;
  281. kUSBAtrSelfPowered = $40;
  282. kUSBAtrRemoteWakeup = $20;
  283. kUSBRel10 = $0100;
  284. kUSBRel11 = $0110;
  285. kUSBRel20 = $0200;
  286. kUSBDeviceDescriptorLength = $12;
  287. kUSBInterfaceDescriptorLength = $09;
  288. kUSBConfigDescriptorLength = $09;
  289. type
  290. USBDeviceDescriptorPtr = ^USBDeviceDescriptor;
  291. USBDeviceDescriptor = record
  292. length: SInt8;
  293. descType: SInt8;
  294. usbRel: UInt16;
  295. deviceClass: SInt8;
  296. deviceSubClass: SInt8;
  297. protocol: SInt8;
  298. maxPacketSize: SInt8;
  299. vendor: UInt16;
  300. product: UInt16;
  301. devRel: UInt16;
  302. manuIdx: SInt8;
  303. prodIdx: SInt8;
  304. serialIdx: SInt8;
  305. numConf: SInt8;
  306. end;
  307. USBDescriptorHeaderPtr = ^USBDescriptorHeader;
  308. USBDescriptorHeader = record
  309. length: SInt8;
  310. descriptorType: SInt8;
  311. end;
  312. USBConfigurationDescriptorPtr = ^USBConfigurationDescriptor;
  313. USBConfigurationDescriptor = packed record
  314. length: UInt8;
  315. descriptorType: UInt8;
  316. totalLength: UInt16;
  317. numInterfaces: UInt8;
  318. configValue: UInt8;
  319. configStrIndex: UInt8;
  320. attributes: UInt8;
  321. maxPower: UInt8;
  322. end;
  323. USBInterfaceDescriptorPtr = ^USBInterfaceDescriptor;
  324. USBInterfaceDescriptor = packed record
  325. length: UInt8;
  326. descriptorType: UInt8;
  327. interfaceNumber: UInt8;
  328. alternateSetting: UInt8;
  329. numEndpoints: UInt8;
  330. interfaceClass: UInt8;
  331. interfaceSubClass: UInt8;
  332. interfaceProtocol: UInt8;
  333. interfaceStrIndex: UInt8;
  334. end;
  335. USBEndPointDescriptorPtr = ^USBEndPointDescriptor;
  336. USBEndPointDescriptor = packed record
  337. length: UInt8;
  338. descriptorType: UInt8;
  339. endpointAddress: UInt8;
  340. attributes: UInt8;
  341. maxPacketSize: UInt16;
  342. interval: UInt8;
  343. end;
  344. USBHIDDescriptorPtr = ^USBHIDDescriptor;
  345. USBHIDDescriptor = packed record
  346. descLen: UInt8;
  347. descType: UInt8;
  348. descVersNum: UInt16;
  349. hidCountryCode: UInt8;
  350. hidNumDescriptors: UInt8;
  351. hidDescriptorType: UInt8;
  352. hidDescriptorLengthLo: UInt8; { can't make this a single 16bit value or the compiler will add a filler byte }
  353. hidDescriptorLengthHi: UInt8;
  354. end;
  355. USBHIDReportDescPtr = ^USBHIDReportDesc;
  356. USBHIDReportDesc = packed record
  357. hidDescriptorType: UInt8;
  358. hidDescriptorLengthLo: UInt8; { can't make this a single 16bit value or the compiler will add a filler byte }
  359. hidDescriptorLengthHi: UInt8;
  360. end;
  361. USBHubPortStatusPtr = ^USBHubPortStatus;
  362. USBHubPortStatus = record
  363. portFlags: UInt16; { Port status flags }
  364. portChangeFlags: UInt16; { Port changed flags }
  365. end;
  366. { ********* ProtoTypes *************** }
  367. { For dealing with endianisms }
  368. {$ifc CALL_NOT_IN_CARBON}
  369. {
  370. * HostToUSBWord()
  371. *
  372. * Availability:
  373. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  374. * CarbonLib: not available
  375. * Mac OS X: not available
  376. }
  377. function HostToUSBWord(value: UInt16): UInt16; external name '_HostToUSBWord';
  378. {
  379. * USBToHostWord()
  380. *
  381. * Availability:
  382. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  383. * CarbonLib: not available
  384. * Mac OS X: not available
  385. }
  386. function USBToHostWord(value: UInt16): UInt16; external name '_USBToHostWord';
  387. {
  388. * HostToUSBLong()
  389. *
  390. * Availability:
  391. * Non-Carbon CFM: in USBServicesLib 1.1 and later
  392. * CarbonLib: not available
  393. * Mac OS X: not available
  394. }
  395. function HostToUSBLong(value: UInt32): UInt32; external name '_HostToUSBLong';
  396. {
  397. * USBToHostLong()
  398. *
  399. * Availability:
  400. * Non-Carbon CFM: in USBServicesLib 1.1 and later
  401. * CarbonLib: not available
  402. * Mac OS X: not available
  403. }
  404. function USBToHostLong(value: UInt32): UInt32; external name '_USBToHostLong';
  405. { Main prototypes }
  406. { Transfer commands }
  407. {
  408. * USBDeviceRequest()
  409. *
  410. * Availability:
  411. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  412. * CarbonLib: not available
  413. * Mac OS X: not available
  414. }
  415. function USBDeviceRequest(var pb: USBPB): OSStatus; external name '_USBDeviceRequest';
  416. {
  417. * USBBulkWrite()
  418. *
  419. * Availability:
  420. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  421. * CarbonLib: not available
  422. * Mac OS X: not available
  423. }
  424. function USBBulkWrite(var pb: USBPB): OSStatus; external name '_USBBulkWrite';
  425. {
  426. * USBBulkRead()
  427. *
  428. * Availability:
  429. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  430. * CarbonLib: not available
  431. * Mac OS X: not available
  432. }
  433. function USBBulkRead(var pb: USBPB): OSStatus; external name '_USBBulkRead';
  434. {
  435. * USBIntRead()
  436. *
  437. * Availability:
  438. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  439. * CarbonLib: not available
  440. * Mac OS X: not available
  441. }
  442. function USBIntRead(var pb: USBPB): OSStatus; external name '_USBIntRead';
  443. {
  444. * USBIntWrite()
  445. *
  446. * Availability:
  447. * Non-Carbon CFM: in USBServicesLib 1.2 and later
  448. * CarbonLib: not available
  449. * Mac OS X: not available
  450. }
  451. function USBIntWrite(var pb: USBPB): OSStatus; external name '_USBIntWrite';
  452. {
  453. * USBIsocRead()
  454. *
  455. * Availability:
  456. * Non-Carbon CFM: in USBServicesLib 1.1 and later
  457. * CarbonLib: not available
  458. * Mac OS X: not available
  459. }
  460. function USBIsocRead(var pb: USBPB): OSStatus; external name '_USBIsocRead';
  461. {
  462. * USBIsocWrite()
  463. *
  464. * Availability:
  465. * Non-Carbon CFM: in USBServicesLib 1.1 and later
  466. * CarbonLib: not available
  467. * Mac OS X: not available
  468. }
  469. function USBIsocWrite(var pb: USBPB): OSStatus; external name '_USBIsocWrite';
  470. { Pipe state control }
  471. {
  472. * USBClearPipeStallByReference()
  473. *
  474. * Availability:
  475. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  476. * CarbonLib: not available
  477. * Mac OS X: not available
  478. }
  479. function USBClearPipeStallByReference(ref: USBPipeRef): OSStatus; external name '_USBClearPipeStallByReference';
  480. {
  481. * USBAbortPipeByReference()
  482. *
  483. * Availability:
  484. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  485. * CarbonLib: not available
  486. * Mac OS X: not available
  487. }
  488. function USBAbortPipeByReference(ref: USBReference): OSStatus; external name '_USBAbortPipeByReference';
  489. {
  490. * USBResetPipeByReference()
  491. *
  492. * Availability:
  493. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  494. * CarbonLib: not available
  495. * Mac OS X: not available
  496. }
  497. function USBResetPipeByReference(ref: USBReference): OSStatus; external name '_USBResetPipeByReference';
  498. {
  499. * USBSetPipeIdleByReference()
  500. *
  501. * Availability:
  502. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  503. * CarbonLib: not available
  504. * Mac OS X: not available
  505. }
  506. function USBSetPipeIdleByReference(ref: USBPipeRef): OSStatus; external name '_USBSetPipeIdleByReference';
  507. {
  508. * USBSetPipeActiveByReference()
  509. *
  510. * Availability:
  511. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  512. * CarbonLib: not available
  513. * Mac OS X: not available
  514. }
  515. function USBSetPipeActiveByReference(ref: USBPipeRef): OSStatus; external name '_USBSetPipeActiveByReference';
  516. {
  517. * USBClosePipeByReference()
  518. *
  519. * Availability:
  520. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  521. * CarbonLib: not available
  522. * Mac OS X: not available
  523. }
  524. function USBClosePipeByReference(ref: USBPipeRef): OSStatus; external name '_USBClosePipeByReference';
  525. {
  526. * USBGetPipeStatusByReference()
  527. *
  528. * Availability:
  529. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  530. * CarbonLib: not available
  531. * Mac OS X: not available
  532. }
  533. function USBGetPipeStatusByReference(ref: USBReference; var state: USBPipeState): OSStatus; external name '_USBGetPipeStatusByReference';
  534. { Configuration services }
  535. {
  536. * USBFindNextInterface()
  537. *
  538. * Availability:
  539. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  540. * CarbonLib: not available
  541. * Mac OS X: not available
  542. }
  543. function USBFindNextInterface(var pb: USBPB): OSStatus; external name '_USBFindNextInterface';
  544. {
  545. * USBOpenDevice()
  546. *
  547. * Availability:
  548. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  549. * CarbonLib: not available
  550. * Mac OS X: not available
  551. }
  552. function USBOpenDevice(var pb: USBPB): OSStatus; external name '_USBOpenDevice';
  553. {
  554. * USBSetConfiguration()
  555. *
  556. * Availability:
  557. * Non-Carbon CFM: in USBServicesLib 1.1 and later
  558. * CarbonLib: not available
  559. * Mac OS X: not available
  560. }
  561. function USBSetConfiguration(var pb: USBPB): OSStatus; external name '_USBSetConfiguration';
  562. {
  563. * USBNewInterfaceRef()
  564. *
  565. * Availability:
  566. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  567. * CarbonLib: not available
  568. * Mac OS X: not available
  569. }
  570. function USBNewInterfaceRef(var pb: USBPB): OSStatus; external name '_USBNewInterfaceRef';
  571. {
  572. * USBDisposeInterfaceRef()
  573. *
  574. * Availability:
  575. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  576. * CarbonLib: not available
  577. * Mac OS X: not available
  578. }
  579. function USBDisposeInterfaceRef(var pb: USBPB): OSStatus; external name '_USBDisposeInterfaceRef';
  580. {
  581. * USBConfigureInterface()
  582. *
  583. * Availability:
  584. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  585. * CarbonLib: not available
  586. * Mac OS X: not available
  587. }
  588. function USBConfigureInterface(var pb: USBPB): OSStatus; external name '_USBConfigureInterface';
  589. {
  590. * USBFindNextPipe()
  591. *
  592. * Availability:
  593. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  594. * CarbonLib: not available
  595. * Mac OS X: not available
  596. }
  597. function USBFindNextPipe(var pb: USBPB): OSStatus; external name '_USBFindNextPipe';
  598. {
  599. * USBSetPipePolicy()
  600. *
  601. * Availability:
  602. * Non-Carbon CFM: in USBServicesLib 1.4 and later
  603. * CarbonLib: not available
  604. * Mac OS X: not available
  605. }
  606. function USBSetPipePolicy(var pb: USBPB): OSStatus; external name '_USBSetPipePolicy';
  607. { Dealing with descriptors. }
  608. { Note most of this is temprorary }
  609. {
  610. * USBGetConfigurationDescriptor()
  611. *
  612. * Availability:
  613. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  614. * CarbonLib: not available
  615. * Mac OS X: not available
  616. }
  617. function USBGetConfigurationDescriptor(var pb: USBPB): OSStatus; external name '_USBGetConfigurationDescriptor';
  618. {
  619. * USBGetFullConfigurationDescriptor()
  620. *
  621. * Availability:
  622. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  623. * CarbonLib: not available
  624. * Mac OS X: not available
  625. }
  626. function USBGetFullConfigurationDescriptor(var pb: USBPB): OSStatus; external name '_USBGetFullConfigurationDescriptor';
  627. {
  628. * USBGetStringDescriptor()
  629. *
  630. * Availability:
  631. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  632. * CarbonLib: not available
  633. * Mac OS X: not available
  634. }
  635. function USBGetStringDescriptor(var pb: USBPB): OSStatus; external name '_USBGetStringDescriptor';
  636. {
  637. * USBFindNextEndpointDescriptorImmediate()
  638. *
  639. * Availability:
  640. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  641. * CarbonLib: not available
  642. * Mac OS X: not available
  643. }
  644. function USBFindNextEndpointDescriptorImmediate(var pb: USBPB): OSStatus; external name '_USBFindNextEndpointDescriptorImmediate';
  645. {
  646. * USBFindNextInterfaceDescriptorImmediate()
  647. *
  648. * Availability:
  649. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  650. * CarbonLib: not available
  651. * Mac OS X: not available
  652. }
  653. function USBFindNextInterfaceDescriptorImmediate(var pb: USBPB): OSStatus; external name '_USBFindNextInterfaceDescriptorImmediate';
  654. {
  655. * USBFindNextAssociatedDescriptor()
  656. *
  657. * Availability:
  658. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  659. * CarbonLib: not available
  660. * Mac OS X: not available
  661. }
  662. function USBFindNextAssociatedDescriptor(var pb: USBPB): OSStatus; external name '_USBFindNextAssociatedDescriptor';
  663. { Utility functions }
  664. {
  665. * USBResetDevice()
  666. *
  667. * Availability:
  668. * Non-Carbon CFM: in USBServicesLib 1.1 and later
  669. * CarbonLib: not available
  670. * Mac OS X: not available
  671. }
  672. function USBResetDevice(var pb: USBPB): OSStatus; external name '_USBResetDevice';
  673. {
  674. * USBPortStatus()
  675. *
  676. * Availability:
  677. * Non-Carbon CFM: in USBServicesLib 1.4 and later
  678. * CarbonLib: not available
  679. * Mac OS X: not available
  680. }
  681. function USBPortStatus(var pb: USBPB): OSStatus; external name '_USBPortStatus';
  682. {
  683. * USBSuspendDevice()
  684. *
  685. * Availability:
  686. * Non-Carbon CFM: in USBServicesLib 1.3 and later
  687. * CarbonLib: not available
  688. * Mac OS X: not available
  689. }
  690. function USBSuspendDevice(var pb: USBPB): OSStatus; external name '_USBSuspendDevice';
  691. {
  692. * USBResumeDeviceByReference()
  693. *
  694. * Availability:
  695. * Non-Carbon CFM: in USBServicesLib 1.3 and later
  696. * CarbonLib: not available
  697. * Mac OS X: not available
  698. }
  699. function USBResumeDeviceByReference(refIn: USBReference): OSStatus; external name '_USBResumeDeviceByReference';
  700. {
  701. * USBGetBandwidthAvailableByReference()
  702. *
  703. * Availability:
  704. * Non-Carbon CFM: in USBServicesLib 1.4 and later
  705. * CarbonLib: not available
  706. * Mac OS X: not available
  707. }
  708. function USBGetBandwidthAvailableByReference(ref: USBReference; var avail: UInt32): OSStatus; external name '_USBGetBandwidthAvailableByReference';
  709. {
  710. * USBGetFrameNumberImmediate()
  711. *
  712. * Availability:
  713. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  714. * CarbonLib: not available
  715. * Mac OS X: not available
  716. }
  717. function USBGetFrameNumberImmediate(var pb: USBPB): OSStatus; external name '_USBGetFrameNumberImmediate';
  718. {
  719. * USBDelay()
  720. *
  721. * Availability:
  722. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  723. * CarbonLib: not available
  724. * Mac OS X: not available
  725. }
  726. function USBDelay(var pb: USBPB): OSStatus; external name '_USBDelay';
  727. {
  728. * USBSAbortQueuesByReference()
  729. *
  730. * Availability:
  731. * Non-Carbon CFM: in USBServicesLib 1.3 and later
  732. * CarbonLib: not available
  733. * Mac OS X: not available
  734. }
  735. function USBSAbortQueuesByReference(ref: USBReference): OSStatus; external name '_USBSAbortQueuesByReference';
  736. {
  737. * USBAllocMem()
  738. *
  739. * Availability:
  740. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  741. * CarbonLib: not available
  742. * Mac OS X: not available
  743. }
  744. function USBAllocMem(var pb: USBPB): OSStatus; external name '_USBAllocMem';
  745. {
  746. * USBDeallocMem()
  747. *
  748. * Availability:
  749. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  750. * CarbonLib: not available
  751. * Mac OS X: not available
  752. }
  753. function USBDeallocMem(var pb: USBPB): OSStatus; external name '_USBDeallocMem';
  754. { Expert interface functions }
  755. {
  756. * USBExpertInstallInterfaceDriver()
  757. *
  758. * Availability:
  759. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  760. * CarbonLib: not available
  761. * Mac OS X: not available
  762. }
  763. function USBExpertInstallInterfaceDriver(ref: USBDeviceRef; desc: USBDeviceDescriptorPtr; interfacePtr: USBInterfaceDescriptorPtr; hubRef: USBReference; busPowerAvailable: UInt32): OSStatus; external name '_USBExpertInstallInterfaceDriver';
  764. {
  765. * USBExpertRemoveInterfaceDriver()
  766. *
  767. * Availability:
  768. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  769. * CarbonLib: not available
  770. * Mac OS X: not available
  771. }
  772. function USBExpertRemoveInterfaceDriver(ref: USBDeviceRef): OSStatus; external name '_USBExpertRemoveInterfaceDriver';
  773. {
  774. * USBExpertInstallDeviceDriver()
  775. *
  776. * Availability:
  777. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  778. * CarbonLib: not available
  779. * Mac OS X: not available
  780. }
  781. function USBExpertInstallDeviceDriver(ref: USBDeviceRef; desc: USBDeviceDescriptorPtr; hubRef: USBReference; port: UInt32; busPowerAvailable: UInt32): OSStatus; external name '_USBExpertInstallDeviceDriver';
  782. {
  783. * USBExpertRemoveDeviceDriver()
  784. *
  785. * Availability:
  786. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  787. * CarbonLib: not available
  788. * Mac OS X: not available
  789. }
  790. function USBExpertRemoveDeviceDriver(ref: USBDeviceRef): OSStatus; external name '_USBExpertRemoveDeviceDriver';
  791. {
  792. * USBExpertStatus()
  793. *
  794. * Availability:
  795. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  796. * CarbonLib: not available
  797. * Mac OS X: not available
  798. }
  799. function USBExpertStatus(ref: USBDeviceRef; pointer: UnivPtr; value: UInt32): OSStatus; external name '_USBExpertStatus';
  800. {
  801. * USBExpertFatalError()
  802. *
  803. * Availability:
  804. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  805. * CarbonLib: not available
  806. * Mac OS X: not available
  807. }
  808. function USBExpertFatalError(ref: USBDeviceRef; status: OSStatus; pointer: UnivPtr; value: UInt32): OSStatus; external name '_USBExpertFatalError';
  809. {
  810. * USBExpertNotify()
  811. *
  812. * Availability:
  813. * Non-Carbon CFM: in USBFamilyExpertLib 1.0 and later
  814. * CarbonLib: not available
  815. * Mac OS X: not available
  816. }
  817. function USBExpertNotify(note: UnivPtr): OSStatus; external name '_USBExpertNotify';
  818. {
  819. * USBExpertStatusLevel()
  820. *
  821. * Availability:
  822. * Non-Carbon CFM: in USBServicesLib 1.2 and later
  823. * CarbonLib: not available
  824. * Mac OS X: not available
  825. }
  826. function USBExpertStatusLevel(level: UInt32; ref: USBDeviceRef; status: StringPtr; value: UInt32): OSStatus; external name '_USBExpertStatusLevel';
  827. {
  828. * USBExpertGetStatusLevel()
  829. *
  830. * Availability:
  831. * Non-Carbon CFM: in USBServicesLib 1.3 and later
  832. * CarbonLib: not available
  833. * Mac OS X: not available
  834. }
  835. function USBExpertGetStatusLevel: UInt32; external name '_USBExpertGetStatusLevel';
  836. {
  837. * USBExpertSetStatusLevel()
  838. *
  839. * Availability:
  840. * Non-Carbon CFM: in USBServicesLib 1.3 and later
  841. * CarbonLib: not available
  842. * Mac OS X: not available
  843. }
  844. procedure USBExpertSetStatusLevel(level: UInt32); external name '_USBExpertSetStatusLevel';
  845. {
  846. * USBExpertSetDevicePowerStatus()
  847. *
  848. * Availability:
  849. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  850. * CarbonLib: not available
  851. * Mac OS X: not available
  852. }
  853. function USBExpertSetDevicePowerStatus(ref: USBDeviceRef; reserved1: UInt32; reserved2: UInt32; powerStatus: UInt32; busPowerAvailable: UInt32; busPowerNeeded: UInt32): OSStatus; external name '_USBExpertSetDevicePowerStatus';
  854. {$endc} {CALL_NOT_IN_CARBON}
  855. const
  856. kUSBDevicePower_PowerOK = 0;
  857. kUSBDevicePower_BusPowerInsufficient = 1;
  858. kUSBDevicePower_BusPowerNotAllFeatures = 2;
  859. kUSBDevicePower_SelfPowerInsufficient = 3;
  860. kUSBDevicePower_SelfPowerNotAllFeatures = 4;
  861. kUSBDevicePower_HubPortOk = 5;
  862. kUSBDevicePower_HubPortOverCurrent = 6;
  863. kUSBDevicePower_BusPoweredHubOnLowPowerPort = 7;
  864. kUSBDevicePower_BusPoweredHubToBusPoweredHub = 8;
  865. kUSBDevicePower_Reserved3 = 9;
  866. kUSBDevicePower_Reserved4 = 10;
  867. { For hubs only }
  868. {$ifc CALL_NOT_IN_CARBON}
  869. {
  870. * USBHubAddDevice()
  871. *
  872. * Availability:
  873. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  874. * CarbonLib: not available
  875. * Mac OS X: not available
  876. }
  877. function USBHubAddDevice(var pb: USBPB): OSStatus; external name '_USBHubAddDevice';
  878. {
  879. * USBHubConfigurePipeZero()
  880. *
  881. * Availability:
  882. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  883. * CarbonLib: not available
  884. * Mac OS X: not available
  885. }
  886. function USBHubConfigurePipeZero(var pb: USBPB): OSStatus; external name '_USBHubConfigurePipeZero';
  887. {
  888. * USBHubSetAddress()
  889. *
  890. * Availability:
  891. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  892. * CarbonLib: not available
  893. * Mac OS X: not available
  894. }
  895. function USBHubSetAddress(var pb: USBPB): OSStatus; external name '_USBHubSetAddress';
  896. {
  897. * USBHubDeviceRemoved()
  898. *
  899. * Availability:
  900. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  901. * CarbonLib: not available
  902. * Mac OS X: not available
  903. }
  904. function USBHubDeviceRemoved(var pb: USBPB): OSStatus; external name '_USBHubDeviceRemoved';
  905. {
  906. * USBMakeBMRequestType()
  907. *
  908. * Availability:
  909. * Non-Carbon CFM: in USBServicesLib 1.0 and later
  910. * CarbonLib: not available
  911. * Mac OS X: not available
  912. }
  913. function USBMakeBMRequestType(direction: ByteParameter; reqtype: ByteParameter; recipient: ByteParameter): ByteParameter; external name '_USBMakeBMRequestType';
  914. {
  915. * USBControlRequest()
  916. *
  917. * Availability:
  918. * Non-Carbon CFM: in USBServicesLib 1.2 and later
  919. * CarbonLib: not available
  920. * Mac OS X: not available
  921. }
  922. function USBControlRequest(var pb: USBPB): OSStatus; external name '_USBControlRequest';
  923. {$endc} {CALL_NOT_IN_CARBON}
  924. type
  925. USBLocationID = UInt32;
  926. const
  927. kUSBLocationNibbleFormat = 0; { Other values are reserved for future types (like when we have more than 16 ports per hub) }
  928. kNoDeviceRef = -1;
  929. { Status Level constants }
  930. {
  931. Level 1: Fatal errors
  932. Level 2: General errors that may or may not effect operation
  933. Level 3: General driver messages. The "AddStatus" call that drivers use comes through as a level 3. This is also the default level at boot time.
  934. Level 4: Important status messages from the Expert and USL.
  935. Level 5: General status messages from the Expert and USL.
  936. }
  937. kUSBStatusLevelFatal = 1;
  938. kUSBStatusLevelError = 2;
  939. kUSBStatusLevelClient = 3;
  940. kUSBStatusLevelGeneral = 4;
  941. kUSBStatusLevelVerbose = 5;
  942. { Expert Notification Types }
  943. type
  944. USBNotificationType = UInt8;
  945. const
  946. kNotifyAddDevice = $00;
  947. kNotifyRemoveDevice = $01;
  948. kNotifyAddInterface = $02;
  949. kNotifyRemoveInterface = $03;
  950. kNotifyGetDeviceDescriptor = $04;
  951. kNotifyGetInterfaceDescriptor = $05;
  952. kNotifyGetNextDeviceByClass = $06;
  953. kNotifyGetDriverConnectionID = $07;
  954. kNotifyInstallDeviceNotification = $08;
  955. kNotifyRemoveDeviceNotification = $09;
  956. kNotifyDeviceRefToBusRef = $0A;
  957. kNotifyDriverNotify = $0C;
  958. kNotifyParentNotify = $0D;
  959. kNotifyAnyEvent = $FF;
  960. kNotifyPowerState = $17;
  961. kNotifyStatus = $18;
  962. kNotifyFatalError = $19;
  963. kNotifyStatusLevel = $20;
  964. type
  965. USBDriverMessage = USBNotificationType;
  966. {
  967. USB Manager wildcard constants for USBGetNextDeviceByClass
  968. and USBInstallDeviceNotification.
  969. }
  970. USBManagerWildcard = UInt16;
  971. const
  972. kUSBAnyClass = $FFFF;
  973. kUSBAnySubClass = $FFFF;
  974. kUSBAnyProtocol = $FFFF;
  975. kUSBAnyVendor = $FFFF;
  976. kUSBAnyProduct = $FFFF;
  977. type
  978. ExpertNotificationDataPtr = ^ExpertNotificationData;
  979. ExpertNotificationData = record
  980. notification: SInt8;
  981. filler: SInt8; { unused due to 2-byte 68k alignment }
  982. deviceRef: USBDeviceRefPtr;
  983. busPowerAvailable: UInt32;
  984. data: Ptr;
  985. info1: UInt32;
  986. info2: UInt32;
  987. end;
  988. { Definition of function pointer passed in ExpertEntryProc }
  989. {$ifc TYPED_FUNCTION_POINTERS}
  990. ExpertNotificationProcPtr = function(pNotificationData: ExpertNotificationDataPtr): OSStatus;
  991. {$elsec}
  992. ExpertNotificationProcPtr = ProcPtr;
  993. {$endc}
  994. { Definition of expert's callback installation function }
  995. {$ifc TYPED_FUNCTION_POINTERS}
  996. ExpertEntryProcPtr = function(pExpertNotify: ExpertNotificationProcPtr): OSStatus;
  997. {$elsec}
  998. ExpertEntryProcPtr = ProcPtr;
  999. {$endc}
  1000. { Device Notification Callback Routine }
  1001. {$ifc TYPED_FUNCTION_POINTERS}
  1002. USBDeviceNotificationCallbackProcPtr = procedure(pb: UnivPtr);
  1003. {$elsec}
  1004. USBDeviceNotificationCallbackProcPtr = ProcPtr;
  1005. {$endc}
  1006. { Device Notification Parameter Block }
  1007. USBDeviceNotificationParameterBlockPtr = ^USBDeviceNotificationParameterBlock;
  1008. USBDeviceNotificationParameterBlock = record
  1009. pbLength: UInt16;
  1010. pbVersion: UInt16;
  1011. usbDeviceNotification: SInt8;
  1012. reserved1: SInt8; { needed because of 2-byte 68k alignment }
  1013. usbDeviceRef: USBDeviceRef_fix;
  1014. usbClass: UInt16;
  1015. usbSubClass: UInt16;
  1016. usbProtocol: UInt16;
  1017. usbVendor: UInt16;
  1018. usbProduct: UInt16;
  1019. result: OSStatus;
  1020. token: UInt32;
  1021. callback: USBDeviceNotificationCallbackProcPtr;
  1022. refcon: UInt32;
  1023. end;
  1024. { Definition of USBDriverNotificationCallback Routine }
  1025. {$ifc TYPED_FUNCTION_POINTERS}
  1026. USBDriverNotificationCallbackPtr = procedure(status: OSStatus; refcon: UInt32);
  1027. {$elsec}
  1028. USBDriverNotificationCallbackPtr = ProcPtr;
  1029. {$endc}
  1030. { Public Functions }
  1031. {$ifc CALL_NOT_IN_CARBON}
  1032. {
  1033. * USBGetVersion()
  1034. *
  1035. * Availability:
  1036. * Non-Carbon CFM: in USBServicesLib 1.3 and later
  1037. * CarbonLib: not available
  1038. * Mac OS X: not available
  1039. }
  1040. function USBGetVersion: UInt32; external name '_USBGetVersion';
  1041. {
  1042. * USBGetNextDeviceByClass()
  1043. *
  1044. * Availability:
  1045. * Non-Carbon CFM: in USBManagerLib 1.0 and later
  1046. * CarbonLib: not available
  1047. * Mac OS X: not available
  1048. }
  1049. function USBGetNextDeviceByClass(var deviceRef: USBDeviceRef; var connID: CFragConnectionID; theClass: UInt16; theSubClass: UInt16; theProtocol: UInt16): OSStatus; external name '_USBGetNextDeviceByClass';
  1050. {
  1051. * USBGetDeviceDescriptor()
  1052. *
  1053. * Availability:
  1054. * Non-Carbon CFM: in USBManagerLib 1.0 and later
  1055. * CarbonLib: not available
  1056. * Mac OS X: not available
  1057. }
  1058. function USBGetDeviceDescriptor(var deviceRef: USBDeviceRef; var deviceDescriptor: USBDeviceDescriptor; size: UInt32): OSStatus; external name '_USBGetDeviceDescriptor';
  1059. {
  1060. * USBGetInterfaceDescriptor()
  1061. *
  1062. * Availability:
  1063. * Non-Carbon CFM: in USBManagerLib 1.0 and later
  1064. * CarbonLib: not available
  1065. * Mac OS X: not available
  1066. }
  1067. function USBGetInterfaceDescriptor(var interfaceRef: USBInterfaceRef; var interfaceDescriptor: USBInterfaceDescriptor; size: UInt32): OSStatus; external name '_USBGetInterfaceDescriptor';
  1068. {
  1069. * USBGetDriverConnectionID()
  1070. *
  1071. * Availability:
  1072. * Non-Carbon CFM: in USBManagerLib 1.0 and later
  1073. * CarbonLib: not available
  1074. * Mac OS X: not available
  1075. }
  1076. function USBGetDriverConnectionID(var deviceRef: USBDeviceRef; var connID: CFragConnectionID): OSStatus; external name '_USBGetDriverConnectionID';
  1077. {
  1078. * USBInstallDeviceNotification()
  1079. *
  1080. * Availability:
  1081. * Non-Carbon CFM: in USBManagerLib 1.0 and later
  1082. * CarbonLib: not available
  1083. * Mac OS X: not available
  1084. }
  1085. procedure USBInstallDeviceNotification(var pb: USBDeviceNotificationParameterBlock); external name '_USBInstallDeviceNotification';
  1086. {
  1087. * USBRemoveDeviceNotification()
  1088. *
  1089. * Availability:
  1090. * Non-Carbon CFM: in USBManagerLib 1.0 and later
  1091. * CarbonLib: not available
  1092. * Mac OS X: not available
  1093. }
  1094. function USBRemoveDeviceNotification(token: UInt32): OSStatus; external name '_USBRemoveDeviceNotification';
  1095. {
  1096. * USBDeviceRefToBusRef()
  1097. *
  1098. * Availability:
  1099. * Non-Carbon CFM: in USBManagerLib 1.0 and later
  1100. * CarbonLib: not available
  1101. * Mac OS X: not available
  1102. }
  1103. function USBDeviceRefToBusRef(var deviceRef: USBDeviceRef; var busRef: USBBusRef): OSStatus; external name '_USBDeviceRefToBusRef';
  1104. {
  1105. * USBDriverNotify()
  1106. *
  1107. * Availability:
  1108. * Non-Carbon CFM: in USBManagerLib 1.1 and later
  1109. * CarbonLib: not available
  1110. * Mac OS X: not available
  1111. }
  1112. function USBDriverNotify(reference: USBReference; mesg: ByteParameter; refcon: UInt32; callback: USBDriverNotificationCallbackPtr): OSStatus; external name '_USBDriverNotify';
  1113. {
  1114. * USBExpertNotifyParent()
  1115. *
  1116. * Availability:
  1117. * Non-Carbon CFM: in USBManagerLib 1.1 and later
  1118. * CarbonLib: not available
  1119. * Mac OS X: not available
  1120. }
  1121. function USBExpertNotifyParent(reference: USBReference; pointer: UnivPtr): OSStatus; external name '_USBExpertNotifyParent';
  1122. {
  1123. * USBAddDriverForFSSpec()
  1124. *
  1125. * Availability:
  1126. * Non-Carbon CFM: in USBManagerLib 1.3 and later
  1127. * CarbonLib: not available
  1128. * Mac OS X: not available
  1129. }
  1130. function USBAddDriverForFSSpec(reference: USBReference; var fileSpec: FSSpec): OSStatus; external name '_USBAddDriverForFSSpec';
  1131. {
  1132. * USBAddShimFromDisk()
  1133. *
  1134. * Availability:
  1135. * Non-Carbon CFM: in USBManagerLib 1.4 and later
  1136. * CarbonLib: not available
  1137. * Mac OS X: not available
  1138. }
  1139. function USBAddShimFromDisk(var shimFilePtr: FSSpec): OSStatus; external name '_USBAddShimFromDisk';
  1140. {
  1141. * USBReferenceToRegEntry()
  1142. *
  1143. * Availability:
  1144. * Non-Carbon CFM: in USBManagerLib 1.4 and later
  1145. * CarbonLib: not available
  1146. * Mac OS X: not available
  1147. }
  1148. function USBReferenceToRegEntry(var parentEntry: RegEntryID; parentDeviceRef: USBDeviceRef): OSStatus; external name '_USBReferenceToRegEntry';
  1149. {
  1150. * USBConfigureADBShim()
  1151. *
  1152. * Availability:
  1153. * Non-Carbon CFM: in USBManagerLib 1.4 and later
  1154. * CarbonLib: not available
  1155. * Mac OS X: not available
  1156. }
  1157. function USBConfigureADBShim(inCommandID: UInt32; arg1: UnivPtr; arg2: UnivPtr): OSStatus; external name '_USBConfigureADBShim';
  1158. {$endc} {CALL_NOT_IN_CARBON}
  1159. type
  1160. {$ifc TYPED_FUNCTION_POINTERS}
  1161. HIDInterruptProcPtr = procedure(refcon: UInt32; theData: UnivPtr);
  1162. {$elsec}
  1163. HIDInterruptProcPtr = ProcPtr;
  1164. {$endc}
  1165. {$ifc TYPED_FUNCTION_POINTERS}
  1166. HIDNotificationProcPtr = procedure(refcon: UInt32; reportSize: UInt32; theReport: UnivPtr; theInterfaceRef: USBReference);
  1167. {$elsec}
  1168. HIDNotificationProcPtr = ProcPtr;
  1169. {$endc}
  1170. { HID Install Interrupt prototype }
  1171. {$ifc TYPED_FUNCTION_POINTERS}
  1172. USBHIDInstallInterruptProcPtr = function(pInterruptProc: HIDInterruptProcPtr; refcon: UInt32): OSStatus;
  1173. {$elsec}
  1174. USBHIDInstallInterruptProcPtr = ProcPtr;
  1175. {$endc}
  1176. { HID Poll Device prototype }
  1177. {$ifc TYPED_FUNCTION_POINTERS}
  1178. USBHIDPollDeviceProcPtr = function: OSStatus;
  1179. {$elsec}
  1180. USBHIDPollDeviceProcPtr = ProcPtr;
  1181. {$endc}
  1182. { HID Control Device prototype }
  1183. {$ifc TYPED_FUNCTION_POINTERS}
  1184. USBHIDControlDeviceProcPtr = function(theControlSelector: UInt32; theControlData: UnivPtr): OSStatus;
  1185. {$elsec}
  1186. USBHIDControlDeviceProcPtr = ProcPtr;
  1187. {$endc}
  1188. { HID Get Device Info prototype }
  1189. {$ifc TYPED_FUNCTION_POINTERS}
  1190. USBHIDGetDeviceInfoProcPtr = function(theInfoSelector: UInt32; theInfo: UnivPtr): OSStatus;
  1191. {$elsec}
  1192. USBHIDGetDeviceInfoProcPtr = ProcPtr;
  1193. {$endc}
  1194. { HID Enter Polled Mode prototype }
  1195. {$ifc TYPED_FUNCTION_POINTERS}
  1196. USBHIDEnterPolledModeProcPtr = function: OSStatus;
  1197. {$elsec}
  1198. USBHIDEnterPolledModeProcPtr = ProcPtr;
  1199. {$endc}
  1200. { HID Exit Polled Mode prototype }
  1201. {$ifc TYPED_FUNCTION_POINTERS}
  1202. USBHIDExitPolledModeProcPtr = function: OSStatus;
  1203. {$elsec}
  1204. USBHIDExitPolledModeProcPtr = ProcPtr;
  1205. {$endc}
  1206. { HID Install Notification prototype }
  1207. {$ifc TYPED_FUNCTION_POINTERS}
  1208. USBHIDInstallNotificationProcPtr = function(pNotificationProc: HIDNotificationProcPtr; refcon: UInt32): OSStatus;
  1209. {$elsec}
  1210. USBHIDInstallNotificationProcPtr = ProcPtr;
  1211. {$endc}
  1212. const
  1213. kHIDStandardDispatchVersion = 0;
  1214. kHIDReservedDispatchVersion = 1;
  1215. kHIDNotificationDispatchVersion = 2;
  1216. kHIDCurrentDispatchVersion = 2;
  1217. type
  1218. USBHIDRev2DispatchTablePtr = ^USBHIDRev2DispatchTable;
  1219. USBHIDRev2DispatchTable = record
  1220. hidDispatchVersion: UInt32;
  1221. pUSBHIDInstallInterrupt: USBHIDInstallInterruptProcPtr;
  1222. pUSBHIDPollDevice: USBHIDPollDeviceProcPtr;
  1223. pUSBHIDControlDevice: USBHIDControlDeviceProcPtr;
  1224. pUSBHIDGetDeviceInfo: USBHIDGetDeviceInfoProcPtr;
  1225. pUSBHIDEnterPolledMode: USBHIDEnterPolledModeProcPtr;
  1226. pUSBHIDExitPolledMode: USBHIDExitPolledModeProcPtr;
  1227. pUSBHIDInstallNotification: USBHIDInstallNotificationProcPtr;
  1228. end;
  1229. USBHIDModuleDispatchTablePtr = ^USBHIDModuleDispatchTable;
  1230. USBHIDModuleDispatchTable = record
  1231. hidDispatchVersion: UInt32;
  1232. pUSBHIDInstallInterrupt: USBHIDInstallInterruptProcPtr;
  1233. pUSBHIDPollDevice: USBHIDPollDeviceProcPtr;
  1234. pUSBHIDControlDevice: USBHIDControlDeviceProcPtr;
  1235. pUSBHIDGetDeviceInfo: USBHIDGetDeviceInfoProcPtr;
  1236. pUSBHIDEnterPolledMode: USBHIDEnterPolledModeProcPtr;
  1237. pUSBHIDExitPolledMode: USBHIDExitPolledModeProcPtr;
  1238. end;
  1239. { Prototypes Tue, Mar 17, 1998 4:54:30 PM }
  1240. {$ifc CALL_NOT_IN_CARBON}
  1241. {
  1242. * USBHIDInstallInterrupt()
  1243. *
  1244. * Availability:
  1245. * Non-Carbon CFM: not available
  1246. * CarbonLib: not available
  1247. * Mac OS X: not available
  1248. }
  1249. function USBHIDInstallInterrupt(HIDInterruptFunction: HIDInterruptProcPtr; refcon: UInt32): OSStatus; external name '_USBHIDInstallInterrupt';
  1250. {
  1251. * USBHIDPollDevice()
  1252. *
  1253. * Availability:
  1254. * Non-Carbon CFM: not available
  1255. * CarbonLib: not available
  1256. * Mac OS X: not available
  1257. }
  1258. function USBHIDPollDevice: OSStatus; external name '_USBHIDPollDevice';
  1259. {
  1260. * USBHIDControlDevice()
  1261. *
  1262. * Availability:
  1263. * Non-Carbon CFM: not available
  1264. * CarbonLib: not available
  1265. * Mac OS X: not available
  1266. }
  1267. function USBHIDControlDevice(theControlSelector: UInt32; theControlData: UnivPtr): OSStatus; external name '_USBHIDControlDevice';
  1268. {
  1269. * USBHIDGetDeviceInfo()
  1270. *
  1271. * Availability:
  1272. * Non-Carbon CFM: not available
  1273. * CarbonLib: not available
  1274. * Mac OS X: not available
  1275. }
  1276. function USBHIDGetDeviceInfo(theInfoSelector: UInt32; theInfo: UnivPtr): OSStatus; external name '_USBHIDGetDeviceInfo';
  1277. {
  1278. * USBHIDEnterPolledMode()
  1279. *
  1280. * Availability:
  1281. * Non-Carbon CFM: not available
  1282. * CarbonLib: not available
  1283. * Mac OS X: not available
  1284. }
  1285. function USBHIDEnterPolledMode: OSStatus; external name '_USBHIDEnterPolledMode';
  1286. {
  1287. * USBHIDExitPolledMode()
  1288. *
  1289. * Availability:
  1290. * Non-Carbon CFM: not available
  1291. * CarbonLib: not available
  1292. * Mac OS X: not available
  1293. }
  1294. function USBHIDExitPolledMode: OSStatus; external name '_USBHIDExitPolledMode';
  1295. {
  1296. * USBHIDInstallNotification()
  1297. *
  1298. * Availability:
  1299. * Non-Carbon CFM: not available
  1300. * CarbonLib: not available
  1301. * Mac OS X: not available
  1302. }
  1303. function USBHIDInstallNotification(HIDNotificationFunction: HIDNotificationProcPtr; refcon: UInt32): OSStatus; external name '_USBHIDInstallNotification';
  1304. {
  1305. * HIDNotification()
  1306. *
  1307. * Availability:
  1308. * Non-Carbon CFM: not available
  1309. * CarbonLib: not available
  1310. * Mac OS X: not available
  1311. }
  1312. procedure HIDNotification(devicetype: UInt32; var NewHIDData: UInt8; var OldHIDData: UInt8); external name '_HIDNotification';
  1313. {$endc} {CALL_NOT_IN_CARBON}
  1314. const
  1315. kHIDRqGetReport = 1;
  1316. kHIDRqGetIdle = 2;
  1317. kHIDRqGetProtocol = 3;
  1318. kHIDRqSetReport = 9;
  1319. kHIDRqSetIdle = 10;
  1320. kHIDRqSetProtocol = 11;
  1321. kHIDRtInputReport = 1;
  1322. kHIDRtOutputReport = 2;
  1323. kHIDRtFeatureReport = 3;
  1324. kHIDBootProtocolValue = 0;
  1325. kHIDReportProtocolValue = 1;
  1326. kHIDKeyboardInterfaceProtocol = 1;
  1327. kHIDMouseInterfaceProtocol = 2;
  1328. kHIDSetLEDStateByBits = 1;
  1329. kHIDSetLEDStateByBitMask = 1;
  1330. kHIDSetLEDStateByIDNumber = 2;
  1331. kHIDRemoveInterruptHandler = 3;
  1332. kHIDEnableDemoMode = 4;
  1333. kHIDDisableDemoMode = 5;
  1334. kHIDRemoveNotification = $1000;
  1335. kHIDGetLEDStateByBits = 1; { not supported in 1.0 of keyboard module }
  1336. kHIDGetLEDStateByBitMask = 1; { not supported in 1.0 of keyboard module }
  1337. kHIDGetLEDStateByIDNumber = 2;
  1338. kHIDGetDeviceCountryCode = 3; { not supported in 1.0 HID modules }
  1339. kHIDGetDeviceUnitsPerInch = 4; { only supported in mouse HID module }
  1340. kHIDGetInterruptHandler = 5;
  1341. kHIDGetCurrentKeys = 6; { only supported in keyboard HID module }
  1342. kHIDGetInterruptRefcon = 7;
  1343. kHIDGetVendorID = 8;
  1344. kHIDGetProductID = 9;
  1345. kNumLockLED = 0;
  1346. kCapsLockLED = 1;
  1347. kScrollLockLED = 2;
  1348. kComposeLED = 3;
  1349. kKanaLED = 4;
  1350. kNumLockLEDMask = $01;
  1351. kCapsLockLEDMask = $02;
  1352. kScrollLockLEDMask = $04;
  1353. kComposeLEDMask = $08;
  1354. kKanaLEDMask = $10;
  1355. kUSBCapsLockKey = $39;
  1356. kUSBNumLockKey = $53;
  1357. kUSBScrollLockKey = $47;
  1358. type
  1359. USBMouseDataPtr = ^USBMouseData;
  1360. USBMouseData = record
  1361. buttons: UInt16;
  1362. XDelta: SInt16;
  1363. YDelta: SInt16;
  1364. end;
  1365. USBKeyboardDataPtr = ^USBKeyboardData;
  1366. USBKeyboardData = record
  1367. keycount: UInt16;
  1368. usbkeycode: array [0..31] of UInt16;
  1369. end;
  1370. USBHIDDataPtr = ^USBHIDData;
  1371. USBHIDData = record
  1372. case SInt16 of
  1373. 0: (
  1374. kbd: USBKeyboardData;
  1375. );
  1376. 1: (
  1377. mouse: USBMouseData;
  1378. );
  1379. end;
  1380. {$ifc CALL_NOT_IN_CARBON}
  1381. {
  1382. * StartCompoundClassDriver()
  1383. *
  1384. * Availability:
  1385. * Non-Carbon CFM: not available
  1386. * CarbonLib: not available
  1387. * Mac OS X: not available
  1388. }
  1389. procedure StartCompoundClassDriver(device: USBDeviceRef; classID: UInt16; subClass: UInt16); external name '_StartCompoundClassDriver';
  1390. {$endc} {CALL_NOT_IN_CARBON}
  1391. const
  1392. kUSBCompositeClass = 0;
  1393. kUSBAudioClass = 1;
  1394. kUSBCommClass = 2;
  1395. kUSBHIDClass = 3;
  1396. kUSBDisplayClass = 4;
  1397. kUSBPrintingClass = 7;
  1398. kUSBMassStorageClass = 8;
  1399. kUSBHubClass = 9;
  1400. kUSBDataClass = 10;
  1401. kUSBVendorSpecificClass = $FF;
  1402. kUSBCompositeSubClass = 0;
  1403. kUSBHubSubClass = 1;
  1404. kUSBPrinterSubclass = 1;
  1405. kUSBVendorSpecificSubClass = $FF;
  1406. kUSBHIDInterfaceClass = $03;
  1407. kUSBNoInterfaceSubClass = $00;
  1408. kUSBBootInterfaceSubClass = $01;
  1409. kUSBNoInterfaceProtocol = $00;
  1410. kUSBKeyboardInterfaceProtocol = $01;
  1411. kUSBMouseInterfaceProtocol = $02;
  1412. kUSBVendorSpecificProtocol = $FF;
  1413. kUSBPrinterUnidirectionalProtocol = $01;
  1414. kUSBPrinterBidirectionalProtocol = $02;
  1415. kServiceCategoryUSB = $75736220 (* 'usb ' *); { USB }
  1416. kUSBDriverFileType = $6E647276 (* 'ndrv' *);
  1417. kUSBDriverRsrcType = $75736264 (* 'usbd' *);
  1418. kUSBShimRsrcType = $75736273 (* 'usbs' *);
  1419. kTheUSBDriverDescriptionSignature = $75736264 (* 'usbd' *);
  1420. kInitialUSBDriverDescriptor = 0;
  1421. type
  1422. USBDriverDescVersion = UInt32;
  1423. USBDriverDescVersion_fix = USBDriverDescVersion; { used as field type when a record declaration contains a USBDriverDescVersion field identifier }
  1424. { Driver Loading Options }
  1425. USBDriverLoadingOptions = UInt32;
  1426. USBDriverLoadingOptions_fix = USBDriverLoadingOptions; { used as field type when a record declaration contains a USBDriverLoadingOptions field identifier }
  1427. const
  1428. kUSBDoNotMatchGenericDevice = $00000001; { Driver's VendorID must match Device's VendorID }
  1429. kUSBDoNotMatchInterface = $00000002; { Do not load this driver as an interface driver. }
  1430. kUSBProtocolMustMatch = $00000004; { Do not load this driver if protocol field doesn't match. }
  1431. kUSBInterfaceMatchOnly = $00000008; { Only load this driver as an interface driver. }
  1432. kClassDriverPluginVersion = $00001100;
  1433. type
  1434. USBDeviceInfoPtr = ^USBDeviceInfo;
  1435. USBDeviceInfo = record
  1436. usbVendorID: UInt16; { USB Vendor ID }
  1437. usbProductID: UInt16; { USB Product ID. }
  1438. usbDeviceReleaseNumber: UInt16; { Release Number of Device }
  1439. usbDeviceProtocol: UInt16; { Protocol Info. }
  1440. end;
  1441. USBDeviceInfo_fix = USBDeviceInfo; { used as field type when a record declaration contains a USBDeviceInfo field identifier }
  1442. USBInterfaceInfoPtr = ^USBInterfaceInfo;
  1443. USBInterfaceInfo = record
  1444. usbConfigValue: SInt8; { Configuration Value }
  1445. usbInterfaceNum: SInt8; { Interface Number }
  1446. usbInterfaceClass: SInt8; { Interface Class }
  1447. usbInterfaceSubClass: SInt8; { Interface SubClass }
  1448. usbInterfaceProtocol: SInt8; { Interface Protocol }
  1449. pad: SInt8
  1450. end;
  1451. USBInterfaceInfo_fix = USBInterfaceInfo; { used as field type when a record declaration contains a USBInterfaceInfo field identifier }
  1452. USBDriverTypePtr = ^USBDriverType;
  1453. USBDriverType = record
  1454. nameInfoStr: Str31; { Driver's name when loading into the Name Registry. }
  1455. usbDriverClass: SInt8; { USB Class this driver belongs to. }
  1456. usbDriverSubClass: SInt8; { Module type }
  1457. usbDriverVersion: NumVersion; { Class driver version number. }
  1458. end;
  1459. USBDriverType_fix = USBDriverType; { used as field type when a record declaration contains a USBDriverType field identifier }
  1460. USBDriverDescriptionPtr = ^USBDriverDescription;
  1461. USBDriverDescription = record
  1462. usbDriverDescSignature: OSType; { Signature field of this structure. }
  1463. usbDriverDescVersion: USBDriverDescVersion_fix; { Version of this data structure. }
  1464. usbDeviceInfo: USBDeviceInfo_fix; { Product & Vendor Info }
  1465. usbInterfaceInfo: USBInterfaceInfo_fix; { Interface info }
  1466. usbDriverType: USBDriverType_fix; { Driver Info. }
  1467. usbDriverLoadingOptions: USBDriverLoadingOptions_fix; { Options for class driver loading. }
  1468. end;
  1469. {
  1470. Dispatch Table
  1471. Definition of class driver's HW Validation proc.
  1472. }
  1473. {$ifc TYPED_FUNCTION_POINTERS}
  1474. USBDValidateHWProcPtr = function(device: USBDeviceRef; pDesc: USBDeviceDescriptorPtr): OSStatus;
  1475. {$elsec}
  1476. USBDValidateHWProcPtr = ProcPtr;
  1477. {$endc}
  1478. {
  1479. Definition of class driver's device initialization proc.
  1480. Called if the driver is being loaded for a device
  1481. }
  1482. {$ifc TYPED_FUNCTION_POINTERS}
  1483. USBDInitializeDeviceProcPtr = function(device: USBDeviceRef; pDesc: USBDeviceDescriptorPtr; busPowerAvailable: UInt32): OSStatus;
  1484. {$elsec}
  1485. USBDInitializeDeviceProcPtr = ProcPtr;
  1486. {$endc}
  1487. { Definition of class driver's interface initialization proc. }
  1488. {$ifc TYPED_FUNCTION_POINTERS}
  1489. USBDInitializeInterfaceProcPtr = function(interfaceNum: UInt32; pInterface: USBInterfaceDescriptorPtr; pDevice: USBDeviceDescriptorPtr; interfaceRef: USBInterfaceRef): OSStatus;
  1490. {$elsec}
  1491. USBDInitializeInterfaceProcPtr = ProcPtr;
  1492. {$endc}
  1493. { Definition of class driver's finalization proc. }
  1494. {$ifc TYPED_FUNCTION_POINTERS}
  1495. USBDFinalizeProcPtr = function(device: USBDeviceRef; pDesc: USBDeviceDescriptorPtr): OSStatus;
  1496. {$elsec}
  1497. USBDFinalizeProcPtr = ProcPtr;
  1498. {$endc}
  1499. USBDriverNotification = UInt32;
  1500. const
  1501. kNotifySystemSleepRequest = $00000001;
  1502. kNotifySystemSleepDemand = $00000002;
  1503. kNotifySystemSleepWakeUp = $00000003;
  1504. kNotifySystemSleepRevoke = $00000004;
  1505. kNotifyHubEnumQuery = $00000006;
  1506. kNotifyChildMessage = $00000007;
  1507. kNotifyExpertTerminating = $00000008;
  1508. kNotifyDriverBeingRemoved = $0000000B;
  1509. kNotifyAllowROMDriverRemoval = $0000000E;
  1510. {
  1511. Definition of driver's notification proc.
  1512. Added refcon for 1.1 version of dispatch table
  1513. }
  1514. type
  1515. {$ifc TYPED_FUNCTION_POINTERS}
  1516. USBDDriverNotifyProcPtr = function(notification: USBDriverNotification; pointer: UnivPtr; refcon: UInt32): OSStatus;
  1517. {$elsec}
  1518. USBDDriverNotifyProcPtr = ProcPtr;
  1519. {$endc}
  1520. USBClassDriverPluginDispatchTablePtr = ^USBClassDriverPluginDispatchTable;
  1521. USBClassDriverPluginDispatchTable = record
  1522. pluginVersion: UInt32;
  1523. validateHWProc: USBDValidateHWProcPtr; { Proc for driver to verify proper HW }
  1524. initializeDeviceProc: USBDInitializeDeviceProcPtr; { Proc that initializes the class driver. }
  1525. initializeInterfaceProc: USBDInitializeInterfaceProcPtr; { Proc that initializes a particular interface in the class driver. }
  1526. finalizeProc: USBDFinalizeProcPtr; { Proc that finalizes the class driver. }
  1527. notificationProc: USBDDriverNotifyProcPtr; { Proc to pass notifications to the driver. }
  1528. end;
  1529. { Shim Defines }
  1530. const
  1531. kTheUSBShimDescriptionSignature = $75736273 (* 'usbs' *);
  1532. type
  1533. USBShimDescVersion = UInt32;
  1534. USBShimDescVersion_fix = USBShimDescVersion; { used as field type when a record declaration contains a USBShimDescVersion field identifier }
  1535. const
  1536. kCurrentUSBShimDescVers = $0100;
  1537. { Shim Loading Options }
  1538. type
  1539. USBShimLoadingOptions = UInt32;
  1540. const
  1541. kUSBRegisterShimAsSharedLibrary = $00000001; { Driver's VendorID must match Device's VendorID }
  1542. type
  1543. USBShimDescriptionPtr = ^USBShimDescription;
  1544. USBShimDescription = record
  1545. usbShimDescSignature: OSType; { Signature field of this structure. }
  1546. usbShimDescVersion: USBShimDescVersion_fix; { Version of this data structure. }
  1547. usbDriverLoadingOptions: USBShimLoadingOptions; { Options for shim loading. }
  1548. libraryName: Str63; { For optional shared library registration }
  1549. end;
  1550. { Hub defines }
  1551. const
  1552. kUSBHubDescriptorType = $29;
  1553. { Hub features }
  1554. kUSBHubLocalPowerChangeFeature = 0;
  1555. kUSBHubOverCurrentChangeFeature = 1; { port features }
  1556. kUSBHubPortConnectionFeature = 0;
  1557. kUSBHubPortEnableFeature = 1;
  1558. kUSBHubPortSuspendFeature = 2;
  1559. kUSBHubPortOverCurrentFeature = 3;
  1560. kUSBHubPortResetFeature = 4;
  1561. kUSBHubPortPowerFeature = 8;
  1562. kUSBHubPortLowSpeedFeature = 9;
  1563. kUSBHubPortConnectionChangeFeature = 16;
  1564. kUSBHubPortEnableChangeFeature = 17;
  1565. kUSBHubPortSuspendChangeFeature = 18;
  1566. kUSBHubPortOverCurrentChangeFeature = 19;
  1567. kUSBHubPortResetChangeFeature = 20;
  1568. kHubPortConnection = 1;
  1569. kHubPortEnabled = 2;
  1570. kHubPortSuspend = 4;
  1571. kHubPortOverCurrent = 8;
  1572. kHubPortBeingReset = 16;
  1573. kHubPortPower = $0100;
  1574. kHubPortLowSpeed = $0200;
  1575. kHubPortHighSpeed = $0400;
  1576. kHubPortTestMode = $0800;
  1577. kHubPortPortIndicator = $1000;
  1578. { Originally this was a Boolean, (low speed)? }
  1579. kUSBFullSpeed = 0;
  1580. kUSBLowSpeed = 1;
  1581. kUSBHighSpeed = 2;
  1582. kHubLocalPowerStatus = 1;
  1583. kHubOverCurrentIndicator = 2;
  1584. kHubLocalPowerStatusChange = 1;
  1585. kHubOverCurrentIndicatorChange = 2;
  1586. off = false;
  1587. on = true;
  1588. type
  1589. hubDescriptorPtr = ^hubDescriptor;
  1590. hubDescriptor = packed record
  1591. { See usbDoc pg 250?? }
  1592. dummy: UInt8; { to align charcteristics }
  1593. length: UInt8;
  1594. hubType: UInt8;
  1595. numPorts: UInt8;
  1596. characteristics: UInt16;
  1597. powerOnToGood: UInt8; { Port settling time, in 2ms }
  1598. hubCurrent: UInt8;
  1599. { These are received packed, will have to be unpacked }
  1600. removablePortFlags: packed array [0..7] of UInt8;
  1601. pwrCtlPortFlags: packed array [0..7] of UInt8;
  1602. end;
  1603. {$ALIGN MAC68K}
  1604. end.