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