|
|
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: * ! 24: * IOFWCommand.h ! 25: * ! 26: */ ! 27: #ifndef _IOKIT_IOFWCOMMAND_H ! 28: #define _IOKIT_IOFWCOMMAND_H ! 29: ! 30: #include <IOKit/IOCommandGate.h> ! 31: #include <IOKit/firewire/IOFWRegs.h> ! 32: ! 33: class IOMemoryDescriptor; ! 34: class IOSyncer; ! 35: class IOFireWireBus; ! 36: class IOFireWireController; ! 37: class IOFireWireNub; ! 38: class IOFWAddressSpace; // Description of chunk of local FW address space ! 39: class IOFWCommand; ! 40: class IOFWBusCommand; ! 41: struct AsyncPendingTrans; ! 42: ! 43: // Callback when device command completes asynchronously ! 44: typedef void (*FWDeviceCallback)(void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd); ! 45: ! 46: // Callback when bus command completes asynchronously ! 47: typedef void (*FWBusCallback)(void *refcon, IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd); ! 48: ! 49: /* ! 50: * Base class for FireWire commands ! 51: */ ! 52: class IOFWCommand : public OSObject ! 53: { ! 54: OSDeclareAbstractStructors(IOFWCommand) ! 55: ! 56: protected: ! 57: IOCommandGate * fGate; ! 58: IOFireWireController *fControl; ! 59: IOSyncer * fSyncWakeup; ! 60: bool fSync; ! 61: ! 62: virtual IOReturn complete(IOReturn status) = 0; ! 63: ! 64: public: ! 65: IOReturn fStatus; ! 66: IOByteCount fBytesTransferred; ! 67: ! 68: virtual bool initWithGate(IOCommandGate *gate); ! 69: ! 70: /* ! 71: * Submit the FWCommand to the FireWire command queue ! 72: */ ! 73: virtual IOReturn submit(); ! 74: /* ! 75: * Execute the FWCommand immediately (usually called from work loop) ! 76: */ ! 77: virtual IOReturn execute() = 0; ! 78: }; ! 79: ! 80: /* ! 81: * Bus control commands ! 82: */ ! 83: class IOFWBusCommand : public IOFWCommand ! 84: { ! 85: OSDeclareAbstractStructors(IOFWBusCommand) ! 86: ! 87: protected: ! 88: FWBusCallback fComplete; ! 89: void * fRefCon; ! 90: ! 91: virtual IOReturn complete(IOReturn status); ! 92: ! 93: virtual bool initWithController(IOFireWireController *control, ! 94: FWBusCallback completion=NULL, void *refcon=NULL); ! 95: virtual IOReturn reinit(FWBusCallback completion, void *refcon); ! 96: }; ! 97: ! 98: /* ! 99: * Allocation of local address space, accessable to the ! 100: * specified firewire device. ! 101: * May also want the ability to change address mapping ! 102: * instead of freeing old space and allocing new one. ! 103: */ ! 104: class IOFWAllocAddressCommand : public IOFWBusCommand ! 105: { ! 106: OSDeclareDefaultStructors(IOFWAllocAddressCommand) ! 107: ! 108: protected: ! 109: IOFWAddressSpace *fSpace; ! 110: ! 111: public: ! 112: virtual IOReturn execute(); ! 113: virtual bool initWithSpace(IOFireWireNub *dev, IOFWAddressSpace *space, ! 114: FWBusCallback completion, void *refcon); ! 115: virtual IOReturn reinit(IOFWAddressSpace *space, ! 116: FWBusCallback completion=NULL, void *refcon=NULL); ! 117: }; ! 118: ! 119: /* ! 120: * Deallocate the address range (make it inactive) ! 121: */ ! 122: class IOFWDeallocAddressCommand : public IOFWBusCommand ! 123: { ! 124: OSDeclareDefaultStructors(IOFWDeallocAddressCommand) ! 125: ! 126: protected: ! 127: IOFWAddressSpace *fSpace; ! 128: ! 129: public: ! 130: virtual IOReturn execute(); ! 131: virtual bool initWithSpace(IOFireWireNub *dev, IOFWAddressSpace *space, ! 132: FWBusCallback completion, void *refcon); ! 133: virtual IOReturn reinit(IOFWAddressSpace *space, ! 134: FWBusCallback completion=NULL, void *refcon=NULL); ! 135: }; ! 136: ! 137: /* ! 138: * Little command for local ROM instantiation ! 139: */ ! 140: class IOFWUpdateROM : public IOFWBusCommand ! 141: { ! 142: OSDeclareDefaultStructors(IOFWUpdateROM) ! 143: ! 144: public: ! 145: virtual IOReturn execute(); ! 146: virtual bool initWithController(IOFireWireController *control, ! 147: FWBusCallback completion=NULL, void *refcon=NULL); ! 148: ! 149: }; ! 150: ! 151: /* ! 152: * Send an async request to a device ! 153: */ ! 154: class IOFWAsyncCommand : public IOFWCommand ! 155: { ! 156: OSDeclareAbstractStructors(IOFWAsyncCommand) ! 157: ! 158: protected: ! 159: IOFireWireNub * fDevice; ! 160: FWDeviceCallback fComplete; ! 161: void * fRefCon; ! 162: IOMemoryDescriptor *fMemDesc; ! 163: AsyncPendingTrans * fTrans; ! 164: UInt32 fAddressHi; ! 165: UInt32 fAddressLo; ! 166: UInt32 fNodeID; ! 167: UInt32 fGeneration; // bus topology fNodeID is valid for. ! 168: int fSize; ! 169: int fSpeed; ! 170: int fMaxPack; ! 171: bool fFailOnReset; ! 172: ! 173: virtual IOReturn complete(IOReturn status); ! 174: virtual bool initAll(IOFireWireController *control, ! 175: IOFireWireNub *device, FWAddress devAddress, ! 176: IOMemoryDescriptor *hostMem, ! 177: FWDeviceCallback completion, void *refcon, bool failOnReset); ! 178: virtual IOReturn reinit(FWAddress devAddress, IOMemoryDescriptor *hostMem, ! 179: FWDeviceCallback completion, void *refcon, bool failOnReset); ! 180: ! 181: public: ! 182: ! 183: // To be called by IOFireWireController and derived classes. ! 184: virtual void gotPacket(IOFireWireController* control, ! 185: int rcode, UInt8* data, int size) = 0; ! 186: virtual void gotAck(int ackCode); ! 187: ! 188: ! 189: }; ! 190: ! 191: /* ! 192: * Concrete async requests - read, write and hordes of read/modify/write ! 193: */ ! 194: class IOFWReadCommand : public IOFWAsyncCommand ! 195: { ! 196: OSDeclareDefaultStructors(IOFWReadCommand) ! 197: ! 198: protected: ! 199: virtual void gotPacket(IOFireWireController* control, ! 200: int rcode, UInt8* data, int size); ! 201: ! 202: public: ! 203: virtual bool initAll(IOFireWireNub *device, FWAddress devAddress, ! 204: IOMemoryDescriptor *hostMem, ! 205: FWDeviceCallback completion, void *refcon, bool failOnReset); ! 206: virtual IOReturn reinit(FWAddress devAddress, IOMemoryDescriptor *hostMem, ! 207: FWDeviceCallback completion=NULL, void *refcon=NULL, ! 208: bool failOnReset=false); ! 209: virtual IOReturn execute(); ! 210: ! 211: }; ! 212: ! 213: class IOFWReadQuadCommand : public IOFWAsyncCommand ! 214: { ! 215: OSDeclareDefaultStructors(IOFWReadQuadCommand) ! 216: ! 217: protected: ! 218: ! 219: UInt32 * fQuads; ! 220: ! 221: virtual void gotPacket(IOFireWireController* control, ! 222: int rcode, UInt8* data, int size); ! 223: ! 224: public: ! 225: virtual bool initAll(IOFireWireController *control, ! 226: IOFireWireNub *device, FWAddress devAddress, ! 227: UInt32 *quads, int numQuads, ! 228: FWDeviceCallback completion, void *refcon, bool failOnReset); ! 229: ! 230: virtual IOReturn reinit(FWAddress devAddress, UInt32 *quads, int numQuads, ! 231: FWDeviceCallback completion=NULL, void *refcon=NULL, ! 232: bool failOnReset=false); ! 233: ! 234: virtual IOReturn execute(); ! 235: }; ! 236: ! 237: class IOFWWriteCommand : public IOFWAsyncCommand ! 238: { ! 239: OSDeclareDefaultStructors(IOFWWriteCommand) ! 240: protected: ! 241: ! 242: int fPackSize; ! 243: ! 244: virtual void gotPacket(IOFireWireController* control, ! 245: int rcode, UInt8* data, int size); ! 246: ! 247: public: ! 248: virtual bool initAll(IOFireWireNub *device, FWAddress devAddress, ! 249: IOMemoryDescriptor *hostMem, ! 250: FWDeviceCallback completion, void *refcon, bool failOnReset); ! 251: virtual IOReturn reinit(FWAddress devAddress, IOMemoryDescriptor *hostMem, ! 252: FWDeviceCallback completion=NULL, void *refcon=NULL, ! 253: bool failOnReset=false); ! 254: virtual IOReturn execute(); ! 255: ! 256: }; ! 257: ! 258: class IOFWWriteQuadCommand : public IOFWAsyncCommand ! 259: { ! 260: OSDeclareDefaultStructors(IOFWWriteQuadCommand) ! 261: ! 262: protected: ! 263: ! 264: UInt32 fQuads[2]; ! 265: UInt32 * fQPtr; ! 266: int fPackSize; ! 267: ! 268: virtual void gotPacket(IOFireWireController* control, ! 269: int rcode, UInt8* data, int size); ! 270: ! 271: public: ! 272: virtual bool initAll(IOFireWireController *control, ! 273: IOFireWireNub *device, FWAddress devAddress, ! 274: UInt32 *quads, int numQuads, ! 275: FWDeviceCallback completion, void *refcon, bool failOnReset); ! 276: ! 277: virtual IOReturn reinit(FWAddress devAddress, UInt32 *quads, int numQuads, ! 278: FWDeviceCallback completion=NULL, void *refcon=NULL, ! 279: bool failOnReset=false); ! 280: ! 281: virtual IOReturn execute(); ! 282: }; ! 283: ! 284: ! 285: /* ! 286: * May need more parameters for some of these, ! 287: * and/or derive from a base Lock transaction command ! 288: */ ! 289: class IOFWCompareAndSwapCommand : public IOFWAsyncCommand ! 290: { ! 291: OSDeclareDefaultStructors(IOFWCompareAndSwapCommand) ! 292: ! 293: protected: ! 294: UInt32 fInputVals[4]; ! 295: UInt32 fOldVal[2]; ! 296: ! 297: virtual void gotPacket(IOFireWireController* control, ! 298: int rcode, UInt8* data, int size); ! 299: ! 300: public: ! 301: // Compare to cmpVal, and if equal replace with newVal. ! 302: // Size = 1 for 32 bit operation (one quad), 2 for 64 bit (two quads) ! 303: virtual bool initAll(IOFireWireNub *device, FWAddress devAddress, ! 304: const UInt32 *cmpVal, const UInt32 *newVal, int size, ! 305: FWDeviceCallback completion, void *refcon, bool failOnReset); ! 306: ! 307: // sets oldVal to the old value returned by the device, and ! 308: // returns true if it was the expected value, ie. the lock succeeded ! 309: virtual bool locked(UInt32 *oldVal); ! 310: virtual IOReturn execute(); ! 311: ! 312: }; ! 313: ! 314: class IOFWBitAndCommand : public IOFWAsyncCommand ! 315: { ! 316: OSDeclareDefaultStructors(IOFWBitAndCommand) ! 317: ! 318: public: ! 319: virtual IOReturn execute(); ! 320: ! 321: }; ! 322: ! 323: class IOFWBitOrCommand : public IOFWAsyncCommand ! 324: { ! 325: OSDeclareDefaultStructors(IOFWBitOrCommand) ! 326: ! 327: public: ! 328: virtual IOReturn execute(); ! 329: ! 330: }; ! 331: ! 332: class IOFWBitXOrCommand : public IOFWAsyncCommand ! 333: { ! 334: OSDeclareDefaultStructors(IOFWBitXOrCommand) ! 335: ! 336: public: ! 337: virtual IOReturn execute(); ! 338: ! 339: }; ! 340: ! 341: class IOFWIncrementCommand : public IOFWAsyncCommand ! 342: { ! 343: OSDeclareDefaultStructors(IOFWIncrementCommand) ! 344: ! 345: public: ! 346: virtual IOReturn execute(); ! 347: ! 348: }; ! 349: ! 350: class IOFWDecrementCommand : public IOFWAsyncCommand ! 351: { ! 352: OSDeclareDefaultStructors(IOFWDecrementCommand) ! 353: ! 354: public: ! 355: virtual IOReturn execute(); ! 356: ! 357: }; ! 358: ! 359: class IOFWAddCommand : public IOFWAsyncCommand ! 360: { ! 361: OSDeclareDefaultStructors(IOFWAddCommand) ! 362: ! 363: public: ! 364: virtual IOReturn execute(); ! 365: ! 366: }; ! 367: ! 368: class IOFWThresholdAddCommand : public IOFWAsyncCommand ! 369: { ! 370: OSDeclareDefaultStructors(IOFWThresholdAddCommand) ! 371: ! 372: public: ! 373: virtual IOReturn execute(); ! 374: ! 375: }; ! 376: ! 377: class IOFWThresholdSubtractCommand : public IOFWAsyncCommand ! 378: { ! 379: OSDeclareDefaultStructors(IOFWThresholdSubtractCommand) ! 380: ! 381: public: ! 382: virtual IOReturn execute(); ! 383: ! 384: }; ! 385: ! 386: class IOFWClippedAddCommand : public IOFWAsyncCommand ! 387: { ! 388: OSDeclareDefaultStructors(IOFWClippedAddCommand) ! 389: ! 390: public: ! 391: virtual IOReturn execute(); ! 392: ! 393: }; ! 394: ! 395: class IOFWClippedSubtractCommand : public IOFWAsyncCommand ! 396: { ! 397: OSDeclareDefaultStructors(IOFWClippedSubtractCommand) ! 398: ! 399: public: ! 400: virtual IOReturn execute(); ! 401: ! 402: }; ! 403: ! 404: #endif /* _IOKIT_IOFWCOMMAND_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.