Annotation of kernel/bsd/dev/ppc/drvUSBCMD/Library/uslpriv.h, revision 1.1

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:           uslpriv.h
        !            27: 
        !            28:        Contains:       USB Services Library private include.
        !            29: 
        !            30:        Version:        Neptune 1.0
        !            31:        
        !            32:        Copyright:      � 1997-1998 by Apple Computer, Inc., all rights reserved.
        !            33: 
        !            34:        File Ownership:
        !            35: 
        !            36:                DRI:                            Barry Twycross
        !            37: 
        !            38:                Other Contact:          xxx put other contact here xxx
        !            39: 
        !            40:                Technology:                     USB
        !            41: 
        !            42:        Writers:
        !            43: 
        !            44:                (DF)    David Ferguson
        !            45:                (TC)    Tom Clark
        !            46:                (CJK)   Craig Keithley
        !            47:                (BT)    Barry Twycross
        !            48: 
        !            49:        Change History (most recent first):
        !            50: 
        !            51:         <USB52>        10/29/98        BT              Close old configurations on reset or reconfiguration.
        !            52:         <USB51>        10/22/98        BT              Fix wrong status for deleted devices.
        !            53:         <USB50>        10/21/98        DF              Add uslDeviceAddrToBus function
        !            54:         <USB49>         9/29/98        BT              Use real frame timing
        !            55:         <USB48>         9/28/98        BT              Add device reset function
        !            56:         <USB47>         9/17/98        BT              1.1 rules for captive devices.
        !            57:         <USB46>         8/31/98        BT              Add isoc pipes
        !            58:         <USB45>         8/24/98        BT              Isoc param block definition
        !            59:         <USB44>         8/13/98        BT              Add multibus support
        !            60:         <USB43>          7/9/98        BT              Clean up after delete device and config clash. Merge in branch
        !            61:         <USB42>         6/30/98        BT              Some defs moved to usb.i
        !            62:         <USB41>         6/22/98        BT              Add Alt interface to configure interface
        !            63:         <USB40>         6/14/98        DF              Add RemoveRootHub function prototype
        !            64:         <USB39>          6/5/98        BT              Add pb param to deletedvice
        !            65:         <USB38>          6/5/98        TC              Change uxBusRef to USBBusRef.
        !            66:         <USB37>         5/21/98        BT              Add uslOpenDevice
        !            67:         <USB36>         5/20/98        BT              Lots of stuff for V2 PB s
        !            68:         <USB35>         5/17/98        BT              Add config stuff
        !            69:         <USB34>         5/12/98        BT              New interface stuff
        !            70:         <USB33>          5/8/98        BT              Add open interface for Tom
        !            71:         <USB32>         4/30/98        BT              Add real interrupt driven timer
        !            72:         <USB31>         4/28/98        BT              Add bulk performance monitoring.
        !            73:         <USB30>         4/26/98        BT              Make find pipe global
        !            74:         <USB29>         4/24/98        BT              Add pipe functions
        !            75:         <USB28>         4/23/98        BT              Add hub watchdog function
        !            76:         <USB27>         4/21/98        BT              Allow requests to device zero, pipe zero.
        !            77:         <USB26>         4/16/98        BT              Remove duplicated defn
        !            78:         <USB25>         4/14/98        BT              Note restrictions on device structure. uslDeleteDevice makes
        !            79:                                                                        assumptions
        !            80:         <USB24>         4/14/98        BT              Impliment device remove
        !            81:         <USB23>         4/11/98        CJK             Now that USB.i has been re-built, the problem of the qtypes is
        !            82:                                                                        gone...
        !            83:         <USB22>         4/11/98        CJK             investigate qtype problem
        !            84:         <USB21>         4/10/98        BT              Re add q type defines
        !            85:         <USB20>          4/9/98        CJK             trim down to only those defines not yet present in USBPriv.h
        !            86:         <USB19>          4/9/98        BT              Move defines from public
        !            87:                <18>      4/8/98        BT              Move error codes to public file
        !            88:                <17>      4/8/98        BT              Add error codes (should be in USL.h)
        !            89:                <16>      4/2/98        BT              Start on config/interface/endpoint stuff. First caching config
        !            90:                                                                        descriptors.
        !            91:                <15>     3/19/98        BT              Add USLprivate.h
        !            92:                <14>     3/19/98        BT              Split USBServices.h into public and private
        !            93:                <13>      3/5/98        BT              Add int transactions
        !            94:                <12>      2/4/98        BT              Fix uslControlPacket to have errors. Add more support for
        !            95:                                                                        usbProbe
        !            96:                <11>      2/2/98        BT              Add bulk stuff
        !            97:                <10>     1/29/98        BT              Carve up the flags
        !            98:                 <9>     1/26/98        BT              Mangle names after design review
        !            99:                 <8>     1/26/98        BT              Make expert notify public
        !           100:                 <7>     1/19/98        BT              More root hub sim
        !           101:                 <6>     1/15/98        BT              Add extra defines for bMRequestType
        !           102:                 <5>     1/13/98        BT              Change uslPacket to uslControlPacket, get ready for Int
        !           103:                                                                        transactions.
        !           104:                 <4>    12/22/97        BT              StartRootHub moving to USL
        !           105:                 <3>    12/18/97        BT              Emulate expert notification proc.
        !           106: */
        !           107: 
        !           108: /* Need to autoinclude all files here */
        !           109: /* Must conditionalise this */
        !           110: 
        !           111: #ifndef __USLPRIVH__
        !           112: #define __USLPRIVH__
        !           113: #include "../driverservices.h"
        !           114: /* ************* Constants ************* */
        !           115: 
        !           116: #if 0
        !           117: enum{
        !           118:        kUSBBus = 0
        !           119:        };
        !           120: #endif
        !           121: 
        !           122: enum{
        !           123:        kUSBDeviceIDShift = 7,
        !           124:        kUSBMaxDevices = 128,
        !           125:        kUSBMaxDevice = kUSBMaxDevices-1,
        !           126:        kUSBDeviceIDMask = 0x7f,
        !           127: 
        !           128:        kUSBMaxPipeIDShift =7,
        !           129:        kUSBMaxPipes = (1<<kUSBMaxPipeIDShift),
        !           130:        kUSBPipeIDMask = (kUSBMaxPipes-1),
        !           131:        
        !           132:        kUSBMaxEndptPerDevice = 30,
        !           133:        
        !           134:        kUSBEndPtShift = 7,
        !           135:        kUSBDeviceMask = ((1 << kUSBEndPtShift) -1),
        !           136:        
        !           137:        kUSBNoPipeIdx = -1,
        !           138:        
        !           139:        kUSBHubQType = 21,
        !           140:        kUSBDelayQType = 22
        !           141:        
        !           142:        };
        !           143: 
        !           144: enum{
        !           145:        kUSBIdleStalled = kUSBStalled+1
        !           146:        };
        !           147: 
        !           148: 
        !           149: 
        !           150: /* Flag long word of PB. Used internally 
        !           151: 
        !           152: Should probably make this a seperate reserved field 
        !           153:        b0    Task Time, wow a real flag
        !           154:        b1
        !           155:        b2
        !           156:        b3
        !           157:        b4
        !           158:        b5
        !           159:        b6
        !           160:        b7
        !           161:        b8
        !           162:        b9
        !           163:        b10
        !           164:        b11    der/alloc - 1 bit is this an alloc or dealloc of task time memory
        !           165:        b12    bus    - bus 4 bit internal bus number
        !           166:        b13    bus
        !           167:        b14    bus
        !           168:        b15    bus
        !           169:        b16    stage - 4 bit internal stage counter
        !           170:        b17    stage
        !           171:        b18    stage
        !           172:        b19    stage
        !           173:        b20    endp - 5 bits of endpoint (if we need direction).
        !           174:        b21    endp
        !           175:        b22    endp
        !           176:        b23    endp
        !           177:        b24    endp
        !           178:        b25    addr - 7 bits of function addr
        !           179:        b26    addr
        !           180:        b27    addr
        !           181:        b28    addr
        !           182:        b29    addr
        !           183:        b30    addr
        !           184:        b31    addr
        !           185: 
        !           186: */
        !           187: enum{
        !           188:        kUSLTTMemDeAllocFlagShift = 11,
        !           189:        kUSLBusShift = 12,
        !           190:        kUSLBusMask = 0xf000,
        !           191:        kUSLStageShift = 16,
        !           192:        kUSLStageMask = 0xf0000,
        !           193:        kUSLEndpShift = 20,
        !           194:        kUSLEndpMask =  0x1f00000,
        !           195:        kUSLAddrShift = 25,
        !           196:        kUSLAddrMask = 0xfe000000
        !           197:        };
        !           198: 
        !           199: 
        !           200: /* ************* types ************* */
        !           201: 
        !           202: 
        !           203: #define addrStash reserved6
        !           204: #define wIndexStash reserved7
        !           205: #define wValueStash reserved8
        !           206: 
        !           207: typedef short pipesIdx;
        !           208: typedef short InterfacesIdx;
        !           209: typedef short packetIdx;
        !           210: typedef short transIndex;
        !           211: 
        !           212: typedef struct{
        !           213:        USBPipeRef ref;
        !           214:        USBReference devIntfRef;        /* device or interface ref of container */
        !           215:        
        !           216:        UInt32 bus;
        !           217:        
        !           218:        long maxPacket;
        !           219:        USBFlags flags; 
        !           220:        USBPipeState state;
        !           221:        
        !           222:        UInt8 devAddress;
        !           223:        UInt8 endPt;
        !           224:        UInt8 direction;
        !           225:        UInt8 type;
        !           226: 
        !           227:        /* For perforance monitoring */
        !           228:        UInt32 lastRead;
        !           229:        UInt32 bytesTransfered;
        !           230:        UInt32 transferTime;
        !           231:        Boolean monitorPerformance;
        !           232:        
        !           233:        }pipe;
        !           234: 
        !           235: typedef struct{
        !           236:        USBInterfaceRef ref;
        !           237:        USBDeviceRef device;
        !           238:        UInt32 interfaceNum;
        !           239:        UInt32 alt;
        !           240:        }uslInterface;
        !           241: 
        !           242: /* This one is the beginnings of a config descriptor, so we can extract total length */
        !           243: typedef struct{
        !           244:        UInt8 len;
        !           245:        UInt8 type;
        !           246:        UInt16 totalLen;
        !           247:        } configHeader;
        !           248: 
        !           249: typedef struct{
        !           250:        /* uslDeleteDevice assumes that this is the first entry in this struct */
        !           251:        USBDeviceRef ID;
        !           252: 
        !           253:        /* it assumes this is the second. Beware if you change the order here */
        !           254:        void *allConfigDescriptors;
        !           255:        UInt32 allConfigLen;
        !           256:        UInt32 powerAvailable;
        !           257:        UInt32 configLock;
        !           258:        UInt32 killMe;
        !           259:        
        !           260:        UInt32 bus;
        !           261:        
        !           262:        pipesIdx pipe0;
        !           263:        pipesIdx pipes[kUSBMaxEndptPerDevice];
        !           264: 
        !           265:        configHeader configScratch;
        !           266:        USBDeviceDescriptor deviceDescriptor;
        !           267: 
        !           268:        UInt8 currentConfiguration;
        !           269:        UInt8 usbAddress;
        !           270:        Boolean confValid;
        !           271:        Boolean speed;
        !           272:        }usbDevice;
        !           273:        
        !           274: 
        !           275: #define OFFSET(ty, fl)  ((UInt32)  &(((ty *)0)->fl))
        !           276: 
        !           277: void uslInterruptPriority(UInt32);
        !           278: 
        !           279: Boolean uslIsInterfaceRef(USBInterfaceRef interf);
        !           280: OSStatus findInterface(USBInterfaceRef InterfaceRef, uslInterface **p);
        !           281: OSStatus uslOpenPipeImmed(USBInterfaceRef intrfc, USBEndPointDescriptor *endp);
        !           282: usbDevice *getDevicePtrFromIdx(unsigned deviceIndex);
        !           283: int makeDevPipeIdx( UInt8 endpoint, UInt8 direction);
        !           284: pipe *getPipeByIdx(pipesIdx idx);
        !           285: OSStatus uslOpenDevice(USBPB *pb);
        !           286: 
        !           287: //UInt32 uslDeviceToBus(USBDeviceRef ref);
        !           288: Boolean uslHubValidateDevZero(USBDeviceRef ref, UInt32 *bus);
        !           289: void uslHubAddDevice(USBPB *pb);
        !           290: void UIMSetRootHubRef(UInt32 bus, USBDeviceRef ref);
        !           291: 
        !           292: 
        !           293: Boolean checkPBVersion(USBPB *pb, UInt32 flags);
        !           294: Boolean checkPBVersionIsoc(USBPB *pb, UInt32 flags);
        !           295: 
        !           296: OSStatus USBExpertNotifyParentMsg(USBReference reference, void *pointer);
        !           297: USBDeviceRef MakeDevRef(UInt32 bus, UInt16 addr);
        !           298: USBDeviceRef addNewDevice(UInt32 bus, UInt16 addr, UInt8 speed, UInt8 maxPacket, UInt32 power);
        !           299: UInt32 uslDeviceAddrToBus(UInt16 addr);
        !           300: UInt8 getNewAddress(void);
        !           301: usbDevice *getDevicePtr(USBDeviceRef device);
        !           302: OSStatus findPipe(USBPipeRef pipeRef, pipe **p);
        !           303: USBPipeRef getPipeZero(USBDeviceRef device);
        !           304: long recoverPipeIdx(USBPipeRef pipeRef);
        !           305: pipe *getPipe(usbDevice *device, UInt8 endpoint, UInt8 direction);
        !           306: pipe *AllocPipe(usbDevice *device, UInt8 endpoint, UInt8 direction);
        !           307: unsigned makeDeviceIdx(USBDeviceRef device);
        !           308: void deallocPipe(usbDevice *device, UInt8 endpoint, UInt8 direction);
        !           309: pipe *GetPipePtr(USBPipeRef pipeRef);
        !           310: void uslSetPipeStall(USBPipeRef ref);
        !           311: uslInterface *AllocInterface(USBDeviceRef device);
        !           312: 
        !           313: OSStatus validateRef(USBReference ref, UInt32 *bus);
        !           314: void uslCleanHubQueue(USBDeviceRef ref);
        !           315: void uslCleanDelayQueue(USBDeviceRef ref);
        !           316: void uslCleanNotifyQueue(USBDeviceRef ref);
        !           317: void uslCleanMemQueue(USBDeviceRef ref);
        !           318: void uslCleanAQueue(QHdrPtr queue, USBDeviceRef ref);
        !           319: Boolean isSameDevice(USBReference ref, USBDeviceRef devRef);
        !           320: 
        !           321: 
        !           322: 
        !           323: 
        !           324: 
        !           325: OSStatus uslClosePipe(pipesIdx pipe);
        !           326: void uslCloseNonDefaultPipes(usbDevice *deviceP);
        !           327: void uslUnconfigureDevice(usbDevice *device);
        !           328: void uslCloseInterfacePipes(USBInterfaceRef iRef, usbDevice *deviceP);
        !           329: OSStatus uslDeleteDevice(USBPB *pb, usbDevice *device);
        !           330: UInt32 deltaFrames(UInt32 previous, UInt32 bus);
        !           331: UInt32 UIMGetAFrame(void);
        !           332: void uslHubWatchDog(Duration currentMilliSec);
        !           333: 
        !           334: OSStatus usbControlPacket(UInt32 bus, USBPB *pb, UInt8 address, UInt8 endpoint);
        !           335: OSStatus usbIntPacket(UInt32 bus, USBPB *pb, UInt8 address, UInt8 endpoint, UInt8 direction);
        !           336: OSStatus usbIsocPacket(UInt32 bus, USBPB *pb, UInt8 address, UInt8 endpoint, UInt8 direction);
        !           337: OSStatus usbBulkPacket(UInt32 bus, USBPB *pb, UInt8 address, UInt8 endpoint, UInt8 direction);
        !           338: OSStatus xUSLControlRequest(UInt32 bus, USBPB *pb, pipe *thisPipe);
        !           339: 
        !           340: Boolean immediateError(OSStatus err);
        !           341: OSStatus StartRootHub(UInt32 bus);
        !           342: 
        !           343: void initialiseNotifications(void);
        !           344: void initialiseDelays(void);
        !           345: void initialiseTimer(void);
        !           346: void initialiseHubs(void);
        !           347: 
        !           348: void finaliseNotifications(void);
        !           349: void finaliseDelays(void);
        !           350: void finaliseHubs(void);
        !           351: 
        !           352: void SetExpertFunction(void *exProc);
        !           353: 
        !           354: void resolvePerformance(USBPB *pb);
        !           355: OSStatus uslMonitorBulkPerformanceByReference(USBPipeRef ref, UInt32 what, 
        !           356:                                        UInt32 *lastRead, UInt32 *bytesTransfered, UInt32 *transferTime);
        !           357: 
        !           358: 
        !           359: /* these are internal versions of USB... with less error checking */
        !           360: OSStatus uslDeviceRequest(struct USBPB *pb);
        !           361: 
        !           362: OSStatus uslAllocMem(USBPB *pb);
        !           363: OSStatus uslDeallocMem(USBPB *pb);
        !           364: 
        !           365: 
        !           366: #endif /*__USLPRIVH__ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.