#ifndef _AppleKiwiROOT_H
#define _AppleKiwiROOT_H
#include <IOKit/IOTypes.h>
#include <IOKit/IOService.h>
#include <IOKit/IOLocks.h>
#include <IOKit/IODeviceTreeSupport.h>
#include <IOKit/IOInterruptController.h>
#include <IOKit/IOFilterInterruptEventSource.h>
class AppleKiwiDevice;
class AppleKiwiIC;
class AppleKiwiRoot : public IOService
{
OSDeclareDefaultStructors(AppleKiwiRoot)
public:
virtual bool init(OSDictionary* properties);
virtual IOService* probe( IOService* provider, SInt32* score );
virtual bool start( IOService * provider );
virtual AppleKiwiDevice * createNub( IORegistryEntry * from );
virtual void processNub( AppleKiwiDevice * nub );
void publishBelow( IORegistryEntry * root );
virtual bool compareNubName( const IOService * nub, OSString * name,
OSString ** matched = 0 ) const;
virtual IOReturn getNubResources( IOService * nub );
virtual void getLock(bool lock); virtual IOReturn powerStateWillChangeTo (IOPMPowerFlags theFlags, unsigned long, IOService*);
virtual IOReturn powerStateDidChangeTo ( IOPMPowerFlags theFlags, unsigned long, IOService*);
virtual IOReturn setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice );
protected:
IOMemoryMap* baseZeroMap;
IOMemoryMap* baseOneMap;
IOMemoryMap* baseTwoMap;
IOMemoryMap* baseThreeMap;
IOMemoryMap* baseFourMap;
IOMemoryMap* baseFiveMap;
UInt8* baseAddrZero;
UInt8* baseAddrOne;
UInt8* baseAddrTwo;
UInt8* baseAddrThree;
UInt8* baseAddrFour;
UInt8* baseAddrFive;
AppleKiwiIC* kiwiInterruptController;
IORecursiveLock* kiwiChipLock;
IOPMrootDomain *pmRootDomain;
bool systemIsSleeping;
bool chiplockOnBus;
bool pdc271;
UInt16 masterpllF;
void setupPDC270(IOService* _pciNub);
UInt8 conf40Val;
virtual void free();
};
class AppleKiwiDevice : public IOService
{
OSDeclareDefaultStructors(AppleKiwiDevice);
public:
virtual bool init( IORegistryEntry * from,
const IORegistryPlane * inPlane );
virtual IOService *matchLocation(IOService *client);
virtual IOReturn getResources( void );
virtual void initProperties(void);
virtual bool deviceIsPresent(void);
virtual IOReturn powerStateWillChangeTo (IOPMPowerFlags theFlags, unsigned long, IOService*);
virtual IOReturn powerStateDidChangeTo ( IOPMPowerFlags theFlags, unsigned long, IOService*);
virtual IOReturn setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice );
protected:
enum {
kBayInitialState = 'Init', kBayEmpty = 'Emty', kBayDriveNotLocked = 'nLoc', kBayDriveLocked = 'Lock', kBayDrivePendRemoval = 'Rmvl', kLEDOff = 'Loff',
kLEDGreen = 'Lgrn',
kLEDOrange = 'Lorg',
kLEDRed = 'Lred',
kBayPowerOn = 'Bay+',
kBayPowerOff = 'Bay-',
kBusEnable = 'Bus+',
kBusDisable = 'Bus-',
kEventsOn = 'Evt+',
kEventsOff = 'Evt-',
kChildBusNone = 'none',
kChildBusStarting = 'strt',
kChildBusOnline = 'onli',
kChildBusFail = 'fail'
};
UInt32 bayPHandle;
UInt32 bayState;
UInt32 eventGate;
UInt32 childBusState;
UInt32 currPwrState; IOPMrootDomain *pmRootDomain;
bool systemIsSleeping;
virtual IOReturn message (UInt32 type, IOService* provider, void* argument = 0);
virtual void makeBayReady(UInt32 delayMS);
virtual void handleBayRemoved(void);
virtual void handleBayEvent(UInt32 event, UInt32 newData);
virtual void setLEDColor( UInt32 color);
virtual void setBayPower( UInt32 powerState );
virtual UInt32 getBayStatus( void );
virtual void enableBayEvents(void);
virtual void disableBayEvents(void);
static void sBayEventOccured( void* p1, void* p2, void* p3, void* p4);
};
class AppleKiwiIC : public IOInterruptController
{
OSDeclareDefaultStructors(AppleKiwiIC);
public:
virtual bool start(IOService *provider, UInt8* bar5);
virtual IOReturn getInterruptType(IOService *nub, int source,
int *interruptType);
virtual IOInterruptAction getInterruptHandlerAddress(void);
virtual IOReturn handleInterrupt( void *refCon,
IOService *nub,
int source );
virtual bool vectorCanBeShared(long vectorNumber, IOInterruptVector *vector);
virtual void initVector(long vectorNumber, IOInterruptVector *vector);
virtual void disableVectorHard(long vectorNumber, IOInterruptVector *vector);
virtual void enableVector(long vectorNumber, IOInterruptVector *vector);
virtual IOReturn setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice );
protected:
volatile UInt32* gcr0;
volatile UInt32* gcr1;
OSSymbol *interruptControllerName;
};
#endif // _AppleKiwiROOT_H