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@
29 #include <IOKit/IODeviceTreeSupport.h>
30 #include <libkern/c++/OSContainers.h>
31 #include <IOKit/IOLib.h>
37 extern int debug_container_malloc_size
;
38 extern int debug_ivars_size
;
41 static void DumpTree( void )
43 IORegistryEntry
* next
;
44 IORegistryEntry
* packages
= 0;
45 IORegistryEntry
* deblocker
= 0;
46 IORegistryEntry
* keyboard
= 0;
47 IORegistryIterator
* iter
;
50 IOLog("ivars %08x, containers %08x\n",
51 debug_ivars_size
, debug_container_malloc_size
);
53 iter
= IORegistryIterator::iterateOver( gIODTPlane
);
56 all
= iter
->iterateAll();
57 IOLog("\nCount %d\n", all
->getCount() );
61 while( (next
= iter
->nextEntryRecursive())) {
62 if( 0 == strcmp( "packages", next
->getName()))
64 if( 0 == strcmp( "deblocker", next
->getName()))
66 if( 0 == strcmp( "keyboard", next
->getName()))
70 if( deblocker
&& keyboard
)
71 deblocker
->attachToParent( keyboard
, gIODTPlane
);
74 while( (next
= iter
->nextEntryRecursive())) {
75 IOLog("%s=%d,", next
->getName(), next
->getDepth( gIODTPlane
));
76 if( 0 == strcmp( "gc", next
->getName())) {
81 IOLog("ivars %08x, containers %08x\n",
82 debug_ivars_size
, debug_container_malloc_size
);
85 packages
->detachAll( gIODTPlane
);
86 all
= iter
->iterateAll();
87 IOLog("del gc/, count now %d\n", all
->getCount() );
92 IOLog("ivars %08x, containers %08x\n",
93 debug_ivars_size
, debug_container_malloc_size
);
98 void PathTests( void )
100 const char * tests
[] = {
101 "IODeviceTree:/bandit",
103 "IODeviceTree:/xxxx",
104 "IODeviceTree:/bandit/xxx",
105 "IODeviceTree:/bandit@F2000000",
106 "IODeviceTree:/bandit/gc",
107 "IODeviceTree:/bandit/gc/mace:17.202.42.95,\\mach_kernel",
108 "IODeviceTree:/bandit/@10/mesh",
109 "IODeviceTree:enet:17.202",
110 "IODeviceTree:scsi/@0:0",
111 "IODeviceTree:scsi-int",
112 "IODeviceTree:/bandit/gc@10/mesh",
113 "IODeviceTree:/bandit/gc/53c94/disk@0:6,mach_kernel",
115 "IOService:/ApplePlatformExpert",
116 "IOService:/ApplePlatformExpert/hammerhead@F8000000",
117 "IOService:/ApplePlatformExpert/bandit/AppleMacRiscPCI"
120 IORegistryEntry
* entry
;
124 for( unsigned int i
= 0; i
< sizeof(tests
)/sizeof(tests
[0]); i
++) {
127 entry
= IORegistryEntry::fromPath( tests
[i
], 0, str
, &len
);
128 IOLog("\"%s\" ", tests
[i
] );
130 IOLog("found %s, tail = \"%s\"\n", entry
->getName(), str
);
132 if( entry
->getPath( str
, &len
,
133 IORegistryEntry::getPlane("IODeviceTree"))) {
134 IOLog("path = \"%s\"\n", str
);
138 IOLog("not found\n");
143 void TestsCpp( void * dtTop
)
145 IORegistryEntry
* dt
;
147 IOLog("\nivars %08x, containers %08x\n",
148 debug_ivars_size
, debug_container_malloc_size
);
150 OSMetaClass::printInstanceCounts();
151 dt
= IODeviceTreeAlloc( dtTop
);
154 // OSMetaClass::printInstanceCounts();
156 // OSMetaClass::printInstanceCounts();
157 dt
->detachAll( gIODTPlane
);
158 OSMetaClass::printInstanceCounts();
159 IOLog("ivars %08x, containers %08x\n",
160 debug_ivars_size
, debug_container_malloc_size
);