2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 #include <IOKit/IODeviceTreeSupport.h>
27 #include <libkern/c++/OSContainers.h>
28 #include <IOKit/IOLib.h>
34 extern int debug_container_malloc_size
;
35 extern int debug_ivars_size
;
38 static void DumpTree( void )
40 IORegistryEntry
* next
;
41 IORegistryEntry
* packages
= 0;
42 IORegistryEntry
* deblocker
= 0;
43 IORegistryEntry
* keyboard
= 0;
44 IORegistryIterator
* iter
;
47 IOLog("ivars %08x, containers %08x\n",
48 debug_ivars_size
, debug_container_malloc_size
);
50 iter
= IORegistryIterator::iterateOver( gIODTPlane
);
53 all
= iter
->iterateAll();
54 IOLog("\nCount %d\n", all
->getCount() );
58 while( (next
= iter
->nextEntryRecursive())) {
59 if( 0 == strcmp( "packages", next
->getName()))
61 if( 0 == strcmp( "deblocker", next
->getName()))
63 if( 0 == strcmp( "keyboard", next
->getName()))
67 if( deblocker
&& keyboard
)
68 deblocker
->attachToParent( keyboard
, gIODTPlane
);
71 while( (next
= iter
->nextEntryRecursive())) {
72 IOLog("%s=%d,", next
->getName(), next
->getDepth( gIODTPlane
));
73 if( 0 == strcmp( "gc", next
->getName())) {
78 IOLog("ivars %08x, containers %08x\n",
79 debug_ivars_size
, debug_container_malloc_size
);
82 packages
->detachAll( gIODTPlane
);
83 all
= iter
->iterateAll();
84 IOLog("del gc/, count now %d\n", all
->getCount() );
89 IOLog("ivars %08x, containers %08x\n",
90 debug_ivars_size
, debug_container_malloc_size
);
95 void PathTests( void )
97 const char * tests
[] = {
98 "IODeviceTree:/bandit",
100 "IODeviceTree:/xxxx",
101 "IODeviceTree:/bandit/xxx",
102 "IODeviceTree:/bandit@F2000000",
103 "IODeviceTree:/bandit/gc",
104 "IODeviceTree:/bandit/gc/mace:17.202.42.95,\\mach_kernel",
105 "IODeviceTree:/bandit/@10/mesh",
106 "IODeviceTree:enet:17.202",
107 "IODeviceTree:scsi/@0:0",
108 "IODeviceTree:scsi-int",
109 "IODeviceTree:/bandit/gc@10/mesh",
110 "IODeviceTree:/bandit/gc/53c94/disk@0:6,mach_kernel",
112 "IOService:/ApplePlatformExpert",
113 "IOService:/ApplePlatformExpert/hammerhead@F8000000",
114 "IOService:/ApplePlatformExpert/bandit/AppleMacRiscPCI"
117 IORegistryEntry
* entry
;
121 for( unsigned int i
= 0; i
< sizeof(tests
)/sizeof(tests
[0]); i
++) {
124 entry
= IORegistryEntry::fromPath( tests
[i
], 0, str
, &len
);
125 IOLog("\"%s\" ", tests
[i
] );
127 IOLog("found %s, tail = \"%s\"\n", entry
->getName(), str
);
129 if( entry
->getPath( str
, &len
,
130 IORegistryEntry::getPlane("IODeviceTree"))) {
131 IOLog("path = \"%s\"\n", str
);
135 IOLog("not found\n");
140 void TestsCpp( void * dtTop
)
142 IORegistryEntry
* dt
;
144 IOLog("\nivars %08x, containers %08x\n",
145 debug_ivars_size
, debug_container_malloc_size
);
147 OSMetaClass::printInstanceCounts();
148 dt
= IODeviceTreeAlloc( dtTop
);
151 // OSMetaClass::printInstanceCounts();
153 // OSMetaClass::printInstanceCounts();
154 dt
->detachAll( gIODTPlane
);
155 OSMetaClass::printInstanceCounts();
156 IOLog("ivars %08x, containers %08x\n",
157 debug_ivars_size
, debug_container_malloc_size
);