#ifndef _IOKIT_ADBCONTROLLER_H
#define _IOKIT_ADBCONTROLLER_H
#include <IOKit/IOService.h>
#include <IOKit/adb/adb.h>
#include <IOKit/adb/IOADBBus.h>
extern "C" {
#include <kern/thread_call.h>
}
void autopollHandler ( IOService *, UInt8, IOByteCount, UInt8 * );
class IOADBDevice;
#define ADB_RET_OK 0
#define ADB_RET_INUSE 1
#define ADB_RET_NOTPRESENT 2
#define ADB_RET_TIMEOUT 3
#define ADB_RET_UNEXPECTED_RESULT 4
#define ADB_RET_REQUEST_ERROR 5
#define ADB_RET_BUS_ERROR 6
class IOPMrootDomain;
class IOADBController: public IOADBBus
{
OSDeclareAbstractStructors(IOADBController)
public:
bool start ( IOService * nub );
IOReturn setOwner ( void * device, IOService * client, ADB_callback_func handler );
virtual IOReturn claimDevice ( unsigned long, IOService *, ADB_callback_func );
virtual IOReturn releaseDevice ( unsigned long );
virtual IOReturn readDeviceForUser(unsigned long, unsigned long, UInt8 *, IOByteCount *);
virtual IOReturn writeDeviceForUser(unsigned long, unsigned long, UInt8 *, IOByteCount *);
virtual IOReturn setAutoPollPeriod (int microseconds) = 0;
virtual IOReturn getAutoPollPeriod (int * microseconds) = 0;
virtual IOReturn setAutoPollList(UInt16 activeAddressMask) = 0;
virtual IOReturn getAutoPollList(UInt16 * activeAddressMask) = 0;
virtual IOReturn setAutoPollEnable(bool enable) = 0;
virtual IOReturn resetBus(void) = 0;
virtual IOReturn cancelAllIO(void) = 0;
virtual IOReturn flushDevice(IOADBAddress address) = 0;
virtual IOReturn readFromDevice(IOADBAddress address, IOADBRegister adbRegister,
UInt8 * data, IOByteCount * length) = 0;
virtual IOReturn writeToDevice(IOADBAddress address, IOADBRegister adbRegister,
UInt8 * data, IOByteCount * length) = 0;
void packet ( UInt8 * data, IOByteCount length, UInt8 adbCommand );
IOReturn flush ( ADBDeviceControl * busRef );
IOReturn readRegister ( ADBDeviceControl * busRef, IOADBRegister adbRegister,
UInt8 * data, IOByteCount * length );
IOReturn writeRegister ( ADBDeviceControl * busRef, IOADBRegister adbRegister,
UInt8 * data, IOByteCount * length );
IOADBAddress address ( ADBDeviceControl * busRef );
IOADBAddress defaultAddress ( ADBDeviceControl * busRef );
UInt8 handlerID ( ADBDeviceControl * busRef );
UInt8 defaultHandlerID ( ADBDeviceControl * busRef );
IOReturn setHandlerID ( ADBDeviceControl * busRef, UInt8 handlerID );
bool matchNubWithPropertyTable( IOService * device, OSDictionary * propertyTable );
IOReturn newUserClient( task_t, void *, UInt32, IOUserClient ** );
IOReturn powerStateWillChangeTo ( IOPMPowerFlags, unsigned long, IOService*);
IOReturn powerStateDidChangeTo ( IOPMPowerFlags, unsigned long, IOService*);
IOReturn probeBus ( void );
IOReturn clearOwner ( void * );
IOPMrootDomain * rootDomain;
private:
bool claimed_devices[16];
bool probeAddress ( IOADBAddress addr );
bool moveDeviceFrom ( IOADBAddress from, IOADBAddress to, bool check );
unsigned int firstBit ( unsigned int mask );
int getURLComponentUnit ( IOService * device, char * path, int maxLen );
bool busProbed;
thread_call_t probeThread;
};
#endif