2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
27 #include <IOKit/IODeviceTreeSupport.h>
28 #include <libkern/c++/OSContainers.h>
29 #include <IOKit/IOLib.h>
35 extern int debug_container_malloc_size
;
36 extern int debug_ivars_size
;
39 static void DumpTree( void )
41 IORegistryEntry
* next
;
42 IORegistryEntry
* packages
= 0;
43 IORegistryEntry
* deblocker
= 0;
44 IORegistryEntry
* keyboard
= 0;
45 IORegistryIterator
* iter
;
48 IOLog("ivars %08x, containers %08x\n",
49 debug_ivars_size
, debug_container_malloc_size
);
51 iter
= IORegistryIterator::iterateOver( gIODTPlane
);
54 all
= iter
->iterateAll();
55 IOLog("\nCount %d\n", all
->getCount() );
59 while( (next
= iter
->nextEntryRecursive())) {
60 if( 0 == strcmp( "packages", next
->getName()))
62 if( 0 == strcmp( "deblocker", next
->getName()))
64 if( 0 == strcmp( "keyboard", next
->getName()))
68 if( deblocker
&& keyboard
)
69 deblocker
->attachToParent( keyboard
, gIODTPlane
);
72 while( (next
= iter
->nextEntryRecursive())) {
73 IOLog("%s=%d,", next
->getName(), next
->getDepth( gIODTPlane
));
74 if( 0 == strcmp( "gc", next
->getName())) {
79 IOLog("ivars %08x, containers %08x\n",
80 debug_ivars_size
, debug_container_malloc_size
);
83 packages
->detachAll( gIODTPlane
);
84 all
= iter
->iterateAll();
85 IOLog("del gc/, count now %d\n", all
->getCount() );
90 IOLog("ivars %08x, containers %08x\n",
91 debug_ivars_size
, debug_container_malloc_size
);
96 void PathTests( void )
98 const char * tests
[] = {
99 "IODeviceTree:/bandit",
101 "IODeviceTree:/xxxx",
102 "IODeviceTree:/bandit/xxx",
103 "IODeviceTree:/bandit@F2000000",
104 "IODeviceTree:/bandit/gc",
105 "IODeviceTree:/bandit/gc/mace:17.202.42.95,\\mach_kernel",
106 "IODeviceTree:/bandit/@10/mesh",
107 "IODeviceTree:enet:17.202",
108 "IODeviceTree:scsi/@0:0",
109 "IODeviceTree:scsi-int",
110 "IODeviceTree:/bandit/gc@10/mesh",
111 "IODeviceTree:/bandit/gc/53c94/disk@0:6,mach_kernel",
113 "IOService:/ApplePlatformExpert",
114 "IOService:/ApplePlatformExpert/hammerhead@F8000000",
115 "IOService:/ApplePlatformExpert/bandit/AppleMacRiscPCI"
118 IORegistryEntry
* entry
;
122 for( unsigned int i
= 0; i
< sizeof(tests
)/sizeof(tests
[0]); i
++) {
125 entry
= IORegistryEntry::fromPath( tests
[i
], 0, str
, &len
);
126 IOLog("\"%s\" ", tests
[i
] );
128 IOLog("found %s, tail = \"%s\"\n", entry
->getName(), str
);
130 if( entry
->getPath( str
, &len
,
131 IORegistryEntry::getPlane("IODeviceTree"))) {
132 IOLog("path = \"%s\"\n", str
);
136 IOLog("not found\n");
141 void TestsCpp( void * dtTop
)
143 IORegistryEntry
* dt
;
145 IOLog("\nivars %08x, containers %08x\n",
146 debug_ivars_size
, debug_container_malloc_size
);
148 OSMetaClass::printInstanceCounts();
149 dt
= IODeviceTreeAlloc( dtTop
);
152 // OSMetaClass::printInstanceCounts();
154 // OSMetaClass::printInstanceCounts();
155 dt
->detachAll( gIODTPlane
);
156 OSMetaClass::printInstanceCounts();
157 IOLog("ivars %08x, containers %08x\n",
158 debug_ivars_size
, debug_container_malloc_size
);