2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * 18 June 1998 sdouglas Start IOKit version.
24 * 12 Nov 1998 suurballe Port objc protocol to c++ abstract class.
26 #ifndef _IOKIT_ADBCONTROLLER_H
27 #define _IOKIT_ADBCONTROLLER_H
29 #include <IOKit/IOService.h>
30 #include <IOKit/adb/adb.h>
31 #include <IOKit/adb/IOADBBus.h>
34 #include <kern/thread_call.h>
37 // referenced in subclasses:
38 void autopollHandler ( IOService
*, UInt8
, IOByteCount
, UInt8
* );
46 #define ADB_RET_OK 0 /* Successful */
47 #define ADB_RET_INUSE 1 /* ADB Device in use */
48 #define ADB_RET_NOTPRESENT 2 /* ADB Device not present */
49 #define ADB_RET_TIMEOUT 3 /* ADB Timeout */
50 #define ADB_RET_UNEXPECTED_RESULT 4 /* Unknown result */
51 #define ADB_RET_REQUEST_ERROR 5 /* Packet Request Error */
52 #define ADB_RET_BUS_ERROR 6 /* ADB Bus Error */
56 class IOADBController
: public IOADBBus
58 OSDeclareAbstractStructors(IOADBController
)
62 bool start ( IOService
* nub
);
63 IOReturn
setOwner ( void * device
, IOService
* client
, ADB_callback_func handler
);
64 virtual IOReturn
claimDevice ( unsigned long, IOService
*, ADB_callback_func
);
65 virtual IOReturn
releaseDevice ( unsigned long );
66 virtual IOReturn
readDeviceForUser(unsigned long, unsigned long, UInt8
*, IOByteCount
*);
67 virtual IOReturn
writeDeviceForUser(unsigned long, unsigned long, UInt8
*, IOByteCount
*);
68 virtual IOReturn
setAutoPollPeriod (int microseconds
) = 0;
69 virtual IOReturn
getAutoPollPeriod (int * microseconds
) = 0;
70 virtual IOReturn
setAutoPollList(UInt16 activeAddressMask
) = 0;
71 virtual IOReturn
getAutoPollList(UInt16
* activeAddressMask
) = 0;
72 virtual IOReturn
setAutoPollEnable(bool enable
) = 0;
73 virtual IOReturn
resetBus(void) = 0;
74 virtual IOReturn
cancelAllIO(void) = 0;
75 virtual IOReturn
flushDevice(IOADBAddress address
) = 0;
76 virtual IOReturn
readFromDevice(IOADBAddress address
, IOADBRegister adbRegister
,
77 UInt8
* data
, IOByteCount
* length
) = 0;
78 virtual IOReturn
writeToDevice(IOADBAddress address
, IOADBRegister adbRegister
,
79 UInt8
* data
, IOByteCount
* length
) = 0;
80 void packet ( UInt8
* data
, IOByteCount length
, UInt8 adbCommand
);
82 IOReturn
flush ( ADBDeviceControl
* busRef
);
83 IOReturn
readRegister ( ADBDeviceControl
* busRef
, IOADBRegister adbRegister
,
84 UInt8
* data
, IOByteCount
* length
);
85 IOReturn
writeRegister ( ADBDeviceControl
* busRef
, IOADBRegister adbRegister
,
86 UInt8
* data
, IOByteCount
* length
);
87 IOADBAddress
address ( ADBDeviceControl
* busRef
);
88 IOADBAddress
defaultAddress ( ADBDeviceControl
* busRef
);
89 UInt8
handlerID ( ADBDeviceControl
* busRef
);
90 UInt8
defaultHandlerID ( ADBDeviceControl
* busRef
);
91 IOReturn
setHandlerID ( ADBDeviceControl
* busRef
, UInt8 handlerID
);
92 bool matchNubWithPropertyTable( IOService
* device
, OSDictionary
* propertyTable
);
93 IOReturn
newUserClient( task_t
, void *, UInt32
, IOUserClient
** );
94 IOReturn
powerStateWillChangeTo ( IOPMPowerFlags
, unsigned long, IOService
*);
95 IOReturn
powerStateDidChangeTo ( IOPMPowerFlags
, unsigned long, IOService
*);
96 IOReturn
probeBus ( void );
98 IOReturn
clearOwner ( void * );
100 IOPMrootDomain
* rootDomain
;
104 bool claimed_devices
[16]; // true if a device has been claimed by user
106 bool probeAddress ( IOADBAddress addr
);
107 bool moveDeviceFrom ( IOADBAddress from
, IOADBAddress to
, bool check
);
108 unsigned int firstBit ( unsigned int mask
);
109 int getURLComponentUnit ( IOService
* device
, char * path
, int maxLen
);
111 thread_call_t probeThread
;
114 #endif /* ! _IOKIT_ADBCONTROLLER_H */