1/* 2 * 3 * @APPLE_LICENSE_HEADER_START@ 4 * 5 * Copyright (c) 1998-2003 Apple Computer, Inc. All Rights Reserved. 6 * 7 * This file contains Original Code and/or Modifications of Original Code 8 * as defined in and that are subject to the Apple Public Source License 9 * Version 2.0 (the 'License'). You may not use this file except in 10 * compliance with the License. Please obtain a copy of the License at 11 * http://www.opensource.apple.com/apsl/ and read it before using this 12 * 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, QUIET ENJOYMENT OR NON-INFRINGEMENT. 19 * Please see the License for the specific language governing rights and 20 * limitations under the License. 21 * 22 * @APPLE_LICENSE_HEADER_END@ 23 */ 24 25 26#ifndef __APPLEUSBCDCECMControl__ 27#define __APPLEUSBCDCECMControl__ 28 29#include "AppleUSBCDCCommon.h" 30#include "AppleUSBCDCECMData.h" 31 32 // Miscellaneous 33 34#define COMM_BUFF_SIZE 16 35#define WATCHDOG_TIMER_MS 1000 36#define kDeviceSelfPowered 1 37 38enum 39{ 40 kCDCPowerOffState = 0, 41 kCDCPowerOnState = 1, 42 kNumCDCStates = 2 43}; 44 45class AppleUSBCDCECMData; 46 47 /* AppleUSBCDCECMControl.h - This file contains the class definition for the */ 48 /* USB Communication Device Class (CDC) Ethernet Control driver. */ 49 50 51class AppleUSBCDCECMControl : public IOService 52{ 53 OSDeclareDefaultStructors(AppleUSBCDCECMControl); // Constructor & Destructor stuff 54 55private: 56 AppleUSBCDC *fCDCDriver; // The CDC driver 57 AppleUSBCDCECMData *fDataDriver; // Our data interface driver 58 bool fdataAcquired; // Has the data port been acquired 59 bool fTerminate; // Are we being terminated (ie the device was unplugged) 60 UInt8 fPowerState; // Ordinal for power management 61 bool fCommDead; // Interrupt read status 62 IOUSBPipe *fCommPipe; // The interrupt pipe 63 IOBufferMemoryDescriptor *fCommPipeMDP; // Interrupt pipe memory descriptor 64 UInt8 *fCommPipeBuffer; // Interrupt pipe buffer 65 IOUSBCompletion fCommCompletionInfo; // Interrupt completion routine 66 IOUSBCompletion fMERCompletionInfo; // MER Completion routine 67 IOUSBCompletion fStatsCompletionInfo; // Stats Completion routine 68 UInt8 fCommInterfaceNumber; // My interface number 69 70 bool fReady; 71 UInt8 fLinkStatus; 72 UInt32 fUpSpeed; 73 UInt32 fDownSpeed; 74 75 bool fStatInProgress; 76 UInt16 fCurrStat; 77 UInt32 fStatValue; 78 79 static void commReadComplete( void *obj, void *param, IOReturn ior, UInt32 remaining); 80 static void merWriteComplete(void *obj, void *param, IOReturn ior, UInt32 remaining); 81 static void statsWriteComplete(void *obj, void *param, IOReturn rc, UInt32 remaining); 82 83 UInt16 fVendorID; 84 UInt16 fProductID; 85 86public: 87 88 IOUSBInterface *fControlInterface; 89 UInt8 fDataInterfaceNumber; // Matching Data interface number 90 91 UInt16 fPacketFilter; 92 UInt8 fEaddr[6]; 93 UInt16 fMcFilters; 94 95 UInt16 fMax_Block_Size; 96 97 IONetworkStats *fpNetStats; 98 IOEthernetStats *fpEtherStats; 99 bool fInputPktsOK; 100 bool fInputErrsOK; 101 bool fOutputPktsOK; 102 bool fOutputErrsOK; 103 UInt8 fEthernetStatistics[4]; 104 105 // IOKit methods: 106 107 virtual IOService *probe(IOService *provider, SInt32 *score); 108 virtual bool start(IOService *provider); 109 virtual void stop(IOService *provider); 110 virtual IOReturn message(UInt32 type, IOService *provider, void *argument = 0); 111 112 // CDC ECM Control Driver Methods 113 114 UInt8 Asciihex_to_binary(char c); 115 bool configureECM(void); 116 bool getFunctionalDescriptors(void); 117 virtual bool dataAcquired(IONetworkStats *netStats, IOEthernetStats *etherStats); 118 virtual void dataReleased(void); 119 bool allocateResources(void); 120 void releaseResources(void); 121 virtual bool checkInterfaceNumber(AppleUSBCDCECMData *dataDriver); 122 IOReturn checkPipe(IOUSBPipe *thePipe, bool devReq); 123 virtual bool USBSetMulticastFilter(IOEthernetAddress *addrs, UInt32 count); 124 virtual bool USBSetPacketFilter(void); 125 virtual bool statsProcessing(void); 126 127 // Power Manager Methods 128 129// bool initForPM(IOService *provider); 130// unsigned long initialPowerStateForDomainState(IOPMPowerFlags flags); 131// IOReturn setPowerState(unsigned long powerStateOrdinal, IOService *whatDevice); 132 133}; /* end class AppleUSBCDCECMControl */ 134#endif