Annotation of kernel/bsd/dev/ppc/drvUSBCMD/CompositeClassDriver/CompositeDriverDescription.c, revision 1.1.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:           CompositeDriverDescription.c
                     27: 
                     28:        Contains:       Composite Class Driver Definition Header
                     29: 
                     30:        Version:        xxx put version here xxx
                     31: 
                     32:        Copyright:      � 1997-1998 by Apple Computer, Inc., all rights reserved.
                     33: 
                     34:        File Ownership:
                     35: 
                     36:                DRI:                            Craig Keithley
                     37: 
                     38:                Other Contact:          xxx put other contact here xxx
                     39: 
                     40:                Technology:                     xxx put technology here xxx
                     41: 
                     42:        Writers:
                     43: 
                     44:                (TC)    Tom Clark
                     45:                (DF)    David Ferguson
                     46:                (BT)    Barry Twycross
                     47:                (CJK)   Craig Keithley
                     48: 
                     49:        Change History (most recent first):
                     50: 
                     51:          <USB7>          9/4/98        TC              Update CompositeDriverNotifyProc to use version 1.1 of dispatch
                     52:                                                                        table.
                     53:          <USB6>         8/25/98        BT              Isoc name changes
                     54:          <USB5>          6/8/98        CJK             add bus power available to DeviceInitialize params
                     55:          <USB4>          6/5/98        CJK             clean up/straighten up Initialize routine
                     56:          <USB3>         4/27/98        DF              Don't load against a matching interface!
                     57:          <USB2>          4/9/98        CJK             change to use USB.h
                     58:                 <1>      4/7/98        CJK             first checked in as USBCompositeClassDriver
                     59:                <27>      4/2/98        CJK             Change kUSBCompound� to kUSBComposite�
                     60:                <26>     3/17/98        CJK             Replace "};" with just "}". Moved function prototypes to header
                     61:                                                                        file. Changed pragma unuseds so that MW doesn't complain about
                     62:                                                                        them.
                     63:                <25>      3/6/98        CJK             Add dispatch table for add/remove simulation
                     64:                <24>      3/5/98        CJK             Add include of version.h file. Change descriptor header to use
                     65:                                                                        the defines from the version.h file.
                     66:                <23>     2/26/98        CJK             remove driver services mem alloc/dealloc function calls
                     67:                <22>      2/9/98        CJK             Add pragma unused for buspoweravailable
                     68:                <21>      2/9/98        CJK             remove HIDEmulation.h include
                     69:                <20>      2/9/98        BT              Stub in new functions
                     70:                <19>      2/6/98        BT              Power allocation stuff
                     71:                <18>      2/6/98        CJK             remove debugstr. Add pragma unused
                     72:                <17>      2/4/98        CJK             Remove expert entry proc.
                     73:                <16>      2/3/98        CJK             change pFullConfig field name to pFullConfigDescriptor.
                     74:                <15>      2/2/98        CJK             change vendor/product ids back to 0
                     75:                <14>     1/30/98        CJK             move HID Module dispatch table to HIDEmulation.c
                     76:                <13>     1/27/98        CJK             Change dispatch table to have a separate HID API dispatch table.
                     77:                <12>     1/26/98        CJK             Change to use USBDeviceDescriptor structure
                     78:                <11>     1/26/98        BT              Mangle names after design review
                     79:                <10>     1/26/98        CJK             Add other dispatch functions needed by the ADB/USB shim.
                     80:                 <9>     1/23/98        CJK             Add pFullConfig MemDeAlloc call.
                     81:                 <8>     1/15/98        CJK             Change include of USL.h to USBServicesLib.h
                     82:                 <7>     1/14/98        BT              Getting rid of time entry, change to USBClassDriver.h
                     83:                 <6>     1/14/98        BT              Removing outdated pre expert stuff
                     84:                 <5>     1/14/98        CJK             Change name registry name.
                     85:                 <4>      1/8/98        CJK             Moved the initialize & finalize routines into this file (allows
                     86:                                                                        them to be static and thus not have the symbols exported).
                     87:                 <3>      1/6/98        CJK             Add dispatch table entry points needed by expert.
                     88:                 <2>    12/17/97        CJK             Add BBS file header
                     89:                 <1>    12/17/97        CJK             First time checkin
                     90: */
                     91: /*naga
                     92: #include <Types.h>
                     93: #include <Devices.h>
                     94: #include <DriverServices.h>
                     95: #include <USB.h>
                     96: */
                     97: #include "../driverservices.h"  
                     98: #include "../USB.h"
                     99: 
                    100: #include "CompositeClassDriver.h"
                    101: #include "CompositeClassVersion.h"
                    102: 
                    103: usbCompositePBStruct newInterfacesPB[2];
                    104: 
                    105: 
                    106: OSStatus CompositeDriverInitInterface(
                    107:                        UInt32                                          interfaceNum, 
                    108:                        USBInterfaceDescriptor          *interfaceDesc, 
                    109:                        USBDeviceDescriptor                     *deviceDesc, 
                    110:                        USBDeviceRef                            device);
                    111: 
                    112: //------------------------------------------------------
                    113: //
                    114: //     This is the driver description structure that the expert looks for first.
                    115: //  If it's here, the information within is used to match the driver
                    116: //  to the device whose descriptor was passed to the expert.
                    117: //     Information in this block is also used by the expert when an
                    118: //  entry is created in the Name Registry.
                    119: //
                    120: //------------------------------------------------------
                    121: /*naga
                    122: USBDriverDescription   TheUSBDriverDescription = 
                    123: {
                    124:        // Signature info
                    125:        kTheUSBDriverDescriptionSignature,
                    126:        kInitialUSBDriverDescriptor,
                    127:        
                    128:        // Device Info
                    129:        {0,                                                                             // vendor = not device specific
                    130:        0,                                                                              // product = not device specific
                    131:        0,                                                                              // version of product = not device specific
                    132:        0,},                                                                            // protocol = not device specific
                    133:        
                    134:        // Interface Info       (* I don't think this would always be required...*)                             
                    135:        0,                                                                              // Configuration Value
                    136:        0,                                                                              // Interface Number
                    137:        0,                                                                              // Interface Class
                    138:        0,                                                                              // Interface SubClass
                    139:        0,                                                                              // Interface Protocol
                    140:                
                    141:        
                    142:        // Driver Info
                    143:        "USBCompositeDevice",                                   // Driver name for Name Registry
                    144:        kUSBCompositeClass,                                             // Device Class  (from USBDeviceDefines.h)
                    145:        kUSBCompositeSubClass,                                  // Device Subclass 
                    146:        kCMPHexMajorVers, 
                    147:        kCMPHexMinorVers, 
                    148:        kCMPCurrentRelease, 
                    149:        kCMPReleaseStage,                                               // version of driver
                    150:        
                    151:        // Driver Loading Info
                    152:        kUSBDoNotMatchInterface                                 // Please don't load us as an interface driver.
                    153: };
                    154: naga */
                    155: USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
                    156: {
                    157:        kClassDriverPluginVersion,                              // Version of this structure
                    158:        CompositeDriverValidateHW,                              // Hardware Validation Procedure
                    159:        CompositeDriverInitialize,                              // Initialization Procedure
                    160:        CompositeDriverInitInterface,                   // Interface Initialization Procedure
                    161:        CompositeDriverFinalize,                                        // Finalization Procedure
                    162:        CompositeDriverNotifyProc                               // Driver Notification Procedure
                    163: };
                    164: 
                    165: // hubDriverInitInterface function
                    166: // Called to initialize driver for an individual interface - either by expert or
                    167: // internally by driver
                    168: OSStatus CompositeDriverInitInterface(
                    169:                        UInt32                                          interfaceNum, 
                    170:                        USBInterfaceDescriptor          *interfaceDesc, 
                    171:                        USBDeviceDescriptor                     *deviceDesc, 
                    172:                        USBDeviceRef                            device)
                    173: {
                    174: #pragma unused (interfaceNum)
                    175: #pragma unused (interfaceDesc)
                    176: #pragma unused (deviceDesc)
                    177: #pragma unused (device)
                    178: 
                    179:        return (OSStatus)kUSBNoErr;
                    180: }
                    181: 
                    182: OSStatus       CompositeDriverNotifyProc(UInt32        notification, void *pointer, UInt32 refcon)
                    183: {
                    184: #pragma unused (pointer)
                    185: #pragma unused (notification)
                    186: #pragma unused (refcon)
                    187:        return(kUSBNoErr);
                    188: }
                    189: 
                    190: // Hardware Validation
                    191: // Called upon load by Expert
                    192: OSStatus CompositeDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc)
                    193: {
                    194: #pragma unused (device)
                    195: #pragma unused (desc)
                    196: 
                    197:        return (OSStatus)kUSBNoErr;
                    198: }
                    199: 
                    200: // Initialization function
                    201: // Called upon load by Expert
                    202: OSStatus       CompositeDriverInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc,  UInt32 busPowerAvailable)
                    203: {
                    204: #pragma unused (busPowerAvailable)
                    205:        // until we get going, it's okay to accept a call to finalize
                    206:        //naga newInterfacesPB[index].okayToFinalizeFlag = true;
                    207:     if(pDesc->protocol == 0)
                    208:           newInterfacesPB[0].okayToFinalizeFlag = true;
                    209:     else newInterfacesPB[1].okayToFinalizeFlag = true;
                    210:        DeviceInitialize(device, pDesc, busPowerAvailable);
                    211:        return (OSStatus)kUSBNoErr;
                    212: }
                    213: 
                    214: // Termination function
                    215: // Called by Expert when driver is being shut down
                    216: OSStatus CompositeDriverFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
                    217: {
                    218: #pragma unused (pDesc)
                    219: UInt32 i;
                    220: int index;
                    221: OSStatus myErr;
                    222: 
                    223:        // If all the interfaces have been examined and had their interface
                    224:        // drivers loaded, then go ahead and removed them all
                    225:        // otherwise just return with a device busy error code.
                    226:         if(pDesc->protocol == 0)
                    227:             index = 0;
                    228:         else index = 1;
                    229:        USBExpertStatus(newInterfacesPB[index].pb.usbReference, "Composite Driver: Finalize", newInterfacesPB[index].pb.usbStatus);
                    230:        if (theDeviceRef == newInterfacesPB[index].deviceRef)
                    231:        {
                    232:                if (newInterfacesPB[index].okayToFinalizeFlag)
                    233:                {
                    234:                        USBExpertStatus(newInterfacesPB[index].pb.usbReference, "Composite Driver: Removing Interface drivers & InterfaceRefs", newInterfacesPB[index].pb.usbStatus);
                    235:                        for (i=0; i < newInterfacesPB[index].interfaceCount; i++)
                    236:                        {
                    237:                                USBExpertRemoveInterfaceDriver(newInterfacesPB[index].interfaceRefArray[i]);
                    238:                                InitParamBlock(newInterfacesPB[index].deviceRef, &newInterfacesPB[index].pb);
                    239:                                newInterfacesPB[index].pb.usbRefcon = 0;                        
                    240:                                newInterfacesPB[index].pb.usb.cntl.WIndex = i;
                    241:                                newInterfacesPB[index].pb.usbCompletion = (USBCompletion)-1;
                    242:                                myErr = USBDisposeInterfaceRef(&newInterfacesPB[index].pb);
                    243:                        }
                    244:                        
                    245:                        InitParamBlock(newInterfacesPB[index].deviceRef, &newInterfacesPB[index].pb);
                    246:                        newInterfacesPB[index].pb.usbRefcon = 0;                        
                    247:                        newInterfacesPB[index].pb.usbBuffer = newInterfacesPB[index].pFullConfigDescriptor;             
                    248:                        newInterfacesPB[index].pb.usbCompletion = (USBCompletion)-1;
                    249:                        myErr = USBDeallocMem(&newInterfacesPB[index].pb);
                    250:                        return (OSStatus)kUSBNoErr;
                    251:                }
                    252:                else
                    253:                {
                    254:                        return (OSStatus)kUSBDeviceBusy;
                    255:                }
                    256:        }
                    257:        else
                    258:        {
                    259:                USBExpertFatalError(newInterfacesPB[index].pb.usbReference, kUSBInternalErr, "Composite Driver - Finalize received unknown deviceRef", newInterfacesPB[index].pb.usbRefcon);
                    260:                return (OSStatus)kUSBUnknownDeviceErr;
                    261:        }
                    262: }
                    263: 
                    264: void DeviceInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDeviceDescriptor, UInt32 busPowerAvailable)
                    265: {
                    266: Boolean beenThereDoneThat = false;
                    267: int index;
                    268:     if(pDeviceDescriptor->protocol == 0)
                    269:          index = 0;
                    270:     else index = 1;
                    271: kprintf("USB: in DeviceInitialize Composite Driver\n");
                    272:        if(beenThereDoneThat)
                    273:        {
                    274:                USBExpertFatalError(device, kUSBInternalErr, "Composite driver is not reentrant!", 0);
                    275:                return;
                    276:        }
                    277: //naga beenThereDoneThat = true;
                    278:        newInterfacesPB[index].okayToFinalizeFlag = false;
                    279:        
                    280:        newInterfacesPB[index].deviceRef = device;      
                    281:        newInterfacesPB[index].deviceDescriptor = *pDeviceDescriptor;   
                    282:        
                    283:        newInterfacesPB[index].busPowerAvailable = busPowerAvailable;                                                   
                    284:        newInterfacesPB[index].delayLevel = 0;                                                  
                    285:        newInterfacesPB[index].transDepth = 0;                                                  
                    286:        newInterfacesPB[index].retryCount = kCompositeRetryCount;
                    287:        newInterfacesPB[index].pFullConfigDescriptor = nil;
                    288:        
                    289:        InitParamBlock(device, &newInterfacesPB[index].pb);
                    290:        newInterfacesPB[index].pb.usbRefcon = kGetFullConfiguration0;                   /* Start out at first state */
                    291:        
                    292: //     DebugStr("In Composite Driver");
                    293:        CompositeDeviceInitiateTransaction(&newInterfacesPB[index].pb);
                    294: }
                    295: 
                    296: 

unix.superglobalmegacorp.com

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