1/* 2 * Copyright (c) 1998-2001 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 * IOFireWireLibConfigDirectory.h 24 * IOFireWireFamily 25 * 26 * Created by NWG on Thu Jan 18 2001. 27 * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved. 28 * 29 */ 30 31#import "IOFireWireLibIUnknown.h" 32#import "IOFireWireLibPriv.h" 33 34namespace IOFireWireLib { 35 36 class Device ; 37 class ConfigDirectory: public IOFireWireIUnknown 38 { 39 protected: 40 typedef ::IOFireWireLibConfigDirectoryRef DirRef ; 41 42 public: 43 ConfigDirectory( const IUnknownVTbl & interface, Device& inUserClient, UserObjectHandle inDirRef ) ; 44 ConfigDirectory( const IUnknownVTbl & interface, Device& inUserClient ) ; 45 virtual ~ConfigDirectory() ; 46 47 /*! 48 @function update 49 makes sure that the ROM has at least the specified capacity, 50 and that the ROM is uptodate from its start to at least the 51 specified quadlet offset. 52 @result kIOReturnSuccess if the specified offset is now 53 accessable at romBase[offset]. 54 */ 55 IOReturn Update(UInt32 offset) ; 56 57 /*! 58 @function getKeyType 59 Gets the data type for the specified key 60 @param type on return, set to the data type 61 @result kIOReturnSuccess if the key exists in the dictionary 62 */ 63 IOReturn GetKeyType(int key, IOConfigKeyType& type); 64 65 /*! 66 @function getKeyValue 67 Gets the value for the specified key, in a variety of forms. 68 @param value on return, set to the data type 69 @param text if non-zero, on return points to the 70 string description of the field, or NULL if no text found. 71 @result kIOReturnSuccess if the key exists in the dictionary 72 and is of a type appropriate for the value parameter 73 @param value reference to variable to store the entry's value 74 */ 75 IOReturn GetKeyValue(int key, UInt32 &value, CFStringRef*& text); 76 IOReturn GetKeyValue(int key, CFDataRef* value, CFStringRef*& text); 77 IOReturn GetKeyValue(int key, DirRef& value, REFIID iid, CFStringRef*& text); 78 IOReturn GetKeyOffset(int key, FWAddress& value, CFStringRef*& text); 79 IOReturn GetKeyValue(int key, UserObjectHandle& value) ; 80 81 /*! 82 @function getIndexType 83 Gets the data type for entry at the specified index 84 @param type on return, set to the data type 85 @result kIOReturnSuccess if the index exists in the dictionary 86 */ 87 IOReturn GetIndexType(int index, IOConfigKeyType &type); 88 /*! 89 @function getIndexKey 90 Gets the key for entry at the specified index 91 @param key on return, set to the key 92 @result kIOReturnSuccess if the index exists in the dictionary 93 */ 94 IOReturn GetIndexKey(int index, int &key); 95 96 /*! 97 @function getIndexValue 98 Gets the value at the specified index of the directory, 99 in a variety of forms. 100 @param type on return, set to the data type 101 @result kIOReturnSuccess if the index exists in the dictionary 102 and is of a type appropriate for the value parameter 103 @param value reference to variable to store the entry's value 104 */ 105 IOReturn GetIndexValue(int index, UInt32& value); 106 IOReturn GetIndexValue(int index, CFDataRef* value); 107 IOReturn GetIndexValue(int index, CFStringRef* value); 108// IOReturn GetIndexValue(int index, UserObjectHandle& value) ; 109 IOReturn GetIndexValue(int index, DirRef& value, REFIID iid); 110 111 IOReturn GetIndexOffset(int index, FWAddress& value); 112 IOReturn GetIndexOffset(int index, UInt32& value); 113 114 /*! 115 @function getIndexEntry 116 Gets the entry at the specified index of the directory, 117 as a raw UInt32. 118 @param entry on return, set to the entry value 119 @result kIOReturnSuccess if the index exists in the dictionary 120 @param value reference to variable to store the entry's value 121 */ 122 IOReturn GetIndexEntry(int index, UInt32 &value); 123 124 /*! 125 @function getSubdirectories 126 Creates an iterator over the subdirectories of the directory. 127 @param iterator on return, set to point to an OSIterator 128 @result kIOReturnSuccess if the iterator could be created 129 */ 130 IOReturn GetSubdirectories(io_iterator_t *outIterator); 131 132 /*! 133 @function getKeySubdirectories 134 Creates an iterator over subdirectories of a given type of the directory. 135 @param key type of subdirectory to iterate over 136 @param iterator on return, set to point to an io_iterator_t 137 @result kIOReturnSuccess if the iterator could be created 138 */ 139 IOReturn GetKeySubdirectories(int key, io_iterator_t *outIterator); 140 IOReturn GetType(int *outType) ; 141 IOReturn GetNumEntries(int *outNumEntries) ; 142 143 protected: 144 Device& mUserClient ; 145 UserObjectHandle mKernConfigDirectoryRef ; 146 } ; 147 148 class ConfigDirectoryCOM: public ConfigDirectory 149 { 150 protected: 151 typedef ::IOFireWireConfigDirectoryInterface Interface ; 152 153 public: 154 ConfigDirectoryCOM(Device& inUserClient) ; 155 ConfigDirectoryCOM(Device& inUserClient, UserObjectHandle inDirRef) ; 156 virtual ~ConfigDirectoryCOM() ; 157 158 private: 159 static Interface sInterface ; 160 161 public: 162 // --- IUNKNOWN support ---------------- 163 static IUnknownVTbl** Alloc(Device& inUserClient, UserObjectHandle inDirRef) ; 164 static IUnknownVTbl** Alloc(Device& inUserClient) ; 165 virtual HRESULT QueryInterface(REFIID iid, void ** ppv ) ; 166 167 protected: 168 // --- static methods ------------------ 169 static IOReturn SUpdate( 170 DirRef inDir, 171 UInt32 inOffset) ; 172 static IOReturn SGetKeyType( 173 DirRef inDir, 174 int inKey, 175 IOConfigKeyType* outType); 176 static IOReturn SGetKeyValue_UInt32( 177 DirRef inDir, 178 int inKey, 179 UInt32* outValue, 180 CFStringRef* outText); 181 static IOReturn SGetKeyValue_Data( 182 DirRef inDir, 183 int inKey, 184 CFDataRef* outValue, 185 CFStringRef* outText); 186 static IOReturn SGetKeyValue_ConfigDirectory( 187 DirRef inDir, 188 int inKey, 189 DirRef * outValue, 190 REFIID iid, 191 CFStringRef* outText); 192 static IOReturn SGetKeyOffset_FWAddress( 193 DirRef inDir, 194 int inKey, 195 FWAddress* outValue, 196 CFStringRef* text); 197 static IOReturn SGetIndexType( 198 DirRef inDir, 199 int inIndex, 200 IOConfigKeyType* type); 201 static IOReturn SGetIndexKey( 202 DirRef inDir, 203 int inIndex, 204 int * key); 205 static IOReturn SGetIndexValue_UInt32( 206 DirRef inDir, 207 int inIndex, 208 UInt32 * value); 209 static IOReturn SGetIndexValue_Data( 210 DirRef inDir, 211 int inIndex, 212 CFDataRef * value); 213 static IOReturn SGetIndexValue_String( 214 DirRef inDir, 215 int inIndex, 216 CFStringRef* outValue); 217 static IOReturn SGetIndexValue_ConfigDirectory( 218 DirRef inDir, 219 int inIndex, 220 DirRef * outValue, 221 REFIID iid); 222 static IOReturn SGetIndexOffset_FWAddress( 223 DirRef inDir, 224 int inIndex, 225 FWAddress* outValue); 226 static IOReturn SGetIndexOffset_UInt32( 227 DirRef inDir, 228 int inIndex, 229 UInt32* outValue); 230 static IOReturn SGetIndexEntry( 231 DirRef inDir, 232 int inIndex, 233 UInt32* outValue); 234 static IOReturn SGetSubdirectories( 235 DirRef inDir, 236 io_iterator_t* outIterator); 237 static IOReturn SGetKeySubdirectories( 238 DirRef inDir, 239 int inKey, 240 io_iterator_t * outIterator); 241 static IOReturn SGetType( 242 DirRef inDir, 243 int * outType) ; 244 static IOReturn SGetNumEntries( 245 DirRef inDir, 246 int * outNumEntries) ; 247 } ; 248} 249