#ifndef _APPLEMEDIABAY_H_
#define _APPLEMEDIABAY_H_
#include <IOKit/IOService.h>
#include <IOKit/IOWorkLoop.h>
#include <IOKit/IOCommandGate.h>
#include <IOKit/IOInterruptEventSource.h>
#include <IOKit/platform/AppleMacIODevice.h>
class AppleMediaBayATANub;
class AppleMediaBay : public IOService
{
OSDeclareDefaultStructors(AppleMediaBay)
private:
typedef enum {
kMBControllerUndefined = -1,
kMBControllerOHare = 0,
kMBControllerHeathrow = 1,
kMBControllerKeyLargo = 2
} ControllerType;
typedef enum {
mediaBayIDMask = 0x00700000,
mediaBayIDMask_KeyLargo = 0x70000000,
} MediaBayMask;
typedef enum {
deviceAutoFloppy = 0,
deviceManualFloppy = 1,
deviceSound = 2,
deviceATA = 3,
device4 = 4,
devicePCI = 5,
devicePower = 6,
deviceNone = 7
} MediaBayDeviceType;
typedef enum {
mbSoundOn = 0x08,
floppyOn = 0x04,
ATAOn = 0x02,
PCIOn = 0x01,
mbOff = 0
} PowerBit;
typedef enum {
registerNub = 1,
deRegisterNub = 2,
powerOn = 3,
powerOff = 4
};
ControllerType mbControllerType;
MediaBayDeviceType mbCurrentDevice;
MediaBayDeviceType mbPreviousDevice;
IOWorkLoop *workloop;
IOInterruptEventSource *intSource;
IOCommandGate *commandGate;
IOMemoryMap *configAddrMap;
volatile UInt32 *configAddr;
const OSSymbol *powerMediaBay;
AppleMediaBayATANub *ioClient;
IOService *myMacIO;
static void handleInterrupt(OSObject *owner, IOInterruptEventSource *src, int count);
static IOReturn commandGateCaller(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3r);
protected:
virtual MediaBayDeviceType readMBID(void);
virtual void dispatchInterrupt();
IOReturn dispatchMBCommand(int commandID, void *arg1, void *arg2, void *arg3r);
virtual void handleDeviceInsertion();
virtual void handleDeviceEjection();
virtual void setMediaBayDevicePower(bool powerUp, MediaBayDeviceType thisDevice);
virtual bool registerMBClient(AppleMediaBayATANub *registerMe);
virtual bool deRegisterMBClient(AppleMediaBayATANub *deRegisterMe);
public:
virtual bool init(OSDictionary *dictionary = 0);
virtual void free(void);
virtual bool start(IOService *provider);
virtual bool isFloppyOn(void);
virtual bool isATAOn(void);
virtual bool isPCIOn(void);
virtual bool isSoundOn(void);
virtual bool isPowerOn(void);
bool initForPM(IOService *provider);
IOReturn setPowerState(unsigned long powerStateOrdinal, IOService* whatDevice);
IOReturn registerMediaNub(AppleMacIODevice *registerMe);
IOReturn deRegisterMediaNub(AppleMacIODevice *deRegisterMe);
};
#endif _APPLEMEDIABAY_H_