2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_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. 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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 #include <IOKit/IODeviceTreeSupport.h>
33 #include <libkern/c++/OSContainers.h>
34 #include <IOKit/IOLib.h>
40 extern int debug_container_malloc_size
;
41 extern int debug_ivars_size
;
44 static void DumpTree( void )
46 IORegistryEntry
* next
;
47 IORegistryEntry
* packages
= 0;
48 IORegistryEntry
* deblocker
= 0;
49 IORegistryEntry
* keyboard
= 0;
50 IORegistryIterator
* iter
;
53 IOLog("ivars %08x, containers %08x\n",
54 debug_ivars_size
, debug_container_malloc_size
);
56 iter
= IORegistryIterator::iterateOver( gIODTPlane
);
59 all
= iter
->iterateAll();
60 IOLog("\nCount %d\n", all
->getCount() );
64 while( (next
= iter
->nextEntryRecursive())) {
65 if( 0 == strcmp( "packages", next
->getName()))
67 if( 0 == strcmp( "deblocker", next
->getName()))
69 if( 0 == strcmp( "keyboard", next
->getName()))
73 if( deblocker
&& keyboard
)
74 deblocker
->attachToParent( keyboard
, gIODTPlane
);
77 while( (next
= iter
->nextEntryRecursive())) {
78 IOLog("%s=%d,", next
->getName(), next
->getDepth( gIODTPlane
));
79 if( 0 == strcmp( "gc", next
->getName())) {
84 IOLog("ivars %08x, containers %08x\n",
85 debug_ivars_size
, debug_container_malloc_size
);
88 packages
->detachAll( gIODTPlane
);
89 all
= iter
->iterateAll();
90 IOLog("del gc/, count now %d\n", all
->getCount() );
95 IOLog("ivars %08x, containers %08x\n",
96 debug_ivars_size
, debug_container_malloc_size
);
101 void PathTests( void )
103 const char * tests
[] = {
104 "IODeviceTree:/bandit",
106 "IODeviceTree:/xxxx",
107 "IODeviceTree:/bandit/xxx",
108 "IODeviceTree:/bandit@F2000000",
109 "IODeviceTree:/bandit/gc",
110 "IODeviceTree:/bandit/gc/mace:17.202.42.95,\\mach_kernel",
111 "IODeviceTree:/bandit/@10/mesh",
112 "IODeviceTree:enet:17.202",
113 "IODeviceTree:scsi/@0:0",
114 "IODeviceTree:scsi-int",
115 "IODeviceTree:/bandit/gc@10/mesh",
116 "IODeviceTree:/bandit/gc/53c94/disk@0:6,mach_kernel",
118 "IOService:/ApplePlatformExpert",
119 "IOService:/ApplePlatformExpert/hammerhead@F8000000",
120 "IOService:/ApplePlatformExpert/bandit/AppleMacRiscPCI"
123 IORegistryEntry
* entry
;
127 for( unsigned int i
= 0; i
< sizeof(tests
)/sizeof(tests
[0]); i
++) {
130 entry
= IORegistryEntry::fromPath( tests
[i
], 0, str
, &len
);
131 IOLog("\"%s\" ", tests
[i
] );
133 IOLog("found %s, tail = \"%s\"\n", entry
->getName(), str
);
135 if( entry
->getPath( str
, &len
,
136 IORegistryEntry::getPlane("IODeviceTree"))) {
137 IOLog("path = \"%s\"\n", str
);
141 IOLog("not found\n");
146 void TestsCpp( void * dtTop
)
148 IORegistryEntry
* dt
;
150 IOLog("\nivars %08x, containers %08x\n",
151 debug_ivars_size
, debug_container_malloc_size
);
153 OSMetaClass::printInstanceCounts();
154 dt
= IODeviceTreeAlloc( dtTop
);
157 // OSMetaClass::printInstanceCounts();
159 // OSMetaClass::printInstanceCounts();
160 dt
->detachAll( gIODTPlane
);
161 OSMetaClass::printInstanceCounts();
162 IOLog("ivars %08x, containers %08x\n",
163 debug_ivars_size
, debug_container_malloc_size
);