Chameleon

Chameleon Svn Source Tree

Root/branches/rewrite/i386/include/IOKit/firewire/IOFireWireController.h

Source at commit 1146 created 12 years 11 months ago.
By azimutz, Sync with trunk (r1145). Add nVidia dev id's, 0DF4 for "GeForce GT 450M" (issue 99) and 1251 for "GeForce GTX 560M" (thanks to oSxFr33k for testing).
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 * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved.
24 *
25 * HISTORY
26 *
27 */
28
29#ifndef _IOKIT_IOFIREWIRECONTROLLER_H
30#define _IOKIT_IOFIREWIRECONTROLLER_H
31
32#ifndef FIREWIREPRIVATE
33#warning Please do not include this file. Include IOFireWireBus.h instead.
34#endif
35
36#include <IOKit/IOEventSource.h>
37#include <IOKit/firewire/IOFireWireBus.h>
38#include <IOKit/firewire/IOFireWireFamilyCommon.h>
39#include <IOKit/firewire/IOFireWireIRMAllocation.h>
40#include <IOKit/firewire/IOFWPHYPacketListener.h>
41#include <IOKit/firewire/IOFireWireMultiIsochReceive.h>
42
43class OSData;
44class IOWorkLoop;
45class IOEventSource;
46class IOFWQEventSource;
47class IOTimerEventSource;
48class IOMemoryDescriptor;
49class IOFireWireController;
50class IOFWAddressSpace;
51class IOFWPseudoAddressSpace;
52class IOFireWireNub;
53class IOFireWireDevice;
54class IOFireWireDeviceAux;
55class IOFireWireUnit;
56class IODCLProgram;
57class IOLocalConfigDirectory;
58class IOFireWireLink;
59class IOFireWireSBP2ORB;
60class IOFireWireSBP2Login;
61class IOFireWireROMCache;
62class IOFireWireLocalNode;
63class IOFWWorkLoop;
64class IOFireWireIRM;
65class IOFireWirePowerManager;
66class IOFWSimplePhysicalAddressSpace;
67class IOFWSimpleContiguousPhysicalAddressSpace;
68class IOFWAsyncStreamReceiver;
69class IOFWAsyncStreamListener;
70class IOFWUserVectorCommand;
71class IOFWAsyncPHYCommand;
72class IOFWPHYPacketListener;
73class IOFWUserPHYPacketListener;
74
75#if FIRELOGCORE
76class IOFireLog;
77class IOFireLogPublisher;
78#endif
79
80const UInt32 kMaxWaitForValidSelfID = 20; // Still invalid SelfID after 20 retries
81
82// Phy packet defs.
83
84enum
85{
86kFWPhyPacketID= FWBitRange (0, 1),
87kFWPhyPacketIDPhase= FWBitRangePhase (0, 1),
88
89kFWPhyPacketPhyID= FWBitRange (2, 7),
90kFWPhyPacketPhyIDPhase= FWBitRangePhase (2, 7)
91};
92
93enum
94{
95kSelfIDPacketSize= 8,
96kMaxSelfIDs= 4// SelfID 0,1,3,8
97};
98
99enum
100{
101kFWConfigurationPacketID= 0,
102kFWLinkOnPacketID= 1,
103kFWSelfIDPacketID= 2
104};
105
106enum
107{
108kFWPhyConfigurationR= FW_BIT(8),
109kFWPhyConfigurationT= FW_BIT(9),
110kFWPhyConfigurationGapCnt= FWBitRange (10, 15),
111kFWPhyConfigurationGapCntPhase= FWBitRangePhase (10, 15)
112};
113
114enum
115{
116kFWSelfIDPortStatusChild= 3,
117kFWSelfIDPortStatusParent= 2,
118kFWSelfIDPortStatusNotConnected= 1,
119kFWSelfIDPortStatusNotPresent= 0,
120
121kFWSelfIDNoPower= 0,
122kFWSelfIDSelfPowered15W= 1,
123kFWSelfIDSelfPowered30W= 2,
124kFWSelfIDSelfPowered45W= 3,
125kFWSelfIDBusPowered1W= 4,
126kFWSelfIDBusPowered3W= 5,
127kFWSelfIDBusPowered6W= 6,
128kFWSelfIDBusPowered10W= 7,
129
130kFWSelfIDPhyID= kFWPhyPacketPhyID,//zzz do we need or want this?
131kFWSelfIDPhyIDPhase= kFWPhyPacketPhyIDPhase,
132kFWSelfIDM= FW_BIT(31),
133
134kFWSelfID0L= FW_BIT(9),
135kFWSelfID0GapCnt= FWBitRange (10, 15),
136kFWSelfID0GapCntPhase= FWBitRangePhase (10, 15),
137kFWSelfID0SP= FWBitRange (16, 17),
138kFWSelfID0SPPhase= FWBitRangePhase (16, 17),
139kFWSelfID0Del= FWBitRange (18, 19),
140kFWSelfID0DelPhase= FWBitRangePhase (18, 19),
141kFWSelfID0C= FW_BIT(20),
142kFWSelfID0Pwr= FWBitRange (21, 23),
143kFWSelfID0PwrPhase= FWBitRangePhase (21, 23),
144kFWSelfID0P0= FWBitRange (24, 25),
145kFWSelfID0P0Phase= FWBitRangePhase (24, 25),
146kFWSelfID0P1= FWBitRange (26, 27),
147kFWSelfID0P1Phase= FWBitRangePhase (26, 27),
148kFWSelfID0P2= FWBitRange (28, 29),
149kFWSelfID0P2Phase= FWBitRangePhase (28, 29),
150kFWSelfID0I= FW_BIT(30),
151
152kFWSelfIDPacketType= FW_BIT(8),
153kFWSelfIDNN= FWBitRange (9, 11),
154kFWSelfIDNNPhase= FWBitRangePhase (9, 11),
155kFWSelfIDNPa= FWBitRange (14, 15),
156kFWSelfIDNPaPhase= FWBitRangePhase (14, 15),
157kFWSelfIDNPb= FWBitRange (16, 17),
158kFWSelfIDNPbPhase= FWBitRangePhase (16, 17),
159kFWSelfIDNPc= FWBitRange (18, 19),
160kFWSelfIDNPcPhase= FWBitRangePhase (18, 19),
161kFWSelfIDNPd= FWBitRange (20, 21),
162kFWSelfIDNPdPhase= FWBitRangePhase (20, 21),
163kFWSelfIDNPe= FWBitRange (22, 23),
164kFWSelfIDNPePhase= FWBitRangePhase (22, 23),
165kFWSelfIDNPf= FWBitRange (24, 25),
166kFWSelfIDNPfPhase= FWBitRangePhase (24, 25),
167kFWSelfIDNPg= FWBitRange (26, 27),
168kFWSelfIDNPgPhase= FWBitRangePhase (26, 27),
169kFWSelfIDNPh= FWBitRange (28, 29),
170kFWSelfIDNPhPhase= FWBitRangePhase (28, 29),
171kFWSelfIDMore= FW_BIT(31)
172};
173
174// Primary packet defs.
175enum
176{
177kFWPacketTCode= FWBitRange (24, 27),
178kFWPacketTCodePhase= FWBitRangePhase (24, 27)
179};
180
181
182enum
183{
184kFWAsynchSpd= FWBitRange (14, 15),
185kFWAsynchSpdPhase= FWBitRangePhase (14, 15),
186
187kFWAsynchTLabel= FWBitRange (16, 21),
188kFWAsynchTLabelPhase= FWBitRangePhase (16, 21),
189kFWAsynchTTotal = ((0xffffffff & kFWAsynchTLabel) >> kFWAsynchTLabelPhase)+1,
190kFWAsynchRt= FWBitRange (22, 23),
191kFWAsynchRtPhase= FWBitRangePhase (22, 23),
192kFWAsynchNew= 0,
193kFWAsynchRetryA= 2,
194kTIAsycnhRetryB= 3,
195
196kFWAsynchPriority= FWBitRange (28, 31),
197kFWAsynchPriorityPhase= FWBitRangePhase (28, 31),
198
199kFWAsynchDestinationID= FWBitRange (0, 15),
200kFWAsynchDestinationIDPhase= FWBitRangePhase (0, 15),
201
202kFWAsynchSourceID= FWBitRange (0, 15),
203kFWAsynchSourceIDPhase= FWBitRangePhase (0, 15),
204
205kFWAsynchDestinationOffsetHigh= FWBitRange (16, 31),
206kFWAsynchDestinationOffsetHighPhase= FWBitRangePhase (16, 31),
207
208kFWAsynchDestinationOffsetLow= FWBitRange (0, 31),
209kFWAsynchDestinationOffsetLowPhase= FWBitRangePhase (0, 31),
210
211kFWAsynchDataLength= FWBitRange (0, 15),
212kFWAsynchDataLengthPhase= FWBitRangePhase (0, 15),
213
214kFWAsynchExtendedTCode= FWBitRange (16, 31),
215kFWAsynchExtendedTCodePhase= FWBitRangePhase (16, 31),
216
217kFWAsynchAckSent= FWBitRange (28, 31),
218kFWAsynchAckSentPhase= FWBitRangePhase (28, 31),
219
220kFWAsynchRCode= FWBitRange (16, 19),
221kFWAsynchRCodePhase= FWBitRangePhase (16, 19)
222};
223
224enum
225{
226kFWTCodeWriteQuadlet= 0,
227kFWTCodeWriteBlock= 1,
228kFWTCodeWriteResponse= 2,
229kFWTCodeReadQuadlet= 4,
230kFWTCodeReadBlock= 5,
231kFWTCodeReadQuadletResponse= 6,
232kFWTCodeReadBlockResponse= 7,
233kFWTCodeCycleStart= 8,
234kFWTCodeLock= 9,
235kFWTCodeIsochronousBlock= 10,
236kFWTCodeLockResponse= 11,
237kFWTCodePHYPacket= 14
238};
239
240enum
241{
242kFWExtendedTCodeMaskSwap= 1,
243kFWExtendedTCodeCompareSwap= 2,
244kFWExtendedTCodeFetchAdd= 3,
245kFWExtendedTCodeLittleAdd= 4,
246kFWExtendedTCodeBoundedAdd= 5,
247kFWExtendedTCodeWrapAdd= 6,
248kFWExtendedTCodeVendorDependent= 7
249};
250
251// debug boot-arg constants
252enum
253{
254kFWDebugIgnoreNodeNone= 0xFFFFFFFF
255};
256
257struct AsyncPendingTrans {
258 IOFWAsyncCommand *fHandler;
259 IOFWCommand *fAltHandler;
260 intfTCode;
261 boolfInUse;
262};
263
264struct IOFWNodeScan {
265 IOFireWireController *fControl;
266 FWAddressfAddr;
267 UInt32fBuf[5];// Enough for bus info block
268 UInt32 *fSelfIDs;
269 intfNumSelfIDs;
270 intfROMSize;
271 intfRead;
272 IOFWReadQuadCommand * fCmd;
273IOFWCompareAndSwapCommand * fLockCmd;
274UInt32generation;
275 UInt32fIRMBitBucketOld;
276 UInt32fIRMBitBucketNew;
277 boolfIRMisBad;
278 boolspeedChecking;
279 boolfContenderNeedsChecking;
280 boolfIRMCheckingRead;
281 boolfIRMCheckingLock;
282intfRetriesBumped;
283boolfMustNotBeRoot;
284};
285
286
287typedef struct IOFWDuplicateGUIDStruct IOFWDuplicateGUIDRec;
288struct IOFWDuplicateGUIDStruct
289 {
290IOFWDuplicateGUIDRec* fNextGUID;
291CSRNodeUniqueIDfGUID;
292UInt32fLastGenSeen;
293};
294
295
296// IOFireWireDuplicateGUIDList
297//
298// A little class for keeping track of GUIDs which where we have observed 2 nodes with
299// the same GUID
300
301class IOFireWireDuplicateGUIDList : public OSObject
302{
303 OSDeclareDefaultStructors(IOFireWireDuplicateGUIDList);
304
305private:
306 IOFWDuplicateGUIDRec* fFirstGUID;
307
308protected:
309 virtual void free();
310
311public:
312
313static IOFireWireDuplicateGUIDList * create( void );
314
315void addDuplicateGUID( CSRNodeUniqueID guid, UInt32 gen );
316void removeDuplicateGUID( CSRNodeUniqueID guid );
317
318bool findDuplicateGUID( CSRNodeUniqueID guid, UInt32 gen );
319
320};
321
322#define kMaxPendingTransfers kFWAsynchTTotal
323
324class IOFireWireController;
325
326#pragma mark -
327
328/*!
329@class IOFireWireControllerAux
330*/
331
332class IOFireWireControllerAux : public IOFireWireBusAux
333{
334 OSDeclareDefaultStructors(IOFireWireControllerAux)
335
336friend class IOFireWireController;
337
338protected:
339
340IOFireWireController * fPrimary;
341
342UInt8fMaxRec;
343
344UInt8fPadding;
345UInt16fPadding2;
346
347IOFWUserObjectExporter *fSessionRefExporter;
348
349/*!
350@struct ExpansionData
351@discussion This structure will be used to expand the capablilties of the class in the future.
352 */
353
354 struct ExpansionData { };
355
356/*!
357@var reserved
358Reserved for future use. (Internal use only)
359*/
360
361ExpansionData * reserved;
362
363 virtual bool init (
364IOFireWireController * primary );
365virtualvoid free ();
366virtual IOFWDCLPool *createDCLPool ( unsigned capacity ) const ;
367virtual UInt8getMaxRec( void );
368
369virtual UInt64 getFireWirePhysicalAddressMask( void );
370virtual UInt32 getFireWirePhysicalAddressBits( void );
371virtual UInt64 getFireWirePhysicalBufferMask( void );
372virtual UInt32 getFireWirePhysicalBufferBits( void );
373
374virtual IOFWSimpleContiguousPhysicalAddressSpace * createSimpleContiguousPhysicalAddressSpace( vm_size_t size, IODirection direction );
375virtual IOFWSimplePhysicalAddressSpace * createSimplePhysicalAddressSpace( vm_size_t size, IODirection direction );
376
377virtual IOFWUserObjectExporter * getSessionRefExporter( void );
378
379private:
380 OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 0);
381 OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 1);
382 OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 2);
383 OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 3);
384 OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 4);
385 OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 5);
386 OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 6);
387 OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 7);
388
389};
390
391
392#pragma mark -
393
394/*! @class IOFireWireController
395*/
396class IOFireWireController : public IOFireWireBus
397{
398 OSDeclareAbstractStructors(IOFireWireController)
399
400protected:
401 enum busState {
402 kStarting = 0,
403kAsleep,// Link off, zzzzzz
404kWaitingBusReset,
405 kWaitingSelfIDs,// Bus has been reset, no selfIDs yet
406 kWaitingScan,// Got selfIDs, waiting a bit before hitting lame devices
407 kScanning,// Reading node ROMs
408 kWaitingPrune,// Read all ROMs, pausing before pruning missing devices
409 kRunning,// Normal happy state,
410kWaitingBusResetStart// bus reset is desired, but not yet sent to the fwim
411 };
412
413enum ResetState
414{
415kResetStateResetting,
416kResetStateDisabled,
417kResetStateArbitrated
418};
419
420enum
421{
422kDisablePhysicalAccess = (1 << 0)
423};
424
425 struct timeoutQ: public IOFWCmdQ
426 {
427 IOTimerEventSource *fTimer;
428 virtual void headChanged(IOFWCommand *oldHead);
429 void busReset();
430 };
431
432 struct pendingQ: public IOFWCmdQ
433 {
434 IOFWQEventSource *fSource;
435 virtual void headChanged(IOFWCommand *oldHead);
436 };
437
438 friend class IOFireWireLink;
439friend class IOFireWireDevice;
440friend class IOFireWireDeviceAux;
441friend class IOFWAddressSpace;
442friend class IOFWAddressSpaceAux;
443 friend class IOFWPseudoAddressSpace;
444 friend class IOFireWireSBP2ORB;
445friend class IOFireWireSBP2Login;
446friend class IOFWLocalIsochPort;
447friend class IOFWCommand;
448 friend class IOFireWireUnit;
449friend class IOFireWirePCRSpace;
450 friend class IOFireWireROMCache;
451 friend class IOFWAsyncStreamCommand;
452friend class IOFireWireAVCLocalUnit;
453friend class IOFireWireAVCUnit;
454 friend class IOFireWireAVCCommand;
455friend class IOFireWirePowerManager;
456friend class IOFWWriteQuadCommand;
457friend class IOFWWriteCommand;
458friend class IOFWCompareAndSwapCommand;
459friend class IOFWAsyncCommand;
460friend class IOFireWireAVCTargetSpace;
461friend class AppleFWOHCI;
462friend class IOFireWireNub;
463friend class IOFWAsyncStreamListener;
464friend class IOFireWireLocalNode;
465friend class IOFireWireIRMAllocation;
466friend class IOFWUserVectorCommand;
467friend class IOFWAsyncPHYCommand;
468friend class IOFWUserPHYPacketListener;
469friend class IOFWAsyncStreamReceiver;
470
471#if FIRELOGCORE
472friend class IOFireLog;
473#endif
474
475 IOFireWireLink *fFWIM;
476 IOFWWorkLoop *fWorkLoop;
477 IOTimerEventSource *fTimer;
478 OSSet *fLocalAddresses;// Collection of local adress spaces
479 OSIterator *fSpaceIterator;// Iterator over local addr spaces
480
481 OSSet *fAllocatedChannels;// Need to be informed of bus resets
482 OSIterator *fAllocChannelIterator;// Iterator over channels
483
484OSSet *fIRMAllocations;// Need to be informed of bus resets
485 OSIterator *fIRMAllocationsIterator;// Iterator over channels
486OSSet *fIRMAllocationsAllocated;// Need to be informed of bus resets
487
488 // Bus management variables (although we aren't a FireWire Bus Manager...)
489 AbsoluteTimefResetTime;// Time of last reset
490 UInt32fBusGeneration;// ID of current bus topology.
491 UInt16fLocalNodeID;// ID of local node, ie. this computer
492 UInt16fRootNodeID;// ID of root, ie. highest node id in use.
493 UInt16fIRMNodeID;// ID of Isochronous resource manager, or kFWBadNodeID
494 boolfBusMgr;// true if at least one node is bus manager capable
495 IORegistryEntry *fNodes[kFWMaxNodesPerBus];// FireWire nodes on this bus
496 UInt32 *fNodeIDs[kFWMaxNodesPerBus+1];// Pointer to SelfID list for each node
497// +1 so we know how many selfIDs the last node has
498
499 UInt32fGapCount;// What we think the gap count should be
500 //UInt8fSpeedCodes[(kFWMaxNodesPerBus+1)*kFWMaxNodesPerBus];
501 UInt8fSpeedVector[((kFWMaxNodesPerBus+1)*kFWMaxNodesPerBus)/2];
502// Max speed between two nodes
503 busStatefBusState;// Which state are we in?
504 intfNumROMReads;// Number of device ROMs we are still reading
505 // SelfIDs
506 intfNumSelfIDs;// Total number of SelfID packets
507 UInt32fSelfIDs[kMaxSelfIDs*kFWMaxNodesPerBus];
508
509 // The local device's Config ROM
510 UInt32fROMHeader[5];// More or less fixed header and bus info block
511 IOLocalConfigDirectory *fRootDir;// Local Config ROM root directory.
512
513 // log base 2 of maximum packet size the FWIM can send/receive
514 // Normally calculated from bus info block.
515 intfMaxSendLog;
516 int fMaxRecvLog;
517
518 IOFWAddressSpace *fROMAddrSpace;
519 IOMemoryDescriptor *fBadReadResponse;// Send back easily identified bad data to out of range addrs.
520
521 // Array for outstanding requests (up to 64)
522 AsyncPendingTransfTrans[kMaxPendingTransfers];
523 intfLastTrans;
524
525 // queue for executing commands that may timeout
526 timeoutQfTimeoutQ;
527
528 // queue for commands that can't execute yet
529 pendingQfPendingQ;
530
531 // queue for async commands interrupted by bus reset
532 IOFWCmdQfAfterResetHandledQ;
533
534 // Command to change bus state after a delay.
535 IOFWDelayCommand *fDelayedStateChangeCmd;
536 boolfDelayedStateChangeCmdNeedAbort;
537
538UInt32fDelayedPhyPacket;
539boolfBusResetScheduled;
540ResetStatefBusResetState;
541IOFWDelayCommand *fBusResetStateChangeCmd;
542UInt32fBusResetDisabledCount;
543
544#if FIRELOGCORE
545 IOFireLogPublisher *fFireLogPublisher;
546#else
547 void *fFireLogPublisher;
548#endif
549
550 OSData *fAllocatedAddresses;
551
552UInt32fDevicePruneDelay;
553
554IOFWPhysicalAccessModefPhysicalAccessMode;
555IOFWSecurityModefSecurityMode;
556IONotifier *fKeyswitchNotifier;
557
558IOFireWireIRM *fIRM;
559IOFireWirePowerManager *fBusPowerManager;
560
561boolfGapCountMismatch;
562
563boolfUseHalfSizePackets;
564boolfRequestedHalfSizePackets;
565
566IOFWNodeScan *fScans[kFWMaxNodesPerBus];
567IOFireWireDuplicateGUIDList*fGUIDDups;
568
569boolfDelegateCycleMaster;
570boolfBadIRMsKnown;
571
572UInt32fPreviousGap;
573
574UInt32fOutOfTLabels;
575UInt32fOutOfTLabels10S;
576UInt32fOutOfTLabelsThreshold;
577
578#ifdef LEGACY_SHUTDOWN
579IONotifier *fPowerEventNotifier;
580#endif
581
582boolfStarted;
583
584UInt32fIOCriticalSectionCount;
585UInt32fHubPort;
586UInt32fDebugIgnoreNode;
587
588OSSet *fLocalAsyncStreamReceivers;
589 OSIterator *fAsyncStreamReceiverIterator;
590
591boolfInstantiated;
592
593IOReturnfStartStatus;
594UInt32fWaitingForSelfID;
595
596UInt32fForcedRootNodeID;
597boolfNodeMustBeRootFlag;
598boolfNodeMustNotBeRootFlag;
599
600UInt32fForcedGapCount;
601boolfForcedGapFlag;
602
603OSSet *fPHYPacketListeners;
604 OSIterator *fPHYPacketListenersIterator;
605
606boolfDSLimited;
607
608/*! @struct ExpansionData
609 @discussion This structure will be used to expand the capablilties of the class in the future.
610 */
611 struct ExpansionData { };
612
613/*! @var reserved
614 Reserved for future use. (Internal use only) */
615 ExpansionData *reserved;
616
617 static void clockTick(OSObject *, IOTimerEventSource *);
618 static void readROMGlue(void *refcon, IOReturn status,
619IOFireWireNub *device, IOFWCommand *fwCmd);
620 static void delayedStateChange(void *refcon, IOReturn status,
621 IOFireWireBus *bus, IOFWBusCommand *fwCmd);
622
623 virtual void processBusReset();
624 virtual void processSelfIDs(UInt32 *IDs, int numIDs, UInt32 *ownIDs, int numOwnIDs);
625 virtual void processTimeout(IOTimerEventSource *src);
626 virtual void processRcvPacket( UInt32 *data, int numQuads, IOFWSpeed speed );
627 virtual void processWriteRequest(UInt16 sourceID, UInt32 tlabel,
628UInt32 *hdr, void *buf, int len, IOFWSpeed speed);
629 virtual void processLockRequest(UInt16 sourceID, UInt32 tlabel,
630UInt32 *hdr, void *buf, int len, IOFWSpeed speed);
631
632 // Process read from a local address, return rcode
633 virtual UInt32 doReadSpace(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len,
634 IOMemoryDescriptor **buf, IOByteCount * offset, IODMACommand **dma_command,
635 IOFWRequestRefCon refcon);
636
637 // Process write to a local address, return rcode
638 virtual UInt32 doWriteSpace(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len,
639 const void *buf, IOFWRequestRefCon refcon);
640
641 // Process lock to a local address, return rcode
642 UInt32 doLockSpace(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 inlen,
643 const UInt32 *newVal, UInt32 &outLen, UInt32 *oldVal,
644 UInt32 extType, IOFWRequestRefCon refcon);
645
646 virtual void updatePlane();
647 virtual void startBusScan();
648
649 // Called when all devices on bus have been examined
650 virtual void finishedBusScan();
651
652 virtual void buildTopology(bool doFWPlane);
653
654 virtual void readDeviceROM(IOFWNodeScan *refCon, IOReturn status);
655
656 virtual IOReturn UpdateROM();
657 virtual IOReturn allocAddress(IOFWAddressSpace *space);
658 virtual void freeAddress(IOFWAddressSpace *space);
659
660IOFireWireBusAux * createAuxiliary( void );
661
662public:
663
664 // Initialization
665 virtual bool init(IOFireWireLink *fwim);
666 virtual void free();
667 virtual bool start(IOService *provider);
668 virtual void stop( IOService * provider );
669 virtual bool finalize( IOOptionBits options );
670 virtual bool requestTerminate( IOService * provider, IOOptionBits options );
671
672// Power management
673 virtual IOReturn setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice );
674
675 // Implement IOService::getWorkLoop
676 virtual IOWorkLoop *getWorkLoop() const;
677
678 // Allocate struct for tracking a transaction
679 virtual AsyncPendingTrans *allocTrans(IOFWAsyncCommand *cmd=NULL);
680 virtual void freeTrans(AsyncPendingTrans *trans);
681
682 // Really public methods
683
684 virtual IOReturn getCycleTime(UInt32 &cycleTime);
685 virtual IOReturn getBusCycleTime(UInt32 &busTime, UInt32 &cycleTime);
686
687 // Methods to manipulate the local Config ROM
688 virtual IOReturn AddUnitDirectory(IOLocalConfigDirectory *unitDir);
689 virtual IOReturn RemoveUnitDirectory(IOLocalConfigDirectory *unitDir);
690
691 // Cause a bus reset
692 virtual IOReturn resetBus();
693
694 // Send async request packets
695 virtual IOReturn asyncRead(UInt32 generation,
696UInt16 nodeID,
697UInt16 addrHi,
698UInt32 addrLo,
699 int speed,
700int label,
701int size,
702IOFWAsyncCommand *cmd );
703
704 virtual IOReturn asyncWrite(UInt32 generation,
705UInt16 nodeID,
706UInt16 addrHi,
707UInt32 addrLo,
708int speed,
709int label,
710IOMemoryDescriptor *buf,
711IOByteCount offset,
712int size,
713IOFWAsyncCommand *cmd );
714
715 /* DEPRECATED */ virtual IOReturn asyncWrite(UInt32 generation,
716/* DEPRECATED */UInt16 nodeID,
717/* DEPRECATED */UInt16 addrHi,
718/* DEPRECATED */UInt32 addrLo,
719/* DEPRECATED */int speed,
720/* DEPRECATED */int label,
721/* DEPRECATED */void *data,
722/* DEPRECATED */int size,
723/* DEPRECATED */IOFWAsyncCommand *cmd );
724
725 /* DEPRECATED */ virtual IOReturn asyncLock(UInt32 generation,
726/* DEPRECATED */UInt16 nodeID,
727/* DEPRECATED */UInt16 addrHi,
728/* DEPRECATED */UInt32 addrLo,
729/* DEPRECATED */int speed,
730/* DEPRECATED */int label,
731/* DEPRECATED */int type,
732/* DEPRECATED */void *data,
733/* DEPRECATED */int size,
734/* DEPRECATED */IOFWAsyncCommand *cmd);
735
736
737 // Send async read response packets
738 // useful for pseudo address spaces that require servicing outside the FireWire work loop.
739 virtual IOReturn asyncReadResponse(UInt32 generation,
740UInt16 nodeID,
741int speed,
742IOMemoryDescriptor *buf,
743IOByteCount offset,
744int len,
745IOFWRequestRefCon refcon );
746
747 virtual IOReturn asyncLockResponse( UInt32 generation,
748UInt16 nodeID,
749int speed,
750 IOMemoryDescriptor *buf,
751IOByteCount offset,
752int len,
753 IOFWRequestRefCon refcon );
754
755 // Try to fix whatever might have caused the other device to not respond
756 virtual IOReturn handleAsyncTimeout(IOFWAsyncCommand *cmd);
757
758 // Convert a firewire nodeID into the IOFireWireDevice for it
759 virtual IOFireWireDevice * nodeIDtoDevice(UInt32 generation, UInt16 nodeID);
760
761 // Add/remove a channel from the list informed of bus resets
762 virtual void addAllocatedChannel(IOFWIsochChannel *channel);
763 virtual void removeAllocatedChannel(IOFWIsochChannel *channel);
764
765// Add/remove a IRM allocation from the list informed of bus resets
766 virtual void addIRMAllocation(IOFireWireIRMAllocation *irmAllocation);
767 virtual void removeIRMAllocation(IOFireWireIRMAllocation *irmAllocation);
768
769 // Create an Isochronous Channel object
770 // doIRM = true => allocate channel and bandwith in Isochronous Resource Manager
771 // packetSize packet size (in bytes), used to calculate bandwidth needed.
772 virtual IOFWIsochChannel *createIsochChannel(
773bool doIRM, UInt32 packetSize, IOFWSpeed prefSpeed,
774FWIsochChannelForceStopNotificationProc stopProc=NULL,
775void *stopRefCon=NULL);
776
777 // Create a local isochronous port to run the given DCL program
778 // if task is 0, the DCL program is for the kernel task,
779 // otherwise all DCL pointers are valid in the specified task.
780 // opcodes is also pointer valid in the specified task.
781 virtual IOFWLocalIsochPort *createLocalIsochPort(bool talking,
782 DCLCommand* opcodes, DCLTaskInfo *info = 0,
783UInt32 startEvent = 0, UInt32 startState = 0, UInt32 startMask = 0);
784
785 // Execute specified function on workloop after specified delay
786 // Returned command is for delay, call it's cancel() function to cancel timeout.
787 virtual IOFWDelayCommand * createDelayedCmd(UInt32 uSecDelay, FWBusCallback func, void *refcon);
788
789 virtual IOFWPhysicalAddressSpace *createPhysicalAddressSpace(IOMemoryDescriptor *mem);
790 virtual IOFWPseudoAddressSpace *createPseudoAddressSpace(FWAddress *addr, UInt32 len,
791 FWReadCallback reader, FWWriteCallback writer, void *refcon);
792
793 // Extract info about the async request
794 virtual bool isLockRequest(IOFWRequestRefCon refcon);
795 virtual bool isQuadRequest(IOFWRequestRefCon refcon);
796 virtual UInt32 getExtendedTCode(IOFWRequestRefCon refcon);
797
798 // Inline accessors for protected member variables
799 IOFWCmdQ &getTimeoutQ();
800IOFWCmdQ &getPendingQ();
801 IOFWCmdQ &getAfterResetHandledQ();
802 IOFireWireLink * getLink() const;
803
804 IOLocalConfigDirectory *getRootDir() const;
805 bool checkGeneration(UInt32 gen) const;
806 UInt32 getGeneration() const;
807 UInt16 getLocalNodeID() const;
808 IOReturn getIRMNodeID(UInt32 &generation, UInt16 &id);
809
810 const AbsoluteTime * getResetTime() const;
811
812 IOFWSpeed FWSpeed(UInt16 nodeAddress) const;
813 IOFWSpeed FWSpeed(UInt16 nodeA, UInt16 nodeB) const;
814
815 // How big (as a power of two) can packets sent to/received from the node be?
816 virtual int maxPackLog(bool forSend, UInt16 nodeAddress) const;
817
818 // How big (as a power of two) can packets sent from A to B be?
819 virtual int maxPackLog(UInt16 nodeA, UInt16 nodeB) const;
820
821 // Force given node to be root (via root holdoff Phy packet)
822 virtual IOReturn makeRoot(UInt32 generation, UInt16 nodeID) ;
823
824 virtual IOFWPseudoAddressSpace *createInitialAddressSpace(UInt32 addressLo, UInt32 len,
825 FWReadCallback reader, FWWriteCallback writer, void *refcon);
826
827 virtual IOFWAddressSpace *getAddressSpace(FWAddress address);
828
829 // Extract info about the async request - was the request ack'ed complete already?
830 virtual bool isCompleteRequest(IOFWRequestRefCon refcon);
831
832 // Are we currently scanning the bus?
833 bool scanningBus() const;
834
835protected:
836
837 void openGate();
838 void closeGate();
839
840protected:
841virtual void doBusReset( void );
842static void resetStateChange( void *refcon, IOReturn status,
843 IOFireWireBus *bus, IOFWBusCommand *fwCmd);
844
845public:
846virtual IOReturn disableSoftwareBusResets( void );
847virtual void enableSoftwareBusResets( void );
848
849 virtual IOFWAsyncStreamCommand * createAsyncStreamCommand( UInt32 generation,
850 UInt32 channel, UInt32 sync, UInt32 tag, IOMemoryDescriptor *hostMem,
851UInt32 size, int speed,FWAsyncStreamCallback completion, void *refcon);
852
853virtualIOReturn asyncStreamWrite(UInt32 generation,
854 int speed, int tag, int sync, int channel,
855 IOMemoryDescriptor *buf, IOByteCount offset,
856 int size, IOFWAsyncStreamCommand *cmd);
857
858protected:
859bool inGate();
860
861 virtual IOReturn allocatePseudoAddress(FWAddress *addr, UInt32 lenDummy);
862 virtual void freePseudoAddress(FWAddress addr, UInt32 lenDummy);
863
864virtual IORegistryEntry * createDummyRegistryEntry( IOFWNodeScan *scan );
865
866static IOFireWireLocalNode * getLocalNode(IOFireWireController *control);
867
868virtual void setPhysicalAccessMode( IOFWPhysicalAccessMode mode );
869virtual IOFWPhysicalAccessMode getPhysicalAccessMode( void );
870virtual void physicalAccessProcessBusReset( void );
871virtual void setNodeIDPhysicalFilter( UInt16 nodeID, bool state );
872
873virtual void initSecurity( void );
874virtual void freeSecurity( void );
875static bool serverKeyswitchCallback( void * target, void * refCon, IOService * service, IONotifier * notifier );
876virtual void setSecurityMode( IOFWSecurityMode mode );
877virtual IOFWSecurityMode getSecurityMode( void );
878
879virtual IOReturn createTimeoutQ( void );
880virtual void destroyTimeoutQ( void );
881virtual IOReturn createPendingQ( void );
882virtual void destroyPendingQ( void );
883
884virtual UInt32 countNodeIDChildren( UInt16 nodeID, int hub_port = 0, int * hubChildRemainder = NULL, bool * hubParentFlag = NULL );
885
886public:
887virtual UInt32 hopCount(UInt16 nodeAAddress, UInt16 nodeBAddress );
888virtual UInt32 hopCount(UInt16 nodeAAddress );
889
890virtual IOFireWirePowerManager * getBusPowerManager( void );
891
892protected:
893virtual void handleARxReqIntComplete();
894
895 virtual IOReturn asyncLock(UInt32 generation,
896UInt16 nodeID,
897UInt16 addrHi,
898UInt32 addrLo,
899int speed,
900int label,
901int type,
902IOMemoryDescriptor *buf,
903IOByteCount offset,
904int size,
905IOFWAsyncCommand *cmd );
906
907 virtual IOReturn asyncWrite(UInt32 generation,
908UInt16 nodeID,
909UInt16 addrHi,
910UInt32 addrLo,
911int speed,
912int label,
913IOMemoryDescriptor *buf,
914IOByteCount offset,
915int size,
916IOFWAsyncCommand *cmd,
917IOFWWriteFlags flags );
918
919protected:
920bool delayedStateCommandInUse() const;
921void enterBusResetDisabledState( );
922
923virtual UInt32 getPortNumberFromIndex( UInt16 index );
924
925 virtual bool checkForDuplicateGUID(IOFWNodeScan *scan, CSRNodeUniqueID *currentGUIDs );
926 virtual void updateDevice(IOFWNodeScan *scan );
927 virtual bool AssignCycleMaster();
928
929public:
930
931 IOReturn clipMaxRec2K(Boolean clipMaxRec );
932void setNodeSpeed( UInt16 nodeAddress, IOFWSpeed speed );
933void useHalfSizePackets( void );
934void disablePhyPortOnSleepForNodeID( UInt32 nodeID );
935
936IOReturn handleAsyncCompletion( IOFWCommand *cmd, IOReturn status );
937void processCycle64Int();
938
939#ifdef LEGACY_SHUTDOWN
940static IOReturn systemShutDownHandler( void * target, void * refCon,
941 UInt32 messageType, IOService * service,
942 void * messageArgument, vm_size_t argSize );
943#else
944 virtual void systemWillShutdown( IOOptionBits specifier );
945#endif
946
947IOReturn beginIOCriticalSection( void );
948void endIOCriticalSection( void );
949
950protected:
951IOReturn poweredStart( void );
952void setNodeSpeed( UInt16 nodeA, UInt16 nodeB, UInt8 speed );
953void setNodeSpeed( UInt16 nodeAddress, UInt8 speed );
954
955public:
956bool isPhysicalAccessEnabledForNodeID( UInt16 nodeID );
957
958// Allocate IRM bandwidth if the specified generation is the current FireWire generation.
959IOReturn allocateIRMBandwidthInGeneration(UInt32 bandwidthUnits, UInt32 generation) ;
960
961// Release IRM bandwidth if the specified generation is the current FireWire generation.
962IOReturn releaseIRMBandwidthInGeneration(UInt32 bandwidthUnits, UInt32 generation) ;
963
964// Allocate IRM channel if the specified generation is the current FireWire generation.
965IOReturn allocateIRMChannelInGeneration(UInt8 isochChannel, UInt32 generation) ;
966
967// Release IRM channel if the specified generation is the current FireWire generation.
968IOReturn releaseIRMChannelInGeneration(UInt8 isochChannel, UInt32 generation) ;
969
970// Create an IOFireWireIRMAllocation object which can be used to allocate isoch resources that are automatically reallocated after bus-resets!
971IOFireWireIRMAllocation *createIRMAllocation(Boolean releaseIRMResourcesOnFree = true,
972IOFireWireIRMAllocation::AllocationLostNotificationProc allocationLostProc = NULL,
973void *pLostNotificationProcRefCon = NULL);
974
975IOFWAsyncStreamListener *createAsyncStreamListener( UInt32channel, FWAsyncStreamReceiveCallback proc, void *refcon );
976
977void removeAsyncStreamListener( IOFWAsyncStreamListener *listener );
978
979IOFWSpeed getBroadcastSpeed(){ return FWSpeed( fLocalNodeID ); };
980
981private:
982
983IOFWAsyncStreamReceiver *allocAsyncStreamReceiver( UInt32 channel, FWAsyncStreamReceiveCallback proc, void *refcon );
984
985IOFWAsyncStreamReceiver *getAsyncStreamReceiver( UInt32 channel );
986
987void freeAllAsyncStreamReceiver();
988
989void activateAsyncStreamReceivers();
990
991void deactivateAsyncStreamReceivers();
992
993protected:
994IOService *findKeyswitchDevice( void );
995void suspendBus( void );
996
997public:
998virtual IOReturnasyncRead(UInt32 generation,
999UInt16 nodeID,
1000UInt16 addrHi,
1001UInt32 addrLo,
1002int speed,
1003int label,
1004int size,
1005IOFWAsyncCommand *cmd,
1006IOFWReadFlagsflags );
1007
1008void checkProgress( void );
1009
1010void terminateDevice( IOFireWireDevice * device );
1011
1012void nodeMustBeRoot( UInt32 nodeID );
1013
1014void nodeMustNotBeRoot( UInt32 nodeID );
1015
1016void setGapCount( UInt32gapCount );
1017
1018IOReturn asyncPHYPacket(UInt32generation,
1019UInt32data,
1020UInt32data2,
1021IOFWAsyncPHYCommand *cmd );
1022
1023 IOFWAsyncPHYCommand * createAsyncPHYCommand(UInt32generation,
1024UInt32data1,
1025UInt32data2,
1026FWAsyncPHYCallbackcompletion,
1027void *refcon,
1028boolfailOnReset );
1029
1030private:
1031AsyncPendingTrans * allocTrans( IOFWAsyncCommand * cmd, IOFWCommand * altcmd );
1032
1033public:
1034
1035IOReturn activatePHYPacketListener( IOFWPHYPacketListener * listener );
1036void deactivatePHYPacketListener( IOFWPHYPacketListener * listener );
1037
1038IOFWPHYPacketListener * createPHYPacketListener( FWPHYPacketCallback proc, void * refcon );
1039
1040private:
1041void processPHYPacket( UInt32 data1, UInt32 data2 );
1042void enterLoggingMode( void );
1043
1044public:
1045IOReturn getCycleTimeAndUpTime( UInt32 &cycleTime, UInt64 &uptime );
1046
1047protected:
1048void removeAsyncStreamReceiver( IOFWAsyncStreamReceiver *receiver );
1049
1050public:
1051
1052// Create a multi-isoch-receive listener
1053IOFireWireMultiIsochReceiveListener * createMultiIsochReceiveListener(UInt32 channel,
1054 FWMultiIsochReceiveListenerCallback callback,
1055 void *pCallbackRefCon,
1056 FWMultiIsochReceiveListenerParams *pListenerParams = NULL);
1057
1058// Activate a multi-isoch-receive listener
1059IOReturn activateMultiIsochReceiveListener(IOFireWireMultiIsochReceiveListener *pListener);
1060
1061// Deactivate a multi-isoch-receive listener
1062IOReturn deactivateMultiIsochReceiveListener(IOFireWireMultiIsochReceiveListener *pListener);
1063
1064// Call for client to specify he is done with a multi-isoch receiver isoch packet
1065void clientDoneWithMultiIsochReceivePacket(IOFireWireMultiIsochReceivePacket *pPacket);
1066
1067public:
1068 virtual IOFWAsyncStreamCommand * createAsyncStreamCommand( UInt32 generation,
1069 UInt32 channel, UInt32 sync, UInt32 tag, IOMemoryDescriptor *hostMem,
1070UInt32 size, int speed,FWAsyncStreamCallback completion, void *refcon, boolfailOnReset);
1071
1072private:
1073void addToIRMAllocationSet(IOFireWireIRMAllocation *anObject);
1074void removeFromIRMAllocationSet(IOFireWireIRMAllocation *anObject);
1075
1076protected:
1077OSMetaClassDeclareReservedUnused(IOFireWireController, 0);
1078 OSMetaClassDeclareReservedUnused(IOFireWireController, 1);
1079 OSMetaClassDeclareReservedUnused(IOFireWireController, 2);
1080 OSMetaClassDeclareReservedUnused(IOFireWireController, 3);
1081 OSMetaClassDeclareReservedUnused(IOFireWireController, 4);
1082 OSMetaClassDeclareReservedUnused(IOFireWireController, 5);
1083 OSMetaClassDeclareReservedUnused(IOFireWireController, 6);
1084 OSMetaClassDeclareReservedUnused(IOFireWireController, 7);
1085 OSMetaClassDeclareReservedUnused(IOFireWireController, 8);
1086
1087};
1088
1089#endif /* ! _IOKIT_IOFIREWIRECONTROLLER_H */
1090

Archive Download this file

Revision: 1146