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#ifndef _IOKIT_IOFIREWIRESBP2LIBORB_H_ 24#define _IOKIT_IOFIREWIRESBP2LIBORB_H_ 25 26#include "IOFireWireSBP2LibLUN.h" 27#include "IOFireWireSBP2UserClientCommon.h" 28 29class IOFireWireSBP2LibORB 30{ 31 32public: 33 34 struct InterfaceMap 35 { 36 IUnknownVTbl *pseudoVTable; 37 IOFireWireSBP2LibORB *obj; 38 }; 39 40 IOFireWireSBP2LibORB( void ); 41 virtual ~IOFireWireSBP2LibORB(); 42 43 virtual IOReturn init( io_connect_t connection, mach_port_t asyncPort ); 44 45protected: 46 47 typedef struct 48 { 49 uint64_t address; 50 uint64_t length; 51 } FWSBP2PrivateVirtualRange; 52 53 ////////////////////////////////////// 54 // cf plugin interfaces 55 56 static IOFireWireSBP2LibORBInterface sIOFireWireSBP2LibORBInterface; 57 InterfaceMap fIOFireWireSBP2LibORBInterface; 58 59 ////////////////////////////////////// 60 // cf plugin ref counting 61 62 UInt32 fRefCount; 63 64 ////////////////////////////////////// 65 // user client connection 66 67 io_connect_t fConnection; // connection to user client in kernel 68 mach_port_t fAsyncPort; // async port for callback from kernel 69 uint64_t fORBRef; // reference to kernel orb object 70 71 void * fRefCon; 72 73 FWSBP2PrivateVirtualRange * fRangeScratch; 74 UInt32 fRangeScratchLength; 75 76 ////////////////////////////////////// 77 // IUnknown static methods 78 79 static HRESULT staticQueryInterface( void * self, REFIID iid, void **ppv ); 80 virtual HRESULT queryInterface( REFIID iid, void **ppv ); 81 82 static UInt32 staticAddRef( void * self ); 83 virtual UInt32 addRef( void ); 84 85 static UInt32 staticRelease( void * self ); 86 virtual UInt32 release( void ); 87 88 ////////////////////////////////////// 89 // IOFireWireSBP2LibORB static methods 90 91 static void staticSetRefCon( void * self, void * refCon ); 92 virtual void setRefCon( void * refCon ); 93 94 static void * staticGetRefCon( void * self ); 95 virtual void * getRefCon( void ); 96 97 static void staticSetCommandFlags( void * self, UInt32 flags ); 98 virtual void setCommandFlags( UInt32 flags ); 99 100 static void staticSetMaxORBPayloadSize( void * self, UInt32 size ); 101 virtual void setMaxORBPayloadSize( UInt32 size ); 102 103 static void staticSetCommandTimeout( void * self, UInt32 timeout ); 104 virtual void setCommandTimeout( UInt32 timeout ); 105 106 static void staticSetCommandGeneration( void * self, UInt32 generation ); 107 virtual void setCommandGeneration( UInt32 generation ); 108 109 static void staticSetToDummy( void * self ); 110 virtual void setToDummy( void ); 111 112 static IOReturn staticSetCommandBuffersAsRanges( void * self, FWSBP2VirtualRange * ranges, 113 UInt32 withCount, UInt32 withDirection, 114 UInt32 offset, UInt32 length ); 115 virtual IOReturn setCommandBuffersAsRanges( FWSBP2VirtualRange * ranges, UInt32 withCount, 116 UInt32 withDirection, UInt32 offset, 117 UInt32 length ); 118 119 static IOReturn staticReleaseCommandBuffers( void * self ); 120 virtual IOReturn releaseCommandBuffers( void ); 121 122 static IOReturn staticSetCommandBlock( void * self, void * buffer, UInt32 length ); 123 virtual IOReturn setCommandBlock( void * buffer, UInt32 length ); 124 125 static IOReturn staticLSIWorkaroundSetCommandBuffersAsRanges 126 ( void * self, FWSBP2VirtualRange * ranges, UInt32 withCount, 127 UInt32 withDirection, UInt32 offset, UInt32 length ); 128 virtual IOReturn LSIWorkaroundSetCommandBuffersAsRanges 129 ( FWSBP2VirtualRange * ranges, UInt32 withCount, 130 UInt32 withDirection, UInt32 offset, UInt32 length ); 131 132 static IOReturn staticLSIWorkaroundSyncBuffersForOutput( void * self ); 133 virtual IOReturn LSIWorkaroundSyncBuffersForOutput( void ); 134 135 static IOReturn staticLSIWorkaroundSyncBuffersForInput( void * self ); 136 virtual IOReturn LSIWorkaroundSyncBuffersForInput( void ); 137 138public: 139 140 // utility function to get "this" pointer from interface 141 static inline IOFireWireSBP2LibORB *getThis( void *self ) 142 { return (IOFireWireSBP2LibORB *) ((InterfaceMap *) self)->obj; }; 143 144 static IUnknownVTbl **alloc( io_connect_t connection, mach_port_t asyncPort ); 145 146 virtual UInt32 getORBRef( void ); 147 148}; 149 150#endif