1/* 2 * Copyright (c) 1998-2002 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22/* 23 * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. 24 * 25 * HISTORY 26 * 27 */ 28 29 30#ifndef _IOKIT_IOFWISOCHCHANNEL_H 31#define _IOKIT_IOFWISOCHCHANNEL_H 32 33#include <libkern/c++/OSObject.h> 34#include <IOKit/firewire/IOFireWireFamilyCommon.h> 35 36enum 37{ 38 kFWIsochChannelUnknownCondition = 0, 39 kFWIsochChannelNotEnoughBandwidth = 1, 40 kFWIsochChannelChannelNotAvailable = 2 41}; 42 43class IOFireWireController; 44class IOFWIsochChannel; 45class IOFWIsochPort; 46class OSSet; 47class IOFWReadQuadCommand; 48class IOFWCompareAndSwapCommand; 49 50/*! @class IOFWIsochChannel 51*/ 52class IOFWIsochChannel : public OSObject 53{ 54 OSDeclareDefaultStructors(IOFWIsochChannel) 55 56 public: 57 58 typedef IOReturn (ForceStopNotificationProc)(void* refCon, IOFWIsochChannel* channel, UInt32 stopCondition ); 59 60protected: 61 IOFireWireController * fControl; 62 ForceStopNotificationProc* fStopProc; 63 void * fStopRefCon; 64 IOFWIsochPort * fTalker; 65 OSSet * fListeners; 66 bool fDoIRM; 67 UInt32 fBandwidth; // Allocation units used 68 UInt32 fPacketSize; 69 IOFWSpeed fPrefSpeed; 70 IOFWSpeed fSpeed; // Actual speed used 71 UInt32 fChannel; // Actual channel used 72 IOFWReadQuadCommand * fReadCmd; 73 IOFWCompareAndSwapCommand * fLockCmd; 74 UInt32 fGeneration; // When bandwidth was allocated 75 76 IOLock * fLock; 77 78/*! @struct ExpansionData 79 @discussion This structure will be used to expand the capablilties of the class in the future. 80 */ 81 struct ExpansionData { }; 82 83/*! @var reserved 84 Reserved for future use. (Internal use only) */ 85 ExpansionData *reserved; 86 87 static void threadFunc( void * arg ); 88 89 virtual IOReturn updateBandwidth(bool claim); 90 virtual void reallocBandwidth( UInt32 generation ); 91 virtual void free(); 92 93public: 94 // Called from IOFireWireController 95 virtual bool init( IOFireWireController *control, bool doIRM, UInt32 packetSize, 96 IOFWSpeed prefSpeed, ForceStopNotificationProc* stopProc, 97 void *stopRefCon ); 98 virtual void handleBusReset(); 99 100 // Called by clients 101 virtual IOReturn setTalker(IOFWIsochPort *talker); 102 virtual IOReturn addListener(IOFWIsochPort *listener); 103 104 virtual IOReturn allocateChannel(); 105 virtual IOReturn releaseChannel(); 106 virtual IOReturn start(); 107 virtual IOReturn stop(); 108 109protected: 110 // handles IRM and channel determination and allocation. 111 // called by both user and kernel isoch channels 112 IOReturn allocateChannelBegin( IOFWSpeed speed, UInt64 allowedChans, UInt32 * channel = NULL ) ; 113 114 // handles IRM and channel allocation. 115 // called by both user and kernel isoch channels 116 IOReturn releaseChannelComplete() ; 117 118 IOReturn checkMemoryInRange( IOMemoryDescriptor * memory ); 119 120private: 121 OSMetaClassDeclareReservedUnused(IOFWIsochChannel, 0); 122 OSMetaClassDeclareReservedUnused(IOFWIsochChannel, 1); 123 OSMetaClassDeclareReservedUnused(IOFWIsochChannel, 2); 124 OSMetaClassDeclareReservedUnused(IOFWIsochChannel, 3); 125 126}; 127 128typedef IOFWIsochChannel::ForceStopNotificationProc FWIsochChannelForceStopNotificationProc ; 129typedef IOFWIsochChannel::ForceStopNotificationProc* FWIsochChannelForceStopNotificationProcPtr ; 130 131#endif /* ! _IOKIT_IOFWISOCHCHANNEL_H */ 132 133