|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1998-2000 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 Apple Computer, Inc. All rights reserved. ! 24: * ! 25: * HISTORY ! 26: * ! 27: */ ! 28: ! 29: ! 30: #ifndef _IOKIT_IOFIREWIRECONTROLLER_H ! 31: #define _IOKIT_IOFIREWIRECONTROLLER_H ! 32: ! 33: #include <IOKit/firewire/IOFireWireBus.h> ! 34: #include <IOKit/firewire/IOFWRegs.h> ! 35: #include <IOKit/firewire/IOFireWirePriv.h> ! 36: ! 37: extern const OSSymbol *gFireWireROM; ! 38: extern const OSSymbol *gFireWireNodeID; ! 39: extern const OSSymbol *gFireWireSelfIDs; ! 40: extern const OSSymbol *gFireWireSpeed; ! 41: extern const OSSymbol *gFireWireUnit_Spec_ID; ! 42: extern const OSSymbol *gFireWireUnit_SW_Version; ! 43: extern const OSSymbol *gFireWireVendor_ID; ! 44: extern const OSSymbol *gFireWire_GUID; ! 45: ! 46: class OSData; ! 47: class IOWorkLoop; ! 48: class IOTimerEventSource; ! 49: class IOCommandGate; ! 50: class IOMemoryDescriptor; ! 51: class IOFireWireController; ! 52: class IOFWAddressSpace; ! 53: class IOFireWireNub; ! 54: class IOFireWireDevice; ! 55: class IOFWCommand; ! 56: class IOFWAsyncCommand; ! 57: class IODCLProgram; ! 58: struct NodeScan; ! 59: ! 60: typedef void (*PacketHandler)(void *refCon, IOFireWireController* control, int rcode, UInt8* data, int size); ! 61: ! 62: struct AsyncPendingTrans { ! 63: IOFWAsyncCommand * fHandler; ! 64: int fTCode; ! 65: bool fInUse; ! 66: }; ! 67: ! 68: // May want to change this, to use two tcodes per request block. ! 69: #define kMaxPendingTransfers kFWAsynchTTotal ! 70: ! 71: class IOFireWireController : public IOFireWireBus ! 72: { ! 73: OSDeclareAbstractStructors(IOFireWireController) ! 74: ! 75: protected: ! 76: IOWorkLoop * fWorkLoop; ! 77: IOTimerEventSource *fTimer; ! 78: IOCommandGate * fGate; ! 79: OSSet * fLocalAddresses; // Collection of local adress spaces ! 80: OSIterator * fSpaceIterator; // Iterator over local addr spaces ! 81: ! 82: OSSet * fAllocatedChannels; // Need to be informed of bus resets ! 83: OSIterator * fAllocChannelIterator; // Iterator over channels ! 84: IOLock * fChannelLock; ! 85: ! 86: // Bus management variables (although we aren't a FireWire Bus Manager...) ! 87: AbsoluteTime fResetTime; // Time of last reset ! 88: UInt32 fLocalNodeID; // ID of the local node. ! 89: UInt32 fBusGeneration; // ID of current bus topology. ! 90: UInt16 fRootNodeID; // ID of root, ie. highest node id in use. ! 91: UInt16 fIRMNodeID; // ID of Isochronous resource manager, or kFWBadNodeID ! 92: IOFireWireDevice * fIRMDevice; // NULL if no IRM. ! 93: IORegistryEntry * fNodes[kFWMaxNodesPerBus]; // FireWire nodes on this bus ! 94: UInt32 * fNodeIDs[kFWMaxNodesPerBus+1]; // Pointer to SelfID list for each node ! 95: // +1 so we know how many selfIDs the last node has ! 96: UInt8 fSpeedCodes[(kFWMaxNodesPerBus+1)*kFWMaxNodesPerBus]; ! 97: // Max speed between two nodes ! 98: bool fInReset; // True if processing a reset (waiting for selfIDs) ! 99: int fNumROMReads; // Number of device ROMs we are still reading ! 100: // SelfIDs ! 101: int fNumSelfIDs; // Total number of SelfID packets ! 102: UInt32 fSelfIDs[kMaxSelfIDs*kFWMaxNodesPerBus]; ! 103: ! 104: // The local device's CSR ROM ! 105: UInt32 fCSRROMGeneration; // Generation number of CSR ROM. ! 106: CSRROMDirectoryData fCSRROMRootDirectory; // Local CSR ROM root directory. ! 107: CSRNodeUniqueID fUniqueID; // ID unique to this device. ! 108: UInt32 fROMHeader[5]; // More or less fixed header and bus info block ! 109: IOFWAddressSpace * fROMAddrSpace; ! 110: ! 111: // Array for outstanding requests (up to 64) ! 112: AsyncPendingTrans fTrans[kMaxPendingTransfers]; ! 113: int fLastTrans; ! 114: IOLock * fTransAllocLock; ! 115: ! 116: static IOReturn execCommand(OSObject * obj, void *field0, void *field1, ! 117: void *field2, void *field3); ! 118: static void clockTick(OSObject *, IOTimerEventSource *); ! 119: static void readROMGlue(void *refcon, IOReturn status, ! 120: IOFireWireNub *device, IOFWCommand *fwCmd); ! 121: virtual IOWorkLoop * createWorkLoop(); ! 122: virtual bool startWorkLoop(); ! 123: ! 124: virtual void processBusReset(); ! 125: virtual void processSelfIDs(UInt32 *IDs, int numIDs, UInt32 *ownIDs, int numOwnIDs); ! 126: virtual void processRcvPacket(UInt32 *data, int numQuads); ! 127: virtual void processWriteRequest(UInt16 sourceID, UInt32 tlabel, ! 128: UInt32 *hdr, void *buf, int len); ! 129: virtual void processLockRequest(UInt16 sourceID, UInt32 tlabel, ! 130: UInt32 *hdr, void *buf, int len); ! 131: ! 132: virtual void pruneDevices(); ! 133: ! 134: virtual void buildTopology(bool doFWPlane); ! 135: ! 136: virtual void readDeviceROM(NodeScan *refCon, IOReturn status); ! 137: ! 138: // Hack so old OHCI driver will compile ! 139: virtual IODCLProgram *createDCLProgram(bool talking, DCLCommandStruct *opcodes, ! 140: UInt32 startEvent, UInt32 startState, UInt32 startMask){return NULL;}; ! 141: ! 142: virtual IODCLProgram *createDCLProgram(bool talking, DCLCommandStruct *opcodes, ! 143: DCLTaskInfo *info, UInt32 startEvent, UInt32 startState, UInt32 startMask) ! 144: {return createDCLProgram(talking, opcodes, startEvent, startState, startMask); }; ! 145: ! 146: // Send a PHY packet ! 147: virtual IOReturn sendPHYPacket(UInt32 quad) = 0; ! 148: ! 149: public: ! 150: ! 151: static const IORegistryPlane * gIOFireWirePlane; ! 152: ! 153: // Initialization ! 154: virtual bool init(OSDictionary * dict); ! 155: ! 156: // Implement IOService::getWorkLoop ! 157: virtual IOWorkLoop *getWorkLoop() const; ! 158: ! 159: // Methods called by commands. Not really public. ! 160: virtual void fireBugMsg(const char *msg) = 0; ! 161: virtual IOReturn resetBus() = 0; ! 162: virtual IOReturn asyncRead(UInt16 nodeID, UInt16 addrHi, UInt32 addrLo, ! 163: int speed, int label, int size, IOFWAsyncCommand *cmd) = 0; ! 164: virtual IOReturn asyncReadQuadResponse(UInt16 nodeID, int speed, ! 165: int label, int rcode, UInt32 data) = 0; ! 166: virtual IOReturn asyncReadResponse(UInt16 nodeID, int speed, ! 167: int label, int rcode, void *data, int len) = 0; ! 168: virtual IOReturn asyncReadResponse(UInt16 nodeID, int speed, ! 169: int label, int rcode, IOMemoryDescriptor *buf, ! 170: IOByteCount offset, int len) = 0; ! 171: ! 172: virtual IOReturn asyncWrite(UInt16 nodeID, UInt16 addrHi, UInt32 addrLo, ! 173: int speed, int label, IOMemoryDescriptor *buf, IOByteCount offset, ! 174: int size, IOFWAsyncCommand *cmd) = 0; ! 175: virtual IOReturn asyncWrite(UInt16 nodeID, UInt16 addrHi, UInt32 addrLo, ! 176: int speed, int label, void *data, int size, IOFWAsyncCommand *cmd) = 0; ! 177: virtual IOReturn asyncWriteResponse(UInt16 nodeID, int speed, ! 178: int label, int rcode, UInt16 addrHi) = 0; ! 179: ! 180: virtual IOReturn asyncLock(UInt16 nodeID, UInt16 addrHi, UInt32 addrLo, ! 181: int speed, int label, int type, void *data, int size, IOFWAsyncCommand *cmd) = 0; ! 182: virtual IOReturn asyncLockResponse(UInt16 nodeID, int speed, ! 183: int label, int rcode, int type, void *data, int len) = 0; ! 184: ! 185: // Read Cycle time register. safe to call at any time. ! 186: virtual IOReturn getCycleTime(UInt32 *cycleTime) = 0; ! 187: ! 188: virtual IOReturn allocAddress(IOFWAddressSpace *space); ! 189: virtual void freeAddress(IOFWAddressSpace *space); ! 190: virtual IOReturn UpdateROM(); ! 191: ! 192: // Allocate struct for receiving a read response ! 193: virtual AsyncPendingTrans *allocTrans(bool sleepOK = true); ! 194: virtual void freeTrans(AsyncPendingTrans *trans); ! 195: ! 196: // Really public methods ! 197: ! 198: // Methods to manipulate the local CSR ROM ! 199: virtual IOReturn CSRROMGetRootDirectory(CSRROMEntryID *pCSRROMEntryID); ! 200: virtual IOReturn CSRROMCreateEntry(CSRROMEntryID parentCSRROMEntryID, CSRROMEntryID *pCSRROMEntryID, ! 201: UInt32 entryType, UInt32 entryKeyValue, void *entryData, UInt32 entrySize); ! 202: ! 203: // Convert a firewire nodeID into the IOFireWireDevice for it ! 204: virtual IOFireWireDevice * nodeIDtoDevice(UInt16 nodeID); ! 205: ! 206: // Add/remove a channel from the list informed of bus resets ! 207: virtual void addAllocatedChannel(IOFWIsochChannel *channel); ! 208: virtual void removeAllocatedChannel(IOFWIsochChannel *channel); ! 209: ! 210: // Create a device nub ! 211: virtual IOFireWireDevice *createDeviceNub(OSDictionary *propTable); ! 212: ! 213: // Create an Isochronous Channel object ! 214: virtual IOFWIsochChannel *createIsochChannel( ! 215: bool doIRM, UInt32 bandwidth, IOFWSpeed prefSpeed, ! 216: FWIsochChannelForceStopNotificationProc stopProc=NULL, ! 217: void *stopRefCon=NULL); ! 218: ! 219: // Create a local isochronous port to run the given DCL program ! 220: // if task is 0, the DCL program is for the kernel task, ! 221: // otherwise all DCL pointers are valid in the specified task. ! 222: // opcodes is also pointer valid in the specified task. ! 223: virtual IOFWIsochPort *createLocalIsochPort(bool talking, ! 224: DCLCommandStruct *opcodes, DCLTaskInfo *info = 0, ! 225: UInt32 startEvent = 0, UInt32 startState = 0, UInt32 startMask = 0); ! 226: ! 227: // Inline accessors for protected member variables ! 228: IOCommandGate *getGate() const {return fGate;}; ! 229: bool checkGeneration(UInt32 gen) const {return gen == fBusGeneration;}; ! 230: UInt32 getGeneration() const {return fBusGeneration;}; ! 231: UInt16 getIRMNodeID() const {return fIRMNodeID;}; ! 232: IOFireWireDevice * getIRMDevice() const {return fIRMDevice;}; ! 233: const AbsoluteTime * getResetTime() const {return &fResetTime;}; ! 234: ! 235: IOFWSpeed FWSpeed(UInt16 nodeAddress) const ! 236: {return (IOFWSpeed)fSpeedCodes[(kFWMaxNodesPerBus+1)*(nodeAddress & 63)+(fLocalNodeID & 63)];}; ! 237: IOFWSpeed FWSpeed(UInt16 nodeA, UInt16 nodeB) const ! 238: {return (IOFWSpeed)fSpeedCodes[(kFWMaxNodesPerBus+1)*(nodeA & 63)+(nodeB & 63)];}; ! 239: ! 240: // How big (as a power of two) can packets sent to/received from the node be? ! 241: virtual int maxPackLog(bool forSend, UInt16 nodeAddress) const; ! 242: ! 243: // How big (as a power of two) can packets sent from A to B be? ! 244: virtual int maxPackLog(UInt16 nodeA, UInt16 nodeB) const; ! 245: }; ! 246: ! 247: #endif /* ! _IOKIT_IOFIREWIRECONTROLLER_H */ ! 248:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.