Chameleon

Chameleon Svn Source Tree

Root/branches/Chimera/i386/include/IOKit/firewire/IOFWCommand.h

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 *
24 *IOFWCommand.h
25 *
26 */
27#ifndef _IOKIT_IOFWCOMMAND_H
28#define _IOKIT_IOFWCOMMAND_H
29
30#include <IOKit/IOCommand.h>
31#include <IOKit/IOLib.h>
32
33#include <IOKit/firewire/IOFireWireFamilyCommon.h>
34
35#include <IOKit/firewire/IOFWSyncer.h>
36
37#define kFWCmdDefaultRetries 3
38#define kFWCmdZeroRetries 0
39#define kFWCmdReducedRetries 2
40#define kFWCmdIncreasedRetries 6
41
42class IOMemoryDescriptor;
43class IOSyncer;
44class IOFireWireBus;
45class IOFireWireController;
46class IOFireWireNub;
47class IOFWAddressSpace;// Description of chunk of local FW address space
48class IOFWCommand;
49class IOFWBusCommand;
50class IOFWAsyncStreamCommand;
51class IOCommandGate;
52class IOFWAsyncPHYCommand;
53
54struct AsyncPendingTrans;
55
56// Struct for head of command queue
57/*!
58 @struct IOFWCmdQ
59 @abstract Structure for head of a queue of IOFWCommands
60 @field fHead Points to the head of the queue, or NULL if queue is empty
61 @field fTail Points to the tail of the queue, or NULL if queue is empty
62 @function headChanged called when head command is changed, or the command
63 itself changes state.
64*/
65
66struct IOFWCmdQ
67{
68 IOFWCommand *fHead;
69 IOFWCommand *fTail;
70 bool executeQueue(bool all);
71 virtual void headChanged(IOFWCommand *oldHead);
72
73virtual ~IOFWCmdQ() {}
74
75void checkProgress( void );
76};
77
78// Callback when device command completes asynchronously
79typedef void (*FWDeviceCallback)(void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd);
80
81// Callback when bus command completes asynchronously
82typedef void (*FWBusCallback)(void *refcon, IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd);
83
84// Callback when async stream command completes asynchronously
85typedef void (*FWAsyncStreamCallback)(void *refcon, IOReturn status, IOFireWireBus *bus, IOFWAsyncStreamCommand *fwCmd);
86
87// Callback when async stream command completes asynchronously
88typedef void (*FWAsyncPHYCallback)(void *refcon, IOReturn status, IOFireWireBus *bus, IOFWAsyncPHYCommand *fwCmd );
89
90// Callback when async stream packet is received
91typedef void (*FWAsyncStreamReceiveCallback)(void *refcon, const void *buf);
92
93#pragma mark -
94
95/*
96 * Base class for FireWire commands
97 */
98/*! @class IOFWCommand
99*/
100class IOFWCommand : public IOCommand
101{
102 OSDeclareAbstractStructors(IOFWCommand)
103
104protected:
105 IOReturnfStatus;
106 IOFireWireController *fControl;
107 IOFWCommand *fQueuePrev;
108 IOFWCommand *fQueueNext;
109 IOFWCmdQ *fQueue;
110 UInt32fTimeout;// How long (in microsecs) after execute() to timeout
111 AbsoluteTimefDeadline;// Time after which this command has timed out.
112 IOFWSyncer *fSyncWakeup;
113 UInt8fSync;
114 UInt8fCancelOnReset;
115 UInt8spare[2];
116
117/*! @struct ExpansionData
118 @discussion This structure will be used to expand the capablilties of the class in the future.
119 */
120 struct MemberVariables
121{
122void *fFWIMRefCon;
123IOReturnfCompletionStatus;
124boolfSubmitTimeLatched;
125 AbsoluteTimefSubmitTime;
126boolfFlush;
127};
128
129/*! @var reserved
130 Reserved for future use. (Internal use only) */
131 MemberVariables * fMembers;
132
133 virtual IOReturncomplete(IOReturn status);
134 virtual voidupdateTimer();
135 virtual IOReturnstartExecution();
136
137 /*
138 *Execute the FWCommand immediately
139 *must be called with the workloop gate closed
140 */
141 virtual IOReturnexecute() = 0;
142
143public:
144
145 virtual boolinitWithController(IOFireWireController *control);
146virtual voidfree( void );
147
148 IOReturngetStatus() const { return fStatus; };
149
150 /*
151 *Submit the FWCommand.
152 *if queue is false the command's execute()
153 *method will be called on the caller's thread, otherwise
154 *the command wil be queued for execution on the work loop thread.
155 */
156 virtual IOReturn submit(bool queue = false);
157
158 /*
159 * Cancel command, causes it to complete with given status
160 */
161 virtual IOReturncancel(IOReturn reason);
162
163 /*!
164 @function setHead
165 inserts a command at the head of a queue.
166 @param queue queue command is being added to
167 */
168 virtual void setHead(IOFWCmdQ &queue);
169 /*!
170 @function insertAfter
171 inserts a command after the specified one.
172 @param prev command to insert after
173 @param queue queue command is being added to
174 */
175 virtual void insertAfter(IOFWCommand &prev);
176
177 /*!
178 @function removeFromQ
179 Removes command from current queue.
180 */
181 virtual void removeFromQ();
182
183 IOFWCommand *getPrevious() const
184{ return fQueuePrev; };
185 IOFWCommand *getNext() const
186 { return fQueueNext; };
187 const AbsoluteTime &getDeadline() const
188{ return fDeadline; };
189
190 bool cancelOnReset() const
191 { return fCancelOnReset; };
192
193 bool Busy() const
194 { return fStatus == kIOReturnBusy || fStatus == kIOFireWirePending;};
195
196 void setTimeout( UInt32 timeout )
197 { fTimeout = timeout; };
198
199 friend class IOFWCmdQ;
200
201void * getFWIMRefCon( void )
202{
203return fMembers->fFWIMRefCon;
204}
205
206void setFWIMRefCon( void * refcon )
207{
208fMembers->fFWIMRefCon = refcon;
209}
210
211void setFlush( bool flush )
212{
213fMembers->fFlush = flush;
214}
215
216virtual IOReturn checkProgress( void );
217
218private:
219 OSMetaClassDeclareReservedUsed(IOFWCommand, 0);
220 OSMetaClassDeclareReservedUnused(IOFWCommand, 1);
221
222};
223
224#pragma mark -
225
226/*
227 * Bus control commands
228 */
229/*! @class IOFWBusCommand
230*/
231class IOFWBusCommand : public IOFWCommand
232{
233 OSDeclareAbstractStructors(IOFWBusCommand)
234
235protected:
236 FWBusCallbackfComplete;
237 void *fRefCon;
238
239/*! @struct ExpansionData
240 @discussion This structure will be used to expand the capablilties of the class in the future.
241 */
242 struct ExpansionData { };
243
244/*! @var reserved
245 Reserved for future use. (Internal use only) */
246 ExpansionData *reserved;
247
248 virtual IOReturncomplete(IOReturn status);
249
250 virtual boolinitWithController(IOFireWireController *control,
251FWBusCallback completion=NULL, void *refcon=NULL);
252 virtual IOReturnreinit(FWBusCallback completion, void *refcon);
253
254private:
255 OSMetaClassDeclareReservedUnused(IOFWBusCommand, 0);
256
257};
258
259#pragma mark -
260
261/*
262 * Command to execute some code after a specified delay (in microseconds)
263 * All it does is timeout after the specified delay, hence calling the completion
264 * callback.
265 */
266/*! @class IOFWDelayCommand
267*/
268class IOFWDelayCommand : public IOFWBusCommand
269{
270 OSDeclareDefaultStructors(IOFWDelayCommand)
271
272/*! @struct ExpansionData
273 @discussion This structure will be used to expand the capablilties of the class in the future.
274 */
275 struct ExpansionData { };
276
277/*! @var reserved
278 Reserved for future use. (Internal use only) */
279 ExpansionData *reserved;
280
281protected:
282 virtual IOReturnexecute();
283
284public:
285 virtual boolinitWithDelay(IOFireWireController *control, UInt32 uSecs,
286 FWBusCallback completion, void *refcon);
287 virtual IOReturnreinit(UInt32 uSecs, FWBusCallback completion, void *refcon);
288
289private:
290 OSMetaClassDeclareReservedUnused(IOFWDelayCommand, 0);
291
292};
293
294/*
295 * Send an async request to a device
296 */
297class IOFWUserReadQuadletCommand ;
298class IOFWUserWriteCommand ;
299
300#pragma mark -
301
302/*! @class IOFWAsyncCommand
303*/
304class IOFWAsyncCommand : public IOFWCommand
305{
306OSDeclareAbstractStructors(IOFWAsyncCommand)
307
308protected:
309 IOFireWireNub *fDevice;
310 FWDeviceCallbackfComplete;
311 void *fRefCon;
312 IOMemoryDescriptor *fMemDesc;
313 AsyncPendingTrans *fTrans;
314 UInt32fAddressHi;
315 UInt32fAddressLo;
316 IOByteCountfBytesTransferred;
317 intfSize;
318 intfSpeed;
319 intfMaxPack;
320 intfCurRetries;
321 intfMaxRetries;
322 UInt32fGeneration;// bus topology fNodeID is valid for.
323 UInt16fNodeID;
324 boolfFailOnReset;
325 boolfWrite;
326
327typedef struct
328{
329// some of our subclasses didn't have room for expansion data, so
330// we've reserved space for their use here.
331
332void *fSubclassMembers;
333intfMaxSpeed;
334intfAckCode;
335UInt32fResponseCode;
336UInt32fFastRetryCount;
337intfResponseSpeed;
338boolfForceBlockRequests;
339}
340MemberVariables;
341
342 MemberVariables * fMembers;
343
344 virtual IOReturncomplete(IOReturn status);
345virtual boolinitWithController(IOFireWireController *control);
346 virtual boolinitAll(IOFireWireNub *device, FWAddress devAddress,
347IOMemoryDescriptor *hostMem,
348FWDeviceCallback completion, void *refcon, bool failOnReset);
349 virtual boolinitAll(IOFireWireController *control,
350 UInt32 generation, FWAddress devAddress,
351 IOMemoryDescriptor *hostMem,
352 FWDeviceCallback completion, void *refcon);
353virtual void free( void );
354 virtual IOReturnreinit(FWAddress devAddress, IOMemoryDescriptor *hostMem,
355FWDeviceCallback completion, void *refcon, bool failOnReset);
356 virtual IOReturnreinit(UInt32 generation, FWAddress devAddress, IOMemoryDescriptor *hostMem,
357 FWDeviceCallback completion, void *refcon);
358bool createMemberVariables( void );
359void destroyMemberVariables( void );
360public:
361// Utility for setting generation on newly created command
362virtual voidsetGeneration(UInt32 generation)
363{ fGeneration = generation; }
364
365 // To be called by IOFireWireController and derived classes.
366 virtual void gotPacket(int rcode, const void* data, int size) = 0;
367 virtual voidgotAck(int ackCode);
368
369 // update nodeID/generation after bus reset, from the device object
370 IOReturnupdateGeneration();
371 // explicitly update nodeID/generation after bus reset
372 IOReturnupdateNodeID(UInt32 generation, UInt16 nodeID);
373
374 // Generally useful stuff
375 IOByteCountgetBytesTransferred() const
376 { return fBytesTransferred; };
377
378 FWAddressgetAddress() const
379 { return FWAddress(fAddressHi, fAddressLo, fNodeID); }
380
381 boolfailOnReset() const
382 { return fFailOnReset; }
383
384 IOFireWireNub *getDevice() const
385 { return fDevice; }
386
387 /*!
388 @function setMaxPacket
389 Sets the maximum size for block transfers used by the command.
390 The command is initialized to use the maximum packet size calculated from the device's
391 PHY speed, bus info block and the bus topology.
392 Call this method before calling submit().
393 @param maxBytes Maximum packet size in bytes. If the maxsize is 4 then quadlet transfers will be used.
394 */
395 IOReturnsetMaxPacket(UInt32 maxBytes)
396 {
397 if(fStatus == kIOReturnBusy || fStatus == kIOFireWirePending)
398 return fStatus;
399 fMaxPack = maxBytes;
400 return kIOReturnSuccess;
401 }
402
403void setMaxSpeed( int speed );
404
405void setAckCode( int ack );
406int getAckCode( void );
407
408void setRetries( int retries);
409int getMaxRetries( void );
410
411void setResponseCode( UInt32 rcode );
412UInt32 getResponseCode( void ) const;
413
414void setFastRetryCount( UInt32 count )
415{ fMembers->fFastRetryCount = count; };
416
417UInt32 getFastRetryCount( void )
418{ return fMembers->fFastRetryCount; };
419
420void setResponseSpeed( int speed )
421{ fMembers->fResponseSpeed = speed; };
422
423int getResponseSpeed( void )
424{ return fMembers->fResponseSpeed; };
425
426// forces even 4 byte transactions to be block requests
427void setForceBlockRequests( bool enabled )
428{ fMembers->fForceBlockRequests = enabled; }
429
430virtual IOReturn checkProgress( void );
431
432private:
433 OSMetaClassDeclareReservedUnused(IOFWAsyncCommand, 0);
434 OSMetaClassDeclareReservedUnused(IOFWAsyncCommand, 1);
435 OSMetaClassDeclareReservedUnused(IOFWAsyncCommand, 2);
436 OSMetaClassDeclareReservedUnused(IOFWAsyncCommand, 3);
437
438};
439
440#pragma mark -
441
442/*
443 * Concrete async requests - read, write and hordes of read/modify/write
444 */
445class IOFWReadCommand : public IOFWAsyncCommand
446{
447 OSDeclareDefaultStructors(IOFWReadCommand)
448
449protected:
450
451 virtual void gotPacket(int rcode, const void* data, int size);
452
453 virtual IOReturnexecute();
454
455public:
456 virtual boolinitAll(IOFireWireNub *device, FWAddress devAddress,
457IOMemoryDescriptor *hostMem,
458FWDeviceCallback completion, void *refcon, bool failOnReset);
459 virtual boolinitAll(IOFireWireController *control,
460 UInt32 generation, FWAddress devAddress,
461 IOMemoryDescriptor *hostMem,
462 FWDeviceCallback completion, void *refcon);
463 virtual IOReturnreinit(FWAddress devAddress, IOMemoryDescriptor *hostMem,
464FWDeviceCallback completion=NULL, void *refcon=NULL,
465bool failOnReset=false);
466 virtual IOReturnreinit(UInt32 generation, FWAddress devAddress, IOMemoryDescriptor *hostMem,
467 FWDeviceCallback completion=NULL, void *refcon=NULL);
468
469private:
470 OSMetaClassDeclareReservedUnused(IOFWReadCommand, 0);
471 OSMetaClassDeclareReservedUnused(IOFWReadCommand, 1);
472};
473
474#pragma mark -
475
476/*!
477@class IOFWReadQuadCommand
478@discussion An easier to use version of IOFWReadCommand for use when the data to be transferred
479is an integer number of quads.
480Note that block read requests will be used for transfers greater than one quad unless setMaxPacket(4)
481is called.
482*/
483
484class IOFWReadQuadCommand : public IOFWAsyncCommand
485{
486 OSDeclareDefaultStructors(IOFWReadQuadCommand)
487
488protected:
489
490 UInt32 *fQuads;
491
492typedef struct
493{
494boolfPingTime;
495}
496MemberVariables;
497
498bool createMemberVariables( void );
499void destroyMemberVariables( void );
500virtual void free( void );
501
502 virtual void gotPacket(int rcode, const void* data, int size);
503
504 virtual IOReturnexecute();
505
506public:
507 virtual boolinitAll(IOFireWireNub *device, FWAddress devAddress,
508UInt32 *quads, int numQuads,
509FWDeviceCallback completion, void *refcon, bool failOnReset);
510
511 virtual boolinitAll(IOFireWireController *control,
512 UInt32 generation, FWAddress devAddress,
513 UInt32 *quads, int numQuads,
514 FWDeviceCallback completion, void *refcon);
515
516 virtual IOReturnreinit(FWAddress devAddress, UInt32 *quads, int numQuads,
517FWDeviceCallback completion=NULL, void *refcon=NULL,
518bool failOnReset=false);
519
520 virtual IOReturnreinit(UInt32 generation, FWAddress devAddress, UInt32 *quads, int numQuads,
521 FWDeviceCallback completion=NULL, void *refcon=NULL);
522
523void setPingTime( bool state )
524{ ((MemberVariables*)fMembers->fSubclassMembers)->fPingTime = state; };
525
526private:
527 OSMetaClassDeclareReservedUnused(IOFWReadQuadCommand, 0);
528 OSMetaClassDeclareReservedUnused(IOFWReadQuadCommand, 1);
529};
530
531#pragma mark -
532
533class IOFWWriteCommand : public IOFWAsyncCommand
534{
535
536 OSDeclareDefaultStructors(IOFWWriteCommand)
537
538protected:
539
540 intfPackSize;
541
542typedef struct
543{
544bool fDeferredNotify;
545boolfFastRetryOnBusy;
546}
547MemberVariables;
548
549 virtual IOReturnexecute();
550
551 virtual void gotPacket( int rcode, const void* data, int size );
552
553bool createMemberVariables( void );
554void destroyMemberVariables( void );
555
556public:
557
558virtual boolinitWithController(IOFireWireController *control);
559 virtual boolinitAll(IOFireWireNub *device,
560FWAddress devAddress,
561IOMemoryDescriptor *hostMem,
562FWDeviceCallback completion,
563void *refcon,
564bool failOnReset );
565
566 virtual boolinitAll(IOFireWireController *control,
567 UInt32 generation,
568FWAddress devAddress,
569 IOMemoryDescriptor *hostMem,
570 FWDeviceCallback completion,
571void *refcon );
572virtual void free( void );
573
574 virtual IOReturnreinit(FWAddress devAddress,
575IOMemoryDescriptor *hostMem,
576FWDeviceCallback completion = NULL,
577void *refcon = NULL,
578bool failOnReset = false );
579
580 virtual IOReturnreinit(UInt32 generation,
581FWAddress devAddress,
582IOMemoryDescriptor *hostMem,
583 FWDeviceCallbackcompletion = NULL,
584void *refcon = NULL );
585
586void setDeferredNotify( bool state )
587{ ((MemberVariables*)fMembers->fSubclassMembers)->fDeferredNotify = state; };
588
589void setFastRetryOnBusy( bool state )
590{ ((MemberVariables*)fMembers->fSubclassMembers)->fFastRetryOnBusy = state; };
591
592private:
593
594 OSMetaClassDeclareReservedUnused(IOFWWriteCommand, 0);
595 OSMetaClassDeclareReservedUnused(IOFWWriteCommand, 1);
596
597};
598
599#pragma mark -
600
601/*!
602@class IOFWWriteQuadCommand
603@discussion An easier to use version of IOFWWriteCommand for use when the data to be transferred
604is small and an integer number of quads.
605Note that block read requests will be used for transfers greater than one quad unless setMaxPacket(4)
606is called.
607kMaxWriteQuads is the largest legal number of quads that this object can be asked to transfer
608(the data is copied into an internal buffer in init() and reinit()).
609*/
610
611class IOFWWriteQuadCommand : public IOFWAsyncCommand
612{
613
614 OSDeclareDefaultStructors(IOFWWriteQuadCommand)
615
616public:
617
618 enum
619{
620 kMaxWriteQuads = 8
621 };
622
623protected:
624
625 UInt32fQuads[kMaxWriteQuads];
626 UInt32 *fQPtr;
627 intfPackSize;
628
629typedef struct
630{
631bool fDeferredNotify;
632IOMemoryDescriptor *fMemory;
633}
634MemberVariables;
635
636 virtual void gotPacket( int rcode, const void* data, int size );
637
638 virtual IOReturnexecute();
639
640bool createMemberVariables( void );
641void destroyMemberVariables( void );
642
643public:
644virtual boolinitWithController(IOFireWireController *control);
645
646virtual boolinitAll(IOFireWireNub *device,
647FWAddress devAddress,
648UInt32 *quads,
649int numQuads,
650FWDeviceCallbackcompletion,
651void *refcon,
652bool failOnReset );
653
654 virtual boolinitAll(IOFireWireController *control,
655 UInt32 generation,
656FWAddress devAddress,
657 UInt32 *quads,
658int numQuads,
659 FWDeviceCallback completion,
660void *refcon );
661
662virtual void free( void );
663
664 virtual IOReturnreinit(FWAddress devAddress,
665UInt32 *quads,
666int numQuads,
667FWDeviceCallbackcompletion = NULL,
668void *refcon = NULL,
669bool failOnReset = false );
670
671 virtual IOReturnreinit(UInt32 generation,
672FWAddress devAddress,
673UInt32 *quads,
674int numQuads,
675 FWDeviceCallback completion = NULL,
676void *refcon = NULL );
677
678protected:
679
680void setQuads( UInt32 * quads, int numQuads );
681bool createMemoryDescriptor( void );
682void destroyMemoryDescriptor( void );
683
684public:
685
686 void setDeferredNotify( bool state )
687{ ((MemberVariables*)fMembers->fSubclassMembers)->fDeferredNotify = state; };
688
689private:
690
691OSMetaClassDeclareReservedUnused(IOFWWriteQuadCommand, 0);
692 OSMetaClassDeclareReservedUnused(IOFWWriteQuadCommand, 1);
693
694};
695
696/*
697 * May need more parameters for some of these,
698 * and/or derive from a base Lock transaction command
699 */
700
701#pragma mark -
702
703/*! @class IOFWCompareAndSwapCommand
704*/
705class IOFWCompareAndSwapCommand : public IOFWAsyncCommand
706{
707 OSDeclareDefaultStructors(IOFWCompareAndSwapCommand)
708
709protected:
710 UInt32 fInputVals[4];
711 UInt32 fOldVal[2];
712
713typedef struct
714{
715IOMemoryDescriptor *fMemory;
716}
717MemberVariables;
718
719MemberVariables * fMembers;
720
721 virtual void gotPacket(int rcode, const void* data, int size);
722
723 virtual IOReturnexecute();
724
725public:
726 // Compare to cmpVal, and if equal replace with newVal.
727 // Size = 1 for 32 bit operation (one quad), 2 for 64 bit (two quads)
728virtual boolinitWithController(IOFireWireController *control);
729 virtual boolinitAll(IOFireWireNub *device, FWAddress devAddress,
730const UInt32 *cmpVal, const UInt32 *newVal, int size,
731FWDeviceCallback completion, void *refcon, bool failOnReset);
732 virtual boolinitAll(IOFireWireController *control,
733 UInt32 generation, FWAddress devAddress,
734 const UInt32 *cmpVal, const UInt32 *newVal, int size,
735 FWDeviceCallback completion, void *refcon);
736
737 virtual IOReturnreinit(FWAddress devAddress, const UInt32 *cmpVal, const UInt32 *newVal, int size,
738 FWDeviceCallback completion=NULL, void *refcon=NULL, bool failOnReset=false);
739 virtual IOReturnreinit(UInt32 generation, FWAddress devAddress,
740 const UInt32 *cmpVal, const UInt32 *newVal, int size,
741 FWDeviceCallback completion=NULL, void *refcon=NULL);
742
743 // sets oldVal to the old value returned by the device, and
744 // returns true if it was the expected value, ie. the lock succeeded
745 virtual boollocked(UInt32 *oldVal);
746
747virtual void free( void );
748
749protected:
750
751bool createMemberVariables( void );
752void destroyMemberVariables( void );
753
754void setInputVals( const UInt32 *cmpVal, const UInt32 * newVal, int size );
755
756bool createMemoryDescriptor( void );
757void destroyMemoryDescriptor( void );
758
759private:
760 OSMetaClassDeclareReservedUnused(IOFWCompareAndSwapCommand, 0);
761 OSMetaClassDeclareReservedUnused(IOFWCompareAndSwapCommand, 1);
762 OSMetaClassDeclareReservedUnused(IOFWCompareAndSwapCommand, 2);
763 OSMetaClassDeclareReservedUnused(IOFWCompareAndSwapCommand, 3);
764
765};
766
767/*
768 * Send an async stream packet
769 */
770
771#pragma mark -
772
773/*! @class IOFWAsyncStreamCommand
774*/
775class IOFWAsyncStreamCommand : public IOFWCommand
776{
777// temporary for debugging:
778friend class IOFireWireUserClient ;
779
780OSDeclareDefaultStructors(IOFWAsyncStreamCommand)
781
782protected:
783 FWAsyncStreamCallbackfComplete;
784 void *fRefCon;
785 IOMemoryDescriptor * fMemDesc;
786 intfSpeed;
787 intfSize;
788 intfCurRetries;
789 intfMaxRetries;
790 intfChannel;
791 intfSyncBits;
792 intfTag;
793 UInt32fGeneration;// bus topology fNodeID is valid for.
794 boolfFailOnReset;
795
796typedef struct
797{ }
798MemberVariables;
799
800 MemberVariables * fMembers;
801
802 virtual IOReturncomplete(
803 IOReturn status);
804
805// To be called by IOFireWireController and derived classes.
806 virtual IOReturnexecute();
807
808public:
809
810 virtual boolinitAll(
811 IOFireWireController * control,
812 UInt32 generation,
813 UInt32 channel,
814 UInt32 sync,
815 UInt32 tag,
816 IOMemoryDescriptor * hostMem,
817 UInt32size,
818 intspeed,
819 FWAsyncStreamCallbackcompletion,
820 void * refcon);
821
822virtual void free( void );
823
824 virtual IOReturnreinit(UInt32 generation,
825 UInt32 channel,
826 UInt32 sync,
827 UInt32 tag,
828 IOMemoryDescriptor * hostMem,
829 UInt32size,
830 intspeed,
831 FWAsyncStreamCallbackcompletion,
832 void * refcon);
833
834 virtual voidgotAck(
835 int ackCode);
836// Utility for setting generation on newly created command
837virtual voidsetGeneration(
838UInt32 generation)
839{ fGeneration = generation; }
840
841
842 // update nodeID/generation after bus reset, from the device object
843 IOReturnupdateGeneration();
844
845 boolfailOnReset() const
846 { return fFailOnReset; }
847
848private:
849 OSMetaClassDeclareReservedUnused(IOFWAsyncStreamCommand, 0);
850 OSMetaClassDeclareReservedUnused(IOFWAsyncStreamCommand, 1);
851
852public:
853 virtual boolinitAll(
854 IOFireWireController * control,
855 UInt32 generation,
856 UInt32 channel,
857 UInt32 sync,
858 UInt32 tag,
859 IOMemoryDescriptor * hostMem,
860 UInt32size,
861 intspeed,
862 FWAsyncStreamCallbackcompletion,
863 void * refcon,
864boolfailOnReset );
865
866
867virtual IOReturnreinit(
868UInt32 generation,
869 UInt32 channel,
870 UInt32 sync,
871 UInt32 tag,
872 IOMemoryDescriptor * hostMem,
873 UInt32size,
874 intspeed,
875 FWAsyncStreamCallback completion,
876 void * refcon,
877boolfailOnReset);
878
879
880};
881
882/*
883 * Send an async PHY packet
884 */
885
886#pragma mark -
887
888/*! @class IOFWAsyncPHYCommand
889*/
890class IOFWAsyncPHYCommand : public IOFWCommand
891{
892// temporary for debugging:
893friend class IOFireWireUserClient;
894
895OSDeclareDefaultStructors( IOFWAsyncPHYCommand )
896
897protected:
898AsyncPendingTrans *fTrans;
899 FWAsyncPHYCallbackfComplete;
900 void *fRefCon;
901 intfCurRetries;
902 intfMaxRetries;
903 UInt32fGeneration;
904 boolfFailOnReset;
905UInt32fData1;
906UInt32fData2;
907intfAckCode;
908UInt32fResponseCode;
909
910typedef struct
911{ }
912MemberVariables;
913
914 MemberVariables * fMembers;
915
916 virtual IOReturncomplete(
917 IOReturn status );
918
919// To be called by IOFireWireController and derived classes.
920 virtual IOReturnexecute();
921
922void setResponseCode( UInt32 rcode );
923void setAckCode( int ack );
924
925public:
926
927 virtual boolinitAll(
928 IOFireWireController * control,
929 UInt32 generation,
930 UInt32data1,
931UInt32data2,
932 FWAsyncPHYCallbackcompletion,
933 void * refcon,
934bool failOnReset );
935virtual void free( void );
936
937 virtual IOReturnreinit(UInt32 generation,
938UInt32data1,
939UInt32data2,
940 FWAsyncPHYCallbackcompletion,
941 void * refcon,
942bool failOnReset );
943
944 virtual voidgotAck(
945 int ackCode );
946
947// Utility for setting generation on newly created command
948virtual voidsetGeneration(
949UInt32 generation )
950{ fGeneration = generation; }
951
952
953 // update nodeID/generation after bus reset, from the device object
954 IOReturnupdateGeneration();
955
956 boolfailOnReset() const
957{ return fFailOnReset; }
958
959
960virtual void gotPacket( int rcode );
961
962int getAckCode( void );
963UInt32 getResponseCode( void ) const;
964
965void setRetries( int retries);
966private:
967 OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 0);
968 OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 1);
969 OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 2);
970 OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 3);
971 OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 4);
972 OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 5);
973 OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 6);
974 OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 7);
975};
976
977#endif /* _IOKIT_IOFWCOMMAND_H */
978

Archive Download this file

Revision: 2225