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 * IOFWUserAsyncStreamListener.h 24 * IOFireWireFamily 25 * 26 * Created by Arul on Wed Nov 08 2006. 27 * Copyright (c) 2004-2006 Apple Computer, Inc. All rights reserved. 28 * 29 */ 30/* 31 $Log: IOFWUserAsyncStreamListener.h,v $ 32 Revision 1.4 2007/02/16 19:03:43 arulchan 33 *** empty log message *** 34 35 Revision 1.3 2007/02/07 06:35:20 collin 36 *** empty log message *** 37 38 Revision 1.2 2006/12/21 21:17:44 ayanowit 39 More changes necessary to eventually get support for 64-bit apps working (4222965). 40 41 Revision 1.1 2006/12/06 00:03:27 arulchan 42 Isoch Channel 31 Receiver 43 44*/ 45 46#ifndef __IOFWUSERASYNCSTREAMLISTENER_H__ 47#define __IOFWUSERASYNCSTREAMLISTENER_H__ 48 49// public 50#import <IOKit/firewire/IOFireWireFamilyCommon.h> 51#import <IOKit/firewire/IOFWAsyncStreamListener.h> 52 53// private 54#import "IOFireWireLibPriv.h" 55#import "IOFWUserPseudoAddressSpace.h" 56 57#if defined(__BIG_ENDIAN__) 58typedef struct { 59 UInt16 size; 60 UInt8 tag:2; 61 UInt8 chan:6; 62 UInt8 tcode:4; 63 UInt8 sy:4; 64} ISOC_DATA_PKT; 65#elif defined(__LITTLE_ENDIAN__) 66typedef struct { 67 UInt8 sy:4; 68 UInt8 tcode:4; 69 UInt8 chan:6; 70 UInt8 tag:2; 71 UInt16 size; 72} ISOC_DATA_PKT; 73#else 74#error host endian unknown 75#endif 76 77class IOFireWireUserClient ; 78 79class IOFWUserAsyncStreamListener: public IOFWAsyncStreamListener 80{ 81 OSDeclareDefaultStructors(IOFWUserAsyncStreamListener) 82 83public: 84 // --- OSObject ---------- 85#if IOFIREWIREUSERCLIENTDEBUG > 0 86 virtual bool serialize(OSSerialize *s) const; 87#endif 88 virtual void free() ; 89 90 static void exporterCleanup( OSObject * self, IOFWUserObjectExporter * exporter ); 91 92 bool completeInit( IOFireWireUserClient* userclient, FWUserAsyncStreamListenerCreateParams* params ) ; 93 94 void deactivate(); 95 96 bool initAsyncStreamListener( IOFireWireUserClient* userclient, FWUserAsyncStreamListenerCreateParams* params ) ; 97 98 void doPacket( 99 UInt32 len, 100 const void* buf, 101 IOFWPacketHeader::QueueTag tag, 102 UInt32* oldVal = NULL) ; 103 104 // --- getters ---------- 105 const mach_vm_address_t getUserRefCon() { return fUserRefCon ;} 106 107 const IOFireWireUserClient& getUserClient() { return *fUserClient ;} 108 109 // --- packet handler ---------- 110 static void asyncStreamListenerHandler( 111 void* refCon, 112 const void* buf) ; 113 114 // --- async utility functions ---------- 115 void setAsyncStreamRef_Packet( 116 OSAsyncReference64 inAsyncRef ) ; 117 void setAsyncStreamRef_SkippedPacket( 118 OSAsyncReference64 inAsyncRef ) ; 119 void clientCommandIsComplete( 120 FWClientCommandID inCommandID ) ; 121 void sendPacketNotification( 122 IOFWPacketHeader* inPacketHeader ) ; 123 124private: 125 IOMemoryDescriptor* fPacketQueueBuffer ; // the queue where incoming packets, etc., go 126 IOLock* fLock ; // to lock this object 127 128 mach_vm_address_t fUserRefCon ; 129 IOFireWireUserClient* fUserClient ; 130 IOFWPacketHeader* fLastWrittenHeader ; 131 IOFWPacketHeader* fLastReadHeader; 132 UInt32 fBufferAvailable ; // amount of queue space remaining 133 134 OSAsyncReference64 fSkippedPacketAsyncNotificationRef ; 135 OSAsyncReference64 fPacketAsyncNotificationRef ; 136 bool fWaitingForUserCompletion ; 137 bool fUserLocks ; // are we doing locks in user space? 138 139 UInt32 fFlags ; 140 141 Boolean fPacketQueuePrepared ; 142} ; 143 144#endif // __IOFWUSERASYNCSTREAMLISTENER_H__