]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IORegistryEntry.h
xnu-6153.141.1.tar.gz
[apple/xnu.git] / iokit / IOKit / IORegistryEntry.h
CommitLineData
1c79356b 1/*
cb323159 2 * Copyright (c) 1998-2019 Apple Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
2d21ac55
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
0a7de745 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
2d21ac55
A
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
0a7de745 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
0a7de745 29 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
1c79356b
A
30 *
31 * HISTORY
32 *
33 */
34
35
36#ifndef _IOKIT_IOREGISTRYENTRY_H
37#define _IOKIT_IOREGISTRYENTRY_H
38
39#include <IOKit/IOTypes.h>
40#include <libkern/c++/OSContainers.h>
41
42
43extern const OSSymbol * gIONameKey;
44extern const OSSymbol * gIOLocationKey;
b0d623f7 45extern const OSSymbol * gIORegistryEntryIDKey;
39037602 46extern const OSSymbol * gIORegistryEntryPropertyKeysKey;
1c79356b
A
47
48class IORegistryEntry;
49class IORegistryPlane;
50class IORegistryIterator;
51
52typedef void (*IORegistryEntryApplierFunction)(IORegistryEntry * entry,
0a7de745 53 void * context);
1c79356b
A
54
55enum {
0a7de745
A
56 kIORegistryIterateRecursively = 0x00000001,
57 kIORegistryIterateParents = 0x00000002,
1c79356b
A
58};
59
d9a64523 60#ifdef KERNEL_PRIVATE
0a7de745 61enum{
d9a64523
A
62 kIORegistryEntryIndexedPropertyCLPC = 0,
63 kIORegistryEntryIndexedPropertyCount,
64};
65#endif /* KERNEL_PRIVATE */
66
1c79356b 67/*! @class IORegistryEntry : public OSObject
0a7de745
A
68 * @abstract The base class for all objects in the registry.
69 * @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.
70 */
1c79356b
A
71
72class IORegistryEntry : public OSObject
73{
0a7de745 74 friend class IORegistryIterator;
1c79356b 75
cb323159 76 OSDeclareDefaultStructors(IORegistryEntry);
1c79356b
A
77
78protected:
79/*! @struct ExpansionData
0a7de745
A
80 * @discussion This structure will be used to expand the capablilties of this class in the future.
81 */
82 struct ExpansionData;
1c79356b
A
83
84/*! @var reserved
0a7de745
A
85 * Reserved for future use. (Internal use only) */
86 ExpansionData * reserved;
1c79356b
A
87
88private:
89
0a7de745
A
90 OSDictionary * fRegistryTable;
91 OSDictionary * fPropertyTable;
1c79356b 92
0b4e3aa0 93public:
0a7de745 94/* methods available in Mac OS X 10.1 or later */
0b4e3aa0
A
95
96/*! @function copyProperty
0a7de745
A
97 * @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.
98 * @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).
99 * @param aKey The property's name as a C-string.
100 * @param plane The plane to iterate over, eg. gIOServicePlane.
101 * @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.
102 * @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */
103
104 virtual OSObject * copyProperty( const char * aKey,
105 const IORegistryPlane * plane,
106 IOOptionBits options =
107 kIORegistryIterateRecursively |
108 kIORegistryIterateParents) const;
91447636 109
0b4e3aa0 110/*! @function copyProperty
0a7de745
A
111 * @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.
112 * @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).
113 * @param aKey The property's name as an OSString.
114 * @param plane The plane to iterate over, eg. gIOServicePlane.
115 * @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.
116 * @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */
117
118 virtual OSObject * copyProperty( const OSString * aKey,
119 const IORegistryPlane * plane,
120 IOOptionBits options =
121 kIORegistryIterateRecursively |
122 kIORegistryIterateParents) const;
0b4e3aa0
A
123
124/*! @function copyProperty
0a7de745
A
125 * @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.
126 * @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).
127 * @param aKey The property's name as an OSSymbol.
128 * @param plane The plane to iterate over, eg. gIOServicePlane.
129 * @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.
130 * @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */
131
132 virtual OSObject * copyProperty( const OSSymbol * aKey,
133 const IORegistryPlane * plane,
134 IOOptionBits options =
135 kIORegistryIterateRecursively |
136 kIORegistryIterateParents) const;
0b4e3aa0
A
137
138/*! @function copyParentEntry
0a7de745
A
139 * @abstract Returns an registry entry's first parent entry in a plane. Available in Mac OS X 10.1 or later.
140 * @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.
141 * @param plane The plane object.
142 * @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. */
0b4e3aa0 143
0a7de745 144 virtual IORegistryEntry * copyParentEntry( const IORegistryPlane * plane ) const;
0b4e3aa0
A
145
146/*! @function copyChildEntry
0a7de745
A
147 * @abstract Returns an registry entry's first child entry in a plane. Available in Mac OS X 10.1 or later.
148 * @discussion This function will return the child which first attached to a registry entry.
149 * @param plane The plane object.
150 * @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. */
0b4e3aa0 151
0a7de745 152 virtual IORegistryEntry * copyChildEntry( const IORegistryPlane * plane ) const;
0b4e3aa0 153
0a7de745 154/* method available in Mac OS X 10.4 or later */
91447636 155/*!
0a7de745
A
156 * @typedef Action
157 * @discussion Type and arguments of callout C function that is used when
158 * a runCommand is executed by a client. Cast to this type when you want a C++
159 * member function to be used. Note the arg1 - arg3 parameters are passed straight pass through to the action callout.
160 * @param target
161 * Target of the function, can be used as a refcon. Note if a C++ function
162 * was specified, this parameter is implicitly the first parameter in the target
163 * member function's parameter list.
164 * @param arg0 Argument to action from run operation.
165 * @param arg1 Argument to action from run operation.
166 * @param arg2 Argument to action from run operation.
167 * @param arg3 Argument to action from run operation.
168 */
169 typedef IOReturn (*Action)(OSObject *target,
170 void *arg0, void *arg1,
171 void *arg2, void *arg3);
91447636
A
172
173/*! @function runPropertyAction
0a7de745
A
174 * @abstract Single thread a call to an action w.r.t. the property lock
175 * @discussion Client function that causes the given action to be called in a manner that syncrhonises with the registry iterators and serialisers. This functin can be used to synchronously manipulate the property table of this nub
176 * @param action Pointer to function to be executed in work-loop context.
177 * @param arg0 Parameter for action parameter, defaults to 0.
178 * @param arg1 Parameter for action parameter, defaults to 0.
179 * @param arg2 Parameter for action parameter, defaults to 0.
180 * @param arg3 Parameter for action parameter, defaults to 0.
181 * @result Returns the value of the Action callout.
182 */
183 virtual IOReturn runPropertyAction(Action action, OSObject *target,
cb323159
A
184 void *arg0 = NULL, void *arg1 = NULL,
185 void *arg2 = NULL, void *arg3 = NULL);
0b4e3aa0 186
ea3f0419
A
187#ifdef __BLOCKS__
188 typedef IOReturn (^ActionBlock)(void);
189 IOReturn runPropertyActionBlock(ActionBlock block);
190#endif /* __BLOCKS__ */
191
91447636 192private:
b0d623f7 193#if __LP64__
0a7de745
A
194 OSMetaClassDeclareReservedUnused(IORegistryEntry, 0);
195 OSMetaClassDeclareReservedUnused(IORegistryEntry, 1);
196 OSMetaClassDeclareReservedUnused(IORegistryEntry, 2);
197 OSMetaClassDeclareReservedUnused(IORegistryEntry, 3);
198 OSMetaClassDeclareReservedUnused(IORegistryEntry, 4);
199 OSMetaClassDeclareReservedUnused(IORegistryEntry, 5);
b0d623f7 200#else
0a7de745
A
201 OSMetaClassDeclareReservedUsed(IORegistryEntry, 0);
202 OSMetaClassDeclareReservedUsed(IORegistryEntry, 1);
203 OSMetaClassDeclareReservedUsed(IORegistryEntry, 2);
204 OSMetaClassDeclareReservedUsed(IORegistryEntry, 3);
205 OSMetaClassDeclareReservedUsed(IORegistryEntry, 4);
206 OSMetaClassDeclareReservedUsed(IORegistryEntry, 5);
b0d623f7 207#endif
0a7de745
A
208 OSMetaClassDeclareReservedUnused(IORegistryEntry, 6);
209 OSMetaClassDeclareReservedUnused(IORegistryEntry, 7);
210 OSMetaClassDeclareReservedUnused(IORegistryEntry, 8);
211 OSMetaClassDeclareReservedUnused(IORegistryEntry, 9);
212 OSMetaClassDeclareReservedUnused(IORegistryEntry, 10);
213 OSMetaClassDeclareReservedUnused(IORegistryEntry, 11);
214 OSMetaClassDeclareReservedUnused(IORegistryEntry, 12);
215 OSMetaClassDeclareReservedUnused(IORegistryEntry, 13);
216 OSMetaClassDeclareReservedUnused(IORegistryEntry, 14);
217 OSMetaClassDeclareReservedUnused(IORegistryEntry, 15);
218 OSMetaClassDeclareReservedUnused(IORegistryEntry, 16);
219 OSMetaClassDeclareReservedUnused(IORegistryEntry, 17);
220 OSMetaClassDeclareReservedUnused(IORegistryEntry, 18);
221 OSMetaClassDeclareReservedUnused(IORegistryEntry, 19);
222 OSMetaClassDeclareReservedUnused(IORegistryEntry, 20);
223 OSMetaClassDeclareReservedUnused(IORegistryEntry, 21);
224 OSMetaClassDeclareReservedUnused(IORegistryEntry, 22);
225 OSMetaClassDeclareReservedUnused(IORegistryEntry, 23);
226 OSMetaClassDeclareReservedUnused(IORegistryEntry, 24);
227 OSMetaClassDeclareReservedUnused(IORegistryEntry, 25);
228 OSMetaClassDeclareReservedUnused(IORegistryEntry, 26);
229 OSMetaClassDeclareReservedUnused(IORegistryEntry, 27);
230 OSMetaClassDeclareReservedUnused(IORegistryEntry, 28);
231 OSMetaClassDeclareReservedUnused(IORegistryEntry, 29);
232 OSMetaClassDeclareReservedUnused(IORegistryEntry, 30);
233 OSMetaClassDeclareReservedUnused(IORegistryEntry, 31);
1c79356b
A
234
235public:
236
0a7de745 237/* Registry accessors */
1c79356b
A
238
239/*! @function getRegistryRoot
0a7de745
A
240 * @abstract Returns a pointer to the root instance of the registry.
241 * @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.
242 * @result A pointer to the IORegistryEntry root instance. It should not be released by the caller. */
243
244 static IORegistryEntry * getRegistryRoot( void );
1c79356b 245
1c79356b 246/*! @function getGenerationCount
0a7de745
A
247 * @abstract Returns an generation count for all registry changing operations.
248 * @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.
249 * @result An integer generation count. */
1c79356b 250
0a7de745 251 static SInt32 getGenerationCount( void );
1c79356b
A
252
253/*! @function getPlane
0a7de745
A
254 * @abstract Looks up the plane object by a C-string name.
255 * @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.
256 * @result A pointer to the plane object, or zero if no such plane exists. The returned plane should not be released. */
1c79356b 257
0a7de745 258 static const IORegistryPlane * getPlane( const char * name );
1c79356b 259
0a7de745 260/* Registry Entry allocation & init */
1c79356b
A
261
262/*! @function init
0a7de745
A
263 * @abstract Standard init method for all IORegistryEntry subclasses.
264 * @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.
265 * @param dictionary 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.
266 * @result true on success, or false on a resource failure. */
1c79356b 267
cb323159 268 virtual bool init( OSDictionary * dictionary = NULL );
1c79356b
A
269
270/*! @function free
0a7de745
A
271 * @abstract Standard free method for all IORegistryEntry subclasses.
272 * @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. */
1c79356b 273
0a7de745 274 virtual void free( void ) APPLE_KEXT_OVERRIDE;
1c79356b
A
275
276/*! @function setPropertyTable
0a7de745
A
277 * @abstract Replace a registry entry's property table.
278 * @discussion This method will release the current property table of a the entry and replace it with another, retaining the new property table.
279 * @param dict The new dictionary to be used as the entry's property table. */
1c79356b 280
0a7de745 281 virtual void setPropertyTable( OSDictionary * dict );
1c79356b 282
0a7de745
A
283/* Synchronized property accessors; wrappers to OSDictionary
284 * plus property creation helpers */
1c79356b
A
285
286/*! @function setProperty
0a7de745
A
287 * @abstract Synchronized method to add a property to a registry entry's property table.
288 * @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.
289 * @param aKey The properties name as an OSSymbol.
290 * @param anObject The property value.
291 * @result true on success or false on a resource failure. */
1c79356b 292
0a7de745
A
293 virtual bool setProperty(const OSSymbol * aKey,
294 OSObject * anObject);
1c79356b 295
d9a64523 296#ifdef KERNEL_PRIVATE
0a7de745
A
297 OSObject * setIndexedProperty(uint32_t index, OSObject * anObject);
298 OSObject * getIndexedProperty(uint32_t index) const;
d9a64523
A
299#endif /* KERNEL_PRIVATE */
300
1c79356b 301/*! @function setProperty
0a7de745
A
302 * @abstract Synchronized method to add a property to a registry entry's property table.
303 * @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.
304 * @param aKey The property's name as an OSString.
305 * @param anObject The property value.
306 * @result true on success or false on a resource failure. */
1c79356b 307
0a7de745 308 virtual bool setProperty(const OSString * aKey, OSObject * anObject);
1c79356b
A
309
310/*! @function setProperty
0a7de745
A
311 * @abstract Synchronized method to add a property to a registry entry's property table.
312 * @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.
313 * @param aKey The property's name as a C-string.
314 * @param anObject The property value.
315 * @result true on success or false on a resource failure. */
1c79356b 316
0a7de745 317 virtual bool setProperty(const char * aKey, OSObject * anObject);
1c79356b
A
318
319/*! @function setProperty
0a7de745
A
320 * @abstract Synchronized method to construct and add a OSString property to a registry entry's property table.
321 * @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.
322 * @param aKey The property's name as a C-string.
323 * @param aString The property value as a C-string.
324 * @result true on success or false on a resource failure. */
1c79356b 325
0a7de745 326 virtual bool setProperty(const char * aKey, const char * aString);
1c79356b
A
327
328/*! @function setProperty
0a7de745
A
329 * @abstract Synchronized method to construct and add an OSBoolean property to a registry entry's property table.
330 * @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.
331 * @param aKey The property's name as a C-string.
332 * @param aBoolean The property's boolean value.
333 * @result true on success or false on a resource failure. */
1c79356b 334
0a7de745 335 virtual bool setProperty(const char * aKey, bool aBoolean);
1c79356b
A
336
337/*! @function setProperty
0a7de745
A
338 * @abstract Synchronized method to construct and add an OSNumber property to a registry entry's property table.
339 * @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.
340 * @param aKey The property's name as a C-string.
341 * @param aValue The property's numeric value.
342 * @param aNumberOfBits The property's size in bits, for OSNumber.
343 * @result true on success or false on a resource failure. */
1c79356b 344
0a7de745
A
345 virtual bool setProperty( const char * aKey,
346 unsigned long long aValue,
347 unsigned int aNumberOfBits);
1c79356b
A
348
349/*! @function setProperty
0a7de745
A
350 * @abstract Synchronized method to construct and add an OSData property to a registry entry's property table.
351 * @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 data and length, set in the property table with the given name, and released.
352 * @param aKey The property's name as a C-string.
353 * @param bytes The property's value as a pointer. OSData will copy this data.
354 * @param length The property's size in bytes, for OSData.
355 * @result true on success or false on a resource failure. */
1c79356b 356
0a7de745
A
357 virtual bool setProperty( const char * aKey,
358 void * bytes,
359 unsigned int length);
1c79356b
A
360
361/*! @function removeProperty
0a7de745
A
362 * @abstract Synchronized method to remove a property from a registry entry's property table.
363 * @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.
364 * @param aKey The property's name as an OSSymbol. */
1c79356b 365
0a7de745 366 virtual void removeProperty( const OSSymbol * aKey);
1c79356b
A
367
368/*! @function removeProperty
0a7de745
A
369 * @abstract Synchronized method to remove a property from a registry entry's property table.
370 * @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.
371 * @param aKey The property's name as an OSString. */
1c79356b 372
0a7de745 373 virtual void removeProperty( const OSString * aKey);
1c79356b
A
374
375/*! @function removeProperty
0a7de745
A
376 * @abstract Synchronized method to remove a property from a registry entry's property table.
377 * @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.
378 * @param aKey The property's name as a C-string. */
1c79356b 379
0a7de745 380 virtual void removeProperty( const char * aKey);
1c79356b
A
381
382/*! @function getProperty
0a7de745
A
383 * @abstract Synchronized method to obtain a property from a registry entry's property table.
384 * @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.
385 * @param aKey The property's name as an OSSymbol.
386 * @result The property value found, or zero. */
1c79356b 387
0a7de745 388 virtual OSObject * getProperty( const OSSymbol * aKey) const;
1c79356b
A
389
390/*! @function getProperty
0a7de745
A
391 * @abstract Synchronized method to obtain a property from a registry entry's property table.
392 * @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.
393 * @param aKey The property's name as an OSString.
394 * @result The property value found, or zero. */
1c79356b 395
0a7de745 396 virtual OSObject * getProperty( const OSString * aKey) const;
1c79356b
A
397
398/*! @function getProperty
0a7de745
A
399 * @abstract Synchronized method to obtain a property from a registry entry's property table.
400 * @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.
401 * @param aKey The property's name as a C-string.
402 * @result The property value found, or zero. */
1c79356b 403
0a7de745 404 virtual OSObject * getProperty( const char * aKey) const;
1c79356b
A
405
406/*! @function getProperty
0a7de745
A
407 * @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy.
408 * @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).
409 * @param aKey The property's name as an OSSymbol.
410 * @param plane The plane to iterate over, eg. gIOServicePlane.
411 * @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.
412 * @result The property value found, or zero. */
413
414 virtual OSObject * getProperty( const OSSymbol * aKey,
415 const IORegistryPlane * plane,
416 IOOptionBits options =
417 kIORegistryIterateRecursively |
418 kIORegistryIterateParents) const;
1c79356b
A
419
420/*! @function getProperty
0a7de745
A
421 * @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy.
422 * @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).
423 * @param aKey The property's name as an OSString.
424 * @param plane The plane to iterate over, eg. gIOServicePlane.
425 * @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.
426 * @result The property value found, or zero. */
427
428 virtual OSObject * getProperty( const OSString * aKey,
429 const IORegistryPlane * plane,
430 IOOptionBits options =
431 kIORegistryIterateRecursively |
432 kIORegistryIterateParents) const;
1c79356b
A
433
434/*! @function getProperty
0a7de745
A
435 * @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy.
436 * @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).
437 * @param aKey The property's name as a C-string.
438 * @param plane The plane to iterate over, eg. gIOServicePlane.
439 * @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.
440 * @result The property value found, or zero. */
441
442 virtual OSObject * getProperty( const char * aKey,
443 const IORegistryPlane * plane,
444 IOOptionBits options =
445 kIORegistryIterateRecursively |
446 kIORegistryIterateParents) const;
1c79356b
A
447
448/*! @function copyProperty
0a7de745
A
449 * @abstract Synchronized method to obtain a property from a registry entry's property table.
450 * @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.
451 * @param aKey The property's name as an OSSymbol.
452 * @result The property value found, or zero. It should be released by the caller. */
1c79356b 453
0a7de745 454 virtual OSObject * copyProperty( const OSSymbol * aKey) const;
1c79356b
A
455
456/*! @function copyProperty
0a7de745
A
457 * @abstract Synchronized method to obtain a property from a registry entry's property table.
458 * @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.
459 * @param aKey The property's name as an OSString.
460 * @result The property value found, or zero. It should be released by the caller. */
1c79356b 461
0a7de745 462 virtual OSObject * copyProperty( const OSString * aKey) const;
1c79356b
A
463
464/*! @function copyProperty
0a7de745
A
465 * @abstract Synchronized method to obtain a property from a registry entry's property table.
466 * @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.
467 * @param aKey The property's name as a C-string.
468 * @result The property value found, or zero. It should be released by the caller. */
1c79356b 469
0a7de745 470 virtual OSObject * copyProperty( const char * aKey) const;
1c79356b
A
471
472/*! @function dictionaryWithProperties
0a7de745
A
473 * @abstract Synchronized method to obtain copy a registry entry's property table.
474 * @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.
475 * @result The created dictionary, or zero on a resource value. It should be released by the caller. */
1c79356b 476
0a7de745 477 virtual OSDictionary * dictionaryWithProperties( void ) const;
1c79356b
A
478
479/*! @function serializeProperties
0a7de745
A
480 * @abstract Synchronized method to serialize a registry entry's property table.
481 * @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.
482 * @param serialize The OSSerialize instance representing the serialization request.
483 * @result True on success, false otherwise. */
1c79356b 484
0a7de745 485 virtual bool serializeProperties( OSSerialize * serialize ) const;
1c79356b 486
0a7de745 487/* Unsynchronized(!) property table access */
1c79356b
A
488
489/*! @function getPropertyTable
0a7de745
A
490 * @abstract Unsynchronized accessor to a registry entry's property table.
491 * @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.
492 * @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. */
1c79356b 493
0a7de745
A
494/* inline */ OSDictionary * getPropertyTable( void ) const;
495/* { return(fPropertyTable); } */
1c79356b 496
0a7de745 497/* Set properties from user level, to be overridden if supported */
1c79356b
A
498
499/*! @function setProperties
0a7de745
A
500 * @abstract Optionally supported external method to set properties in a registry entry.
501 * @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.
502 * @param properties Any OSObject subclass, to be interpreted by the implementing method - for example an OSDictionary, OSData etc. may all be appropriate.
503 * @result An IOReturn code to be returned to the caller. */
1c79356b 504
0a7de745 505 virtual IOReturn setProperties( OSObject * properties );
1c79356b 506
0a7de745 507/* Topology */
1c79356b
A
508
509/*! @function getParentIterator
0a7de745
A
510 * @abstract Returns an iterator over an registry entry's parent entries in a specified plane.
511 * @param plane The plane object.
512 * @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. */
1c79356b 513
0a7de745
A
514 virtual OSIterator * getParentIterator( const IORegistryPlane * plane )
515 const;
516 virtual void applyToParents( IORegistryEntryApplierFunction applier,
517 void * context,
518 const IORegistryPlane * plane ) const;
1c79356b
A
519
520/*! @function getParentEntry
0a7de745
A
521 * @abstract Returns an registry entry's first parent entry in a plane.
522 * @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.
523 * @param plane The plane object.
524 * @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. */
1c79356b 525
0a7de745 526 virtual IORegistryEntry * getParentEntry( const IORegistryPlane * plane ) const;
1c79356b
A
527
528/*! @function getChildIterator
0a7de745
A
529 * @abstract Returns an iterator over an registry entry's child entries in a plane.
530 * @discussion This method creates an iterator which will return each of a registry entry's child entries in a specified plane.
531 * @param plane The plane object.
532 * @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. */
1c79356b 533
0a7de745
A
534 virtual OSIterator * getChildIterator( const IORegistryPlane * plane )
535 const;
1c79356b 536
39037602 537#if XNU_KERNEL_PRIVATE
0a7de745
A
538 uint32_t getChildCount( const IORegistryPlane * plane ) const;
539 OSArray * copyPropertyKeys(void) const;
39037602
A
540#endif
541
0a7de745
A
542 virtual void applyToChildren( IORegistryEntryApplierFunction applier,
543 void * context,
544 const IORegistryPlane * plane ) const;
1c79356b
A
545
546/*! @function getChildEntry
0a7de745
A
547 * @abstract Returns an registry entry's first child entry in a plane.
548 * @discussion This function will return the child which first attached to a registry entry.
549 * @param plane The plane object.
550 * @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. */
1c79356b 551
0a7de745 552 virtual IORegistryEntry * getChildEntry( const IORegistryPlane * plane ) const;
1c79356b
A
553
554/*! @function isChild
0a7de745
A
555 * @abstract Determines whether a registry entry is the child of another in a plane.
556 * @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.
557 * @param child The possible child registry entry.
558 * @param plane The plane object.
559 * @param onlyChild If true, check also if the child is the only child.
560 * @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. */
1c79356b 561
0a7de745
A
562 virtual bool isChild( IORegistryEntry * child,
563 const IORegistryPlane * plane,
564 bool onlyChild = false ) const;
1c79356b
A
565
566/*! @function isParent
0a7de745
A
567 * @abstract Determines whether a registry entry is the parent of another in a plane.
568 * @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.
569 * @param parent The possible parent registry entry.
570 * @param plane The plane object.
571 * @param onlyParent If true, check also if the parent is the only parent.
572 * @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. */
1c79356b 573
0a7de745
A
574 virtual bool isParent( IORegistryEntry * parent,
575 const IORegistryPlane * plane,
576 bool onlyParent = false ) const;
1c79356b
A
577
578/*! @function inPlane
0a7de745
A
579 * @abstract Determines whether a registry entry is attached in a plane.
580 * @discussion This method determines if the entry is attached in a plane to any other entry. It can also be used to determine if the entry is a member of any plane.
581 * @param plane The plane object, 0 indicates any plane.
582 * @result If the entry has a parent in the given plane or if plane = 0 then if entry has any parent; return true, otherwise false. */
1c79356b 583
cb323159 584 virtual bool inPlane( const IORegistryPlane * plane = NULL) const;
1c79356b
A
585
586/*! @function getDepth
0a7de745
A
587 * @abstract Counts the maximum number of entries between an entry and the registry root, in a plane.
588 * @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.
589 * @param plane The plane object.
590 * @result The maximum number of entries between the entry and the root. Zero is returned if the entry is not attached in the plane. */
1c79356b 591
0a7de745 592 virtual unsigned int getDepth( const IORegistryPlane * plane ) const;
1c79356b 593
0a7de745 594/* Attach / detach */
1c79356b
A
595
596/*! @function attachToParent
0a7de745
A
597 * @abstract Attaches a entry to a parent entry in a plane.
598 * @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.
599 * @param parent The registry entry to attach to.
600 * @param plane The plane object.
601 * @result true on success, or false on a resource failure, or if the parent is the same as the child. */
1c79356b 602
0a7de745
A
603 virtual bool attachToParent( IORegistryEntry * parent,
604 const IORegistryPlane * plane );
1c79356b
A
605
606/*! @function detachFromParent
0a7de745
A
607 * @abstract Detaches an entry from a parent entry in a plane.
608 * @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.
609 * @param parent The registry entry to detach from.
610 * @param plane The plane object. */
1c79356b 611
0a7de745
A
612 virtual void detachFromParent( IORegistryEntry * parent,
613 const IORegistryPlane * plane );
1c79356b
A
614
615/*! @function attachToChild
0a7de745
A
616 * @abstract Method called in the parent entry when a child attaches.
617 * @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.
618 * @param child The registry entry being attached.
619 * @param plane The plane object.
620 * @result true on success, or false on a resource failure, or if the parent is the same as the child. */
1c79356b 621
0a7de745
A
622 virtual bool attachToChild( IORegistryEntry * child,
623 const IORegistryPlane * plane );
1c79356b
A
624
625/*! @function detachFromChild
0a7de745
A
626 * @abstract Detaches a child entry from its parent in a plane.
627 * @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.
628 * @param child The registry entry to detach.
629 * @param plane The plane object. */
1c79356b 630
0a7de745
A
631 virtual void detachFromChild( IORegistryEntry * child,
632 const IORegistryPlane * plane );
1c79356b
A
633
634/*! @function detachAbove
0a7de745
A
635 * @abstract Detaches an entry from all its parent entries in a plane.
636 * @discussion This method calls detachFromParent in the entry for each of its parent entries in the plane.
637 * @param plane The plane object. */
1c79356b 638
0a7de745 639 virtual void detachAbove( const IORegistryPlane * plane );
1c79356b
A
640
641/*! @function detachAll
0a7de745
A
642 * @abstract Detaches an entry and all its children recursively in a plane.
643 * @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.
644 * @param plane The plane object. */
1c79356b 645
0a7de745 646 virtual void detachAll( const IORegistryPlane * plane );
1c79356b 647
0a7de745 648/* Name, location and path accessors */
1c79356b
A
649
650/*! @function getName
0a7de745
A
651 * @abstract Returns the name assigned to the registry entry as a C-string.
652 * @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.
653 * @param plane The plane object, or zero for the global name.
654 * @result A C-string name, valid while the entry is retained. */
1c79356b 655
cb323159 656 virtual const char * getName( const IORegistryPlane * plane = NULL ) const;
1c79356b
A
657
658/*! @function copyName
0a7de745
A
659 * @abstract Returns the name assigned to the registry entry as an OSSymbol.
660 * @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.
661 * @param plane The plane object, or zero for the global name.
662 * @result A reference to an OSSymbol for the name, which should be released by the caller. */
1c79356b 663
0a7de745 664 virtual const OSSymbol * copyName(
cb323159 665 const IORegistryPlane * plane = NULL ) const;
1c79356b
A
666
667/*! @function compareNames
0a7de745
A
668 * @abstract Compares the name of the entry with one or more names, and optionally returns the matching name.
669 * @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.
670 * @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.
671 * @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.
672 * @result True if one of the names compared true with the entry's global name. */
1c79356b 673
cb323159 674 virtual bool compareNames( OSObject * name, OSString ** matched = NULL ) const;
1c79356b
A
675
676/*! @function compareName
0a7de745
A
677 * @abstract Compares the name of the entry with one name, and optionally returns the matching name.
678 * @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.
679 * @param name The name to compare with as an OSString.
680 * @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.
681 * @result True if the name compared true with the entry's global name. */
1c79356b 682
cb323159 683 virtual bool compareName( OSString * name, OSString ** matched = NULL ) const;
1c79356b
A
684
685/*! @function setName
0a7de745
A
686 * @abstract Sets a name for the registry entry, in a particular plane, or globally.
687 * @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.
688 * @param name An OSSymbol which will be retained.
689 * @param plane The plane object, or zero to set the global name. */
1c79356b 690
0a7de745 691 virtual void setName( const OSSymbol * name,
cb323159 692 const IORegistryPlane * plane = NULL );
1c79356b
A
693
694/*! @function setName
0a7de745
A
695 * @abstract Sets a name for the registry entry, in a particular plane, or globally.
696 * @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.
697 * @param name A const C-string name which will be copied.
698 * @param plane The plane object, or zero to set the global name. */
1c79356b 699
0a7de745 700 virtual void setName( const char * name,
cb323159 701 const IORegistryPlane * plane = NULL );
1c79356b
A
702
703/*! @function getLocation
0a7de745
A
704 * @abstract Returns the location string assigned to the registry entry as a C-string.
705 * @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.
706 * @param plane The plane object, or zero for the global name.
707 * @result A C-string location string, valid while the entry is retained, or zero. */
1c79356b 708
cb323159 709 virtual const char * getLocation( const IORegistryPlane * plane = NULL ) const;
1c79356b
A
710
711/*! @function copyLocation
0a7de745
A
712 * @abstract Returns the location string assigned to the registry entry as an OSSymbol.
713 * @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.
714 * @param plane The plane object, or zero for the global name.
715 * @result A reference to an OSSymbol for the location if one exists, which should be released by the caller, or zero. */
1c79356b 716
0a7de745 717 virtual const OSSymbol * copyLocation(
cb323159 718 const IORegistryPlane * plane = NULL ) const;
1c79356b
A
719
720/*! @function setLocation
0a7de745
A
721 * @abstract Sets a location string for the registry entry, in a particular plane, or globally.
722 * @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.
723 * @param location A C-string location string which will be copied, or an OSSymbol which will be retained.
724 * @param plane The plane object, or zero to set the global location string. */
1c79356b 725
0a7de745 726 virtual void setLocation( const OSSymbol * location,
cb323159 727 const IORegistryPlane * plane = NULL );
0a7de745 728 virtual void setLocation( const char * location,
cb323159 729 const IORegistryPlane * plane = NULL );
1c79356b
A
730
731/*! @function getPath
0a7de745
A
732 * @abstract Create a path for a registry entry.
733 * @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.
734 * @param path A char buffer allocated by the caller.
735 * @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.
736 * @param plane The plane object.
737 * @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. */
1c79356b 738
0a7de745
A
739 virtual bool getPath( char * path, int * length,
740 const IORegistryPlane * plane) const;
1c79356b
A
741
742/*! @function getPathComponent
0a7de745
A
743 * @abstract Create a path component for a registry entry.
744 * @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.
745 * @param path A char buffer allocated by the caller.
746 * @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.
747 * @param plane The plane object.
748 * @result true if the path fits into the supplied buffer or false on a overflow. */
1c79356b 749
0a7de745
A
750 virtual bool getPathComponent( char * path, int * length,
751 const IORegistryPlane * plane ) const;
1c79356b
A
752
753/*! @function fromPath
0a7de745
A
754 * @abstract Looks up a registry entry by path.
755 * @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.
756 * @param path A C-string path.
757 * @param plane The plane to lookup up the path, or zero, in which case the path must begin with the plane name.
758 * @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.
759 * @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.
760 * @param fromEntry The lookup will proceed rooted at this entry if non-zero, otherwise it proceeds from the root of the plane.
761 * @result A retained registry entry is returned on success, or zero on failure. The caller should release the entry. */
762
763 static IORegistryEntry * fromPath( const char * path,
cb323159
A
764 const IORegistryPlane * plane = NULL,
765 char * residualPath = NULL,
766 int * residualLength = NULL,
767 IORegistryEntry * fromEntry = NULL );
1c79356b
A
768
769/*! @function fromPath
0a7de745
A
770 * @abstract Looks up a registry entry by relative path.
771 * @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.
772 * @param path See IORegistryEntry::fromPath.
773 * @param plane See IORegistryEntry::fromPath.
774 * @param residualPath See IORegistryEntry::fromPath.
775 * @param residualLength See IORegistryEntry::fromPath.
776 * @result See IORegistryEntry::fromPath. */
777
778 virtual IORegistryEntry * childFromPath( const char * path,
cb323159
A
779 const IORegistryPlane * plane = NULL,
780 char * residualPath = NULL,
781 int * residualLength = NULL );
1c79356b
A
782
783/*! @function dealiasPath
0a7de745
A
784 * @abstract Strips any aliases from the head of path and returns the full path.
785 * @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.
786 * @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.
787 * @param plane A plane object must be specified.
788 * @result A C-string pointer to the value of the alias if one is found, or zero if not. */
1c79356b 789
0a7de745
A
790 static const char * dealiasPath( const char ** opath,
791 const IORegistryPlane * plane );
1c79356b 792
b0d623f7 793/*! @function makePlane
0a7de745
A
794 * @abstract Constructs an IORegistryPlane object.
795 * @discussion Most planes in IOKit are created by the OS, although other planes may be created.
796 * @param name A C-string name for the new plane, to be copied.
797 * @result A new instance of an IORegistryPlane, or zero on failure. */
b0d623f7 798
0a7de745 799 static const IORegistryPlane * makePlane( const char * name );
b0d623f7
A
800
801/*! @abstract Returns an ID for the registry entry that is global to all tasks.
0a7de745
A
802 * @discussion The entry ID returned by getRegistryEntryID can be used to identify a registry entry across all tasks. A registry entry may be looked up by its entry ID by creating a matching dictionary with IORegistryEntryIDMatching() in user space, or <code>IOService::registryEntryIDMatching()</code> in the kernel, to be used with the IOKit matching functions. The ID is valid only until the machine reboots.
803 * @result An ID for the registry entry, assigned when the entry is first attached in the registry. */
b0d623f7 804
0a7de745 805 uint64_t getRegistryEntryID( void );
b0d623f7 806
0a7de745
A
807/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
808/* * * * * * * * * * * * internals * * * * * * * * * * * */
809/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1c79356b 810
0a7de745
A
811 virtual bool init( IORegistryEntry * from,
812 const IORegistryPlane * inPlane );
b0d623f7
A
813
814#ifdef XNU_KERNEL_PRIVATE
815public:
816#else
817private:
818#endif
0a7de745 819 static LIBKERN_RETURNS_NOT_RETAINED IORegistryEntry * initialize( void );
b0d623f7 820
39037602 821#ifdef XNU_KERNEL_PRIVATE
0a7de745 822 SInt32 getRegistryEntryGenerationCount( void ) const;
cb323159
A
823 void setName(const OSString * name,
824 const IORegistryPlane * plane = NULL);
39037602
A
825#endif
826
1c79356b 827private:
0a7de745
A
828 inline bool arrayMember( OSArray * set,
829 const IORegistryEntry * member,
cb323159 830 unsigned int * index = NULL ) const;
0a7de745
A
831
832 bool makeLink( IORegistryEntry * to,
833 unsigned int relation,
834 const IORegistryPlane * plane ) const;
835 void breakLink( IORegistryEntry * to,
836 unsigned int relation,
837 const IORegistryPlane * plane ) const;
838
839 APPLE_KEXT_COMPATIBILITY_VIRTUAL
b0d623f7 840 OSArray * getParentSetReference( const IORegistryPlane * plane )
0a7de745 841 const;
b0d623f7 842
0a7de745
A
843 APPLE_KEXT_COMPATIBILITY_VIRTUAL
844 OSArray * getChildSetReference( const IORegistryPlane * plane )
845 const;
1c79356b 846
0a7de745
A
847 APPLE_KEXT_COMPATIBILITY_VIRTUAL
848 IORegistryEntry * getChildFromComponent( const char ** path,
849 const IORegistryPlane * plane );
b0d623f7 850
0a7de745 851 APPLE_KEXT_COMPATIBILITY_VIRTUAL
cb323159
A
852 LIBKERN_RETURNS_NOT_RETAINED const OSSymbol * hasAlias(
853 const IORegistryPlane * plane,
854 char * opath = NULL, int * length = NULL ) const;
1c79356b 855
0a7de745
A
856 APPLE_KEXT_COMPATIBILITY_VIRTUAL
857 const char * matchPathLocation( const char * cmp,
858 const IORegistryPlane * plane );
1c79356b
A
859};
860
861/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
862
863/*! @class IORegistryIterator : public OSIterator
0a7de745
A
864 * @abstract An iterator over the registry.
865 * @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. */
1c79356b
A
866
867class IORegistryIterator : public OSIterator
868{
cb323159 869 OSDeclareAbstractStructors(IORegistryIterator);
1c79356b
A
870
871private:
0a7de745
A
872 struct IORegCursor {
873 IORegCursor * next;
874 IORegistryEntry * current;
875 OSIterator * iter;
876 };
877 IORegCursor start;
878 IORegCursor * where;
879 IORegistryEntry * root;
880 OSOrderedSet * done;
881 const IORegistryPlane * plane;
882 IOOptionBits options;
883
884 virtual void free( void ) APPLE_KEXT_OVERRIDE;
1c79356b
A
885
886public:
887/*! @function iterateOver
0a7de745
A
888 * @abstract Create an iterator rooted at a given registry entry.
889 * @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.
890 * @param start The root entry to begin the iteration at.
891 * @param plane A plane object must be specified.
892 * @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.
893 * @result A created IORegistryIterator instance, to be released by the caller when it has finished with it. */
1c79356b 894
0a7de745
A
895 static IORegistryIterator * iterateOver( IORegistryEntry * start,
896 const IORegistryPlane * plane,
897 IOOptionBits options = 0 );
1c79356b
A
898
899/*! @function iterateOver
0a7de745
A
900 * @abstract Create an iterator rooted at the registry root.
901 * @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.
902 * @param plane A plane object must be specified.
903 * @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.
904 * @result A created IORegistryIterator instance, to be released by the caller when it has finished with it. */
1c79356b 905
0a7de745
A
906 static IORegistryIterator * iterateOver( const IORegistryPlane * plane,
907 IOOptionBits options = 0 );
1c79356b
A
908
909/*! @function getNextObject
0a7de745
A
910 * @abstract Return the next object in the registry iteration.
911 * @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.
912 * @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. */
1c79356b 913
0a7de745 914 virtual IORegistryEntry * getNextObject( void ) APPLE_KEXT_OVERRIDE;
1c79356b
A
915
916/*! @function getNextObjectFlat
0a7de745
A
917 * @abstract Return the next object in the registry iteration, ignoring the kIORegistryIterateRecursively option.
918 * @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.
919 * @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. */
1c79356b 920
0a7de745 921 virtual IORegistryEntry * getNextObjectFlat( void );
1c79356b
A
922
923/*! @function getNextObjectRecursive
0a7de745
A
924 * @abstract Return the next object in the registry iteration, and enter it.
925 * @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.
926 * @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. */
1c79356b 927
0a7de745 928 virtual IORegistryEntry * getNextObjectRecursive( void );
1c79356b
A
929
930/*! @function getCurrentEntry
0a7de745
A
931 * @abstract Return the current entry in the registry iteration.
932 * @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.
933 * @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. */
1c79356b 934
0a7de745 935 virtual IORegistryEntry * getCurrentEntry( void );
1c79356b
A
936
937/*! @function enterEntry
0a7de745
A
938 * @abstract Recurse into the current entry in the registry iteration.
939 * @discussion This method makes the current entry, ie. the last entry returned by getNextObject et al., the root in a new level of recursion. */
940
941 virtual void enterEntry( void );
1c79356b 942
1c79356b 943/*! @function enterEntry
0a7de745
A
944 * @abstract Recurse into the current entry in the registry iteration.
945 * @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.
946 * @param plane The new plane to switch into. */
1c79356b 947
0a7de745 948 virtual void enterEntry( const IORegistryPlane * plane );
1c79356b
A
949
950/*! @function exitEntry
0a7de745
A
951 * @abstract Exits a level of recursion, restoring the current entry.
952 * @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.
953 * @result true if a level of recursion was undone, false if no recursive levels are left in the iteration. */
1c79356b 954
0a7de745 955 virtual bool exitEntry( void );
1c79356b
A
956
957/*! @function reset
0a7de745
A
958 * @abstract Exits all levels of recursion, restoring the iterator to its state at creation.
959 * @discussion This method exits all levels of recursion, and restores the iterator to its state at creation. */
1c79356b 960
0a7de745 961 virtual void reset( void ) APPLE_KEXT_OVERRIDE;
1c79356b
A
962
963/*! @function isValid
0a7de745
A
964 * @abstract Checks that no registry changes have invalidated the iteration.
965 * @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.
966 * @result false if the iterator has been invalidated by changes to the registry, true otherwise. */
1c79356b 967
0a7de745 968 virtual bool isValid( void ) APPLE_KEXT_OVERRIDE;
1c79356b
A
969
970/*! @function iterateAll
0a7de745
A
971 * @abstract Iterates all entries (with getNextObject) and returns a set of all returned entries.
972 * @discussion This method will reset, then iterate all entries in the iteration (with getNextObject).
973 * @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. */
1c79356b 974
0a7de745 975 virtual OSOrderedSet * iterateAll( void );
1c79356b
A
976};
977
978#endif /* _IOKIT_IOREGISTRYENTRY_H */