1/*
2 *  IOFireWireLibNuDCLPool.h
3 *  IOFireWireFamily
4 *
5 *  Created by Niels on Tue Feb 11 2003.
6 *  Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
7 *
8 *	$Log: IOFireWireLibNuDCLPool.h,v $
9 *	Revision 1.6  2003/08/27 19:27:04  niels
10 *	*** empty log message ***
11 *
12 *	Revision 1.5  2003/08/26 05:11:22  niels
13 *	*** empty log message ***
14 *
15 *	Revision 1.4  2003/08/25 08:39:17  niels
16 *	*** empty log message ***
17 *
18 *	Revision 1.3  2003/08/20 18:48:45  niels
19 *	*** empty log message ***
20 *
21 *	Revision 1.2  2003/07/21 06:53:11  niels
22 *	merge isoch to TOT
23 *
24 *	Revision 1.1.2.3  2003/07/18 00:17:48  niels
25 *	*** empty log message ***
26 *
27 *	Revision 1.1.2.2  2003/07/09 21:24:08  niels
28 *	*** empty log message ***
29 *
30 *	Revision 1.1.2.1  2003/07/01 20:54:24  niels
31 *	isoch merge
32 *
33 */
34
35#import "IOFireWireLibIUnknown.h"
36
37#import <IOKit/firewire/IOFireWireFamilyCommon.h>
38#import <IOKit/firewire/IOFireWireLibIsoch.h>
39#import <CoreFoundation/CoreFoundation.h>
40
41namespace IOFireWireLib {
42
43	class Device ;
44	class NuDCL ;
45	class CoalesceTree ;
46
47	class NuDCLPool: public IOFireWireIUnknown
48	{
49		protected:
50
51			Device &			fDevice ;
52			DCLNuDCLLeader		fLeader ;
53			CFMutableArrayRef	fProgram ;
54			UInt8				fCurrentTag ;
55			UInt8				fCurrentSync ;
56
57		protected:
58
59			NuDCLPool( const IUnknownVTbl & vTable, Device& device, UInt32 numDCLs ) ;
60			virtual ~NuDCLPool() ;
61
62			void						Free( NuDCLRef* dcl ) ;
63			DCLCommand*					GetProgram( ) ;
64			CFArrayRef					GetDCLs() ;
65
66			void						PrintDCLs( NuDCLRef dcl ) ;
67			void						PrintDCL( NuDCLRef dcl ) ;
68
69			// Allocating
70			NuDCL *						AppendDCL(
71												CFMutableSetRef		saveBag,
72												NuDCL * 			dcl ) ;
73			void						SetCurrentTagAndSync (
74												UInt8 				tag,
75												UInt8 				sync ) ;
76			NuDCLSendPacketRef			AllocateSendPacket (
77												CFMutableSetRef 	saveBag,
78												UInt32 				numBuffers,
79												IOVirtualRange * 	buffers ) ;
80			NuDCLSkipCycleRef			AllocateSkipCycle (
81												CFMutableSetRef 	saveBag = NULL ) ;
82			NuDCLReceivePacketRef		AllocateReceivePacket (
83												CFMutableSetRef 	saveBag,
84												UInt8 				headerBytes,
85												UInt32 				numBuffers,
86												IOVirtualRange * 	buffers ) ;
87
88		public :
89
90			IOByteCount					Export (
91												IOVirtualAddress * 	outRanges,
92												IOVirtualRange		bufferRanges[],
93												unsigned			bufferRangeCount ) const ;
94			void						CoalesceBuffers(
95												CoalesceTree & 		toTree ) const ;
96			Device &					GetDevice() const						{ return fDevice ; }
97
98	} ;
99
100#pragma mark -
101	class NuDCLPoolCOM: public NuDCLPool
102	{
103		private:
104
105			static const IOFireWireNuDCLPoolInterface sInterface ;
106
107
108		public:
109
110			NuDCLPoolCOM( Device& device, UInt32 numDCLs ) ;
111			virtual ~NuDCLPoolCOM() ;
112			static const IUnknownVTbl **	Alloc( Device& device, UInt32 capacity ) ;
113			virtual HRESULT					QueryInterface( REFIID iid, LPVOID* ppv ) ;
114
115			static DCLCommand*				S_GetProgram( IOFireWireLibNuDCLPoolRef self ) ;
116			static CFArrayRef				S_GetDCLs( IOFireWireLibNuDCLPoolRef self ) ;
117			static void						S_PrintProgram( IOFireWireLibNuDCLPoolRef self ) ;
118			static void						S_PrintDCL( NuDCLRef dcl ) ;
119
120			// Allocating NuDCLs:
121
122			static void						S_SetCurrentTagAndSync( IOFireWireLibNuDCLPoolRef self, UInt8 tag, UInt8 sync ) ;
123
124			static NuDCLSendPacketRef		S_AllocateSendPacket( IOFireWireLibNuDCLPoolRef self, CFMutableSetRef saveBag, UInt32 numRanges, IOVirtualRange* ranges ) ;
125			static NuDCLSendPacketRef		S_AllocateSendPacket_v( IOFireWireLibNuDCLPoolRef self, CFMutableSetRef saveBag, IOVirtualRange* firstRange, ... ) ;
126			static NuDCLSkipCycleRef		S_AllocateSkipCycle( IOFireWireLibNuDCLPoolRef self ) ;
127			static NuDCLReceivePacketRef	S_AllocateReceivePacket( IOFireWireLibNuDCLPoolRef self, CFMutableSetRef saveBag, UInt8 headerBytes, UInt32 numBuffers, IOVirtualRange* buffers ) ;
128			static NuDCLReceivePacketRef	S_AllocateReceivePacket_v( IOFireWireLibNuDCLPoolRef self, CFMutableSetRef saveBag, UInt8 headerBytes, IOVirtualRange* firstRange, ... ) ;
129
130			// NuDCL configuration
131
132//			static IOReturn					S_SetDCLNextDCL ( NuDCLRef dcl, NuDCLRef nextDCL ) ;
133			static NuDCLRef					S_FindDCLNextDCL ( IOFireWireLibNuDCLPoolRef self, NuDCLRef dcl ) ;
134			static IOReturn					S_SetDCLBranch ( NuDCLRef dcl, NuDCLRef branchDCL ) ;
135			static NuDCLRef					S_GetDCLBranch ( NuDCLRef dcl ) ;
136			static IOReturn					S_SetDCLTimeStampPtr ( NuDCLRef dcl, UInt32* timeStampPtr ) ;
137			static UInt32*					S_GetDCLTimeStampPtr ( NuDCLRef dcl ) ;
138			static IOReturn					S_SetDCLStatusPtr( NuDCLRef dcl, UInt32* statusPtr ) ;
139			static UInt32*					S_GetDCLStatusPtr( NuDCLRef dcl ) ;
140			static IOReturn					S_AddDCLRanges ( NuDCLRef dcl, UInt32 numRanges, IOVirtualRange* ranges ) ;
141			static IOReturn					S_SetDCLRanges ( NuDCLRef dcl, UInt32 numRanges, IOVirtualRange* ranges ) ;
142			static IOReturn					S_SetDCLRanges_v ( NuDCLRef dcl, IOVirtualRange* firstRange, ... ) ;
143			static UInt32					S_GetDCLRanges ( NuDCLRef dcl, UInt32 maxRanges, IOVirtualRange* outRanges ) ;
144			static UInt32					S_CountDCLRanges ( NuDCLRef dcl ) ;
145			static IOReturn					S_GetDCLSpan ( NuDCLRef dcl, IOVirtualRange* spanRange ) ;
146			static IOByteCount				S_GetDCLSize( NuDCLRef dcl ) ;
147
148			static IOReturn					S_SetDCLCallback ( NuDCLRef dcl, NuDCLCallback callback ) ;
149			static NuDCLCallback			S_GetDCLCallback ( NuDCLRef dcl ) ;
150			static IOReturn					S_SetDCLUserHeaderPtr ( NuDCLRef dcl, UInt32 * headerPtr, UInt32 * mask ) ;
151			static UInt32 *					S_GetDCLUserHeaderPtr ( NuDCLRef dcl ) ;
152			static UInt32 *					S_GetDCLUserHeaderMaskPtr ( NuDCLRef dcl ) ;
153
154			static void						S_SetDCLRefcon( NuDCLRef dcl, void* refcon ) ;
155			static void*					S_GetDCLRefcon( NuDCLRef dcl ) ;
156
157			static IOReturn					S_AppendDCLUpdateList( NuDCLRef dcl, NuDCLRef updateDCL ) ;
158			static IOReturn					S_SetDCLUpdateList( NuDCLRef dcl, CFSetRef dclList ) ;
159			static CFSetRef					S_GetDCLUpdateList( NuDCLRef dcl ) ;
160			static IOReturn					S_EmptyDCLUpdateList( NuDCLRef dcl ) ;
161
162			static IOReturn					S_SetDCLWaitControl( NuDCLRef dcl, Boolean wait ) ;
163			static void						S_SetDCLFlags( NuDCLRef dcl, UInt32 flags ) ;
164			static UInt32					S_GetDCLFlags( NuDCLRef dcl ) ;
165			static IOReturn					S_SetDCLSkipBranch( NuDCLRef dcl, NuDCLRef skipCycleDCL ) ;
166			static NuDCLRef					S_GetDCLSkipBranch( NuDCLRef dcl ) ;
167			static IOReturn					S_SetDCLSkipCallback( NuDCLRef dcl, NuDCLCallback callback ) ;
168			static NuDCLCallback			S_GetDCLSkipCallback( NuDCLRef dcl ) ;
169			static IOReturn					S_SetDCLSkipRefcon( NuDCLRef dcl, void * refcon ) ;
170			static void *					S_GetDCLSkipRefcon( NuDCLRef dcl ) ;
171			static IOReturn					S_SetDCLSyncBits( NuDCLRef dcl, UInt8 syncBits ) ;
172			static UInt8					S_GetDCLSyncBits( NuDCLRef dcl ) ;
173			static IOReturn					S_SetDCLTagBits( NuDCLRef dcl, UInt8 tagBits ) ;
174			static UInt8					S_GetDCLTagBits( NuDCLRef dcl ) ;
175
176	} ;
177
178} // namespace
179