USB.pas 51 KB

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