]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
d7e50217 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
d7e50217 A |
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 | |
13 | * file. | |
14 | * | |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
d7e50217 A |
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. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * | |
27 | */ | |
28 | ||
29 | #include <IOKit/IODeviceTreeSupport.h> | |
30 | #include <libkern/c++/OSContainers.h> | |
31 | #include <IOKit/IOLib.h> | |
32 | ||
33 | #include <assert.h> | |
34 | ||
35 | ||
36 | extern "C" { | |
37 | extern int debug_container_malloc_size; | |
38 | extern int debug_ivars_size; | |
39 | } | |
40 | ||
41 | static void DumpTree( void ) | |
42 | { | |
43 | IORegistryEntry * next; | |
44 | IORegistryEntry * packages = 0; | |
45 | IORegistryEntry * deblocker = 0; | |
46 | IORegistryEntry * keyboard = 0; | |
47 | IORegistryIterator * iter; | |
48 | OSOrderedSet * all; | |
49 | ||
50 | IOLog("ivars %08x, containers %08x\n", | |
51 | debug_ivars_size, debug_container_malloc_size); | |
52 | ||
53 | iter = IORegistryIterator::iterateOver( gIODTPlane ); | |
54 | assert( iter ); | |
55 | ||
56 | all = iter->iterateAll(); | |
57 | IOLog("\nCount %d\n", all->getCount() ); | |
58 | all->release(); | |
59 | ||
60 | iter->reset(); | |
61 | while( (next = iter->nextEntryRecursive())) { | |
62 | if( 0 == strcmp( "packages", next->getName())) | |
63 | packages = next; | |
64 | if( 0 == strcmp( "deblocker", next->getName())) | |
65 | deblocker = next; | |
66 | if( 0 == strcmp( "keyboard", next->getName())) | |
67 | keyboard = next; | |
68 | } | |
69 | ||
70 | if( deblocker && keyboard) | |
71 | deblocker->attachToParent( keyboard, gIODTPlane); | |
72 | ||
73 | iter->reset(); | |
74 | while( (next = iter->nextEntryRecursive())) { | |
75 | IOLog("%s=%d,", next->getName(), next->getDepth( gIODTPlane )); | |
76 | if( 0 == strcmp( "gc", next->getName())) { | |
77 | packages = next; | |
78 | } | |
79 | } | |
80 | ||
81 | IOLog("ivars %08x, containers %08x\n", | |
82 | debug_ivars_size, debug_container_malloc_size); | |
83 | ||
84 | if( packages) | |
85 | packages->detachAll( gIODTPlane); | |
86 | all = iter->iterateAll(); | |
87 | IOLog("del gc/, count now %d\n", all->getCount() ); | |
88 | all->release(); | |
89 | ||
90 | iter->release(); | |
91 | ||
92 | IOLog("ivars %08x, containers %08x\n", | |
93 | debug_ivars_size, debug_container_malloc_size); | |
94 | ||
95 | } | |
96 | ||
97 | extern "C" { | |
98 | void PathTests( void ) | |
99 | { | |
100 | const char * tests[] = { | |
101 | "IODeviceTree:/bandit", | |
102 | "IODeviceTree:/", | |
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", | |
114 | "IOService:/", | |
115 | "IOService:/ApplePlatformExpert", | |
116 | "IOService:/ApplePlatformExpert/hammerhead@F8000000", | |
117 | "IOService:/ApplePlatformExpert/bandit/AppleMacRiscPCI" | |
118 | }; | |
119 | ||
120 | IORegistryEntry * entry; | |
121 | char str[256]; | |
122 | int len; | |
123 | ||
124 | for( unsigned int i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) { | |
125 | ||
126 | len = sizeof( str ); | |
127 | entry = IORegistryEntry::fromPath( tests[i], 0, str, &len ); | |
128 | IOLog("\"%s\" ", tests[i] ); | |
129 | if( entry) { | |
130 | IOLog("found %s, tail = \"%s\"\n", entry->getName(), str ); | |
131 | len = sizeof( str ); | |
132 | if( entry->getPath( str, &len, | |
133 | IORegistryEntry::getPlane("IODeviceTree"))) { | |
134 | IOLog("path = \"%s\"\n", str); | |
135 | } | |
136 | entry->release(); | |
137 | } else | |
138 | IOLog("not found\n"); | |
139 | } | |
140 | } | |
141 | } | |
142 | ||
143 | void TestsCpp( void * dtTop ) | |
144 | { | |
145 | IORegistryEntry * dt; | |
146 | ||
147 | IOLog("\nivars %08x, containers %08x\n", | |
148 | debug_ivars_size, debug_container_malloc_size); | |
149 | ||
150 | OSMetaClass::printInstanceCounts(); | |
151 | dt = IODeviceTreeAlloc( dtTop ); | |
152 | assert( dt ); | |
153 | ||
154 | // OSMetaClass::printInstanceCounts(); | |
155 | DumpTree(); | |
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); | |
161 | } | |
162 |