1/* 2 File: AppleSCSIEmulatorEventSource.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_EVENT_SOURCE_H__ 44#define __APPLE_SCSI_EMULATOR_EVENT_SOURCE_H__ 45 46 47//----------------------------------------------------------------------------- 48// Includes 49//----------------------------------------------------------------------------- 50 51#include <kern/queue.h> 52#include <IOKit/IOEventSource.h> 53#include <IOKit/scsi/spi/IOSCSIParallelInterfaceController.h> 54 55 56//----------------------------------------------------------------------------- 57// Structures 58//----------------------------------------------------------------------------- 59 60typedef struct SCSIEmulatorRequestBlock 61{ 62 queue_chain_t fQueueChain; 63 SCSIParallelTaskIdentifier fParallelRequest; 64 SCSITaskStatus fTaskStatus; 65 SCSIServiceResponse fServiceResponse; 66} SCSIEmulatorRequestBlock; 67 68 69//----------------------------------------------------------------------------- 70// Class Declaration 71//----------------------------------------------------------------------------- 72 73class AppleSCSIEmulatorEventSource : public IOEventSource 74{ 75 76 OSDeclareDefaultStructors ( AppleSCSIEmulatorEventSource ) 77 78public: 79 80 typedef void ( *Action ) ( OSObject * owner, SCSIParallelTaskIdentifier parallelTask ); 81 82 static AppleSCSIEmulatorEventSource * Create ( OSObject * owner, Action action ); 83 84 85 bool Init ( OSObject * owner, Action action ); 86 void AddItemToQueue ( SCSIEmulatorRequestBlock * srb ); 87 SCSIEmulatorRequestBlock * RemoveItemFromQueue ( void ); 88 89protected: 90 91 bool checkForWork ( void ); 92 93private: 94 95 IOSimpleLock * fLock; 96 queue_head_t fResponderQueue; 97 98}; 99 100 101#endif /* __APPLE_SCSI_EMULATOR_EVENT_SOURCE_H__ */ 102