1/*
2 *  IOFireWireLibNuDCLPool.cpp
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.cpp,v $
9 */
10
11#import "IOFireWireLibNuDCLPool.h"
12#import "IOFireWireLibDevice.h"
13#import "IOFireWireLibNuDCL.h"
14#import "IOFireWireLibCoalesceTree.h"
15
16#import <typeinfo>
17#import <mach/mach.h>
18
19#if IOFIREWIRELIBDEBUG
20#define CAST_DCL( _type, _pointer ) reinterpret_cast<_type>(_pointer)
21#define CHECK_DCL( _type, _pointer ) if (!CAST_DCL(_type, _pointer)) { DebugLog("could not cast DCL %p to type ##_type!\n", _pointer); return ; }
22#define CHECK_DCL_IORETURN( _type, _pointer ) if (!CAST_DCL(_type, _pointer)) { return kIOReturnUnsupported ; }
23#define CHECK_DCL_NULL( _type, _pointer ) if (!CAST_DCL( _type, _pointer )) { return NULL ; }
24#define CHECK_DCL_ZERO( _type, _pointer ) if (!CAST_DCL( _type, _pointer )) { return 0 ; }
25#else
26#define CAST_DCL( _type, _pointer ) ((_type)_pointer)
27#define CHECK_DCL( _type, _pointer )
28#define CHECK_DCL_IORETURN( _type, _pointer )
29#define CHECK_DCL_NULL( _type, _pointer )
30#define CHECK_DCL_ZERO( _type, _pointer )
31#endif
32
33#undef super
34#define super IOFireWireIUnknown
35
36#define OUTPUT_FILE stdout
37namespace IOFireWireLib {
38
39	static void cfArrayReleaseNuDCLObject(CFAllocatorRef allocator,const void *ptr)
40	{
41		const NuDCL *	dcl = reinterpret_cast< const NuDCL* >( ptr ) ;
42		delete dcl;
43	}
44
45	NuDCLPool::NuDCLPool( const IUnknownVTbl & vTable, Device& device, UInt32 capacity )
46	: super( vTable )
47	,fDevice( device )
48	,fCurrentTag( 0 )
49	,fCurrentSync( 0 )
50	{
51		CFArrayCallBacks arrayCallbacks;
52
53		// Initialize callbacks
54		arrayCallbacks.version = 0;
55		arrayCallbacks.retain = NULL;
56		arrayCallbacks.copyDescription = NULL;
57		arrayCallbacks.equal = NULL;
58		arrayCallbacks.release = cfArrayReleaseNuDCLObject;
59
60		// Create fProgram array
61		fProgram = ::CFArrayCreateMutable( kCFAllocatorDefault, capacity, &arrayCallbacks );
62	}
63
64	NuDCLPool::~NuDCLPool()
65	{
66		// Release the fProgram array. The array's release callback will delete all the elements!
67		if (fProgram)
68			CFRelease(fProgram);
69	}
70
71	DCLCommand*
72	NuDCLPool::GetProgram()
73	{
74		if ( ::CFArrayGetCount( fProgram ) == 0 )
75			return nil ;
76
77		fLeader.pNextDCLCommand = nil ;
78		fLeader.opcode = kDCLNuDCLLeaderOp ;
79		fLeader.program = this ;
80
81		return reinterpret_cast< DCLCommand * > ( & fLeader ) ;
82	}
83
84	CFArrayRef
85	NuDCLPool::GetDCLs()
86	{
87		if ( fProgram )
88		{
89			::CFRetain( fProgram ) ;
90		}
91
92		return fProgram ;
93	}
94
95	void
96	NuDCLPool::SetCurrentTagAndSync ( UInt8 tag, UInt8 sync )
97	{
98		fCurrentTag = tag ;
99		fCurrentSync = sync ;
100	}
101
102	NuDCL *
103	NuDCLPool::AppendDCL( CFMutableSetRef saveBag, NuDCL * dcl )
104	{
105		if ( dcl )
106		{
107			if ( saveBag )
108			{
109				::CFSetSetValue( saveBag, dcl ) ;
110			}
111
112			::CFArrayAppendValue( fProgram, dcl ) ;
113			dcl->SetExportIndex( ::CFArrayGetCount( fProgram ) ) ;
114		}
115
116		return dcl ;
117	}
118
119	NuDCLSendPacketRef
120	NuDCLPool::AllocateSendPacket ( CFMutableSetRef saveSet, UInt32 numBuffers, IOVirtualRange* buffers )
121	{
122		SendNuDCL *dcl = new SendNuDCL( *this, numBuffers, buffers );
123		dcl->SetSync( fCurrentSync );
124		dcl->SetTag( fCurrentTag );
125		return reinterpret_cast<NuDCLSendPacketRef>( AppendDCL( saveSet, dcl ) ) ;
126	}
127
128	NuDCLSkipCycleRef
129	NuDCLPool::AllocateSkipCycle ( CFMutableSetRef saveSet )
130	{
131		return reinterpret_cast<NuDCLSkipCycleRef>( AppendDCL( saveSet, new SkipCycleNuDCL( *this ) ) ) ;
132	}
133
134
135	NuDCLReceivePacketRef
136	NuDCLPool::AllocateReceivePacket ( CFMutableSetRef saveBag, UInt8 headerBytes, UInt32 numRanges, IOVirtualRange* ranges )
137	{
138		return reinterpret_cast<NuDCLReceivePacketRef>( AppendDCL( saveBag, new ReceiveNuDCL( *this, headerBytes, numRanges, ranges ) ) ) ;
139	}
140
141	IOByteCount
142	NuDCLPool::Export (
143		IOVirtualAddress * 		outExportData,
144		IOVirtualRange			bufferRanges[],
145		unsigned				bufferRangeCount ) const
146	{
147		unsigned programCount = ::CFArrayGetCount( fProgram ) ;
148		IOByteCount exportBytes = 0 ;
149
150		for( unsigned index=0; index < programCount; ++index )
151		{
152			const NuDCL *	dcl = reinterpret_cast< const NuDCL* >(::CFArrayGetValueAtIndex( fProgram, index ) ) ;
153
154			exportBytes += dcl->Export( NULL, NULL, 0 ) ;		// find export data size needed
155		}
156
157		vm_allocate( mach_task_self(), (vm_address_t*)outExportData, exportBytes, true /*anywhere*/ ) ;
158
159		{
160			IOVirtualAddress exportCursor = *outExportData ;
161
162			for ( unsigned index = 0 ; index < programCount ; ++index )
163			{
164				const NuDCL *	dcl = reinterpret_cast< const NuDCL* >(::CFArrayGetValueAtIndex( fProgram, index ) ) ;
165
166				dcl->Export( & exportCursor, bufferRanges, bufferRangeCount ) ;			// make export data.. we don't care about the returned size
167			}
168		}
169
170		// export program ranges... (There is only 1; it points to a block containing a serialized
171		// version our program)
172
173		return exportBytes ;		// 1 range contains serialized program data
174	}
175
176	void
177	NuDCLPool::CoalesceBuffers ( CoalesceTree & toTree ) const
178	{
179		CFIndex count = ::CFArrayGetCount( fProgram ) ;
180		for ( CFIndex index = 0 ; index < count ; ++index )
181		{
182			reinterpret_cast< const NuDCL* >( ::CFArrayGetValueAtIndex( fProgram, index ) )->CoalesceBuffers( toTree ) ;
183		}
184	}
185
186#pragma mark -
187#undef Class
188#define Class NuDCLPoolCOM
189
190#undef super
191#define super NuDCLPool
192
193	const IOFireWireNuDCLPoolInterface NuDCLPoolCOM::sInterface =
194	{
195		INTERFACEIMP_INTERFACE,
196		1, 1, 		// version/revision
197
198		& Class::S_GetProgram
199		,& Class::S_GetDCLs
200		,& Class::S_PrintProgram
201		,& Class::S_PrintDCL
202		,& Class::S_SetCurrentTagAndSync
203		,& Class::S_AllocateSendPacket
204		,& Class::S_AllocateSendPacket_v
205		,& Class::S_AllocateSkipCycle
206		,& Class::S_AllocateReceivePacket
207		,& Class::S_AllocateReceivePacket_v
208//		,& Class::S_SetDCLNextDCL
209		,& Class::S_FindDCLNextDCL
210		,& Class::S_SetDCLBranch
211		,& Class::S_GetDCLBranch
212		,& Class::S_SetDCLTimeStampPtr
213		,& Class::S_GetDCLTimeStampPtr
214		,& Class::S_SetDCLStatusPtr
215		,& Class::S_GetDCLStatusPtr
216		,& Class::S_AddDCLRanges
217		,& Class::S_SetDCLRanges
218		,& Class::S_SetDCLRanges_v
219		,& Class::S_GetDCLRanges
220		,& Class::S_CountDCLRanges
221		,& Class::S_GetDCLSpan
222		,& Class::S_GetDCLSize
223		,& Class::S_SetDCLCallback
224		,& Class::S_GetDCLCallback
225		,& Class::S_SetDCLUserHeaderPtr
226		,& Class::S_GetDCLUserHeaderPtr
227		,& Class::S_GetDCLUserHeaderMaskPtr
228		,& Class::S_SetDCLRefcon
229		,& Class::S_GetDCLRefcon
230		,& Class::S_AppendDCLUpdateList
231		,& Class::S_SetDCLUpdateList
232		,& Class::S_GetDCLUpdateList
233		,& Class::S_EmptyDCLUpdateList
234		,& Class::S_SetDCLWaitControl
235		,& NuDCLPoolCOM::S_SetDCLFlags
236		, & NuDCLPoolCOM::S_GetDCLFlags
237		, & NuDCLPoolCOM::S_SetDCLSkipBranch
238		, & NuDCLPoolCOM::S_GetDCLSkipBranch
239		, & NuDCLPoolCOM::S_SetDCLSkipCallback
240		, & NuDCLPoolCOM::S_GetDCLSkipCallback
241		, & NuDCLPoolCOM::S_SetDCLSkipRefcon
242		, & NuDCLPoolCOM::S_GetDCLSkipRefcon
243		, & NuDCLPoolCOM::S_SetDCLSyncBits
244		, & NuDCLPoolCOM::S_GetDCLSyncBits
245		, & NuDCLPoolCOM::S_SetDCLTagBits
246		, & NuDCLPoolCOM::S_GetDCLTagBits
247	} ;
248
249	NuDCLPoolCOM::NuDCLPoolCOM( Device& device, UInt32 numDCLs )
250	: super( reinterpret_cast<const IUnknownVTbl &>( sInterface ), device, numDCLs )
251	{
252	}
253
254	NuDCLPoolCOM::~NuDCLPoolCOM()
255	{
256	}
257
258	const IUnknownVTbl **
259	NuDCLPoolCOM::Alloc( Device& device, UInt32 capacity )
260	{
261		NuDCLPoolCOM *	me = nil;
262		try {
263			me = new NuDCLPoolCOM( device, capacity ) ;
264		} catch(...) {
265		}
266
267		return (nil == me) ? nil : reinterpret_cast<const IUnknownVTbl**>( & me->GetInterface() ) ;
268	}
269
270	HRESULT
271	NuDCLPoolCOM::QueryInterface( REFIID iid, LPVOID* ppv )
272	{
273		HRESULT		result = S_OK ;
274		*ppv = nil ;
275
276		CFUUIDRef	interfaceID	= CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, iid) ;
277
278		if ( ::CFEqual(interfaceID, IUnknownUUID) ||  ::CFEqual(interfaceID, kIOFireWireNuDCLPoolInterfaceID) )
279		{
280			*ppv = & GetInterface() ;
281			AddRef() ;
282		}
283		else
284		{
285			*ppv = nil ;
286			result = E_NOINTERFACE ;
287		}
288
289		::CFRelease(interfaceID) ;
290		return result ;
291	}
292
293	DCLCommand*
294	NuDCLPoolCOM::S_GetProgram( IOFireWireLibNuDCLPoolRef self  )
295	{
296		return IOFireWireIUnknown::InterfaceMap< Class >::GetThis( self )->GetProgram( ) ;
297	}
298
299	CFArrayRef
300	NuDCLPoolCOM::S_GetDCLs( IOFireWireLibNuDCLPoolRef self )
301	{
302		return IOFireWireIUnknown::InterfaceMap< Class >::GetThis( self )->GetDCLs( ) ;
303	}
304
305	void
306	NuDCLPoolCOM::S_PrintProgram( IOFireWireLibNuDCLPoolRef self )
307	{
308		NuDCLPoolCOM* me = IOFireWireIUnknown::InterfaceMap< NuDCLPoolCOM >::GetThis( self ) ;
309		CFIndex count = ::CFArrayGetCount( me->fProgram ) ;
310
311		for( CFIndex index=0; index < count; ++index )
312		{
313			fprintf( OUTPUT_FILE, "%ld:", index ) ;
314			reinterpret_cast<const NuDCL*>( ::CFArrayGetValueAtIndex( me->fProgram, index ) )->Print( OUTPUT_FILE ) ;
315		}
316	}
317
318	void
319	NuDCLPoolCOM::S_PrintDCL( NuDCLRef dcl  )
320	{
321		CHECK_DCL( NuDCL*, dcl ) ;
322
323		CAST_DCL( NuDCL*, dcl )->Print( OUTPUT_FILE ) ;
324	}
325
326	// Allocating send NuDCLs:
327
328	void
329	NuDCLPoolCOM::S_SetCurrentTagAndSync( IOFireWireLibNuDCLPoolRef self, UInt8 tag, UInt8 sync  )
330	{
331		IOFireWireIUnknown::InterfaceMap< Class >::GetThis( self )->SetCurrentTagAndSync( tag, sync ) ;
332	}
333
334	NuDCLSendPacketRef
335	NuDCLPoolCOM::S_AllocateSendPacket( IOFireWireLibNuDCLPoolRef self, CFMutableSetRef saveBag, UInt32 numBuffers, IOVirtualRange* buffers )
336	{
337		return IOFireWireIUnknown::InterfaceMap< Class >::GetThis( self )->AllocateSendPacket( saveBag, numBuffers, buffers ) ;
338	}
339
340	NuDCLSendPacketRef
341	NuDCLPoolCOM::S_AllocateSendPacket_v( IOFireWireLibNuDCLPoolRef self, CFMutableSetRef saveBag, IOVirtualRange* firstRange, ... )
342	{
343		if ( firstRange )
344		{
345			unsigned 	count = 1 ;
346			va_list 	args;
347
348			// count args
349
350			va_start( args, firstRange ) ;
351			while ( va_arg( args, IOVirtualRange* ) )
352				++count ;
353			va_end( args );
354
355			IOVirtualRange buffers[ count ] ;
356
357			// copy args to buffers array
358
359			buffers[0] = *firstRange ;
360			va_start( args, firstRange ) ;
361			for( unsigned index=1; index < count; ++index )
362				buffers[index] = *va_arg( args, IOVirtualRange* ) ;
363			va_end( args ) ;
364
365			return IOFireWireIUnknown::InterfaceMap< Class >::GetThis( self )->AllocateSendPacket( saveBag, count, buffers ) ;
366		}
367
368		return IOFireWireIUnknown::InterfaceMap< Class >::GetThis( self )->AllocateSendPacket( saveBag, 0, nil ) ;
369	}
370
371
372	NuDCLSkipCycleRef
373	NuDCLPoolCOM::S_AllocateSkipCycle( IOFireWireLibNuDCLPoolRef self  )
374	{
375		return IOFireWireIUnknown::InterfaceMap< Class >::GetThis( self )->AllocateSkipCycle() ;
376	}
377
378	//
379	// Allocating send NuDCLs:
380	//
381
382	NuDCLReceivePacketRef
383	NuDCLPoolCOM::S_AllocateReceivePacket( IOFireWireLibNuDCLPoolRef self, CFMutableSetRef saveBag, UInt8 headerBytes, UInt32 numBuffers, IOVirtualRange* buffers )
384	{
385		return IOFireWireIUnknown::InterfaceMap< Class >::GetThis( self )->AllocateReceivePacket( saveBag, headerBytes, numBuffers, buffers ) ;
386	}
387
388	NuDCLReceivePacketRef
389	NuDCLPoolCOM::S_AllocateReceivePacket_v( IOFireWireLibNuDCLPoolRef self, CFMutableSetRef saveBag, UInt8 headerBytes, IOVirtualRange* firstRange, ... )
390	{
391		if ( firstRange )
392		{
393			unsigned 	count = 1 ;
394			va_list 	args;
395
396			// count args
397
398			va_start( args, firstRange ) ;
399			while ( va_arg( args, IOVirtualRange* ) )
400				++count ;
401			va_end( args );
402
403			IOVirtualRange buffers[ count ] ;
404
405			// copy args to buffers array
406
407			buffers[0] = *firstRange ;
408			va_start( args, firstRange ) ;
409			for( unsigned index=1; index < count; ++index )
410				buffers[index] = *va_arg( args, IOVirtualRange* ) ;
411			va_end( args ) ;
412
413			return IOFireWireIUnknown::InterfaceMap< Class >::GetThis( self )->AllocateReceivePacket( saveBag, headerBytes, count, buffers ) ;
414		}
415
416		return IOFireWireIUnknown::InterfaceMap< Class >::GetThis( self )->AllocateReceivePacket( saveBag, headerBytes, 0, nil ) ;
417	}
418
419	//
420	// NuDCL configuration
421	//
422
423	NuDCLRef
424	NuDCLPoolCOM::S_FindDCLNextDCL( IOFireWireLibNuDCLPoolRef self, NuDCLRef dcl )
425	{
426		CHECK_DCL_NULL( NuDCL*, dcl ) ;
427
428		NuDCLPoolCOM* me = IOFireWireIUnknown::InterfaceMap<NuDCLPoolCOM>::GetThis( self ) ;
429
430		CFIndex count = ::CFArrayGetCount( me->fProgram ) ;
431		CFIndex index = ::CFArrayGetFirstIndexOfValue( me->fProgram, ::CFRangeMake( 0, count ),  dcl ) ;
432		if ( index == kCFNotFound || index == count )
433			return 0 ;
434
435		return (NuDCLRef)::CFArrayGetValueAtIndex( me->fProgram, index+1 ) ;
436	}
437
438	IOReturn
439	NuDCLPoolCOM::S_SetDCLBranch( NuDCLRef dcl, NuDCLRef branchDCL  )
440	{
441		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
442
443		CAST_DCL( NuDCL*, dcl )->SetBranch( CAST_DCL( NuDCL*, branchDCL ) ) ;
444
445		return kIOReturnSuccess ;
446	}
447
448	NuDCLRef
449	NuDCLPoolCOM::S_GetDCLBranch( NuDCLRef dcl  )
450	{
451		CHECK_DCL_NULL( NuDCL*, dcl ) ;
452
453		return reinterpret_cast<NuDCLRef>( CAST_DCL( NuDCL*, dcl )->GetBranch() ) ;
454	}
455
456	IOReturn
457	NuDCLPoolCOM::S_SetDCLTimeStampPtr( NuDCLRef dcl, UInt32* timeStampPtr  )
458	{
459		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
460
461		CAST_DCL( NuDCL*, dcl )->SetTimeStampPtr( timeStampPtr ) ;
462
463		return kIOReturnSuccess ;
464	}
465
466	UInt32*
467	NuDCLPoolCOM::S_GetDCLTimeStampPtr( NuDCLRef dcl  )
468	{
469		CHECK_DCL_NULL( NuDCL*, dcl ) ;
470
471		return CAST_DCL( NuDCL*, dcl )->GetTimeStampPtr() ;
472	}
473
474	IOReturn
475	NuDCLPoolCOM::S_AddDCLRanges( NuDCLRef dcl, UInt32 numRanges, IOVirtualRange* ranges  )
476	{
477		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
478
479		return CAST_DCL( NuDCL*, dcl )->AppendRanges( numRanges, ranges ) ;
480	}
481
482	IOReturn
483	NuDCLPoolCOM::S_SetDCLRanges( NuDCLRef dcl, UInt32 numRanges, IOVirtualRange* ranges  )
484	{
485		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
486
487		return CAST_DCL( NuDCL*, dcl )->SetRanges( numRanges, ranges ) ;
488	}
489
490	IOReturn
491	NuDCLPoolCOM::S_SetDCLRanges_v ( NuDCLRef dcl, IOVirtualRange* firstRange, ... )
492	{
493		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
494
495		if ( firstRange )
496		{
497			unsigned 	count = 1 ;
498			va_list 	args;
499
500			// count args
501
502			va_start( args, firstRange ) ;
503			while ( va_arg( args, IOVirtualRange* ) )
504				++count ;
505			va_end( args );
506
507			IOVirtualRange buffers[ count ] ;
508
509			// copy args to buffers array
510
511			buffers[0] = *firstRange ;
512			va_start( args, firstRange ) ;
513			for( unsigned index=1; index < count; ++index )
514				buffers[index] = *va_arg( args, IOVirtualRange* ) ;
515			va_end( args ) ;
516
517			return CAST_DCL( NuDCL*, dcl )->SetRanges( count, buffers ) ;
518		}
519
520		return kIOReturnSuccess ;
521	}
522
523
524	UInt32
525	NuDCLPoolCOM::S_GetDCLRanges( NuDCLRef dcl, UInt32 maxRanges, IOVirtualRange* outRanges  )
526	{
527		CHECK_DCL_ZERO( NuDCL*, dcl ) ;
528
529		return CAST_DCL( NuDCL*, dcl )->GetRanges( maxRanges, outRanges ) ;
530	}
531
532	UInt32
533	NuDCLPoolCOM::S_CountDCLRanges( NuDCLRef dcl )
534	{
535		CHECK_DCL_ZERO( NuDCL*, dcl ) ;
536
537		return CAST_DCL( NuDCL*, dcl )->CountRanges() ;
538	}
539
540	IOReturn
541	NuDCLPoolCOM::S_GetDCLSpan ( NuDCLRef dcl, IOVirtualRange* spanRange )
542	{
543		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
544
545		return CAST_DCL( NuDCL*, dcl )->GetSpan( *spanRange ) ;
546	}
547
548
549	IOByteCount
550	NuDCLPoolCOM::S_GetDCLSize( NuDCLRef dcl )
551	{
552		CHECK_DCL_ZERO( NuDCL*, dcl ) ;
553
554		return CAST_DCL( NuDCL*, dcl )->GetSize() ;
555	}
556
557
558	IOReturn
559	NuDCLPoolCOM::S_SetDCLCallback( NuDCLRef dcl, NuDCLCallback callback  )
560	{
561		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
562
563		CAST_DCL( NuDCL*, dcl )->SetCallback( callback ) ;
564
565		return kIOReturnSuccess ;
566	}
567
568	NuDCLCallback
569	NuDCLPoolCOM::S_GetDCLCallback( NuDCLRef dcl  )
570	{
571		CHECK_DCL_NULL( NuDCL*,  dcl ) ;
572
573		return CAST_DCL( NuDCL*, dcl )->GetCallback() ;
574	}
575
576	IOReturn
577	NuDCLPoolCOM::S_SetDCLUserHeaderPtr( NuDCLRef dcl, UInt32 * headerPtr, UInt32 * mask )
578	{
579		CHECK_DCL_IORETURN( SendNuDCL*, dcl ) ;
580
581		CAST_DCL( SendNuDCL*, dcl )->SetUserHeaderPtr( headerPtr, mask ) ;
582
583		return kIOReturnSuccess ;
584	}
585
586	UInt32*
587	NuDCLPoolCOM::S_GetDCLUserHeaderPtr ( NuDCLRef dcl )
588	{
589		CHECK_DCL_NULL( SendNuDCL*, dcl ) ;
590
591		return CAST_DCL( SendNuDCL*, dcl )->GetUserHeaderPtr() ;
592	}
593
594	UInt32 *
595	NuDCLPoolCOM::S_GetDCLUserHeaderMaskPtr ( NuDCLRef dcl )
596	{
597		CHECK_DCL_NULL( SendNuDCL*, dcl ) ;
598
599		return CAST_DCL( SendNuDCL*, dcl )->GetUserHeaderMask() ;
600	}
601
602	IOReturn
603	NuDCLPoolCOM::S_SetDCLStatusPtr( NuDCLRef dcl, UInt32* statusPtr  )
604	{
605		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
606
607		CAST_DCL( NuDCL*, dcl )->SetStatusPtr( statusPtr ) ;
608
609		return kIOReturnSuccess ;
610	}
611
612	UInt32*
613	NuDCLPoolCOM::S_GetDCLStatusPtr( NuDCLRef dcl )
614	{
615		CHECK_DCL_NULL( NuDCL*, dcl ) ;
616
617		return CAST_DCL( NuDCL*, dcl )->GetStatusPtr() ;
618	}
619
620	void
621	NuDCLPoolCOM::S_SetDCLRefcon( NuDCLRef dcl, void* refcon  )
622	{
623		CHECK_DCL( NuDCL*, dcl ) ;
624
625		CAST_DCL( NuDCL*, dcl )->SetRefcon( refcon ) ;
626	}
627
628	void*
629	NuDCLPoolCOM::S_GetDCLRefcon( NuDCLRef dcl  )
630	{
631		CHECK_DCL_NULL( NuDCL*, dcl ) ;
632
633		return CAST_DCL( NuDCL*, dcl )->GetRefcon() ;
634	}
635
636	IOReturn
637	NuDCLPoolCOM::S_SetDCLUpdateList( NuDCLRef dcl, CFSetRef dclList  )
638	{
639		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
640
641		CAST_DCL( NuDCL*, dcl )->SetUpdateList( dclList ) ;
642
643		return kIOReturnSuccess ;
644	}
645
646	CFSetRef
647	NuDCLPoolCOM::S_GetDCLUpdateList( NuDCLRef dcl )
648	{
649		CHECK_DCL_NULL( NuDCL*, dcl ) ;
650
651		return CAST_DCL( NuDCL*, dcl )->GetUpdateList() ;
652	}
653
654	IOReturn
655	NuDCLPoolCOM::S_AppendDCLUpdateList( NuDCLRef dcl, NuDCLRef updateDCL  )
656	{
657		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
658		CHECK_DCL_IORETURN( NuDCL*, updateDCL ) ;
659
660		CAST_DCL( NuDCL*, dcl )->AppendUpdateList( CAST_DCL( NuDCL*, updateDCL ) ) ;
661
662		return kIOReturnSuccess ;
663	}
664
665	IOReturn
666	NuDCLPoolCOM::S_EmptyDCLUpdateList( NuDCLRef dcl  )
667	{
668		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
669
670		CAST_DCL( NuDCL*, dcl )->EmptyUpdateList() ;
671
672		return kIOReturnSuccess ;
673	}
674
675	IOReturn
676	NuDCLPoolCOM::S_SetDCLWaitControl( NuDCLRef dcl, Boolean wait  )
677	{
678		CHECK_DCL_IORETURN( ReceiveNuDCL*, dcl ) ;
679
680		return CAST_DCL( ReceiveNuDCL*, dcl )->SetWaitControl( (bool)wait ) ;
681	}
682
683	void
684	NuDCLPoolCOM::S_SetDCLFlags( NuDCLRef dcl, UInt32 flags )
685	{
686		CHECK_DCL( NuDCL*, dcl ) ;
687
688		CAST_DCL( NuDCL*, dcl )->SetFlags( flags ) ;
689	}
690
691	UInt32
692	NuDCLPoolCOM::S_GetDCLFlags( NuDCLRef dcl )
693	{
694		CHECK_DCL_ZERO( NuDCL*, dcl ) ;
695
696		return CAST_DCL( NuDCL*, dcl )->GetFlags() ;
697	}
698
699	IOReturn
700	NuDCLPoolCOM::S_SetDCLSkipBranch( NuDCLRef dcl, NuDCLRef skipCycleDCL )
701	{
702		CHECK_DCL_IORETURN( SendNuDCL*, dcl ) ;
703		CHECK_DCL_IORETURN( NuDCL*, dcl ) ;
704
705		CAST_DCL( SendNuDCL*, dcl )->SetSkipBranch( CAST_DCL( NuDCL*, skipCycleDCL ) ) ;
706		return kIOReturnSuccess ;
707	}
708
709	NuDCLRef
710	NuDCLPoolCOM::S_GetDCLSkipBranch( NuDCLRef dcl )
711	{
712		CHECK_DCL_NULL( SendNuDCL *, dcl ) ;
713
714		return reinterpret_cast<NuDCLRef>( CAST_DCL( SendNuDCL *, dcl )->GetSkipBranch() ) ;
715	}
716
717	IOReturn
718	NuDCLPoolCOM::S_SetDCLSkipCallback( NuDCLRef dcl, NuDCLCallback callback )
719	{
720		CHECK_DCL_IORETURN( SendNuDCL *, dcl ) ;
721
722		CAST_DCL( SendNuDCL *, dcl)->SetSkipCallback( callback ) ;
723		return kIOReturnSuccess ;
724	}
725
726	NuDCLCallback
727	NuDCLPoolCOM::S_GetDCLSkipCallback( NuDCLRef dcl )
728	{
729		CHECK_DCL_NULL( SendNuDCL *, dcl ) ;
730
731		return CAST_DCL( SendNuDCL *, dcl )->GetSkipCallback() ;
732	}
733
734	IOReturn
735	NuDCLPoolCOM::S_SetDCLSkipRefcon( NuDCLRef dcl, void * refcon )
736	{
737		CHECK_DCL_IORETURN( SendNuDCL *, dcl ) ;
738
739		CAST_DCL( SendNuDCL *, dcl )->SetSkipRefcon( refcon ) ;
740		return kIOReturnSuccess ;
741	}
742
743	void *
744	NuDCLPoolCOM::S_GetDCLSkipRefcon( NuDCLRef dcl )
745	{
746		CHECK_DCL_NULL( SendNuDCL *, dcl ) ;
747
748		return CAST_DCL( SendNuDCL *, dcl )->GetSkipRefcon() ;
749	}
750
751	IOReturn
752	NuDCLPoolCOM::S_SetDCLSyncBits( NuDCLRef dcl, UInt8 syncBits )
753	{
754		CHECK_DCL_IORETURN( SendNuDCL *, dcl ) ;
755
756		CAST_DCL( SendNuDCL *, dcl )->SetSync( syncBits ) ;
757		return kIOReturnSuccess ;
758	}
759
760	UInt8
761	NuDCLPoolCOM::S_GetDCLSyncBits( NuDCLRef dcl )
762	{
763		CHECK_DCL_ZERO( SendNuDCL*, dcl ) ;
764
765		return CAST_DCL( SendNuDCL *, dcl )->GetSync() ;
766	}
767
768	IOReturn
769	NuDCLPoolCOM::S_SetDCLTagBits( NuDCLRef dcl, UInt8 tagBits )
770	{
771		CHECK_DCL_IORETURN( SendNuDCL *, dcl ) ;
772
773		CAST_DCL( SendNuDCL *, dcl )->SetTag( tagBits ) ;
774		return kIOReturnSuccess ;
775	}
776
777	UInt8
778	NuDCLPoolCOM::S_GetDCLTagBits( NuDCLRef dcl )
779	{
780		CHECK_DCL_ZERO( SendNuDCL *, dcl ) ;
781
782		return CAST_DCL( SendNuDCL *, dcl )->GetTag() ;
783	}
784
785} // namespace
786