1/*
2  File: AppleSCSIPDT00Emulator.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#ifndef __APPLE_SCSI_PDT00_EMULATOR_H__
43#define __APPLE_SCSI_PDT00_EMULATOR_H__
44
45
46//-----------------------------------------------------------------------------
47//	Includes
48//-----------------------------------------------------------------------------
49
50#include <IOKit/IOMemoryDescriptor.h>
51#include <IOKit/IOBufferMemoryDescriptor.h>
52#include <IOKit/scsi/SCSITask.h>
53#include <IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h>
54#include <IOKit/scsi/SCSICmds_MODE_Definitions.h>
55#include <IOKit/scsi/SCSICmds_INQUIRY_Definitions.h>
56
57#include "AppleSCSILogicalUnitEmulator.h"
58
59
60//-----------------------------------------------------------------------------
61//	Constants
62//-----------------------------------------------------------------------------
63
64#define kTwentyMegabytes	(20 * 1024 * 1024)
65#define kBlockSize			512
66
67extern SCSICmd_INQUIRY_StandardData		gInquiryData;
68
69
70//-----------------------------------------------------------------------------
71//	Class declaration
72//-----------------------------------------------------------------------------
73
74class AppleSCSIPDT00Emulator : public AppleSCSILogicalUnitEmulator
75{
76
77	OSDeclareDefaultStructors ( AppleSCSIPDT00Emulator )
78
79public:
80
81	static AppleSCSIPDT00Emulator *
82	WithCapacity ( UInt64 capacity = kTwentyMegabytes );
83
84	bool	InitWithCapacity ( UInt64 capacity );
85
86	bool SetDeviceBuffers (
87		IOMemoryDescriptor * 	inquiryBuffer,
88		IOMemoryDescriptor * 	inquiryPage00Buffer,
89		IOMemoryDescriptor * 	inquiryPage80Buffer,
90		IOMemoryDescriptor * 	inquiryPage83Buffer );
91
92	void free ( void );
93
94	int SendCommand ( UInt8 *				cdb,
95					  UInt8					cbdLen,
96					  IOMemoryDescriptor * 	dataDesc,
97					  UInt64 *				dataLen,
98					  SCSITaskStatus * 		scsiStatus,
99					  SCSI_Sense_Data * 	senseBuffer,
100					  UInt8 *				senseBufferLen );
101
102private:
103
104	UInt64						fBufferSize;
105	IOBufferMemoryDescriptor *	fMemoryBuffer;
106	UInt8 *						fMemory;
107
108	UInt8 *						fInquiryData;
109	UInt32						fInquiryDataSize;
110
111	UInt8 *						fInquiryPage00Data;
112	UInt32						fInquiryPage00DataSize;
113
114	UInt8 *						fInquiryPage80Data;
115	UInt32						fInquiryPage80DataSize;
116
117	UInt8 *						fInquiryPage83Data;
118	UInt32						fInquiryPage83DataSize;
119
120};
121
122
123#endif	/* __APPLE_SCSI_PDT00_EMULATOR_H__ */