Chameleon

Chameleon Svn Source Tree

Root/branches/rewrite/i386/include/IOKit/firewire/IOFWAddressSpace.h

Source at commit 1146 created 12 years 11 months ago.
By azimutz, Sync with trunk (r1145). Add nVidia dev id's, 0DF4 for "GeForce GT 450M" (issue 99) and 1251 for "GeForce GTX 560M" (thanks to oSxFr33k for testing).
1/*
2 * Copyright (c) 1998-2002 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/*
24 *
25 *IOFWAddressSpace.h
26 *
27 * Classes which describe addresses in the local node which are accessable to other nodes
28 * via firewire asynchronous read/write/lock requests.
29 */
30
31#ifndef _IOKIT_IOFWADDRESSSPACE_H
32#define _IOKIT_IOFWADDRESSSPACE_H
33
34#include <IOKit/IOMemoryDescriptor.h>
35#include <IOKit/firewire/IOFireWireFamilyCommon.h>
36
37class IOFireWireDevice;
38class IOFireWireBus;
39class IOFireWireController;
40
41typedef void * IOFWRequestRefCon;
42
43/*!@functionFWWriteCallback
44@abstractCallback called when a write request packet is received for
45a 'virtual' firewire address.
46@paramdeviceis the node originating the request
47@paramspeedis the FireWire speed of the request, update it if you need to control
48the speed of the reply, otherwise the response will be the same speed.
49@paramaddris the address the device is requesting to write to
50@paramlenis the number of bytes to write
51@parambufcontains the packet data
52@paramrequestRefconrefcon Can be queried for extra info about the request,
53using IOFireWireController::isLockRequest(), isQuadRequest()
54@resultreturn:
55kFWResponseComplete= 0,OK
56kFWResponseConflictError= 4,Resource conflict, may retry
57kFWResponseDataError= 5,Data not available
58kFWResponseTypeError= 6,Operation not supported
59kFWResponseAddressError= 7Address not valid in target device */
60typedef UInt32 (*FWWriteCallback)(void *refcon, UInt16 nodeID, IOFWSpeed &speed,
61 FWAddress addr, UInt32 len, const void *buf, IOFWRequestRefCon requestRefcon);
62
63/*!@functionFWReadCallback
64@abstractCallback called when a read request packet is received for
65a 'virtual' firewire address.
66@param nodeID is the node originating the request
67@paramspeed is the FireWire speed of the request, update it if you need to control
68the speed of the reply, otherwise the response will be the same speed.
69@paramaddr is the address the device is requesting to read from
70@paramlen is the number of bytes to read
71@parambuf contains the packet data
72@paramoffset on return points to the offset into *buf of the packet data
73@paramrequestRefcon refcon to pass back if sending a delayed response. Also can be queried
74for extra info about the request
75@resultreturn:
76 kFWResponsePending= -1,Pseudo response, real response sent later.
77kFWResponseComplete= 0,OK!
78kFWResponseConflictError= 4,Resource conflict, may retry
79kFWResponseDataError= 5,Data not available
80kFWResponseTypeError= 6,Operation not supported
81kFWResponseAddressError= 7Address not valid in target device
82
83A return of kFWResponsePending should be followed at some later time by a call to
84IOFireWireController::asyncReadResponse*/
85typedef UInt32 (*FWReadCallback)(void *refcon, UInt16 nodeID, IOFWSpeed &speed,
86 FWAddress addr, UInt32 len, IOMemoryDescriptor **buf,
87 IOByteCount * offset, IOFWRequestRefCon requestRefcon);
88
89class IOFWAddressSpace;
90
91#pragma mark -
92
93/*! @class IOFWAddressSpaceAux
94@discussion An IOFWAddressSpaceAux is for internal use only. You should never subclass IOFWAddressSpaceAux
95*/
96
97class IOFWAddressSpaceAux : public OSObject
98{
99 OSDeclareDefaultStructors(IOFWAddressSpaceAux)
100
101friend class IOFWAddressSpace;
102
103protected:
104
105IOFWAddressSpace * fPrimary;
106IOFireWireController *fControl;
107
108OSSet *fTrustedNodeSet;
109 OSIterator *fTrustedNodeSetIterator;
110
111boolfExclusive;
112
113/*!
114@struct ExpansionData
115@discussion This structure will be used to expand the capablilties of the class in the future.
116 */
117
118 struct ExpansionData { };
119
120/*!
121@var reserved
122Reserved for future use. (Internal use only)
123*/
124
125ExpansionData * reserved;
126
127 virtual bool init( IOFWAddressSpace * primary );
128virtualvoid free();
129
130virtual bool isTrustedNode( UInt16 nodeID );
131virtual void addTrustedNode( IOFireWireDevice * device );
132virtual void removeTrustedNode( IOFireWireDevice * device );
133virtual void removeAllTrustedNodes( void );
134
135bool isExclusive( void );
136void setExclusive( bool exclusive );
137
138virtual bool intersects( IOFWAddressSpace * space );
139
140private:
141 OSMetaClassDeclareReservedUsed(IOFWAddressSpaceAux, 0);
142 OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 1);
143 OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 2);
144 OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 3);
145 OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 4);
146 OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 5);
147 OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 6);
148 OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 7);
149 OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 8);
150 OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 9);
151
152};
153
154#pragma mark -
155
156/*
157 * Base class for FireWire address space objects
158 */
159
160/*!
161@class IOFWAddressSpace
162*/
163
164class IOFWAddressSpace : public OSObject
165{
166 OSDeclareAbstractStructors(IOFWAddressSpace)
167
168friend class IOFWAddressSpaceAux;
169
170protected:
171
172IOFireWireController *fControl;
173
174/*!
175@struct ExpansionData
176@discussion This structure will be used to expand the capablilties of the class in the future.
177 */
178
179 struct ExpansionData
180{
181IOFWAddressSpaceAux * fAuxiliary;
182};
183
184/*!
185@var reserved
186Reserved for future use. (Internal use only)
187*/
188
189 ExpansionData * fIOFWAddressSpaceExpansion;
190
191 virtual bool init(IOFireWireBus *bus);
192virtualvoid free();
193
194public:
195
196/*!@functiondoRead
197@abstractAn abstract method for processing an address space read request
198@paramnodeIDFireWire Read from nodeID.
199@paramspeedat this 'speed'.
200@paramaddrwith FireWire address 'addr'.
201@paramlenread 'len' bytes from nodeID.
202@parambufpoints to a memory descriptor containing the packet data.
203@paramoffsetstart from this 'offset' in 'buf'.
204@paramrefcon Can be queried for extra info about the request.
205@resultUIn32returns kFWResponseComplete on success */
206virtual UInt32 doRead(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len,
207IOMemoryDescriptor **buf, IOByteCount * offset,
208 IOFWRequestRefCon refcon) = 0;
209
210/*!@functiondoWrite
211@abstractAn abstract method for processing an address space write request
212@paramnodeIDFireWire Write to nodeID.
213@paramspeedat this 'speed'.
214@paramaddrwith FireWire address 'addr'.
215@paramlenwrite 'len' bytes to nodeID.
216@parambufobtain bytes from location given by 'buf'.
217@paramrefcon Can be queried for extra info about the request.
218@resultUIn32returns kFWResponseComplete on success */
219 virtual UInt32 doWrite(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len,
220 const void *buf, IOFWRequestRefCon refcon) = 0;
221
222/*!@functiondoLock
223@abstractA method for processing a lock request.
224@paramnodeIDFireWire Lock request for nodeID.
225@paramspeedat this 'speed'.
226@paramaddrwith FireWire address 'addr'.
227@paraminlen'inlen' bytes to use.
228@paramnewValnew value to write at 'addr' location .
229@paramoutLen'outLen' bytes for result.
230@paramoldValold value read from 'addr' location.
231@paramextTypeType like kFWExtendedTCodeCompareSwap.
232@paramrefcon Can be queried for extra info about the request.
233@resultUIn32returns kFWResponseComplete on success */
234 virtual UInt32 doLock(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 inlen,
235 const UInt32 *newVal, UInt32 &outLen, UInt32 *oldVal,
236 UInt32 extType, IOFWRequestRefCon refcon);
237
238/*!@functionactivate
239@abstractAddress space is ready for handling requests.
240@resultIOReturn
241*/
242 virtual IOReturn activate();
243
244/*!@functiondeactivate
245@abstractAddress space request handler is disabled.
246@resultnone
247*/
248 virtual void deactivate();
249
250/*!@functioncontains
251@abstractreturns number of bytes starting at addr in this space
252@result0 if it doesn't contain the address
253*/
254 virtual UInt32 contains(FWAddress addr);
255
256/*!@functionisTrustedNode
257@abstractreturns true if the node is added as a trusted node
258@paramnodeID is the nodeID to verify whether its trusted.
259@resultfalse if nodeID is not trusted
260*/
261inline bool isTrustedNode( UInt16 nodeID )
262{ return fIOFWAddressSpaceExpansion->fAuxiliary->isTrustedNode( nodeID ); }
263
264/*!@functionaddTrustedNode
265@abstractAdd a trusted node.
266@paramdevice object pointing to a FireWire node on the bus.
267@resultnone
268*/
269inline void addTrustedNode( IOFireWireDevice * device )
270{ fIOFWAddressSpaceExpansion->fAuxiliary->addTrustedNode( device ); }
271
272/*!@functionremoveTrustedNode
273@abstractRemove a trusted node.
274@paramdevice object pointing to a FireWire node on the bus.
275@resultnone
276*/
277inline void removeTrustedNode( IOFireWireDevice * device )
278{ fIOFWAddressSpaceExpansion->fAuxiliary->removeTrustedNode( device ); }
279
280/*!@functionremoveAllTrustedNodes
281@abstractRemove all trusted nodes.
282@resultnone
283*/
284inline void removeAllTrustedNodes( void )
285{ fIOFWAddressSpaceExpansion->fAuxiliary->removeAllTrustedNodes(); }
286
287/*!@functionisExclusive
288@abstractChecks if an address space wants exclusive control of its address range
289@resultTrue if the address space is marked exclusive false otherwise
290*/
291
292inline bool isExclusive( void )
293{ return fIOFWAddressSpaceExpansion->fAuxiliary->isExclusive(); }
294
295/*!@functionsetExclusive
296@abstractSets if this address space requires exclusive control of its address range. Exclusivity should be set before an address space is activated.
297@paramexclusive True if address space should be exclusive, false otherwise
298@resultnone
299*/
300
301inline void setExclusive( bool exclusive )
302{ fIOFWAddressSpaceExpansion->fAuxiliary->setExclusive( exclusive ); }
303
304/*!@functionintersects
305@abstractChecks this address space intersects with the given address range. Currently only supports IOFWPsuedoAddressSpaces.
306@paramspace An address space to compare against
307@resultTrue if the address spaces intersect false otherwise
308*/
309
310inline bool intersects( IOFWAddressSpace * space )
311{ return fIOFWAddressSpaceExpansion->fAuxiliary->intersects( space ); }
312
313
314protected:
315
316virtual IOFWAddressSpaceAux * createAuxiliary( void );
317
318private:
319 OSMetaClassDeclareReservedUsed(IOFWAddressSpace, 0);
320 OSMetaClassDeclareReservedUsed(IOFWAddressSpace, 1);
321
322};
323
324// the physical and psuedo address space classes used to be defined here
325// for backwards compatibility, we pull them in now. the ifdefs surrounding
326// the content of the header files ensures we do not multiply include a header.
327
328#include <IOKit/firewire/IOFWPseudoAddressSpace.h>
329#include <IOKit/firewire/IOFWPhysicalAddressSpace.h>
330
331#endif /* _IOKIT_IOFWADDRESSSPACE */
332

Archive Download this file

Revision: 1146