]>
Commit | Line | Data |
---|---|---|
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 | * Copyright (c) 1998 Apple Computer, Inc. All rights reserved. | |
27 | * | |
28 | * HISTORY | |
29 | * | |
30 | */ | |
31 | ||
32 | ||
33 | #ifndef _IOKIT_IOREGISTRYENTRY_H | |
34 | #define _IOKIT_IOREGISTRYENTRY_H | |
35 | ||
36 | #include <IOKit/IOTypes.h> | |
37 | #include <libkern/c++/OSContainers.h> | |
38 | ||
39 | ||
40 | extern const OSSymbol * gIONameKey; | |
41 | extern const OSSymbol * gIOLocationKey; | |
42 | ||
43 | class IORegistryEntry; | |
44 | class IORegistryPlane; | |
45 | class IORegistryIterator; | |
46 | ||
47 | typedef void (*IORegistryEntryApplierFunction)(IORegistryEntry * entry, | |
48 | void * context); | |
49 | ||
50 | enum { | |
51 | kIORegistryIterateRecursively = 0x00000001, | |
52 | kIORegistryIterateParents = 0x00000002 | |
53 | }; | |
54 | ||
55 | /*! @class IORegistryEntry : public OSObject | |
56 | @abstract The base class for all objects in the registry. | |
57 | @discussion The IORegistryEntry base class provides functions for describing graphs of connected registry entries, each with a dictionary-based property table. Entries may be connected in different planes, with differing topologies. Access to the registry is protected against multiple threads. Inside the kernel planes are specified with plane objects and are published by the creator - IOService exports the gIOServicePlane plane object for example. Non kernel clients specify planes by their name. | |
58 | */ | |
59 | ||
60 | class IORegistryEntry : public OSObject | |
61 | { | |
9bccf70c | 62 | friend class IORegistryIterator; |
1c79356b A |
63 | |
64 | OSDeclareDefaultStructors(IORegistryEntry) | |
65 | ||
66 | protected: | |
67 | /*! @struct ExpansionData | |
68 | @discussion This structure will be used to expand the capablilties of this class in the future. | |
69 | */ | |
70 | struct ExpansionData { }; | |
71 | ||
72 | /*! @var reserved | |
73 | Reserved for future use. (Internal use only) */ | |
74 | ExpansionData * reserved; | |
75 | ||
76 | private: | |
77 | ||
78 | OSDictionary * fRegistryTable; | |
79 | OSDictionary * fPropertyTable; | |
80 | ||
0b4e3aa0 A |
81 | public: |
82 | /* methods available in Mac OS X 10.1 or later */ | |
83 | ||
84 | /*! @function copyProperty | |
85 | @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. Available in Mac OS X 10.1 or later. | |
86 | @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s). | |
87 | @param aKey The property's name as a C-string. | |
88 | @param plane The plane to iterate over, eg. gIOServicePlane. | |
89 | @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children. | |
90 | @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */ | |
91 | ||
92 | virtual OSObject * copyProperty( const char * aKey, | |
93 | const IORegistryPlane * plane, | |
94 | IOOptionBits options = | |
95 | kIORegistryIterateRecursively | | |
96 | kIORegistryIterateParents) const; | |
97 | /*! @function copyProperty | |
98 | @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. Available in Mac OS X 10.1 or later. | |
99 | @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s). | |
100 | @param aKey The property's name as an OSString. | |
101 | @param plane The plane to iterate over, eg. gIOServicePlane. | |
102 | @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children. | |
103 | @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */ | |
104 | ||
105 | virtual OSObject * copyProperty( const OSString * aKey, | |
106 | const IORegistryPlane * plane, | |
107 | IOOptionBits options = | |
108 | kIORegistryIterateRecursively | | |
109 | kIORegistryIterateParents) const; | |
110 | ||
111 | /*! @function copyProperty | |
112 | @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. Available in Mac OS X 10.1 or later. | |
113 | @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s). | |
114 | @param aKey The property's name as an OSSymbol. | |
115 | @param plane The plane to iterate over, eg. gIOServicePlane. | |
116 | @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children. | |
117 | @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */ | |
118 | ||
119 | virtual OSObject * copyProperty( const OSSymbol * aKey, | |
120 | const IORegistryPlane * plane, | |
121 | IOOptionBits options = | |
122 | kIORegistryIterateRecursively | | |
123 | kIORegistryIterateParents) const; | |
124 | ||
125 | /*! @function copyParentEntry | |
126 | @abstract Returns an registry entry's first parent entry in a plane. Available in Mac OS X 10.1 or later. | |
127 | @discussion This function will return the parent to which a registry entry was first attached. Since the majority of registry entrys have only one provider, this is a useful simplification. | |
128 | @param plane The plane object. | |
129 | @result Returns the first parent of the registry entry, or zero if the entry is not attached into the registry in that plane. A reference on the entry is returned to caller, which should be released. */ | |
130 | ||
131 | virtual IORegistryEntry * copyParentEntry( const IORegistryPlane * plane ) const; | |
132 | ||
133 | /*! @function copyChildEntry | |
134 | @abstract Returns an registry entry's first child entry in a plane. Available in Mac OS X 10.1 or later. | |
135 | @discussion This function will return the child which first attached to a registry entry. | |
136 | @param plane The plane object. | |
137 | @result Returns the first child of the registry entry, or zero if the entry is not attached into the registry in that plane. A reference on the entry is returned to caller, which should be released. */ | |
138 | ||
139 | virtual IORegistryEntry * copyChildEntry( const IORegistryPlane * plane ) const; | |
140 | ||
1c79356b | 141 | private: |
0b4e3aa0 A |
142 | |
143 | OSMetaClassDeclareReservedUsed(IORegistryEntry, 0); | |
144 | OSMetaClassDeclareReservedUsed(IORegistryEntry, 1); | |
145 | OSMetaClassDeclareReservedUsed(IORegistryEntry, 2); | |
146 | OSMetaClassDeclareReservedUsed(IORegistryEntry, 3); | |
147 | OSMetaClassDeclareReservedUsed(IORegistryEntry, 4); | |
148 | ||
1c79356b A |
149 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 5); |
150 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 6); | |
151 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 7); | |
152 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 8); | |
153 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 9); | |
154 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 10); | |
155 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 11); | |
156 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 12); | |
157 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 13); | |
158 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 14); | |
159 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 15); | |
160 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 16); | |
161 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 17); | |
162 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 18); | |
163 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 19); | |
164 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 20); | |
165 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 21); | |
166 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 22); | |
167 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 23); | |
168 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 24); | |
169 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 25); | |
170 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 26); | |
171 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 27); | |
172 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 28); | |
173 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 29); | |
174 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 30); | |
175 | OSMetaClassDeclareReservedUnused(IORegistryEntry, 31); | |
176 | ||
177 | public: | |
178 | ||
179 | /* Registry accessors */ | |
180 | ||
181 | /*! @function getRegistryRoot | |
182 | @abstract Returns a pointer to the root instance of the registry. | |
183 | @discussion This method provides an accessor to the root of the registry for the machine. The root may be passed to a registry iterator when iterating a plane, and contains properties that describe the available planes, and diagnostic information for IOKit. Keys for these properties are in IOKitKeys.h. | |
184 | @result A pointer to the IORegistryEntry root instance. It should not be released by the caller. */ | |
185 | ||
186 | static IORegistryEntry * getRegistryRoot( void ); | |
187 | ||
188 | /*! @function getGenerationCount | |
189 | @abstract Returns an generation count for all registry changing operations. | |
190 | @discussion This method provides an accessor to the current generation count (or seed) of the registry which changes when any topology change occurs in the registry - this does not include property table changes. It may be used to invalidate any caching of the results from IORegistryEntry methods. | |
191 | @result An integer generation count. */ | |
192 | ||
193 | static SInt32 getGenerationCount( void ); | |
194 | ||
195 | /*! @function getPlane | |
196 | @abstract Looks up the plane object by a C-string name. | |
197 | @discussion Planes are usually provided as globals by the creator, eg. gIOServicePlane, gIODeviceTreePlane, or gIOAudioPlane, however they may also be looked up by name with this method. | |
198 | @result A pointer to the plane object, or zero if no such plane exists. The returned plane should not be released. */ | |
199 | ||
200 | static const IORegistryPlane * getPlane( const char * name ); | |
201 | ||
202 | /* Registry Entry allocation & init */ | |
203 | ||
204 | /*! @function init | |
205 | @abstract Standard init method for all IORegistryEntry subclasses. | |
206 | @discussion A registry entry must be initialized with this method before it can be used. A property dictionary may passed and will be retained by this method for use as the registry entry's property table, or an empty one will be created. | |
207 | @param A dictionary that will become the registry entry's property table (retaining it), or zero which will cause an empty property table to be created. | |
208 | @result true on success, or false on a resource failure. */ | |
209 | ||
210 | virtual bool init( OSDictionary * dictionary = 0 ); | |
211 | ||
212 | /*! @function free | |
213 | @abstract Standard free method for all IORegistryEntry subclasses. | |
214 | @discussion This method will release any resources of the entry, in particular its property table. Note that the registry entry must always be detached from the registry before free may be called, and subclasses (namely IOService) will have additional protocols for removing registry entries. free should never need be called directly. */ | |
215 | ||
216 | virtual void free( void ); | |
217 | ||
218 | /*! @function setPropertyTable | |
219 | @abstract Replace a registry entry's property table. | |
220 | @discussion This method will release the current property table of a the entry and replace it with another, retaining the new property table. | |
221 | @param dict The new dictionary to be used as the entry's property table. */ | |
222 | ||
223 | virtual void setPropertyTable( OSDictionary * dict ); | |
224 | ||
225 | /* Synchronized property accessors; wrappers to OSDictionary | |
226 | * plus property creation helpers */ | |
227 | ||
228 | /*! @function setProperty | |
229 | @abstract Synchronized method to add a property to a registry entry's property table. | |
230 | @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. | |
231 | @param aKey The properties name as an OSSymbol. | |
232 | @param anObject The property value. | |
233 | @result true on success or false on a resource failure. */ | |
234 | ||
235 | virtual bool setProperty(const OSSymbol * aKey, OSObject * anObject); | |
236 | ||
237 | /*! @function setProperty | |
238 | @abstract Synchronized method to add a property to a registry entry's property table. | |
239 | @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. | |
240 | @param aKey The property's name as an OSString. | |
241 | @param anObject The property value. | |
242 | @result true on success or false on a resource failure. */ | |
243 | ||
244 | virtual bool setProperty(const OSString * aKey, OSObject * anObject); | |
245 | ||
246 | /*! @function setProperty | |
247 | @abstract Synchronized method to add a property to a registry entry's property table. | |
248 | @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. | |
249 | @param aKey The property's name as a C-string. | |
250 | @param anObject The property value. | |
251 | @result true on success or false on a resource failure. */ | |
252 | ||
253 | virtual bool setProperty(const char * aKey, OSObject * anObject); | |
254 | ||
255 | /*! @function setProperty | |
256 | @abstract Synchronized method to construct and add a OSString property to a registry entry's property table. | |
257 | @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSString from the supplied C-string, set in the property table with the given name, and released. | |
258 | @param aKey The property's name as a C-string. | |
259 | @param aString The property value as a C-string. | |
260 | @result true on success or false on a resource failure. */ | |
261 | ||
262 | virtual bool setProperty(const char * aKey, const char * aString); | |
263 | ||
264 | /*! @function setProperty | |
265 | @abstract Synchronized method to construct and add an OSBoolean property to a registry entry's property table. | |
266 | @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSBoolean from the supplied value, set in the property table with the given name, and released. | |
267 | @param aKey The property's name as a C-string. | |
268 | @param aBoolean The property's boolean value. | |
269 | @result true on success or false on a resource failure. */ | |
270 | ||
271 | virtual bool setProperty(const char * aKey, bool aBoolean); | |
272 | ||
273 | /*! @function setProperty | |
274 | @abstract Synchronized method to construct and add an OSNumber property to a registry entry's property table. | |
275 | @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSNumber from the supplied value and size, set in the property table with the given name, and released. | |
276 | @param aKey The property's name as a C-string. | |
277 | @param aValue The property's numeric value. | |
278 | @param aNumberOfBits The property's size in bits, for OSNumber. | |
279 | @result true on success or false on a resource failure. */ | |
280 | ||
281 | virtual bool setProperty( const char * aKey, | |
282 | unsigned long long aValue, | |
283 | unsigned int aNumberOfBits); | |
284 | ||
285 | /*! @function setProperty | |
286 | @abstract Synchronized method to construct and add an OSData property to a registry entry's property table. | |
287 | @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSData copied from the supplied date and length, set in the property table with the given name, and released. | |
288 | @param aKey The property's name as a C-string. | |
289 | @param bytes The property's value as a pointer. OSData will copy this data. | |
290 | @param length The property's size in bytes, for OSData. | |
291 | @result true on success or false on a resource failure. */ | |
292 | ||
293 | virtual bool setProperty( const char * aKey, | |
294 | void * bytes, | |
295 | unsigned int length); | |
296 | ||
297 | /*! @function removeProperty | |
298 | @abstract Synchronized method to remove a property from a registry entry's property table. | |
299 | @discussion This method will remove a property from a registry entry's property table, using the OSDictionary::removeObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. | |
300 | @param aKey The property's name as an OSSymbol. */ | |
301 | ||
302 | virtual void removeProperty( const OSSymbol * aKey); | |
303 | ||
304 | /*! @function removeProperty | |
305 | @abstract Synchronized method to remove a property from a registry entry's property table. | |
306 | @discussion This method will remove a property from a registry entry's property table, using the OSDictionary::removeObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. | |
307 | @param aKey The property's name as an OSString. */ | |
308 | ||
309 | virtual void removeProperty( const OSString * aKey); | |
310 | ||
311 | /*! @function removeProperty | |
312 | @abstract Synchronized method to remove a property from a registry entry's property table. | |
313 | @discussion This method will remove a property from a registry entry's property table, using the OSDictionary::removeObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. | |
314 | @param aKey The property's name as a C-string. */ | |
315 | ||
316 | virtual void removeProperty( const char * aKey); | |
317 | ||
318 | /*! @function getProperty | |
319 | @abstract Synchronized method to obtain a property from a registry entry's property table. | |
320 | @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. | |
321 | @param aKey The property's name as an OSSymbol. | |
322 | @result The property value found, or zero. */ | |
323 | ||
324 | virtual OSObject * getProperty( const OSSymbol * aKey) const; | |
325 | ||
326 | /*! @function getProperty | |
327 | @abstract Synchronized method to obtain a property from a registry entry's property table. | |
328 | @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. | |
329 | @param aKey The property's name as an OSString. | |
330 | @result The property value found, or zero. */ | |
331 | ||
332 | virtual OSObject * getProperty( const OSString * aKey) const; | |
333 | ||
334 | /*! @function getProperty | |
335 | @abstract Synchronized method to obtain a property from a registry entry's property table. | |
336 | @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. | |
337 | @param aKey The property's name as a C-string. | |
338 | @result The property value found, or zero. */ | |
339 | ||
340 | virtual OSObject * getProperty( const char * aKey) const; | |
341 | ||
342 | /*! @function getProperty | |
343 | @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. | |
344 | @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s). | |
345 | @param aKey The property's name as an OSSymbol. | |
346 | @param plane The plane to iterate over, eg. gIOServicePlane. | |
347 | @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children. | |
348 | @result The property value found, or zero. */ | |
349 | ||
350 | virtual OSObject * getProperty( const OSSymbol * aKey, | |
351 | const IORegistryPlane * plane, | |
352 | IOOptionBits options = | |
353 | kIORegistryIterateRecursively | | |
354 | kIORegistryIterateParents) const; | |
355 | ||
356 | /*! @function getProperty | |
357 | @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. | |
358 | @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s). | |
359 | @param aKey The property's name as an OSString. | |
360 | @param plane The plane to iterate over, eg. gIOServicePlane. | |
361 | @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children. | |
362 | @result The property value found, or zero. */ | |
363 | ||
364 | virtual OSObject * getProperty( const OSString * aKey, | |
365 | const IORegistryPlane * plane, | |
366 | IOOptionBits options = | |
367 | kIORegistryIterateRecursively | | |
368 | kIORegistryIterateParents) const; | |
369 | ||
370 | /*! @function getProperty | |
371 | @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. | |
372 | @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s). | |
373 | @param aKey The property's name as a C-string. | |
374 | @param plane The plane to iterate over, eg. gIOServicePlane. | |
375 | @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children. | |
376 | @result The property value found, or zero. */ | |
377 | ||
378 | virtual OSObject * getProperty( const char * aKey, | |
379 | const IORegistryPlane * plane, | |
380 | IOOptionBits options = | |
381 | kIORegistryIterateRecursively | | |
382 | kIORegistryIterateParents) const; | |
383 | ||
384 | /*! @function copyProperty | |
385 | @abstract Synchronized method to obtain a property from a registry entry's property table. | |
386 | @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics, and return a reference to the caller. This method is synchronized with other IORegistryEntry accesses to the property table. | |
387 | @param aKey The property's name as an OSSymbol. | |
388 | @result The property value found, or zero. It should be released by the caller. */ | |
389 | ||
390 | virtual OSObject * copyProperty( const OSSymbol * aKey) const; | |
391 | ||
392 | /*! @function copyProperty | |
393 | @abstract Synchronized method to obtain a property from a registry entry's property table. | |
394 | @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics, and return a reference to the caller. This method is synchronized with other IORegistryEntry accesses to the property table. | |
395 | @param aKey The property's name as an OSString. | |
396 | @result The property value found, or zero. It should be released by the caller. */ | |
397 | ||
398 | virtual OSObject * copyProperty( const OSString * aKey) const; | |
399 | ||
400 | /*! @function copyProperty | |
401 | @abstract Synchronized method to obtain a property from a registry entry's property table. | |
402 | @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics, and return a reference to the caller. This method is synchronized with other IORegistryEntry accesses to the property table. | |
403 | @param aKey The property's name as a C-string. | |
404 | @result The property value found, or zero. It should be released by the caller. */ | |
405 | ||
406 | virtual OSObject * copyProperty( const char * aKey) const; | |
407 | ||
408 | /*! @function dictionaryWithProperties | |
409 | @abstract Synchronized method to obtain copy a registry entry's property table. | |
410 | @discussion This method will copy a registry entry's property table, using the OSDictionary::withDictionary semantics. This method is synchronized with other IORegistryEntry accesses to the property table. Since OSDictionary will only copy property values by reference, synchronization is not guaranteed to any collection values. | |
411 | @result The created dictionary, or zero on a resource value. It should be released by the caller. */ | |
412 | ||
413 | virtual OSDictionary * dictionaryWithProperties( void ) const; | |
414 | ||
415 | /*! @function serializeProperties | |
416 | @abstract Synchronized method to serialize a registry entry's property table. | |
417 | @discussion This method will serialize a registry entry's property table, using the OSDictionary::serialize semantics. This method is synchronized with other IORegistryEntry accesses to the property table. Many non-kernel clients of IOKit read information from the registry via properties, and will invoke this method in a registry entry to create a serialization of all the entry's properties, which is then reconstructed in the client's task as a CFDictionary. This method may be intercepted by subclasses to update their properties or implement a different serialization method, though it is usually better to implement such functionality by creating objects in the property table and implementing their serialize methods, avoiding any need to implement serializeProperties. | |
418 | @param serialize The OSSerialize instance representing the serialization request. | |
419 | @result True on success, false otherwise. */ | |
420 | ||
421 | virtual bool serializeProperties( OSSerialize * serialize ) const; | |
422 | ||
423 | /* Unsynchronized(!) property table access */ | |
424 | ||
425 | /*! @function getPropertyTable | |
426 | @abstract Unsynchronized accessor to a registry entry's property table. | |
427 | @discussion This method will return a pointer to the live property table as an OSDictionery. Its use is not recommended in most cases, instead use the synchronized accessors and helper functions of IORegistryEntry to access properties. It can only safely be used by one thread, which usually means it can only be used before a registry entry is entered into the registry. | |
428 | @result A pointer to the property table as an OSDictionary. The pointer is valid while the registry entry is retained, and should not be released by the caller. */ | |
429 | ||
9bccf70c A |
430 | /* inline */ OSDictionary * getPropertyTable( void ) const; |
431 | /* { return(fPropertyTable); } */ | |
1c79356b A |
432 | |
433 | /* Set properties from user level, to be overridden if supported */ | |
434 | ||
435 | /*! @function setProperties | |
436 | @abstract Optionally supported external method to set properties in a registry entry. | |
437 | @discussion This method is not implemented by IORegistryEntry, but is available to kernel and non-kernel clients to set properties in a registry entry. IOUserClient provides connection based, more controlled access to this functionality and may be more appropriate for many uses, since there is no differentiation between clients available to this method. | |
438 | @param properties Any OSObject subclass, to be interpreted by the implementing method - for example an OSDictionary, OSData etc. may all be appropriate. | |
439 | @result An IOReturn code to be returned to the caller. */ | |
440 | ||
441 | virtual IOReturn setProperties( OSObject * properties ); | |
442 | ||
443 | /* Topology */ | |
444 | ||
445 | /*! @function getParentIterator | |
446 | @abstract Returns an iterator over an registry entry's parent entries in a specified plane. | |
447 | @param plane The plane object. | |
448 | @result Returns an iterator over the parents of the registry entry, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, though they may no longer be attached during the iteration. */ | |
449 | ||
450 | virtual OSIterator * getParentIterator( const IORegistryPlane * plane ) | |
451 | const; | |
452 | virtual void applyToParents( IORegistryEntryApplierFunction applier, | |
453 | void * context, | |
454 | const IORegistryPlane * plane ) const; | |
455 | ||
456 | /*! @function getParentEntry | |
457 | @abstract Returns an registry entry's first parent entry in a plane. | |
458 | @discussion This function will return the parent to which a registry entry was first attached. Since the majority of registry entrys have only one provider, this is a useful simplification. | |
459 | @param plane The plane object. | |
460 | @result Returns the first parent of the registry entry, or zero if the entry is not attached into the registry in that plane. The parent is retained while the entry is attached, and should not be released by the caller. */ | |
461 | ||
0b4e3aa0 | 462 | virtual IORegistryEntry * getParentEntry( const IORegistryPlane * plane ) const; |
1c79356b A |
463 | |
464 | /*! @function getChildIterator | |
465 | @abstract Returns an iterator over an registry entry's child entries in a plane. | |
466 | @discussion This method creates an iterator which will return each of a registry entry's child entries in a specified plane. | |
467 | @param plane The plane object. | |
468 | @result Returns an iterator over the children of the entry, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, though they may no longer be attached during the iteration. */ | |
469 | ||
470 | virtual OSIterator * getChildIterator( const IORegistryPlane * plane ) | |
471 | const; | |
472 | ||
473 | virtual void applyToChildren( IORegistryEntryApplierFunction applier, | |
474 | void * context, | |
475 | const IORegistryPlane * plane ) const; | |
476 | ||
477 | /*! @function getChildEntry | |
478 | @abstract Returns an registry entry's first child entry in a plane. | |
479 | @discussion This function will return the child which first attached to a registry entry. | |
480 | @param plane The plane object. | |
481 | @result Returns the first child of the registry entry, or zero if the entry is not attached into the registry in that plane. The child is retained while the entry is attached, and should not be released by the caller. */ | |
482 | ||
0b4e3aa0 | 483 | virtual IORegistryEntry * getChildEntry( const IORegistryPlane * plane ) const; |
1c79356b A |
484 | |
485 | /*! @function isChild | |
486 | @abstract Determines whether a registry entry is the child of another in a plane. | |
487 | @discussion This method called in the parent entry determines if the specified entry is a child, in a plane. Additionally, it can check if the child is the only child of the parent entry. | |
488 | @param child The possible child registry entry. | |
489 | @param plane The plane object. | |
490 | @param onlyChild If true, check also if the child is the only child. | |
491 | @result If the child argument is not a child of the registry entry, false is returned. If onlyChild is true and the child is not the only child of the entry, false is returned, otherwise true is returned. */ | |
492 | ||
493 | virtual bool isChild( IORegistryEntry * child, | |
494 | const IORegistryPlane * plane, | |
495 | bool onlyChild = false ) const; | |
496 | ||
497 | /*! @function isParent | |
498 | @abstract Determines whether a registry entry is the parent of another in a plane. | |
499 | @discussion This method called in the child entry determines if the specified entry is a parent, in a plane. Additionally, it can check if the parent is the only parent of the child entry. | |
500 | @param parent The possible parent registry entry. | |
501 | @param plane The plane object. | |
502 | @param onlyParent If true, check also if the parent is the only parent. | |
503 | @result If the parent argument is not a parent of the registry entry, false is returned. If onlyParent is true and the parent is not the only parent of the entry, false is returned, otherwise true is returned. */ | |
504 | ||
505 | virtual bool isParent( IORegistryEntry * parent, | |
506 | const IORegistryPlane * plane, | |
507 | bool onlyParent = false ) const; | |
508 | ||
509 | /*! @function inPlane | |
510 | @abstract Determines whether a registry entry is attached in a plane. | |
511 | @discussion This method determines if the entry is attached in a plane to any other entry. | |
512 | @param plane The plane object. | |
513 | @result If the entry has a parent in the plane, true is returned, otherwise false is returned. */ | |
514 | ||
515 | virtual bool inPlane( const IORegistryPlane * plane ) const; | |
516 | ||
517 | /*! @function getDepth | |
518 | @abstract Counts the maximum number of entries between an entry and the registry root, in a plane. | |
519 | @discussion This method counts the number of entries between and entry and the registry root, in a plane, for each parent of the entry and returns the maximum value. | |
520 | @param plane The plane object. | |
521 | @result The maximum number of entries between the entry and the root. Zero is returned if the entry is not attached in the plane. */ | |
522 | ||
523 | virtual unsigned int getDepth( const IORegistryPlane * plane ) const; | |
524 | ||
525 | /* Attach / detach */ | |
526 | ||
527 | /*! @function attachToParent | |
528 | @abstract Attaches a entry to a parent entry in a plane. | |
529 | @discussion This is the usual method of entering an entry into the registry. It is a no-op and success if the entry is already attached to the parent. Attaching the entry into the registry retains both the child and parent while they are attached. This method will call attachToChild in the parent entry if it is not being called from attachToChild. | |
530 | @param parent The registry entry to attach to. | |
531 | @param plane The plane object. | |
532 | @result true on success, or false on a resource failure, or if the parent is the same as the child. */ | |
533 | ||
534 | virtual bool attachToParent( IORegistryEntry * parent, | |
535 | const IORegistryPlane * plane ); | |
536 | ||
537 | /*! @function detachFromParent | |
538 | @abstract Detaches an entry from a parent entry in a plane. | |
539 | @discussion This is the usual method of removing an entry from the registry. It is a no-op if the entry is not attached to the parent. Detaching the entry will release both the child and parent. This method will call detachFromChild in the parent entry if it is not being called from detachFromChild. | |
540 | @param parent The registry entry to detach from. | |
541 | @param plane The plane object. */ | |
542 | ||
543 | virtual void detachFromParent( IORegistryEntry * parent, | |
544 | const IORegistryPlane * plane ); | |
545 | ||
546 | /*! @function attachToChild | |
547 | @abstract Method called in the parent entry when a child attaches. | |
548 | @discussion This method is called in the parent entry when a child attaches, to make overrides possible. This method will also call attachToParent in the child entry if it is not being called from attachToParent. It is a no-op and success if the entry is already a child. Attaching the entry into the registry retains both the child and parent while they are attached. | |
549 | @param child The registry entry being attached. | |
550 | @param plane The plane object. | |
551 | @result true on success, or false on a resource failure, or if the parent is the same as the child. */ | |
552 | ||
553 | virtual bool attachToChild( IORegistryEntry * child, | |
554 | const IORegistryPlane * plane ); | |
555 | ||
556 | /*! @function detachFromChild | |
557 | @abstract Detaches a child entry from its parent in a plane. | |
558 | @discussion This method is called in the parent entry when a child detaches, to make overrides possible. It is a no-op if the entry is not a child of the parent. Detaching the entry will release both the child and parent. This method will call detachFromParent in the child entry if it is not being called from detachFromParent. | |
559 | @param parent The registry entry to detach. | |
560 | @param plane The plane object. */ | |
561 | ||
562 | virtual void detachFromChild( IORegistryEntry * child, | |
563 | const IORegistryPlane * plane ); | |
564 | ||
565 | /*! @function detachAbove | |
566 | @abstract Detaches an entry from all its parent entries in a plane. | |
567 | @discussion This method calls detachFromParent in the entry for each of its parent entries in the plane. | |
568 | @param plane The plane object. */ | |
569 | ||
570 | virtual void detachAbove( const IORegistryPlane * plane ); | |
571 | ||
572 | /*! @function detachAll | |
573 | @abstract Detaches an entry and all its children recursively in a plane. | |
574 | @discussion This method breaks the registry connections for a subtree. detachAbove is called in the entry, and all child entries and their children in the plane. | |
575 | @param plane The plane object. */ | |
576 | ||
577 | virtual void detachAll( const IORegistryPlane * plane ); | |
578 | ||
579 | /* Name, location and path accessors */ | |
580 | ||
581 | /*! @function getName | |
582 | @abstract Returns the name assigned to the registry entry as a C-string. | |
583 | @discussion Entries can be named in a particular plane, or globally. If the entry is named in plane and the plane is specified that name will be returned, otherwise the global name is returned. The global name defaults to the entry's meta class name if it has not been named. | |
584 | @param plane The plane object, or zero for the global name. | |
585 | @result A C-string name, valid while the entry is retained. */ | |
586 | ||
587 | virtual const char * getName( const IORegistryPlane * plane = 0 ) const; | |
588 | ||
589 | /*! @function copyName | |
590 | @abstract Returns the name assigned to the registry entry as an OSSymbol. | |
591 | @discussion Entries can be named in a particular plane, or globally. If the entry is named in plane and the plane is specified that name will be returned, otherwise the global name is returned. The global name defaults to the entry's meta class name if it has not been named. | |
592 | @param plane The plane object, or zero for the global name. | |
593 | @result A reference to an OSSymbol for the name, which should be released by the caller. */ | |
594 | ||
595 | virtual const OSSymbol * copyName( | |
596 | const IORegistryPlane * plane = 0 ) const; | |
597 | ||
598 | /*! @function compareNames | |
599 | @abstract Compares the name of the entry with one or more names, and optionally returns the matching name. | |
600 | @discussion This method is called during IOService name matching and elsewhere to compare the entry's global name with a list of names, or a single name. A list of names may be passed as any OSCollection of OSStrings, while a single name may be passed an OSString, in the name parameter. compareNames will call the compareName method for each name, for overrides. | |
601 | @param name The name or names to compare with as any OSCollection (eg. OSArray, OSSet, OSDictionary) of OSStrings, or a single name may be passed an OSString. | |
602 | @param matched If the caller wants the successfully matched name returned, pass a non-zero pointer for the matched parameter and an OSString will be returned here. It should be released by the caller. | |
603 | @result True if one of the names compared true with the entry's global name. */ | |
604 | ||
605 | virtual bool compareNames( OSObject * name, OSString ** matched = 0 ) const; | |
606 | ||
607 | /*! @function compareName | |
608 | @abstract Compares the name of the entry with one name, and optionally returns the matching name. | |
609 | @discussion This method is called during IOService name matching and elsewhere from the compareNames method. It should be overridden to provide non-standard name matching. | |
610 | @param name The name to compare with as an OSString. | |
611 | @param matched If the caller wants the successfully matched name returned, pass a non-zero pointer for the matched parameter and an OSString will be returned here. It should be released by the caller. Generally, this will be the same as the name parameter, but may not be if wildcards are used. | |
612 | @result True if the name compared true with the entry's global name. */ | |
613 | ||
614 | virtual bool compareName( OSString * name, OSString ** matched = 0 ) const; | |
615 | ||
616 | /*! @function setName | |
617 | @abstract Sets a name for the registry entry, in a particular plane, or globally. | |
618 | @discussion Entries can be named in a particular plane, or globally. If the plane is specified the name applies only to that plane, otherwise the global name is set. The global name defaults to the entry's meta class name if it has not been named. | |
619 | @param name An OSSymbol which will be retained. | |
620 | @param plane The plane object, or zero to set the global name. */ | |
621 | ||
622 | virtual void setName( const OSSymbol * name, | |
623 | const IORegistryPlane * plane = 0 ); | |
624 | ||
625 | /*! @function setName | |
626 | @abstract Sets a name for the registry entry, in a particular plane, or globally. | |
627 | @discussion Entries can be named in a particular plane, or globally. If the plane is specified the name applies only to that plane, otherwise the global name is set. The global name defaults to the entry's meta class name if it has not been named. | |
628 | @param name A const C-string name which will be copied. | |
629 | @param plane The plane object, or zero to set the global name. */ | |
630 | ||
631 | virtual void setName( const char * name, | |
632 | const IORegistryPlane * plane = 0 ); | |
633 | ||
634 | /*! @function getLocation | |
635 | @abstract Returns the location string assigned to the registry entry as a C-string. | |
636 | @discussion Entries can given a location string in a particular plane, or globally. If the entry has had a location set in a plane and the plane is specified that location string will be returned, otherwise the global location string is returned. If no global location string has been set, zero is returned. | |
637 | @param plane The plane object, or zero for the global name. | |
638 | @result A C-string location string, valid while the entry is retained, or zero. */ | |
639 | ||
640 | virtual const char * getLocation( const IORegistryPlane * plane = 0 ) const; | |
641 | ||
642 | /*! @function copyLocation | |
643 | @abstract Returns the location string assigned to the registry entry as an OSSymbol. | |
644 | @discussion Entries can given a location string in a particular plane, or globally. If the entry has had a location set in a plane and the plane is specified that location string will be returned, otherwise the global location string is returned. If no global location string has been set, zero is returned. | |
645 | @param plane The plane object, or zero for the global name. | |
646 | @result A reference to an OSSymbol for the location if one exists, which should be released by the caller, or zero. */ | |
647 | ||
648 | virtual const OSSymbol * copyLocation( | |
649 | const IORegistryPlane * plane = 0 ) const; | |
650 | ||
651 | /*! @function setLocation | |
652 | @abstract Sets a location string for the registry entry, in a particular plane, or globally. | |
653 | @discussion Entries can be given a location string in a particular plane, or globally. If the plane is specified the location applies only to that plane, otherwise the global location is set. The location string may be used during path lookups of registry entries, to distinguish between sibling entries with the same name. The default IORegistryEntry parsing of location strings expects a list of hex numbers separated by commas, though subclasses of IORegistryEntry might do their own parsing. | |
654 | @param location A C-string location string which will be copied, or an OSSymbol which will be retained. | |
655 | @param plane The plane object, or zero to set the global location string. */ | |
656 | ||
657 | virtual void setLocation( const OSSymbol * location, | |
658 | const IORegistryPlane * plane = 0 ); | |
659 | virtual void setLocation( const char * location, | |
660 | const IORegistryPlane * plane = 0 ); | |
661 | ||
662 | /*! @function getPath | |
663 | @abstract Create a path for a registry entry. | |
664 | @discussion The path for a registry entry is copied to the caller's buffer. The path describes the entry's attachment in a particular plane, which must be specified. The path begins with the plane name followed by a colon, and then followed by '/' separated path components for each of the entries between the root and the registry entry. Each component is constructed with the getPathComponent method called in each entry. An alias may also exist for the entry, which are described as properties in a registry entry found at /aliases in the plane. If a property value interpreted as a path in a call to IORegistryEntry::fromPath yields the entry, then the property name is used as the entry's path. | |
665 | @param path A char buffer allocated by the caller. | |
666 | @param length An in/out parameter - the caller sets the length of the buffer available, and getPath returns the total length of the path copied to the buffer. | |
667 | @param plane The plane object. | |
668 | @result getPath will fail if the entry is not attached in the plane, or if the buffer is not large enough to contain the path. */ | |
669 | ||
670 | virtual bool getPath( char * path, int * length, | |
671 | const IORegistryPlane * plane) const; | |
672 | ||
673 | /*! @function getPathComponent | |
674 | @abstract Create a path component for a registry entry. | |
675 | @discussion Each component of a path created with getPath is created with getPathComponent. The default implementation concatenates the entry's name in the the plane, with the "at" symbol and the location string of the entry in the plane if it has been set. | |
676 | @param path A char buffer allocated by the caller. | |
677 | @param length An in/out parameter - the caller sets the length of the buffer available, and getPathComponent returns the total length of the path component copied to the buffer. | |
678 | @param plane The plane object. | |
679 | @result true if the path fits into the supplied buffer or false on a overflow. */ | |
680 | ||
681 | virtual bool getPathComponent( char * path, int * length, | |
682 | const IORegistryPlane * plane ) const; | |
683 | ||
684 | /*! @function fromPath | |
685 | @abstract Looks up a registry entry by path. | |
686 | @discussion This function parses paths to lookup registry entries. The path may begin with the <plane name>: created by getPath, or the plane may be set by the caller. If there are characters remaining unparsed after an entry has been looked up, this may be considered an invalid lookup, or those characters may be passed back to the caller and the lookup successful. | |
687 | @param path A C-string path. | |
688 | @param plane The plane to lookup up the path, or zero, in which case the path must begin with the plane name. | |
689 | @param residualPath If the path may contain residual characters after the last path component, the residual will be copied back to the caller's residualPath buffer. If there are residual characters and no residual buffer is specified, fromPath will fail. | |
690 | @param residualLength An in/out parameter - the caller sets the length of the residual buffer available, and fromPath returns the total length of the residual path copied to the buffer. If there is no residualBuffer (residualPath = 0) then residualLength may be zero also. | |
691 | @param fromEntry The lookup will proceed rooted at this entry if non-zero, otherwise it proceeds from the root of the plane. | |
692 | @result A retained registry entry is returned on success, or zero on failure. The caller should release the entry. */ | |
693 | ||
694 | static IORegistryEntry * fromPath( const char * path, | |
695 | const IORegistryPlane * plane = 0, | |
696 | char * residualPath = 0, | |
697 | int * residualLength = 0, | |
698 | IORegistryEntry * fromEntry = 0 ); | |
699 | ||
700 | /*! @function fromPath | |
701 | @abstract Looks up a registry entry by relative path. | |
702 | @discussion This function looks up a entry below the called entry by a relative path. It is just a convenience that calls IORegistryEntry::fromPath with this as the fromEntry parameter. | |
703 | @param path See IORegistryEntry::fromPath. | |
704 | @param plane See IORegistryEntry::fromPath. | |
705 | @param residualPath See IORegistryEntry::fromPath. | |
706 | @param residualLength See IORegistryEntry::fromPath. | |
707 | @result See IORegistryEntry::fromPath. */ | |
708 | ||
709 | virtual IORegistryEntry * childFromPath( const char * path, | |
710 | const IORegistryPlane * plane = 0, | |
711 | char * residualPath = 0, | |
712 | int * residualLength = 0 ); | |
713 | ||
714 | /*! @function dealiasPath | |
715 | @abstract Strips any aliases from the head of path and returns the full path. | |
716 | @discussion If the path specified begins with an alias found in the /aliases entry, the value of the alias is returned, and a pointer into the passed in path after the alias is passed back to the caller. If an alias is not found, zero is returned and the path parameter is unchanged. | |
717 | @param opath An in/out paramter - the caller passes in a pointer to a C-string pointer to a path. If an alias is found, dealiasPath returns a pointer into the path just beyond the end of the alias. | |
718 | @param plane A plane object must be specified. | |
719 | @result A C-string pointer to the value of the alias if one is found, or zero if not. */ | |
720 | ||
721 | static const char * dealiasPath( const char ** opath, | |
722 | const IORegistryPlane * plane ); | |
723 | ||
724 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
725 | /* * * * * * * * * * * * internals * * * * * * * * * * * */ | |
726 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
727 | ||
728 | public: | |
729 | static IORegistryEntry * initialize( void ); | |
730 | static const IORegistryPlane * makePlane( const char * name ); | |
731 | // don't even think about using this | |
732 | virtual bool init( IORegistryEntry * from, | |
733 | const IORegistryPlane * inPlane ); | |
734 | private: | |
735 | inline bool arrayMember( OSArray * set, | |
736 | const IORegistryEntry * member, | |
737 | unsigned int * index = 0 ) const; | |
738 | ||
739 | bool makeLink( IORegistryEntry * to, | |
740 | unsigned int relation, | |
741 | const IORegistryPlane * plane ) const; | |
742 | void breakLink( IORegistryEntry * to, | |
743 | unsigned int relation, | |
744 | const IORegistryPlane * plane ) const; | |
745 | ||
746 | virtual OSArray * getParentSetReference( const IORegistryPlane * plane ) | |
747 | const; | |
748 | virtual OSArray * getChildSetReference( const IORegistryPlane * plane ) | |
749 | const; | |
750 | virtual IORegistryEntry * getChildFromComponent( const char ** path, | |
751 | const IORegistryPlane * plane ); | |
752 | ||
753 | virtual const OSSymbol * hasAlias( const IORegistryPlane * plane, | |
754 | char * opath = 0, int * length = 0 ) const; | |
755 | virtual const char * matchPathLocation( const char * cmp, | |
756 | const IORegistryPlane * plane ); | |
757 | ||
758 | }; | |
759 | ||
760 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
761 | ||
762 | /*! @class IORegistryIterator : public OSIterator | |
763 | @abstract An iterator over the registry. | |
764 | @discussion An iterator that can traverse the children or parents of a registry entry in a plane, and recurse. Access to the registry is protected against multiple threads, but an IORegistryIterator instance is for use by one thread only. */ | |
765 | ||
766 | class IORegistryIterator : public OSIterator | |
767 | { | |
768 | OSDeclareAbstractStructors(IORegistryIterator) | |
769 | ||
770 | private: | |
771 | struct IORegCursor { | |
772 | IORegCursor * next; | |
773 | IORegistryEntry * current; | |
774 | OSIterator * iter; | |
775 | }; | |
776 | IORegCursor start; | |
777 | IORegCursor * where; | |
778 | IORegistryEntry * root; | |
779 | OSOrderedSet * done; | |
780 | const IORegistryPlane * plane; | |
781 | IOOptionBits options; | |
782 | ||
783 | virtual void free( void ); | |
784 | ||
785 | public: | |
786 | /*! @function iterateOver | |
787 | @abstract Create an iterator rooted at a given registry entry. | |
788 | @discussion This method creates an IORegistryIterator that is set up with options to iterate children or parents of a root entry, and to recurse automatically into entries as they are returned, or only when instructed. The iterator object keeps track of entries that have been recursed into previously to avoid loops. | |
789 | @param start The root entry to begin the iteration at. | |
790 | @param plane A plane object must be specified. | |
791 | @param options kIORegistryIterateRecursively may be set to recurse automatically into each entry as it is returned. This option affects the behaviour of the getNextObject method, which is defined in the OSIterator superclass. Other methods will override this behaviour. kIORegistryIterateParents may be set to iterate the parents of each entry, by default the children are iterated. | |
792 | @result A created IORegistryIterator instance, to be released by the caller when it has finished with it. */ | |
793 | ||
794 | static IORegistryIterator * iterateOver( IORegistryEntry * start, | |
795 | const IORegistryPlane * plane, | |
796 | IOOptionBits options = 0 ); | |
797 | ||
798 | /*! @function iterateOver | |
799 | @abstract Create an iterator rooted at the registry root. | |
800 | @discussion This method creates an IORegistryIterator that is set up with options to iterate children of the registry root entry, and to recurse automatically into entries as they are returned, or only when instructed. The iterator object keeps track of entries that have been recursed into previously to avoid loops. | |
801 | @param plane A plane object must be specified. | |
802 | @param options kIORegistryIterateRecursively may be set to recurse automatically into each entry as it is returned. This option affects the behaviour of the getNextObject method, which is defined in the OSIterator superclass. Other methods will override this behaviour. kIORegistryIterateParents may be set to iterate the parents of each entry, by default the children are iterated. | |
803 | @result A created IORegistryIterator instance, to be released by the caller when it has finished with it. */ | |
804 | ||
805 | static IORegistryIterator * iterateOver( const IORegistryPlane * plane, | |
806 | IOOptionBits options = 0 ); | |
807 | ||
808 | /*! @function getNextObject | |
809 | @abstract Return the next object in the registry iteration. | |
810 | @discussion This method calls either getNextObjectFlat or getNextObjectRecursive depending on the options the iterator was created with. This implements the OSIterator defined getNextObject method. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. | |
811 | @result The next registry entry in the iteration (the current entry), or zero if the iteration has finished at this level of recursion. The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */ | |
812 | ||
813 | virtual IORegistryEntry * getNextObject( void ); | |
814 | ||
815 | /*! @function getNextObjectFlat | |
816 | @abstract Return the next object in the registry iteration, ignoring the kIORegistryIterateRecursively option. | |
817 | @discussion This method returns the next child, or parent if the kIORegistryIterateParents option was used to create the iterator, of the current root entry. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. | |
818 | @result The next registry entry in the iteration (the current entry), or zero if the iteration has finished at this level of recursion, or the iteration is invalid (see isValid). The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */ | |
819 | ||
820 | virtual IORegistryEntry * getNextObjectFlat( void ); | |
821 | ||
822 | /*! @function getNextObjectRecursive | |
823 | @abstract Return the next object in the registry iteration, and enter it. | |
824 | @discussion If the iterator has a current entry, and the iterator has not already entered previously, enterEntry is called to recurse into it, ie. make it the new root, and the next child, or parent if the kIORegistryIterateParents option was used to create the iterator, at this new level of recursion is returned. If there is no current entry at this level of recursion, exitEntry is called and the process repeats, until the iteration returns to the entry the iterator was created with and zero is returned. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. | |
825 | @result The next registry entry in the iteration (the current entry), or zero if its finished, or the iteration is invalid (see isValid). The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */ | |
826 | ||
827 | virtual IORegistryEntry * getNextObjectRecursive( void ); | |
828 | ||
829 | /*! @function getCurrentEntry | |
830 | @abstract Return the current entry in the registry iteration. | |
831 | @discussion This method returns the current entry, last returned by getNextObject et al. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. If the iteration is no longer valid (see isValid), the current entry is zero. | |
832 | @result The current registry entry in the iteration, or zero if the last iteration returned zero, or the iteration is invalid (see isValid). The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */ | |
833 | ||
834 | virtual IORegistryEntry * getCurrentEntry( void ); | |
835 | ||
836 | /*! @function enterEntry | |
837 | @abstract Recurse into the current entry in the registry iteration. | |
838 | @discussion This method makes the current entry, ie. the last entry returned by getNextObject et al., the root in a new level of recursion. */ | |
839 | ||
840 | virtual void enterEntry( void ); | |
841 | ||
842 | /*! @function enterEntry | |
843 | @abstract Recurse into the current entry in the registry iteration. | |
844 | @discussion This method recurses into an entry as with enterEntry, but also switches from the current plane to a new one set by the caller. | |
845 | @param plane The new plane to switch into. */ | |
846 | ||
847 | virtual void enterEntry( const IORegistryPlane * plane ); | |
848 | ||
849 | /*! @function exitEntry | |
850 | @abstract Exits a level of recursion, restoring the current entry. | |
851 | @discussion This method undoes an enterEntry, restoring the current entry. If there are no more levels of recursion to exit false is returned, otherwise true is returned. | |
852 | @result true if a level of recursion was undone, false if no recursive levels are left in the iteration. */ | |
853 | ||
854 | virtual bool exitEntry( void ); | |
855 | ||
856 | /*! @function reset | |
857 | @abstract Exits all levels of recursion, restoring the iterator to its state at creation. | |
858 | @discussion This method exits all levels of recursion, and restores the iterator to its state at creation. */ | |
859 | ||
860 | virtual void reset( void ); | |
861 | ||
862 | /*! @function isValid | |
863 | @abstract Checks that no registry changes have invalidated the iteration. | |
864 | @discussion If a registry iteration is invalidated by changes to the registry, it will be made invalid, the currentEntry will be considered zero, and further calls to getNextObject et al. will return zero. The iterator should be reset to restart the iteration when this happens. | |
865 | @result false if the iterator has been invalidated by changes to the registry, true otherwise. */ | |
866 | ||
867 | virtual bool isValid( void ); | |
868 | ||
869 | /*! @function iterateAll | |
870 | @abstract Iterates all entries (with getNextObject) and returns a set of all returned entries. | |
871 | @discussion This method will reset, then iterate all entries in the iteration (with getNextObject) until successful (ie. the iterator is valid at the end of the iteration). | |
872 | @result A set of entries returned by the iteration. The caller should release the set when it has finished with it. Zero is returned on a resource failure. */ | |
873 | ||
874 | virtual OSOrderedSet * iterateAll( void ); | |
875 | }; | |
876 | ||
877 | #endif /* _IOKIT_IOREGISTRYENTRY_H */ |