#ifndef _IOKIT_HEATHROW_H
#define _IOKIT_HEATHROW_H
#include <IOKit/platform/AppleMacIO.h>
#include <IOKit/IOInterrupts.h>
#include <IOKit/IOInterruptController.h>
#define kPrimaryHeathrow (0)
#define kSecondaryHeathrow (1)
#define kNumVectors (64)
#define kVectorsPerReg (32)
#define kTypeLevelMask (0x1FF00000)
#define kEvents1Offset (0x00020)
#define kEvents2Offset (0x00010)
#define kMask1Offset (0x00024)
#define kMask2Offset (0x00014)
#define kClear1Offset (0x00028)
#define kClear2Offset (0x00018)
#define kLevels1Offset (0x0002C)
#define kLevels2Offset (0x0001C)
#define kChassisLightColor (0x00032)
class HeathrowInterruptController;
class Heathrow : public AppleMacIO
{
OSDeclareDefaultStructors(Heathrow);
private:
enum {
heathrowFCTrans = 1 << 24, heathrowFCMBPwr = 1 << 25, heathrowFCPCIMBEn = 1 << 26, heathrowFCATAMBEn = 1 << 27, heathrowFCFloppyEn = 1 << 28, heathrowFCATAINTEn = 1 << 29, heathrowFCATA0Reset = 1 << 30, heathrowFCMBReset = 1 << 31, heathrowFCIOBusEn = 1 << 16, heathrowFCSCCCEn = 1 << 17, heathrowFCSCSICEn = 1 << 18, heathrowFCSWIMCEn = 1 << 19, heathrowFCSndPwr = 1 << 20, heathrowFCSndClkEn = 1 << 21, heathrowFCSCCAEn = 1 << 22, heathrowFCSCCBEn = 1 << 23, heathrowFCVIAPort = 1 << 8, heathrowFCPWM = 1 << 9, heathrowFCHookPB = 1 << 10, heathrowFCSWIM3 = 1 << 11, heathrowFCAud22 = 1 << 12, heathrowFCSCSILink = 1 << 13, heathrowFCArbByPass = 1 << 14, heathrowFCATA1Reset = 1 << 15, heathrowFCSCCPClk = 1 << 0, heathrowFCResetSCC = 1 << 1,
heathrowFCMediaBaybits = heathrowFCPCIMBEn | heathrowFCATAMBEn | heathrowFCFloppyEn,
heathrowFCMBlogical = heathrowFCMBPwr | heathrowFCMBReset };
enum
{
vBufB = 0, vBufAH = 0x200, vDIRB = 0x400, vDIRA = 0x600, vT1C = 0x800, vT1CH = 0xA00, vT1L = 0xC00, vT1LH = 0xE00, vT2C = 0x1000, vT2CH = 0x1200, vSR = 0x1400, vACR = 0x1600, vPCR = 0x1800, vIFR = 0x1A00, vIER = 0x1C00, vBufA = 0x1E00, vBufD = vBufA };
enum
{
heathrowIDOffset = 0x00000034,
heathrowFCROffset = 0x00000038,
heathrowAUXFCROffset = 0x0000003C,
heathrowVIAOffset = 0x00016000
};
struct DBDMAChannelRegisters {
UInt32 commandPtrLo;
UInt32 interruptSelect;
UInt32 branchSelect;
UInt32 waitSelect;
};
typedef struct DBDMAChannelRegisters DBDMAChannelRegisters;
typedef volatile DBDMAChannelRegisters *DBDMAChannelRegistersPtr;
struct HeathrowState {
bool thisStateIsValid;
UInt32 interruptMask1;
UInt32 interruptMask2;
UInt32 featureControlReg;
UInt32 auxControlReg;
DBDMAChannelRegisters savedDBDMAState[13];
UInt8 savedVIAState[9];
};
typedef struct HeathrowState HeathrowState;
HeathrowState savedState;
bool mediaIsOn;
private:
IOLogicalAddress heathrowBaseAddress;
long heathrowNum;
HeathrowInterruptController *interruptController;
virtual bool installInterrupts(IOService *provider);
virtual OSSymbol *getInterruptControllerName(void);
virtual void processNub(IOService *nub);
virtual void enableMBATA();
virtual void powerMediaBay(bool powerOn, UInt8 whichDevice);
void EnableSCC(bool state);
void PowerModem(bool state);
void ModemResetLow();
void ModemResetHigh();
const OSSymbol *heathrow_enableSCC;
const OSSymbol *heathrow_powerModem;
const OSSymbol *heathrow_modemResetLow;
const OSSymbol *heathrow_modemResetHigh;
const OSSymbol *heathrow_sleepState;
const OSSymbol *heathrow_powerMediaBay;
const OSSymbol *heathrow_set_light;
const OSSymbol *heathrow_writeRegUInt8;
const OSSymbol *heathrow_safeWriteRegUInt8;
const OSSymbol *heathrow_safeReadRegUInt8;
const OSSymbol *heathrow_safeWriteRegUInt32;
const OSSymbol *heathrow_safeReadRegUInt32;
IOSimpleLock *mutex;
public:
virtual bool start(IOService *provider);
virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
bool waitForFunction,
void *param1, void *param2,
void *param3, void *param4);
void initForPM (IOService *provider);
IOReturn setPowerState(unsigned long powerStateOrdinal, IOService* whatDevice);
void setSCSIActiveTermState(bool EnableTermPower);
virtual void sleepState(bool sleepMe);
virtual void saveVIAState(void);
virtual void restoreVIAState(void);
virtual void saveDMAState(void);
virtual void restoreDMAState(void);
virtual void saveGPState(void);
virtual void restoreGPState(void);
virtual void saveInterruptState(void);
virtual void restoreInterruptState(void);
virtual void setChassisLightFullpower(bool fullpwr);
virtual UInt8 readRegUInt8(unsigned long offset);
virtual void writeRegUInt8(unsigned long offset, UInt8 data);
virtual UInt32 readRegUInt32(unsigned long offset);
virtual void writeRegUInt32(unsigned long offset, UInt32 data);
void safeWriteRegUInt8(unsigned long offset, UInt8 mask, UInt8 data);
UInt8 safeReadRegUInt8(unsigned long offset);
void safeWriteRegUInt32(unsigned long offset, UInt32 mask, UInt32 data);
UInt32 safeReadRegUInt32(unsigned long offset);
};
class HeathrowInterruptController : public IOInterruptController
{
OSDeclareDefaultStructors(HeathrowInterruptController);
private:
IOService *parentNub;
IOLock *taskLock;
IOLogicalAddress interruptControllerBase;
unsigned long pendingEvents1;
unsigned long pendingEvents2;
unsigned long events1Reg;
unsigned long events2Reg;
unsigned long mask1Reg;
unsigned long mask2Reg;
unsigned long clear1Reg;
unsigned long clear2Reg;
unsigned long levels1Reg;
unsigned long levels2Reg;
void privDisableVectorHard(long vectorNumber, IOInterruptVector *vector);
void privEnableVector(long vectorNumber, IOInterruptVector *vector);
void privCauseVector(long vectorNumber, IOInterruptVector *vector);
public:
virtual IOReturn initInterruptController(IOService *provider,
IOLogicalAddress iBase);
virtual void clearAllInterrupts(void);
virtual IOInterruptAction getInterruptHandlerAddress(void);
virtual IOReturn handleInterrupt(void *refCon, IOService *nub, int source);
virtual bool vectorCanBeShared(long vectorNumber, IOInterruptVector *vector);
virtual int getVectorType(long vectorNumber, IOInterruptVector *vector);
virtual void disableVectorHard(long vectorNumber, IOInterruptVector *vector);
virtual void enableVector(long vectorNumber, IOInterruptVector *vector);
virtual void causeVector(long vectorNumber, IOInterruptVector *vector);
};
#endif