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_IOFIREWIRESBP2LIBLUN_H_
24#define _IOKIT_IOFIREWIRESBP2LIBLUN_H_
25
26#include <IOKit/IOCFPlugIn.h>
27
28#include <IOKit/sbp2/IOFireWireSBP2Lib.h>
29
30__BEGIN_DECLS
31void *IOFireWireSBP2LibFactory( CFAllocatorRef allocator, CFUUIDRef typeID );
32__END_DECLS
33
34class IOFireWireSBP2LibLUN
35{
36
37public:
38
39	struct InterfaceMap
40	{
41        IUnknownVTbl *pseudoVTable;
42        IOFireWireSBP2LibLUN *obj;
43    };
44
45	IOFireWireSBP2LibLUN( void );
46	virtual ~IOFireWireSBP2LibLUN();
47
48protected:
49
50	//////////////////////////////////////
51	// cf plugin interfaces
52
53	static IOCFPlugInInterface 				sIOCFPlugInInterface;
54	InterfaceMap 			   				fIOCFPlugInInterface;
55	static IOFireWireSBP2LibLUNInterface	sIOFireWireSBP2LibLUNInterface;
56	InterfaceMap							fIOFireWireSBP2LibLUNInterface;
57
58	//////////////////////////////////////
59	// cf plugin ref counting
60
61	CFUUIDRef 	fFactoryId;
62	UInt32 		fRefCount;
63
64	//////////////////////////////////////
65	// user client connection
66
67	io_service_t 	fService;
68	io_connect_t 	fConnection;
69
70	//////////////////////////////////////
71	// async callbacks
72
73	mach_port_t 			fAsyncPort;
74	CFMachPortRef			fCFAsyncPort;
75	CFRunLoopRef			fCFRunLoop;
76	CFRunLoopSourceRef		fCFRunLoopSource;
77	IOFWSBP2MessageCallback	fMessageCallbackRoutine;
78	void *					fMessageCallbackRefCon;
79	IUnknownVTbl **			fLoginInterface;
80
81	void *			fRefCon;
82
83	// utility function to get "this" pointer from interface
84	static inline IOFireWireSBP2LibLUN *getThis( void *self )
85        { return (IOFireWireSBP2LibLUN *) ((InterfaceMap *) self)->obj; };
86
87	//////////////////////////////////////
88	// IUnknown static methods
89
90	static HRESULT staticQueryInterface( void * self, REFIID iid, void **ppv );
91	virtual HRESULT queryInterface( REFIID iid, void **ppv );
92
93	static UInt32 staticAddRef( void * self );
94	virtual UInt32 addRef( void );
95
96	static UInt32 staticRelease( void * self );
97	virtual UInt32 release( void );
98
99	//////////////////////////////////////
100	// CFPlugin static methods
101
102	static IOReturn staticProbe( void * self, CFDictionaryRef propertyTable,
103								 io_service_t service, SInt32 *order );
104	virtual IOReturn probe( CFDictionaryRef propertyTable, io_service_t service, SInt32 *order );
105
106    static IOReturn staticStart( void * self, CFDictionaryRef propertyTable,
107								 io_service_t service );
108    virtual IOReturn start( CFDictionaryRef propertyTable, io_service_t service );
109
110	static IOReturn staticStop( void * self );
111	virtual IOReturn stop( void );
112
113	//////////////////////////////////////
114	// IOFireWireSBP2LUN static methods
115
116	static IOReturn staticOpen( void * self );
117	virtual IOReturn open( void );
118
119	static IOReturn staticOpenWithSessionRef( void * self, IOFireWireSessionRef sessionRef );
120	virtual IOReturn openWithSessionRef( IOFireWireSessionRef sessionRef );
121
122	static IOFireWireSessionRef staticGetSessionRef(void * self);
123	virtual IOFireWireSessionRef getSessionRef( void );
124
125	static void staticClose( void * self );
126	virtual void close( void );
127
128	static IOReturn staticAddIODispatcherToRunLoop( void *self, CFRunLoopRef cfRunLoopRef );
129	virtual IOReturn addIODispatcherToRunLoop( CFRunLoopRef cfRunLoopRef );
130
131	static void staticRemoveIODispatcherFromRunLoop( void * self );
132	virtual void removeIODispatcherFromRunLoop( void );
133
134	static void staticSetMessageCallback( void * self, void * refCon,
135												IOFWSBP2MessageCallback callback );
136	virtual void setMessageCallback( void * refCon, IOFWSBP2MessageCallback callback );
137
138	static IUnknownVTbl ** staticCreateLogin( void * self, REFIID iid );
139	virtual IUnknownVTbl ** createLogin( REFIID iid );
140
141	static void staticSetRefCon( void * self, void * refCon );
142	virtual void setRefCon( void * refCon );
143
144	static void * staticGetRefCon( void * self );
145	virtual void * getRefCon( void );
146
147	static IUnknownVTbl ** staticCreateMgmtORB( void * self, REFIID iid );
148	virtual IUnknownVTbl ** createMgmtORB( REFIID iid );
149
150	//////////////////////////////////////
151	// callback static methods
152
153	static void staticMessageCallback( void *refcon, IOReturn result,
154													io_user_reference_t *args, int numArgs );
155	virtual void messageCallback( IOReturn result, io_user_reference_t *args, int numArgs );
156
157public:
158
159	static IOCFPlugInInterface **alloc( void );
160
161};
162
163#endif