]> git.saurik.com Git - apple/xnu.git/blame - iokit/Families/IOADBBus/IOADBDevice.cpp
xnu-344.49.tar.gz
[apple/xnu.git] / iokit / Families / IOADBBus / IOADBDevice.cpp
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
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
13 * file.
14 *
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
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
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.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * 18 June 1998 sdouglas Start IOKit version.
27 * 17 Nov 1998 suurballe Port objc to c++
28 */
29
30#include <IOKit/adb/IOADBDevice.h>
31
32#define super IOService
33OSDefineMetaClassAndStructors(IOADBDevice,IOService)
34
35// **********************************************************************************
36// init
37//
38// **********************************************************************************
39bool IOADBDevice::init ( OSDictionary * regEntry, ADBDeviceControl * us )
40{
41if( !super::init(regEntry))
42 return false;
43
44fBusRef = us;
45return true;
46}
47
48
49// **********************************************************************************
50// attach
51//
52// **********************************************************************************
53bool IOADBDevice::attach ( IOADBBus * controller )
54{
55if( !super::attach(controller))
56 return false;
57
58bus = controller;
59return true;
60}
61
62// **********************************************************************************
63// matchPropertyTable
64//
65// **********************************************************************************
66
67bool IOADBDevice::matchPropertyTable( OSDictionary * table )
68{
69 return( bus->matchNubWithPropertyTable( this, table ));
70}
71
72// **********************************************************************************
73// seizeForClient
74//
75// **********************************************************************************
76bool IOADBDevice::seizeForClient ( IOService * client, ADB_callback_func handler )
77{
78bus->setOwner(fBusRef,client,handler);
79
80return true;
81}
82
83
84// **********************************************************************************
85// releaseFromClient
86//
87// **********************************************************************************
88void IOADBDevice::releaseFromClient ( IORegistryEntry * )
89{
90 kprintf("IOADBDevice::releaseFromClient\n");
91 bus->clearOwner(fBusRef);
92}
93
94
95// **********************************************************************************
96// flush
97//
98// **********************************************************************************
99IOReturn IOADBDevice::flush ( void )
100{
0b4e3aa0
A
101if ( isInactive() ) {
102 return kIOReturnNotOpen;
103}
1c79356b
A
104return( bus->flush(fBusRef) );
105}
106
107
108// **********************************************************************************
109// readRegister
110//
111// **********************************************************************************
112IOReturn IOADBDevice::readRegister ( IOADBRegister adbRegister, UInt8 * data,
113 IOByteCount * length )
114{
0b4e3aa0
A
115if ( isInactive() ) {
116 return kIOReturnNotOpen;
117}
1c79356b
A
118return( bus->readRegister(fBusRef,adbRegister,data,length) );
119}
120
121
122// **********************************************************************************
123// writeRegister
124//
125// **********************************************************************************
126IOReturn IOADBDevice::writeRegister ( IOADBRegister adbRegister, UInt8 * data,
127 IOByteCount * length )
128{
0b4e3aa0
A
129if ( isInactive() ) {
130 return kIOReturnNotOpen;
131}
1c79356b
A
132return( bus->writeRegister(fBusRef,adbRegister,data,length) );
133}
134
135
136// **********************************************************************************
137// address
138//
139// **********************************************************************************
140IOADBAddress IOADBDevice::address ( void )
141{
142return( bus->address(fBusRef) );
143}
144
145
146// **********************************************************************************
147// defaultAddress
148//
149// **********************************************************************************
150IOADBAddress IOADBDevice::defaultAddress ( void )
151{
152return( bus->defaultAddress(fBusRef) );
153}
154
155
156// **********************************************************************************
157// handlerID
158//
159// **********************************************************************************
160UInt8 IOADBDevice::handlerID ( void )
161{
162return( bus->handlerID(fBusRef) );
163}
164
165
166// **********************************************************************************
167// defaultHandlerID
168//
169// **********************************************************************************
170UInt8 IOADBDevice::defaultHandlerID ( void )
171{
172return( bus->defaultHandlerID(fBusRef) );
173}
174
175
176// **********************************************************************************
177// setHandlerID
178//
179// **********************************************************************************
180IOReturn IOADBDevice::setHandlerID ( UInt8 handlerID )
181{
182return( bus->setHandlerID(fBusRef,handlerID) );
183}
184
185
186// **********************************************************************************
187// busRef
188//
189// **********************************************************************************
190void * IOADBDevice::busRef ( void )
191{
192return fBusRef;
193}