2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
34 #include <IOKit/IODeviceTreeSupport.h>
35 #include <libkern/c++/OSContainers.h>
36 #include <IOKit/IOLib.h>
42 extern int debug_container_malloc_size
;
43 extern int debug_ivars_size
;
46 static void DumpTree( void )
48 IORegistryEntry
* next
;
49 IORegistryEntry
* packages
= 0;
50 IORegistryEntry
* deblocker
= 0;
51 IORegistryEntry
* keyboard
= 0;
52 IORegistryIterator
* iter
;
55 IOLog("ivars %08x, containers %08x\n",
56 debug_ivars_size
, debug_container_malloc_size
);
58 iter
= IORegistryIterator::iterateOver( gIODTPlane
);
61 all
= iter
->iterateAll();
62 IOLog("\nCount %d\n", all
->getCount() );
66 while( (next
= iter
->nextEntryRecursive())) {
67 if( 0 == strcmp( "packages", next
->getName()))
69 if( 0 == strcmp( "deblocker", next
->getName()))
71 if( 0 == strcmp( "keyboard", next
->getName()))
75 if( deblocker
&& keyboard
)
76 deblocker
->attachToParent( keyboard
, gIODTPlane
);
79 while( (next
= iter
->nextEntryRecursive())) {
80 IOLog("%s=%d,", next
->getName(), next
->getDepth( gIODTPlane
));
81 if( 0 == strcmp( "gc", next
->getName())) {
86 IOLog("ivars %08x, containers %08x\n",
87 debug_ivars_size
, debug_container_malloc_size
);
90 packages
->detachAll( gIODTPlane
);
91 all
= iter
->iterateAll();
92 IOLog("del gc/, count now %d\n", all
->getCount() );
97 IOLog("ivars %08x, containers %08x\n",
98 debug_ivars_size
, debug_container_malloc_size
);
103 void PathTests( void )
105 const char * tests
[] = {
106 "IODeviceTree:/bandit",
108 "IODeviceTree:/xxxx",
109 "IODeviceTree:/bandit/xxx",
110 "IODeviceTree:/bandit@F2000000",
111 "IODeviceTree:/bandit/gc",
112 "IODeviceTree:/bandit/gc/mace:17.202.42.95,\\mach_kernel",
113 "IODeviceTree:/bandit/@10/mesh",
114 "IODeviceTree:enet:17.202",
115 "IODeviceTree:scsi/@0:0",
116 "IODeviceTree:scsi-int",
117 "IODeviceTree:/bandit/gc@10/mesh",
118 "IODeviceTree:/bandit/gc/53c94/disk@0:6,mach_kernel",
120 "IOService:/ApplePlatformExpert",
121 "IOService:/ApplePlatformExpert/hammerhead@F8000000",
122 "IOService:/ApplePlatformExpert/bandit/AppleMacRiscPCI"
125 IORegistryEntry
* entry
;
129 for( unsigned int i
= 0; i
< sizeof(tests
)/sizeof(tests
[0]); i
++) {
132 entry
= IORegistryEntry::fromPath( tests
[i
], 0, str
, &len
);
133 IOLog("\"%s\" ", tests
[i
] );
135 IOLog("found %s, tail = \"%s\"\n", entry
->getName(), str
);
137 if( entry
->getPath( str
, &len
,
138 IORegistryEntry::getPlane("IODeviceTree"))) {
139 IOLog("path = \"%s\"\n", str
);
143 IOLog("not found\n");
148 void TestsCpp( void * dtTop
)
150 IORegistryEntry
* dt
;
152 IOLog("\nivars %08x, containers %08x\n",
153 debug_ivars_size
, debug_container_malloc_size
);
155 OSMetaClass::printInstanceCounts();
156 dt
= IODeviceTreeAlloc( dtTop
);
159 // OSMetaClass::printInstanceCounts();
161 // OSMetaClass::printInstanceCounts();
162 dt
->detachAll( gIODTPlane
);
163 OSMetaClass::printInstanceCounts();
164 IOLog("ivars %08x, containers %08x\n",
165 debug_ivars_size
, debug_container_malloc_size
);