]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/adb/IOADBController.h
xnu-124.7.tar.gz
[apple/xnu.git] / iokit / IOKit / adb / IOADBController.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * 18 June 1998 sdouglas Start IOKit version.
24 * 12 Nov 1998 suurballe Port objc protocol to c++ abstract class.
25 */
26#ifndef _IOKIT_ADBCONTROLLER_H
27#define _IOKIT_ADBCONTROLLER_H
28
29#include <IOKit/IOService.h>
30#include <IOKit/adb/adb.h>
31#include <IOKit/adb/IOADBBus.h>
32
33extern "C" {
34#include <kern/thread_call.h>
35}
36
37// referenced in subclasses:
38void autopollHandler ( IOService *, UInt8, IOByteCount, UInt8 * );
39
40class IOADBDevice;
41
42/*
43 * Results
44 */
45
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 */
53
54class IOPMrootDomain;
55
56class IOADBController: public IOADBBus
57{
58OSDeclareAbstractStructors(IOADBController)
59
60public:
61
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 flushDevice(IOADBAddress address) = 0;
75 virtual IOReturn readFromDevice(IOADBAddress address, IOADBRegister adbRegister,
76 UInt8 * data, IOByteCount * length) = 0;
77 virtual IOReturn writeToDevice(IOADBAddress address, IOADBRegister adbRegister,
78 UInt8 * data, IOByteCount * length) = 0;
79 void packet ( UInt8 * data, IOByteCount length, UInt8 adbCommand );
80
81 IOReturn flush ( ADBDeviceControl * busRef );
82 IOReturn readRegister ( ADBDeviceControl * busRef, IOADBRegister adbRegister,
83 UInt8 * data, IOByteCount * length );
84 IOReturn writeRegister ( ADBDeviceControl * busRef, IOADBRegister adbRegister,
85 UInt8 * data, IOByteCount * length );
86 IOADBAddress address ( ADBDeviceControl * busRef );
87 IOADBAddress defaultAddress ( ADBDeviceControl * busRef );
88 UInt8 handlerID ( ADBDeviceControl * busRef );
89 UInt8 defaultHandlerID ( ADBDeviceControl * busRef );
90 IOReturn setHandlerID ( ADBDeviceControl * busRef, UInt8 handlerID );
91 bool matchNubWithPropertyTable( IOService * device, OSDictionary * propertyTable );
92 IOReturn newUserClient( task_t, void *, UInt32, IOUserClient ** );
93 IOReturn powerStateWillChangeTo ( IOPMPowerFlags, unsigned long, IOService*);
94 IOReturn powerStateDidChangeTo ( IOPMPowerFlags, unsigned long, IOService*);
95 IOReturn probeBus ( void );
96
97IOReturn clearOwner ( void * );
98
99IOPMrootDomain * rootDomain;
100
101private:
102
103 bool claimed_devices[16]; // true if a device has been claimed by user
104
105 bool probeAddress ( IOADBAddress addr );
106 bool moveDeviceFrom ( IOADBAddress from, IOADBAddress to, bool check );
107 unsigned int firstBit ( unsigned int mask );
108 int getURLComponentUnit ( IOService * device, char * path, int maxLen );
109 bool busProbed;
110 thread_call_t probeThread;
111};
112
113#endif /* ! _IOKIT_ADBCONTROLLER_H */