|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: /*
26: File: USBPriv.i
27:
28: Contains: Private defines & SPI for USB services
29:
30: Version:
31:
32: Written by: Barry Twycross
33:
34: Copyright: (c) 1998 by Apple Computer, Inc., all rights reserved.
35:
36: File Ownership:
37:
38: DRI: Craig Keithley
39:
40: Other Contact:
41:
42: Technology: I/O
43:
44: Writers:
45:
46: (DRF) Dave Falkenburg
47: (TC) Tom Clark
48: (GG) Guillermo Gallegos
49: (BT) Barry Twycross
50: (CJK) Craig Keithley
51: (DF) David Ferguson
52:
53:
54: Change History (most recent first):
55:
56: <28> 9/9/98 BT Fix size of refcon in Isoc transfers
57: <27> 9/4/98 TC Add definition for 1.0 version of DriverNotifyProc.
58: <26> 9/3/98 GG Another Interface tweak.
59: <25> 9/3/98 GG Fixed Isochronous interface.
60: <24> 8/31/98 GG Changed Isochronous interest. Bumped version Number to 3. Added
61: Isoc Callback.
62: <23> 8/12/98 BT Move root hub into UIM again.
63: <22> 8/11/98 BT Fix semi-colon
64: <21> 8/11/98 BT Add UIM dispatch table version
65: <20> 7/11/98 TC Back out <USB18>.
66: <19> 6/30/98 BT Add hub defs, the hub driver and root hub needs
67: <18> 6/30/98 BT Move RH sim to UIM
68: <17> 6/15/98 DRF Added definitions for USB ExpandMem contents.
69: <16> 6/10/98 CJK add uslGetDeviceRefByID prototype
70: <15> 6/5/98 TC Move declaration of uxBusRef to USB.i, then change it to
71: USBBusRef.
72: <14> 6/4/98 DRF In UIMInitialize & UIMFinalize, add a Ptr to facilitate
73: handing-off global state when performing replacement.
74: <13> 6/3/98 GG Fixed mistake with comments.
75: <12> 6/3/98 GG Add interfaces for UIMFrameCount, IsochEndpointCreate, and
76: IsochTransfer
77: <11> 6/2/98 DRF Added params to UIMInitialize & UIMFinalize for replacement.
78: Also made a few interfacer tweaks for typedef-ed structs.
79: <10> 5/20/98 DF add USLPolledProcessDoneQueue prototype
80: <9> 5/20/98 TC Include definition USBRegisterExpertNotification.
81: <8> 5/5/98 CJK Correct someone's misspelling of my last name.
82: <7> 5/5/98 GG Change Buffersize from short to unsigned long in
83: uimBulkTransferProc.
84: <6> 4/29/98 BT Move common defines to here
85: <5> 4/23/98 BT Add reset portsuspend change
86: <4> 4/15/98 BT Add over current change reset
87: <3> 4/11/98 CJK add back in OHCIPollDoneQueue dispatch table entry.
88: <2> 4/9/98 DF Update to for changes made to Neptune 4/8
89: <1> 4/8/98 DF first checked in
90:
91:
92:
93: */
94:
95: #pragma once
96:
97: #include "mactypes.h"
98: #include "nameregistry.h"
99: #include "USB.h"
100:
101: #pragma push
102:
103: //typedef void (*USBCtlCallbackFn)(struct USBPB *pb);
104: //typedef void (*USBDevCtlCallbackFn)(struct USBPB *pb);
105: #define extern
106:
107: extern void USBIdleTask(void);
108:
109: extern OSStatus USBAddBus(void *regEntry,void *UIM,USBBusRef bus);
110:
111: extern OSStatus USBRemoveBus(USBBusRef bus);
112:
113: extern OSStatus USBServicesInitialise(void * exProc);
114:
115: extern void USBServicesFinalise(void);
116:
117: extern OSStatus USBRegisterExpertNotification (ExpertNotificationProcPtr pExpertNotify);
118:
119: extern OSStatus USBServicesGetVersion(UInt32 ID, VersRec *vers, UInt32 versSize);
120:
121: extern OSStatus USLPolledProcessDoneQueue(void);
122:
123: extern USBDeviceRef uslGetDeviceRefByID(unsigned short deviceID, USBBusRef bus);
124:
125:
126: /*
127: For casting purposes when we are calling a driver compiled with 1.0 version
128: of the driver dispatch table.
129: */
130: typedef extern OSStatus (*ONE_OH_USBDDriverNotifyProcPtr) (USBDriverNotification notification, void *pointer);
131:
132: /* IMPORTANT NOTES!
133: This file contains some OHCI specific functions & data structures, which are
134: currently required because the USL performs some root hub functions. When the
135: root hub simulation in the UIM is fully functional, the OHCI or UHCI specific
136: elements should be removed from this file (and placed in the OHCIUIM.H file)
137: */
138:
139: // Taken out of OHCIUIM.h and uslUIMInterface.c
140: enum{
141: EDDeleteErr = -14,
142: bandWidthFullErr = -15,
143: returnedErr = -16
144: };
145:
146:
147: typedef UInt8 uslBusRef;
148: // Shouldn't this be in USL.H?
149:
150: struct uslRootHubDescriptor
151: {
152:
153: short numPorts;
154: Boolean powerSwitching; /* does it have it? */
155: Boolean gangedSwitching; /* if yes, it is ganged */
156:
157: Boolean compoundDevice;
158: Boolean overCurrent; /* does it have it? */
159: Boolean globalOverCurrent; /* if yes is it global */
160: UInt8 reserved; /* for alignment */
161:
162: UInt8 portFlags[32]; /* Device removable and ganged power flags */
163:
164: };
165:
166: typedef struct uslRootHubDescriptor *uslRootHubDescriptorPtr;
167:
168: struct uslRootHubPortStatus
169: {
170: UInt16 portFlags; /* Port status flags */
171: UInt16 portChangeFlags; /* Port changed flags */
172: };
173:
174: typedef struct uslRootHubPortStatus *uslRootHubPortStatusPtr;
175:
176:
177: typedef extern OSStatus (*OHCIGetRootDescriptorPtr)(
178: uslBusRef bus,
179: uslRootHubDescriptorPtr descr);
180:
181: typedef extern OSStatus (*OHCIGetInterruptStatusPtr)(
182: uslBusRef bus,
183: UInt32 *status);
184:
185: typedef extern OSStatus (*OHCIClearInterruptStatusPtr)(
186: uslBusRef bus,
187: UInt32 status);
188:
189: typedef extern OSStatus (*OHCIGetRhStatusPtr)(
190: uslBusRef bus,
191: UInt32 *status);
192:
193:
194: typedef extern OSStatus (*OHCIRootHubResetChangeConnectionPtr)(
195: uslBusRef bus,
196: short port);
197:
198: typedef extern OSStatus (*OHCIRootHubResetResetChangePtr)(
199: uslBusRef bus,
200: short port);
201:
202: typedef extern OSStatus (*OHCIRootHubResetSuspendChangePtr)(
203: uslBusRef bus,
204: short port);
205:
206: typedef extern OSStatus (*OHCIRootHubResetEnableChangePtr)(
207: uslBusRef bus,
208: short port);
209:
210: typedef extern OSStatus (*OHCIRootHubResetOverCurrentChangePtr)(
211: uslBusRef bus,
212: short port);
213:
214: typedef extern OSStatus (*OHCIRootHubGetPortStatusPtr)(
215: uslBusRef bus,
216: short port,
217: uslRootHubPortStatusPtr portStatus);
218:
219: typedef extern void (*OHCIPollRootHubSimPtr)(
220: uslBusRef bus);
221:
222: typedef extern OSStatus (*OHCIResetRootHubPtr)(
223: uslBusRef bus);
224:
225: typedef extern OSStatus (*OHCIRootHubPortSuspendPtr)(
226: uslBusRef bus,
227: short port,
228: Boolean on);
229:
230: typedef extern OSStatus (*OHCIRootHubPowerPtr)(
231: uslBusRef bus,
232: Boolean on);
233:
234: typedef extern OSStatus(* OHCIRootHubResetPortPtr)(
235: uslBusRef bus,
236: short port);
237:
238: typedef extern OSStatus (*OHCIRootHubPortEnablePtr)(
239: uslBusRef bus,
240: short port,
241: Boolean on);
242:
243: typedef extern OSStatus (*OHCIRootHubPortPowerPtr)(
244: uslBusRef bus,
245: short port,
246: Boolean on);
247:
248:
249: //other Functions
250: typedef extern OSStatus (*OHCIProcessDoneQueuePtr)(void);
251:
252: typedef extern UInt64 (*UIMGetCurrentFrameNumberPtr)(void);
253:
254:
255: typedef extern void (*CallBackFuncPtr) (long lParam, OSStatus status, short s16Param);
256: typedef extern void (*IsocCallBackFuncPtr) (long lParam, OSStatus status, USBIsocFrame *pFrames);
257: //typedef CallBackFunc *CallBackFuncPtr;
258:
259: typedef void *UIMAbortControlEndpointProcPtr;
260: typedef void *UIMEnableControlEndpointProcPtr;
261: typedef void *UIMDisableControlEndpointProcPtr;
262: typedef void *UIMAbortBulkEndpointProcPtr;
263: typedef void *UIMEnableBulkEndpointProcPtr;
264: typedef void *UIMDisableBulkEndpointProcPtr;
265: typedef void *UIMDeleteInterruptEndPointProcPtr;
266: typedef void *UIMAbortInterruptEndpointProcPtr;
267: typedef void *UIMEnableInterruptEndpointProcPtr;
268: typedef void *UIMDisableInterruptEndpointProcPtr;
269: typedef void *UIMDeleteIsochEndPointProcPtr;
270: typedef void *UIMAbortIsochEndpointProcPtr;
271: typedef void *UIMEnableIsochEndpointProcPtr;
272: typedef void *UIMDisableIsochEndpointProcPtr;
273:
274: typedef extern OSStatus (*UIMInitializeProcPtr)(RegEntryIDPtr UIMregEntryID, Boolean replacingOld, Ptr savedState);
275:
276: typedef extern OSStatus (*UIMFinalizeProcPtr)(Boolean beingReplaced,Ptr * savedStatePtr);
277:
278: typedef extern OSStatus (*UIMCreateControlEndpointProcPtr)(
279: UInt8 functionNumber,
280: UInt8 endpointNumber,
281: UInt16 maxPacketSize,
282: UInt8 speed);
283:
284: typedef extern OSStatus (*UIMCreateBulkEndpointProcPtr)(
285: UInt8 functionNumber,
286: UInt8 endpointNumber,
287: UInt8 direction,
288: UInt8 maxPacketSize);
289:
290: typedef extern OSStatus (*UIMCreateControlTransferProcPtr)(
291: UInt32 refcon,
292: CallBackFuncPtr handler,
293: UInt32 CBP,
294: Boolean bufferRounding,
295: short functionNumber,
296: short endpointNumber,
297: short bufferSize,
298: short direction);
299:
300: typedef extern OSStatus (*UIMDeleteControlEndPointProcPtr)(
301: short functionNumber,
302: short endpointNumber);
303:
304: typedef extern OSStatus (*UIMDeleteBulkEndPointProcPtr)(
305: short functionNumber,
306: short endpointNumber,
307: short direction);
308:
309: typedef extern OSStatus (*UIMCreateBulkTransferProcPtr)(
310: UInt32 refcon,
311: CallBackFuncPtr handler,
312: UInt32 CBP,
313: Boolean bufferRounding,
314: short functionNumber,
315: short endpointNumber,
316: UInt32 bufferSize,
317: short direction);
318:
319: typedef extern OSStatus (*UIMClearEndPointStallProcPtr)(
320: short functionNumber,
321: short endpointNumber,
322: short direction);
323:
324: typedef extern OSStatus (*UIMCreateInterruptEndpointProcPtr)(
325: short functionAddress,
326: short endpointNumber,
327: short speed,
328: UInt16 maxPacketSize,
329: short pollingRate,
330: UInt32 reserveBandwidth);
331:
332: typedef extern OSStatus (*UIMCreateInterruptTransferProcPtr)(
333: short functionNumber,
334: short endpointNumber,
335: UInt32 refcon,
336: CallBackFuncPtr handler,
337: UInt32 CBP,
338: Boolean bufferRounding,
339: short bufferSize);
340:
341: typedef extern OSStatus (*UIMAbortEndpointProcPtr)(
342: short functionNumber,
343: short endpointNumber,
344: short direction);
345:
346: typedef extern OSStatus (*UIMDeleteEndpointProcPtr)(
347: short functionNumber,
348: short endpointNumber,
349: short direction);
350:
351: typedef extern OSStatus (*UIMCreateIsochEndpointProcPtr)(
352: short functionAddress,
353: short endpointNumber,
354: UInt32 maxPacketSize,
355: UInt8 direction);
356:
357: typedef extern OSStatus (*UIMCreateIsochTransferProcPtr)(
358: short functionAddress,
359: short endpointNumber,
360: UInt32 refcon,
361: UInt8 direction,
362: IsocCallBackFuncPtr pIsochHandler,
363: UInt64 frameStart,
364: UInt32 pBufferStart,
365: UInt32 frameCount,
366: USBIsocFrame *pFrames);
367:
368: enum{
369: kUIMPluginTableVersion = 3 // BT 11Aug98, bump up with root hub changes
370: };
371:
372: struct UIMPluginDispatchTable
373: {
374: UInt32 pluginVersion;
375: UIMInitializeProcPtr uimInitializeProc;
376: UIMFinalizeProcPtr uimFinalizeProc;
377: UIMCreateControlEndpointProcPtr uimCreateControlEndpointProc;
378: UIMDeleteControlEndPointProcPtr uimDeleteControlEndpointProc;
379: UIMCreateControlTransferProcPtr uimCreateControlTransferProc;
380: UIMAbortControlEndpointProcPtr uimAbortControlEndpointProc;
381: UIMEnableControlEndpointProcPtr uimEnableControlEndpointProc;
382: UIMDisableControlEndpointProcPtr uimDisableControlEndpointProc;
383: UIMCreateBulkEndpointProcPtr uimCreateBulkEndpointProc;
384: UIMDeleteBulkEndPointProcPtr uimDeleteBulkEndpointProc;
385: UIMCreateBulkTransferProcPtr uimCreateBulkTransferProc;
386: UIMAbortBulkEndpointProcPtr uimAbortBulkEndpointProc;
387: UIMEnableBulkEndpointProcPtr uimEnableBulkEndpointProc;
388: UIMDisableBulkEndpointProcPtr uimDisableBulkEndpointProc;
389: UIMCreateInterruptEndpointProcPtr uimCreateInterruptEndpointProc;
390: UIMDeleteInterruptEndPointProcPtr uimDeleteInterruptEndpointProc;
391: UIMCreateInterruptTransferProcPtr uimCreateInterruptTransferProc;
392: UIMAbortInterruptEndpointProcPtr uimAbortInterruptEndpointProc;
393: UIMEnableInterruptEndpointProcPtr uimEnableInterruptEndpointProc;
394: UIMDisableInterruptEndpointProcPtr uimDisableInterruptEndpointProc;
395: UIMCreateIsochEndpointProcPtr uimCreateIsochEndpointProc;
396: UIMDeleteIsochEndPointProcPtr uimDeleteIsochEndpointProc;
397: UIMCreateIsochTransferProcPtr uimCreateIsochTransferProc;
398: UIMAbortIsochEndpointProcPtr uimAbortIsochEndpointProc;
399: UIMEnableIsochEndpointProcPtr uimEnableIsochEndpointProc;
400: UIMDisableIsochEndpointProcPtr uimDisableIsochEndpointProc;
401: UIMAbortEndpointProcPtr uimAbortEndpointProc;
402: UIMDeleteEndpointProcPtr uimDeleteEndpointProc;
403: /* Need this for error recovery */
404: UIMClearEndPointStallProcPtr uimClearEndPointStallProc;
405:
406: OHCIPollRootHubSimPtr uimPollRootHubSim;
407: OHCIResetRootHubPtr uimResetRootHubProc;
408: OHCIProcessDoneQueuePtr uimProcessDoneQueueProc;
409: UIMGetCurrentFrameNumberPtr uimGetCurrentFrameNumberProc;
410:
411: };
412:
413: typedef struct UIMPluginDispatchTable *UIMPluginDispatchTablePtr;
414:
415: // extern UIMPluginDispatchTable ThePluginDispatchTable;
416:
417: // Hub stuff, for root hub
418:
419:
420:
421: enum{
422: /* Byte offsets */
423: bmRqType = 0,
424: bUsedFlag = bmRqType,
425: bRequest,
426: /* Word offsets */
427: wValue =1,
428: wIndex,
429: wLength
430: };
431:
432: union setupPacket{
433: UInt8 byte[8];
434: UInt16 word[4];
435: };
436:
437: typedef union setupPacket setupPacket;
438:
439: enum{
440: kUSBRqDirnShift = 7,
441: kUSBRqDirnMask = 1,
442:
443: kUSBRqTypeShift = 5,
444: kUSBRqTypeMask = 3,
445:
446: kUSBRqRecipientMask = 0X1F
447: };
448:
449:
450:
451: /***************************************************************************
452:
453: Proposal for Product ID in Apple USB devices.
454:
455: Barry Twycross 25Jan98
456:
457:
458: Background.
459:
460: All USB devices have a device descriptor which tells the system
461: basic information about the device. Amoung the information contained
462: therein is a Vendor and a Product code. The Vendor code is assigned
463: by the USB implimenters forum, for Apple this is 1452 (decimal)
464: 0x5AC (hex).
465:
466: The product code is left for the implimentor to use as they see fit.
467: The product code along with the vendor ID is the highest priority way
468: of matching a device to a driver. A driver can claim to be the best
469: driver for a particular product by specifying mathcing product/vendor
470: codes.
471:
472: There appears to be no one responsible for assigning these codes, so
473: the USB group is making this suggestion in an attempt to impose order
474: before chaos reigns.
475:
476:
477: Implimentation.
478:
479: The Product code in a USB device is a 16 bit field. It is transmitted
480: across the USB in Intel byte ordering (swapped from the usual Mac way
481: of doing things). This spec uses the logical value of the field. That
482: it has to be byte swapped to be decoded sensibly after transmission
483: across the bus.
484:
485: These proposals only apply to devices which have the Apple Vendor ID
486: code.
487:
488: Proposal.
489:
490: It is proposed that the 16bit Product ID value (expressed in hex) is
491: decomposed as follows:
492:
493: 0xRTNN
494:
495: There is a 4 bit 'R' (range) field
496: There is a 4 bit 'T' (type) field
497: There is an 8 bit 'NN' field, which finally specifies a product within a type.
498:
499: Range (R)
500:
501: This field specifies the party responsible for naming this series of
502: devices.
503:
504: In general it also specifies a device as internal to a system, or an
505: external, standalone, peripheral.
506:
507: 0-7 Is reserved for external devices.
508: 8-F is reserved for internal devices.
509:
510: Each of the ranges is further farmed out to a responsible entity to
511: define the sub fields. Currently assigned are:
512:
513: 0: Input devices (Harrold Welch).
514: 8: USB team (Barry Twycross)
515:
516:
517: Type (T)
518:
519: This field specifies the type of device within a range of devices.
520: The values are specified by the party responsible for the range.
521:
522: Currently assigned are:
523:
524: R=0, T specifies a device with this equivalent ADB ID.
525: T = 2: Keyboard
526: T = 3: Mouse
527:
528: R=8
529: T = 0: Root hub in a CPU.
530: T = 1: Non-root hub in a CPU
531:
532:
533: Product (NN)
534:
535: This field finally specifies which particular device or a type the
536: product actually is. It is expected the first product will be numbered
537: 1, and further products are numbered sequentially.
538:
539: **********************************************************************/
540:
541:
542: //Known assignments:
543:
544: //These device IDs are currently known to be assigned:
545:
546: enum{
547: kAppleVendorID = 0x05AC, // Assigned by USB-if
548:
549: // 0xRTNN Product
550: // These are Harold Welch's ADB device equivalents
551: kPrdKBCosmoAnsi = 0x0201, // Ansi Cosmo keyboard
552: kPrdKBCosmoIso = 0x0202, // Iso Cosmo keyboard
553: kPrdKBCosmoJis = 0x0203, // Jis Cosmo keyboard
554: kPrdMseRudi = 0x0301, // Rudi mouse
555: // These are the USB root hub simulations
556: kPrdRootHubCMD = 0x8001, // CMD chip root hub
557: kPrdRootHubOPTI = 0x8002, // Opti chip root hub
558: kPrdRootHubLucent = 0x8003 // Lucent chip root hub.
559: };
560:
561:
562: /***************************************************************************
563:
564: USBExpandMemGlobals: a structure that will eventually be more important,
565: but for now, we use this to keep track of the connection ID of the USB
566: FamilyExpertLib so that we can cleanly shut it down from a file-based
567: version of USB Expert.
568:
569: ****************************************************************************/
570:
571: struct USBExpandMemGlobals
572: {
573: UInt32 version;
574: CFragConnectionID expertConnectionID;
575: };
576: typedef struct USBExpandMemGlobals *USBExpandMemGlobalsPtr;
577:
578: enum
579: {
580: kUSBExpandMemVersionOne = 0x0100,
581: kUSBExpandMemCurVersion = kUSBExpandMemVersionOne
582: };
583:
584: #pragma pop
585: #undef extern
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.