1/*
2  File: AppleSCSIEmulatorAdapterUC.h
3
4  Contains:
5
6  Version: 1.0.0
7
8  Copyright: Copyright (c) 2007 by Apple Inc., All Rights Reserved.
9
10Disclaimer:IMPORTANT:  This Apple software is supplied to you by Apple Inc.
11("Apple") in consideration of your agreement to the following terms, and your use,
12installation, modification or redistribution of this Apple software constitutes acceptance
13of these terms.  If you do not agree with these terms, please do not use, install, modify or
14redistribute this Apple software.
15
16In consideration of your agreement to abide by the following terms, and subject
17to these terms, Apple grants you a personal, non-exclusive license, under Apple's
18copyrights in this original Apple software (the "Apple Software"), to use, reproduce,
19modify and redistribute the Apple Software, with or without modifications, in source and/or
20binary forms; provided that if you redistribute the Apple Software in its entirety
21and without modifications, you must retain this notice and the following text
22and disclaimers in all such redistributions of the Apple Software.  Neither the
23name, trademarks, service marks or logos of Apple Inc. may be used to
24endorse or promote products derived from the Apple Software without specific prior
25written permission from Apple.  Except as expressly stated in this notice, no
26other rights or licenses, express or implied, are granted by Apple herein,
27including but not limited to any patent rights that may be infringed by your derivative
28works or by other works in which the Apple Software may be incorporated.
29
30The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO WARRANTIES,
31EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
32MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE
33OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE
34BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
35NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
36OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
37REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
38AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT
39LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40*/
41
42
43#ifndef __APPLE_SCSI_EMULATOR_ADAPTER_UC_H__
44#define __APPLE_SCSI_EMULATOR_ADAPTER_UC_H__
45
46
47//-----------------------------------------------------------------------------
48//	Includes
49//-----------------------------------------------------------------------------
50
51// SCSI Architecture Model Family includes
52#include <IOKit/scsi/SCSITask.h>
53#include <mach/vm_types.h>
54
55
56//-----------------------------------------------------------------------------
57//	Constants
58//-----------------------------------------------------------------------------
59
60#define kSCSIEmulatorAdapterUserClientAccessMask	0x1000
61#define kSCSIEmulatorAdapterUserClientConnection	15
62#define kInitiatorID								15
63
64enum
65{
66	kUserClientCreateLUN		= 0,
67	kUserClientDestroyLUN		= 1,
68	kUserClientDestroyTarget	= 2,
69	kUserClientMethodCount
70};
71
72
73//-----------------------------------------------------------------------------
74//	Structures
75//-----------------------------------------------------------------------------
76
77#pragma pack(1)
78typedef struct EmulatorLUNParamsStruct
79{
80	SCSILogicalUnitNumber	logicalUnit;
81	UInt64					capacity;
82	mach_vm_address_t		inquiryData;
83	UInt32					inquiryDataLength;
84	mach_vm_address_t		inquiryPage00Data;
85	UInt32					inquiryPage00DataLength;
86	mach_vm_address_t		inquiryPage80Data;
87	UInt32					inquiryPage80DataLength;
88	mach_vm_address_t		inquiryPage83Data;
89	UInt32					inquiryPage83DataLength;
90} EmulatorLUNParamsStruct;
91
92typedef struct EmulatorTargetParamsStruct
93{
94	SCSITargetIdentifier	targetID;
95	EmulatorLUNParamsStruct	lun;
96} EmulatorTargetParamsStruct;
97
98#pragma options align=reset
99
100
101#if defined(KERNEL) && defined(__cplusplus)
102
103//-----------------------------------------------------------------------------
104//	Includes
105//-----------------------------------------------------------------------------
106
107#include <IOKit/IOCommandGate.h>
108#include <IOKit/IOService.h>
109#include <IOKit/IOUserClient.h>
110#include <IOKit/IOWorkLoop.h>
111
112
113//-----------------------------------------------------------------------------
114//	Class Declaration
115//-----------------------------------------------------------------------------
116
117class AppleSCSIEmulatorAdapterUserClient : public IOUserClient
118{
119
120	OSDeclareDefaultStructors ( AppleSCSIEmulatorAdapterUserClient )
121
122protected:
123
124	bool 	initWithTask 		( task_t 			owningTask,
125								  void *			securityToken,
126								  UInt32			type,
127								  OSDictionary *	properties );
128
129    bool 		start 			( IOService * provider );
130
131	void		free			( void );
132
133	IOReturn	clientClose		( void );
134
135	bool		finalize		( IOOptionBits options );
136
137	IOReturn	externalMethod (
138					uint32_t						selector,
139					IOExternalMethodArguments * 	args,
140					IOExternalMethodDispatch * 		dispatch,
141					OSObject *						target,
142					void *							reference );
143
144private:
145
146	task_t					fTask;
147	IOService *				fProvider;
148	IOCommandGate *			fCommandGate;
149	IOWorkLoop *			fWorkLoop;
150
151};
152
153
154#endif	/* #if defined(KERNEL) && defined(__cplusplus) */
155
156#endif	/* __APPLE_SCSI_EMULATOR_ADAPTER_UC_H__ */