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