Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch_Modules/i386/include/IOKit/firewire/IOFWPseudoAddressSpace.h

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#ifndef _IOKIT_IOFWPSEUDOADDRESSSPACE_H
24#define _IOKIT_IOFWPSEUDOADDRESSSPACE_H
25
26#include <IOKit/firewire/IOFWAddressSpace.h>
27
28/*
29 * If installed, this callback is invoked for drivers which
30 * would like to coalesce incoming writes and do batch processing
31 * of incoming block write packets.
32 * This callback can be installed by calling setARxReqIntCompleteHandler
33 * method in IOFWPseudoAddressSpace object.
34 */
35typedef void (*IOFWARxReqIntCompleteHandler)( void * refcon );
36
37/*
38 * Pseudo firewire addresses usually represent emulated registers of some kind.
39 * Accesses to these addresses will result in the owner being notified.
40 *
41 * Virtual addresses should not have zero as the top 16 bits of the 48 bit local address,
42 * since that may look like a physical address to hardware (eg. OHCI).
43 * if reader is NULL then reads will not be allowed.
44 * if writer is NULL then writes will not be allowed.
45 * if either is NULL then lock requests will not be allowed.
46 * refcon is passed back as the first argument of read and write callbacks.
47 */
48
49class IOFWPseudoAddressSpace;
50
51#pragma mark -
52
53/*!
54@class IOFWPseudoAddressSpaceAux
55*/
56
57class IOFWPseudoAddressSpaceAux : public IOFWAddressSpaceAux
58{
59 OSDeclareDefaultStructors(IOFWPseudoAddressSpaceAux)
60
61friend class IOFWAddressSpace;
62friend class IOFWPseudoAddressSpace;
63friend class IOFireWireController;
64
65protected:
66
67 struct MemberVariables
68{
69IOFWARxReqIntCompleteHandlerfARxReqIntCompleteHandler;
70void * fARxReqIntCompleteHandlerRefcon;
71};
72
73 MemberVariables * fMembers;
74
75public:
76
77virtual bool init( IOFWAddressSpace * primary );
78virtualvoid free();
79
80protected:
81
82bool createMemberVariables( void );
83void destroyMemberVariables( void );
84
85virtual void handleARxReqIntComplete();
86
87public:
88
89/*!@function setARxReqIntCompleteHandler
90@abstract Installs a callback to receive notification, when FWIM has completed
91 ARxReqInt processing and no incoming packets are left in the queue.
92@param refconClient's callback object.
93@param handlerClient callback to be invoked, at the end of interrupt processing.
94@result none.*/
95virtual void setARxReqIntCompleteHandler( void * refcon, IOFWARxReqIntCompleteHandler handler );
96
97virtual bool intersects( IOFWAddressSpace * space );
98
99private:
100
101 OSMetaClassDeclareReservedUsed(IOFWPseudoAddressSpaceAux, 0);
102 OSMetaClassDeclareReservedUsed(IOFWPseudoAddressSpaceAux, 1);
103 OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 2);
104 OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 3);
105 OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 4);
106 OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 5);
107 OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 6);
108 OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 7);
109 OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 8);
110 OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 9);
111
112};
113
114/*!
115@class IOFWPseudoAddressSpace
116*/
117
118class IOFWPseudoAddressSpace : public IOFWAddressSpace
119{
120 OSDeclareDefaultStructors(IOFWPseudoAddressSpace)
121
122friend class IOFWPseudoAddressSpaceAux;
123friend class IOFireWireController;
124
125protected:
126
127 IOMemoryDescriptor*fDesc;
128 void *fRefCon;
129 FWReadCallbackfReader;
130 FWWriteCallbackfWriter;
131 FWAddressfBase;
132 UInt32fLen;
133
134/*! @struct ExpansionData
135 @discussion This structure will be used to expand the capablilties of the class in the future.
136 */
137 struct ExpansionData { };
138
139/*! @var reserved
140 Reserved for future use. (Internal use only) */
141 ExpansionData *reserved;
142
143 staticOSData *allocatedAddresses; // unused
144
145 virtualvoid free();
146
147public:
148
149/*!@functionsimpleReader
150@abstractA method for processing an address space read request
151@paramrefconClient's callback object.
152@paramnodeIDFireWire Read from nodeID.
153@paramspeedat this 'speed'.
154@paramaddrwith FireWire address 'addr'.
155@paramlenread 'len' bytes from nodeID.
156@parambufpoints to a memory descriptor containing the packet data.
157@paramoffsetstart from this 'offset' in 'buf'.
158@paramreqrefconCan be queried for extra info about the request.
159@resultUIn32returns kFWResponseComplete on success */
160 static UInt32 simpleReader(
161void*refcon,
162UInt16 nodeID,
163IOFWSpeed &speed,
164FWAddress addr,
165UInt32 len,
166IOMemoryDescriptor**buf,
167IOByteCount* offset,
168 IOFWRequestRefConreqrefcon);
169
170/*!@functionsimpleWriter
171@abstractA method for processing an address space write request
172@paramrefconClient's callback object.
173@paramnodeIDFireWire Write to nodeID.
174@paramspeedat this 'speed'.
175@paramaddrwith FireWire address 'addr'.
176@paramlenwrite 'len' bytes to nodeID.
177@parambufobtain bytes from location given by 'buf'.
178@paramreqrefconCan be queried for extra info about the request.
179@resultUIn32returns kFWResponseComplete on success */
180 static UInt32 simpleWriter(
181void*refcon,
182UInt16 nodeID,
183IOFWSpeed&speed,
184FWAddress addr,
185UInt32 len,
186const void*buf,
187 IOFWRequestRefConreqrefcon);
188protected:
189
190 // Get a unique address range
191 IOReturnallocateAddress(
192FWAddress*addr,
193UInt32 len);
194 // free address
195 voidfreeAddress(
196FWAddress addr,
197UInt32 len);
198
199public:
200
201 static IOFWPseudoAddressSpace*readWrite(
202FWAddress addr,
203UInt32 len,
204FWReadCallback reader,
205FWWriteCallback writer,
206void*refcon);
207
208/*!@functionsimpleRead
209@abstractCreate an address space object to handle read-only memory (eg. the local ROM)
210handles everything itself
211@parambusPoints to IOFireWireBus object.
212@paramaddrPoints to starting address for the Pseudo Address Space.
213@paramlenLength of the Pseudo Address Space.
214@paramdataThe virtual address of the first byte in the memory.
215@resultreturns valid IOFWPseudoAddressSpace on success, null on failure */
216 static IOFWPseudoAddressSpace*simpleRead(
217 IOFireWireBus*bus,
218 FWAddress*addr,
219UInt32 len,
220const void*data);
221
222/*!@functionsimpleReadFixed
223@abstractCreate an address space object to handle fixed read-only memory (eg. the local ROM)
224handles everything itself
225@parambusPoints to IOFireWireBus object.
226@paramaddrPoints to starting address for the Pseudo Address Space.
227@paramlenLength of the Pseudo Address Space.
228@paramdataThe virtual address of the first byte in the memory.
229@resultreturns valid IOFWPseudoAddressSpace on success, null on failure */
230 static IOFWPseudoAddressSpace*simpleReadFixed(
231 IOFireWireBus*bus,
232 FWAddress addr,
233UInt32 len,
234const void*data);
235
236/*!@functionsimpleRW
237@abstractCreate an address space object to handle r/w memory
238handles everything itself
239@parambusPoints to IOFireWireBus object.
240@paramaddrPoints to starting address for the Pseudo Address Space.
241@paramlenLength of the Pseudo Address Space.
242@paramdataThe virtual address of the first byte in the memory.
243@resultreturns valid IOFWPseudoAddressSpace on success, null on failure */
244 static IOFWPseudoAddressSpace*simpleRW(
245 IOFireWireBus*bus,
246 FWAddress*addr,
247UInt32 len,
248void *data);
249
250/*!@functionsimpleRW
251@abstractCreate an address space object to handle r/w memory
252handles everything itself
253@parambusPoints to IOFireWireBus object.
254@paramaddrPoints to starting address for the Pseudo Address Space.
255@paramdataThe virtual address of the first byte in the memory.
256@resultreturns valid IOFWPseudoAddressSpace on success, null on failure */
257 static IOFWPseudoAddressSpace*simpleRW(
258 IOFireWireBus*bus,
259 FWAddress*addr,
260IOMemoryDescriptor *data);
261
262/*!@functioninitAll
263@abstractInitialize an address space object to handle r/w memory
264@parambusPoints to IOFireWireBus object.
265@paramaddrPoints to starting address for the Pseudo Address Space.
266@paramlenLength of the Pseudo Address Space.
267@paramreaderCallback handler for incoming Read.
268@paramwriterCallback handler for incoming Write.
269@paramrefconClient's callback object.
270@resultreturns true on success, false on failure */
271 virtual bool initAll(
272 IOFireWireBus*bus,
273 FWAddress*addr,
274UInt32 len,
275FWReadCallback reader,
276FWWriteCallback writer,
277void*refcon);
278
279/*!@functioninitFixed
280@abstractInitialize a fixed address space at top of kCSRRegisterSpaceBaseAddressHi
281@parambusPoints to IOFireWireBus object.
282@paramaddrPoints to starting address for the Pseudo Address Space.
283@paramreaderCallback handler for incoming Read.
284@paramwriterCallback handler for incoming Write.
285@paramrefconClient's callback object.
286@resultreturns true on success, false on failure */
287 virtual bool initFixed(
288 IOFireWireBus*bus,
289 FWAddress addr,
290UInt32 len,
291 FWReadCallback reader,
292FWWriteCallback writer,
293void*refcon);
294
295/*!@functiondoRead
296@abstractA method for processing an address space read request
297@paramnodeIDFireWire Read from nodeID.
298@paramspeedat this 'speed'.
299@paramaddrwith FireWire address 'addr'.
300@paramlenread 'len' bytes from nodeID.
301@parambufpoints to a memory descriptor containing the packet data.
302@paramoffsetstart from this 'offset' in 'buf'.
303@paramreqrefcon Can be queried for extra info about the request.
304@resultUIn32returns kFWResponseComplete on success */
305 virtual UInt32 doRead(
306UInt16 nodeID,
307IOFWSpeed &speed,
308FWAddress addr,
309UInt32 len,
310 IOMemoryDescriptor **buf,
311IOByteCount * offset,
312 IOFWRequestRefConreqrefcon);
313/*!@functiondoWrite
314@abstractA method for processing an address space write request
315@paramnodeIDFireWire Write to nodeID.
316@paramspeedat this 'speed'.
317@paramaddrwith FireWire address 'addr'.
318@paramlenwrite 'len' bytes to nodeID.
319@parambufobtain bytes from location given by 'buf'.
320@paramreqrefcon Can be queried for extra info about the request.
321@resultUIn32returns kFWResponseComplete on success */
322 virtual UInt32 doWrite(
323UInt16 nodeID,
324IOFWSpeed&speed,
325FWAddress addr,
326UInt32 len,
327const void*buf,
328 IOFWRequestRefConreqrefcon);
329
330/*!@functioncontains
331@abstractreturns number of bytes starting at addr in this space
332@result0 if it doesn't contain the address
333*/
334 virtual UInt32contains(FWAddress addr);
335
336/*!@functionsimpleRWFixed
337@abstractCreate a Read/Write fixed address space at top of kCSRRegisterSpaceBaseAddressHi.
338@paramcontrolPoints to IOFireWireBus object.
339@paramaddrPoints to starting address for the Pseudo Address Space.
340@paramlenLength of the address range.
341@paramdataThe virtual address of the first byte in the memory.
342@resultreturns valid IOFWPseudoAddressSpace on success, null on failure */
343static IOFWPseudoAddressSpace * simpleRWFixed( IOFireWireBus *control, FWAddress addr, UInt32 len, const void *data );
344
345protected:
346
347virtual IOFWAddressSpaceAux * createAuxiliary( void );
348
349protected:
350inline void handleARxReqIntComplete( void )
351{ ((IOFWPseudoAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->handleARxReqIntComplete(); }
352
353public:
354/*!@function setARxReqIntCompleteHandler
355@abstract Installs a callback to receive notification, when FWIM has completed
356 ARxReqInt processing and no incoming packets are left in the queue.
357@param refconClient's callback object.
358@param handlerClient callback to be invoked, at the end of interrupt processing.
359@result none.*/
360inline void setARxReqIntCompleteHandler( void * refcon, IOFWARxReqIntCompleteHandler handler )
361{ ((IOFWPseudoAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->setARxReqIntCompleteHandler( refcon, handler ); }
362
363private:
364
365 OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpace, 0);
366 OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpace, 1);
367
368};
369
370#endif
371

Archive Download this file

Revision: 2238