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 *	IOFireWireUnit.h
25 *
26 *
27 */
28#ifndef _IOKIT_IOFIREWIREUNIT_H
29#define _IOKIT_IOFIREWIREUNIT_H
30
31// public
32#include <IOKit/firewire/IOFireWireNub.h>
33
34class IOFireWireDevice;
35class IOFireWireUnit;
36
37#pragma mark -
38
39/*!
40	@class IOFireWireUnitAux
41*/
42
43class IOFireWireUnitAux : public IOFireWireNubAux
44{
45    OSDeclareDefaultStructors(IOFireWireUnitAux)
46
47	friend class IOFireWireUnit;
48
49protected:
50
51	/*!
52		@struct ExpansionData
53		@discussion This structure will be used to expand the capablilties of the class in the future.
54    */
55
56    struct ExpansionData { };
57
58	/*!
59		@var reserved
60		Reserved for future use.  (Internal use only)
61	*/
62
63	ExpansionData * reserved;
64
65    virtual bool init( IOFireWireUnit * primary );
66	virtual	void free();
67
68	virtual bool isPhysicalAccessEnabled( void );
69
70	virtual IOFWSimpleContiguousPhysicalAddressSpace * createSimpleContiguousPhysicalAddressSpace( vm_size_t size, IODirection direction );
71
72    virtual IOFWSimplePhysicalAddressSpace * createSimplePhysicalAddressSpace( vm_size_t size, IODirection direction );
73
74private:
75    OSMetaClassDeclareReservedUnused(IOFireWireUnitAux, 0);
76    OSMetaClassDeclareReservedUnused(IOFireWireUnitAux, 1);
77    OSMetaClassDeclareReservedUnused(IOFireWireUnitAux, 2);
78    OSMetaClassDeclareReservedUnused(IOFireWireUnitAux, 3);
79
80};
81
82#pragma mark -
83
84/*! @class IOFireWireUnit
85*/
86class IOFireWireUnit : public IOFireWireNub
87{
88    OSDeclareDefaultStructors(IOFireWireUnit)
89
90	friend class IOFireWireUnitAux;
91	friend class IOFireWireDevice;
92
93protected:
94    IOFireWireDevice *fDevice;	// The device unit is part of
95
96/*! @struct ExpansionData
97    @discussion This structure will be used to expand the capablilties of the class in the future.
98    */
99    struct ExpansionData { };
100
101/*! @var reserved
102    Reserved for future use.  (Internal use only)  */
103    ExpansionData *reserved;
104
105/*------------------Methods provided to FireWire device clients-----------------------*/
106public:
107
108    virtual bool init(OSDictionary *propTable, IOConfigDirectory *directory);
109
110    /*
111     * Standard nub initialization
112     */
113    virtual bool attach(IOService * provider );
114	virtual void free();
115
116    /*
117     * Matching language support
118     * Match on the following properties of the unit:
119     * Vendor_ID
120     * GUID
121     * Unit_Spec_ID
122     * Unit_SW_Version
123     */
124    virtual bool matchPropertyTable(OSDictionary * table);
125
126
127    virtual IOReturn message( UInt32 type, IOService * provider, void * argument );
128
129    // Override handleOpen() and handleClose() to pass on to device
130    virtual bool handleOpen( 	IOService *	  forClient,
131                                IOOptionBits	  options,
132                                void *		  arg );
133
134    virtual void handleClose(   IOService *	  forClient,
135                                IOOptionBits	  options );
136
137    virtual void setNodeFlags( UInt32 flags );
138	virtual void clearNodeFlags( UInt32 flags );
139    virtual UInt32 getNodeFlags( void );
140
141	virtual IOReturn setConfigDirectory( IOConfigDirectory *directory );
142
143    /*
144     * Create local FireWire address spaces for the device to access
145     */
146    virtual IOFWPhysicalAddressSpace *createPhysicalAddressSpace(IOMemoryDescriptor *mem);
147    virtual IOFWPseudoAddressSpace *createPseudoAddressSpace(FWAddress *addr, UInt32 len,
148                    FWReadCallback reader, FWWriteCallback writer, void *refcon);
149
150protected:
151
152	virtual IOFireWireNubAux * createAuxiliary( void );
153
154public:
155	void setMaxSpeed( IOFWSpeed speed );
156
157protected:
158	void terminateUnit( void );
159	static void terminateUnitThreadFunc( void * refcon );
160
161private:
162    OSMetaClassDeclareReservedUnused(IOFireWireUnit, 0);
163    OSMetaClassDeclareReservedUnused(IOFireWireUnit, 1);
164
165};
166
167#endif /* ! _IOKIT_IOFIREWIREDEVICE_H */
168