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 * IOFireWirePseudoAddressSpacePriv.h 24 * IOFireWireLib 25 * 26 * Created by NWG on Wed Dec 06 2000. 27 * Copyright (c) 2000 Apple, Inc. All rights reserved. 28 * 29 */ 30 31#import "IOFireWireLibIUnknown.h" 32#import "IOFireWireLibPriv.h" 33 34namespace IOFireWireLib { 35 36 class Device ; 37 class PseudoAddressSpace: public IOFireWireIUnknown 38 { 39 typedef ::IOFireWirePseudoAddressSpaceInterface Interface ; 40 typedef ::IOFireWireLibPseudoAddressSpaceRef AddressSpaceRef ; 41 typedef ::IOFireWirePseudoAddressSpaceWriteHandler WriteHandler ; 42 typedef ::IOFireWirePseudoAddressSpaceReadHandler ReadHandler ; 43 typedef ::IOFireWirePseudoAddressSpaceSkippedPacketHandler SkippedPacketHandler ; 44 45 // interfaces 46 static Interface sInterface ; 47 48 public: 49 // static allocator 50 static IUnknownVTbl** Alloc( Device& userclient, UserObjectHandle inKernAddrSpaceRef, 51 void* inBuffer, UInt32 inBufferSize, void* inBackingStore, 52 void* inRefCon) ; 53 54 // QueryInterface 55 virtual HRESULT QueryInterface(REFIID iid, void **ppv ); 56 57 // 58 // === STATIC METHODS ========================== 59 // 60 61 static IOReturn SInit() ; 62 63 // callback management 64 static const WriteHandler SSetWriteHandler( AddressSpaceRef interface, WriteHandler inWriter ) ; 65 static const ReadHandler SSetReadHandler( AddressSpaceRef interface, ReadHandler inReader) ; 66 static const SkippedPacketHandler SSetSkippedPacketHandler( AddressSpaceRef interface, SkippedPacketHandler inHandler ) ; 67 68 static Boolean SNotificationIsOn( 69 AddressSpaceRef interface) ; 70 static Boolean STurnOnNotification( 71 AddressSpaceRef interface) ; 72 static void STurnOffNotification( 73 AddressSpaceRef interface) ; 74 static void SClientCommandIsComplete( 75 AddressSpaceRef interface, 76 FWClientCommandID commandID, 77 IOReturn status) ; 78 79 // accessors 80 static void SGetFWAddress( 81 AddressSpaceRef interface, 82 FWAddress* outAddr) ; 83 static void* SGetBuffer( 84 AddressSpaceRef interface) ; 85 static const UInt32 SGetBufferSize( 86 AddressSpaceRef interface) ; 87 static void* SGetRefCon( 88 AddressSpaceRef interface) ; 89 90 // --- constructor/destructor ---------- 91 PseudoAddressSpace( 92 Device& userclient, 93 UserObjectHandle inKernAddrSpaceRef, 94 void* inBuffer, 95 UInt32 inBufferSize, 96 void* inBackingStore, 97 void* inRefCon = 0) ; 98 virtual ~PseudoAddressSpace() ; 99 100 // --- callback methods ---------------- 101 static void Writer( AddressSpaceRef refcon, IOReturn result, void** args, 102 int numArgs) ; 103 static void Reader( AddressSpaceRef refcon, IOReturn result, void** args, 104 int numArgs) ; 105 static void SkippedPacket( AddressSpaceRef refCon, IOReturn result, FWClientCommandID commandID, 106 UInt32 packetCount) ; 107 108 // --- notification methods ---------- 109 virtual const WriteHandler SetWriteHandler( WriteHandler inWriter ) ; 110 virtual const ReadHandler SetReadHandler( ReadHandler inReader ) ; 111 virtual const SkippedPacketHandler SetSkippedPacketHandler( SkippedPacketHandler inHandler ) ; 112 virtual Boolean NotificationIsOn() const { return mNotifyIsOn ; } 113 virtual Boolean TurnOnNotification( void* callBackRefCon ) ; 114 virtual void TurnOffNotification() ; 115 virtual void ClientCommandIsComplete( FWClientCommandID commandID, IOReturn status) ; 116 117 virtual const FWAddress& GetFWAddress() ; 118 virtual void* GetBuffer() ; 119 virtual const UInt32 GetBufferSize() ; 120 virtual void* GetRefCon() ; 121 122 const ReadHandler GetReader() const { return mReader ; } 123 const WriteHandler GetWriter() const { return mWriter ; } 124 const SkippedPacketHandler GetSkippedPacketHandler() const { return mSkippedPacketHandler ; } 125 126 protected: 127 // callback mgmt. 128 Boolean mNotifyIsOn ; 129 CFRunLoopRef mNotifyRunLoop ; 130 IONotificationPortRef mNotifyPort ; 131 io_object_t mNotify; 132 WriteHandler mWriter ; 133 ReadHandler mReader ; 134 SkippedPacketHandler mSkippedPacketHandler ; 135 Device& mUserClient ; 136 FWAddress mFWAddress ; 137 UserObjectHandle mKernAddrSpaceRef ; 138 char* mBuffer ; 139 UInt32 mBufferSize ; 140 141 void* mBackingStore ; 142 void* mRefCon ; 143 144 CFMutableDictionaryRef mPendingLocks ; 145 } ; 146} 147