1/* 2 * Copyright (c) 1998-2007 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#import <IOKit/firewire/IOFireWireFamilyCommon.h> 24 25#import "IOFireWireLibIUnknown.h" 26#import "IOFireWireLib.h" 27#import "IOFireWireLibPriv.h" 28 29namespace IOFireWireLib 30{ 31 class Device; 32 33 class VectorCommand : public IOFireWireIUnknown 34 { 35 protected: 36 37 static IOFireWireLibVectorCommandInterface sInterface; 38 static CFArrayCallBacks sArrayCallbacks; 39 40 Device & mUserClient; 41 UserObjectHandle mKernCommandRef; 42 void* mRefCon; 43 IOFireWireLibCommandCallback mCallback; 44 CFMutableArrayRef mCommandArray; 45 UInt32 mFlags; 46 UInt32 mInflightCount; 47 IOReturn mStatus; 48 49 CommandSubmitParams * mSubmitBuffer; 50 vm_size_t mSubmitBufferSize; 51 52 CommandSubmitResult * mResultBuffer; 53 vm_size_t mResultBufferSize; 54 55 public: 56 VectorCommand( Device & userClient, 57 IOFireWireLibCommandCallback callback, 58 void * refCon ); 59 60 virtual ~VectorCommand(); 61 62 static IUnknownVTbl** Alloc( Device& userclient, 63 IOFireWireLibCommandCallback callback, 64 void* inRefCon ); 65 66 virtual HRESULT QueryInterface( REFIID iid, LPVOID* ppv ); 67 68 protected: 69 inline VectorCommand * GetThis( IOFireWireLibVectorCommandRef self ) 70 { return IOFireWireIUnknown::InterfaceMap<VectorCommand>::GetThis( self ); } 71 72 static IOReturn SSubmit( IOFireWireLibVectorCommandRef self ); 73 virtual IOReturn Submit(); 74 75 static IOReturn SSubmitWithRefconAndCallback( IOFireWireLibVectorCommandRef self, void* refCon, IOFireWireLibCommandCallback inCallback ); 76 77 static Boolean SIsExecuting( IOFireWireLibVectorCommandRef self ); 78 79 static void SSetCallback( IOFireWireLibVectorCommandRef self, IOFireWireLibCommandCallback inCallback ); 80 81 static void SVectorCompletionHandler( void* refcon, 82 IOReturn result, 83 void* quads[], 84 UInt32 numQuads ); 85 86 virtual void VectorCompletionHandler( IOReturn result, 87 void* quads[], 88 UInt32 numQuads ); 89 90 static void SSetRefCon( IOFireWireLibVectorCommandRef self, void* refCon ); 91 92 static void * SGetRefCon( IOFireWireLibVectorCommandRef self ); 93 94 static void SSetFlags( IOFireWireLibVectorCommandRef self, UInt32 inFlags ); 95 96 static UInt32 SGetFlags( IOFireWireLibVectorCommandRef self ); 97 98 static IOReturn SEnsureCapacity( IOFireWireLibVectorCommandRef self, UInt32 capacity ); 99 virtual IOReturn EnsureCapacity( UInt32 capacity ); 100 101 static void SAddCommand( IOFireWireLibVectorCommandRef self, IOFireWireLibCommandRef command ); 102 103 static void SRemoveCommand( IOFireWireLibVectorCommandRef self, IOFireWireLibCommandRef command ); 104 105 static void SInsertCommandAtIndex( IOFireWireLibVectorCommandRef self, IOFireWireLibCommandRef command, UInt32 index ); 106 107 static IOFireWireLibCommandRef SGetCommandAtIndex( IOFireWireLibVectorCommandRef self, UInt32 index ); 108 109 static UInt32 SGetIndexOfCommand( IOFireWireLibVectorCommandRef self, IOFireWireLibCommandRef command ); 110 111 static void SRemoveCommandAtIndex( IOFireWireLibVectorCommandRef self, UInt32 index ); 112 113 static void SRemoveAllCommands( IOFireWireLibVectorCommandRef self ); 114 115 static UInt32 SGetCommandCount( IOFireWireLibVectorCommandRef self ); 116 117 static const void * SRetainCallback( CFAllocatorRef allocator, const void * value ); 118 static void SReleaseCallback( CFAllocatorRef allocator, const void * value ); 119 120 }; 121 122}