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* IOFireWireLibDCLPool.h 24* IOFireWireFamily 25* 26* Created on Mon Mar 12 2001. 27* Copyright (c) 2001-2002 Apple Computer, Inc. All rights reserved. 28* 29*/ 30 31#import "IOFireWireLibIUnknown.h" 32#import "IOFireWireLibPriv.h" 33#import "IOFireWireLibIsoch.h" 34 35#import <IOKit/IOKitLib.h> 36#import <sys/types.h> 37 38namespace IOFireWireLib { 39 40 class Device ; 41 class TraditionalDCLCommandPool : public IOFireWireIUnknown 42 { 43 protected: 44 45 Device& mUserClient ; 46 CFMutableArrayRef mFreeBlocks ; 47 CFMutableArrayRef mFreeBlockSizes ; 48 CFMutableArrayRef mAllocatedBlocks ; 49 CFMutableArrayRef mAllocatedBlockSizes ; 50 UInt8* mStorage ; 51 IOByteCount mStorageSize ; 52 IOByteCount mBytesRemaining ; 53 pthread_mutex_t mMutex ; 54 55 public: 56 57 TraditionalDCLCommandPool( const IUnknownVTbl & interface, Device& inUserClient, IOByteCount inSize ) ; 58 virtual ~TraditionalDCLCommandPool() ; 59 60 public: 61 62 DCLCommand* Allocate( IOByteCount size ) ; 63 IOReturn AllocateWithOpcode( DCLCommand* dcl, DCLCommand** outDCL, UInt32 opcode, ... ) ; 64 DCLCommand* AllocateTransferPacketDCL( DCLCommand* dcl, UInt32 opcode, void* buffer, IOByteCount size ) ; 65 DCLCommand* AllocateTransferBufferDCL( DCLCommand* dcl, UInt32 opcode, void* buffer, IOByteCount size, IOByteCount packetSize, UInt32 bufferOffset ) ; 66 DCLCommand* AllocateSendPacketStartDCL( 67 DCLCommand* inDCL, 68 void* inBuffer, 69 IOByteCount inSize) ; 70 DCLCommand* AllocateSendPacketWithHeaderStartDCL( 71 DCLCommand* inDCL, 72 void* inBuffer, 73 IOByteCount inSize) ; 74 DCLCommand* AllocateSendBufferDCL( // currently does nothing 75 DCLCommand* inDCL, 76 void* inBuffer, 77 IOByteCount inSize, 78 IOByteCount inPacketSize, 79 UInt32 inBufferOffset) ; 80 DCLCommand* AllocateSendPacketDCL( 81 DCLCommand* inDCL, 82 void* inBuffer, 83 IOByteCount inSize) ; 84 DCLCommand* AllocateReceivePacketStartDCL( 85 DCLCommand* inDCL, 86 void* inBuffer, 87 IOByteCount inSize) ; 88 DCLCommand* AllocateReceivePacketDCL( 89 DCLCommand* inDCL, 90 void* inBuffer, 91 IOByteCount inSize) ; 92 DCLCommand* AllocateReceiveBufferDCL( // currently does nothing 93 DCLCommand* inDCL, 94 void* inBuffer, 95 IOByteCount inSize, 96 IOByteCount inPacketSize, 97 UInt32 inBufferOffset) ; 98 DCLCommand* AllocateCallProcDCL( DCLCommand* inDCL, DCLCallCommandProc* proc, DCLCallProcDataType procData) ; 99 DCLCommand* AllocateLabelDCL( DCLCommand* dcl ) ; 100 DCLCommand* AllocateJumpDCL( DCLCommand* dcl, DCLLabel* pInJumpDCLLabel ) ; 101 DCLCommand* AllocateSetTagSyncBitsDCL( DCLCommand* dcl, UInt16 tagBits, UInt16 syncBits ) ; 102 DCLCommand* AllocateUpdateDCLListDCL( DCLCommand* dcl, DCLCommand** dclCommandList, UInt32 numCommands ) ; 103 DCLCommand* AllocatePtrTimeStampDCL( DCLCommand* dcl, UInt32* timeStampPtr ) ; 104 void Free( DCLCommand* dcl ) ; 105 IOByteCount GetSize() ; 106 Boolean SetSize( IOByteCount size ) ; 107 IOByteCount GetBytesRemaining() ; 108 109 protected: 110 111 void Lock() ; 112 void Unlock() ; 113 void CoalesceFreeBlocks() ; 114 } ; 115 116 117 class TraditionalDCLCommandPoolCOM: public TraditionalDCLCommandPool 118 { 119 typedef IOFireWireLibDCLCommandPoolRef Ref ; 120 typedef IOFireWireDCLCommandPoolInterface Interface ; 121 122 public: 123 TraditionalDCLCommandPoolCOM( Device& inUserClient, IOByteCount inSize ) ; 124 virtual ~TraditionalDCLCommandPoolCOM() ; 125 126 // 127 // --- COM --------------- 128 // 129 static Interface sInterface ; 130 131 // 132 // --- IUNKNOWN support ---------------- 133 // 134 static IUnknownVTbl** Alloc( 135 Device& inUserClient, 136 IOByteCount inSize) ; 137 virtual HRESULT QueryInterface(REFIID iid, void ** ppv ) ; 138 139 // 140 // --- static methods ------------------ 141 // 142 static DCLCommand* SAllocate( 143 IOFireWireLibDCLCommandPoolRef self, 144 IOByteCount inSize ) ; 145 static IOReturn SAllocateWithOpcode( 146 IOFireWireLibDCLCommandPoolRef self, 147 DCLCommand* inDCL, 148 DCLCommand** outDCL, 149 UInt32 opcode, ... ) ; 150 static DCLCommand* SAllocateTransferPacketDCL( 151 IOFireWireLibDCLCommandPoolRef self, 152 DCLCommand* inDCL, 153 UInt32 inOpcode, 154 void* inBuffer, 155 IOByteCount inSize) ; 156 static DCLCommand* SAllocateTransferBufferDCL( 157 IOFireWireLibDCLCommandPoolRef self, 158 DCLCommand* inDCL, 159 UInt32 inOpcode, 160 void* inBuffer, 161 IOByteCount inSize, 162 IOByteCount inPacketSize, 163 UInt32 inBufferOffset) ; 164 static DCLCommand* SAllocateSendPacketStartDCL( 165 IOFireWireLibDCLCommandPoolRef self, 166 DCLCommand* inDCL, 167 void* inBuffer, 168 IOByteCount inSize) ; 169 static DCLCommand* SAllocateSendPacketWithHeaderStartDCL( 170 IOFireWireLibDCLCommandPoolRef self, 171 DCLCommand* inDCL, 172 void* inBuffer, 173 IOByteCount inSize) ; 174 static DCLCommand* SAllocateSendBufferDCL( 175 IOFireWireLibDCLCommandPoolRef self, 176 DCLCommand* inDCL, 177 void* inBuffer, 178 IOByteCount inSize, 179 IOByteCount inPacketSize, 180 UInt32 inBufferOffset) ; 181 static DCLCommand* SAllocateSendPacketDCL( 182 IOFireWireLibDCLCommandPoolRef self, 183 DCLCommand* inDCL, 184 void* inBuffer, 185 IOByteCount inSize) ; 186 static DCLCommand* SAllocateReceivePacketStartDCL( 187 IOFireWireLibDCLCommandPoolRef self, 188 DCLCommand* inDCL, 189 void* inBuffer, 190 IOByteCount inSize) ; 191 static DCLCommand* SAllocateReceivePacketDCL( 192 IOFireWireLibDCLCommandPoolRef self, 193 DCLCommand* inDCL, 194 void* inBuffer, 195 IOByteCount inSize) ; 196 static DCLCommand* SAllocateReceiveBufferDCL( 197 IOFireWireLibDCLCommandPoolRef self, 198 DCLCommand* inDCL, 199 void* inBuffer, 200 IOByteCount inSize, 201 IOByteCount inPacketSize, 202 UInt32 inBufferOffset) ; 203 static DCLCommand* SAllocateCallProcDCL( IOFireWireLibDCLCommandPoolRef self, DCLCommand* dcl, DCLCallCommandProc* proc, DCLCallProcDataType procData ) ; 204 static DCLCommand* SAllocateLabelDCL( IOFireWireLibDCLCommandPoolRef self, DCLCommand* dcl ) ; 205 static DCLCommand* SAllocateJumpDCL( IOFireWireLibDCLCommandPoolRef self, DCLCommand* dcl, DCLLabel* jumpDCLLabel) ; 206 static DCLCommand* SAllocateSetTagSyncBitsDCL( 207 IOFireWireLibDCLCommandPoolRef self, 208 DCLCommand* inDCL, 209 UInt16 inTagBits, 210 UInt16 inSyncBits) ; 211 static DCLCommand* SAllocateUpdateDCLListDCL( 212 IOFireWireLibDCLCommandPoolRef self, 213 DCLCommand* inDCL, 214 DCLCommand** inDCLCommandList, 215 UInt32 inNumCommands) ; 216 static DCLCommand* SAllocatePtrTimeStampDCL( 217 IOFireWireLibDCLCommandPoolRef self, 218 DCLCommand* inDCL, 219 UInt32* inTimeStampPtr) ; 220 static void SFree( 221 IOFireWireLibDCLCommandPoolRef self, 222 DCLCommand* inDCL ) ; 223 static IOByteCount SGetSize( 224 IOFireWireLibDCLCommandPoolRef self ) ; 225 static Boolean SSetSize( 226 IOFireWireLibDCLCommandPoolRef self, 227 IOByteCount inSize ) ; 228 static IOByteCount SGetBytesRemaining( 229 IOFireWireLibDCLCommandPoolRef self ) ; 230 } ; 231} 232