2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
23 * @APPLE_LICENSE_HEADER_END@
25 #ifndef __DEVICE_TREE__
26 #define __DEVICE_TREE__
33 ------------------------------------------------------------------------------------
35 ------------------------------------------------------------------------------------
38 kDTPathNameSeparator
= '/' /* 0x2F */
42 /* Property Name Definitions (Property Names are C-Strings)*/
44 kDTMaxPropertyNameLength
= 31 /* Max length of Property Name (terminator not included) */
47 typedef char DTPropertyNameBuf
[32];
50 /* Entry Name Definitions (Entry Names are C-Strings)*/
52 kDTMaxEntryNameLength
= 31 /* Max length of a C-String Entry Name (terminator not included) */
55 /* length of DTEntryNameBuf = kDTMaxEntryNameLength +1*/
56 typedef char DTEntryNameBuf
[32];
60 typedef struct OpaqueDTEntry
* DTEntry
;
63 typedef struct OpaqueDTEntryIterator
* DTEntryIterator
;
65 /* Property Iterator*/
66 typedef struct OpaqueDTPropertyIterator
* DTPropertyIterator
;
77 ------------------------------------------------------------------------------------
79 ------------------------------------------------------------------------------------
83 ------------------------------------------------------------------------------------
85 ------------------------------------------------------------------------------------
87 /* Compare two Entry's for equality. */
88 extern int DTEntryIsEqual(const DTEntry ref1
, const DTEntry ref2
);
91 ------------------------------------------------------------------------------------
93 ------------------------------------------------------------------------------------
97 Locates an entry given a specified subroot (searchPoint) and path name. If the
98 searchPoint pointer is NULL, the path name is assumed to be an absolute path
99 name rooted to the root of the device tree.
101 extern int DTLookupEntry(const DTEntry searchPoint
, const char *pathName
, DTEntry
*foundEntry
);
104 ------------------------------------------------------------------------------------
106 ------------------------------------------------------------------------------------
109 An Entry Iterator maintains three variables that are of interest to clients.
110 First is an "OutermostScope" which defines the outer boundry of the iteration.
111 This is defined by the starting entry and includes that entry plus all of it's
112 embedded entries. Second is a "currentScope" which is the entry the iterator is
113 currently in. And third is a "currentPosition" which is the last entry returned
116 Create Entry Iterator
117 Create the iterator structure. The outermostScope and currentScope of the iterator
118 are set to "startEntry". If "startEntry" = NULL, the outermostScope and
119 currentScope are set to the root entry. The currentPosition for the iterator is
122 extern int DTCreateEntryIterator(const DTEntry startEntry
, DTEntryIterator
*iterator
);
124 /* Dispose Entry Iterator*/
125 extern int DTDisposeEntryIterator(DTEntryIterator iterator
);
129 Move an Entry Iterator into the scope of a specified child entry. The
130 currentScope of the iterator is set to the entry specified in "childEntry". If
131 "childEntry" is nil, the currentScope is set to the entry specified by the
132 currentPosition of the iterator.
134 extern int DTEnterEntry(DTEntryIterator iterator
, DTEntry childEntry
);
138 Move an Entry Iterator out of the current entry back into the scope of it's parent
139 entry. The currentPosition of the iterator is reset to the current entry (the
140 previous currentScope), so the next iteration call will continue where it left off.
141 This position is returned in parameter "currentPosition".
143 extern int DTExitEntry(DTEntryIterator iterator
, DTEntry
*currentPosition
);
147 Iterate and return entries contained within the entry defined by the current
148 scope of the iterator. Entries are returned one at a time. When
149 int == kIterationDone, all entries have been exhausted, and the
150 value of nextEntry will be Nil.
152 extern int DTIterateEntries(DTEntryIterator iterator
, DTEntry
*nextEntry
);
155 Restart Entry Iteration
156 Restart an iteration within the current scope. The iterator is reset such that
157 iteration of the contents of the currentScope entry can be restarted. The
158 outermostScope and currentScope of the iterator are unchanged. The currentPosition
159 for the iterator is set to "nil".
161 extern int DTRestartEntryIteration(DTEntryIterator iterator
);
164 ------------------------------------------------------------------------------------
166 ------------------------------------------------------------------------------------
169 Get the value of the specified property for the specified entry.
173 extern int DTGetProperty(const DTEntry entry
, const char *propertyName
, void **propertyValue
, int *propertySize
);
176 ------------------------------------------------------------------------------------
178 ------------------------------------------------------------------------------------
181 Create Property Iterator
182 Create the property iterator structure. The target entry is defined by entry.
184 extern int DTCreatePropertyIterator(const DTEntry entry
, DTPropertyIterator
*iterator
);
186 /* Dispose Property Iterator*/
187 extern int DTDisposePropertyIterator(DTPropertyIterator iterator
);
191 Iterate and return properties for given entry.
192 When int == kIterationDone, all properties have been exhausted.
194 extern int DTIterateProperties(DTPropertyIterator iterator
, char **foundProperty
);
197 Restart Property Iteration
198 Used to re-iterate over a list of properties. The Property Iterator is reset to
199 the beginning of the list of properties for an entry.
201 extern int DTRestartPropertyIteration(DTPropertyIterator iterator
);
207 #endif /* __DEVICE_TREE__ */