]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 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, | |
43866e37 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 | * Copyright (c) 1998,1999 Apple Computer, Inc. All rights reserved. | |
27 | * | |
28 | * HISTORY | |
29 | * | |
30 | */ | |
31 | ||
32 | #include <libkern/c++/OSUnserialize.h> | |
33 | #include <IOKit/IORegistryEntry.h> | |
34 | #include <IOKit/IODeviceTreeSupport.h> | |
35 | #include <IOKit/IOCatalogue.h> | |
36 | #include <IOKit/IOUserClient.h> | |
37 | #include <IOKit/IOMemoryDescriptor.h> | |
38 | #include <IOKit/IOPlatformExpert.h> | |
39 | #include <IOKit/IOLib.h> | |
40 | #include <IOKit/IOKitKeys.h> | |
41 | #include <IOKit/IOKitDebug.h> | |
1c79356b A |
42 | |
43 | #include <IOKit/assert.h> | |
44 | ||
45 | extern "C" { | |
46 | ||
47 | extern void OSlibkernInit (void); | |
48 | extern void IOLibInit(void); | |
49 | ||
50 | #include <kern/clock.h> | |
51 | ||
0b4e3aa0 A |
52 | /*XXX power management hacks XXX*/ |
53 | #include <IOKit/IOReturn.h> | |
54 | #include <IOKit/IOMessage.h> | |
55 | ||
56 | extern void *registerSleepWakeInterest( | |
57 | void *callback, | |
58 | void *target, | |
59 | void *refCon); | |
60 | /*XXX power management hacks XXX*/ | |
61 | ||
62 | static void | |
63 | calend_wakeup_resynch( | |
64 | thread_call_param_t p0, | |
65 | thread_call_param_t p1) | |
66 | { | |
67 | void IOKitResetTime(void); | |
68 | ||
69 | IOKitResetTime(); | |
70 | } | |
71 | ||
72 | static thread_call_t calend_sleep_wake_call; | |
73 | ||
74 | static IOReturn | |
75 | calend_sleep_wake_notif( | |
76 | void *target, | |
77 | void *refCon, | |
78 | unsigned int messageType, | |
79 | void *provider, | |
80 | void *messageArg, | |
81 | vm_size_t argSize) | |
82 | { | |
83 | if (messageType != kIOMessageSystemHasPoweredOn) | |
84 | return (kIOReturnUnsupported); | |
85 | ||
86 | if (calend_sleep_wake_call != NULL) | |
87 | thread_call_enter(calend_sleep_wake_call); | |
88 | ||
89 | return (kIOReturnSuccess); | |
90 | } | |
1c79356b A |
91 | |
92 | void IOKitResetTime( void ) | |
93 | { | |
94 | mach_timespec_t t; | |
95 | ||
96 | t.tv_sec = 30; | |
97 | t.tv_nsec = 0; | |
98 | IOService::waitForService( | |
99 | IOService::resourceMatching("IORTC"), &t ); | |
100 | #ifndef i386 | |
101 | IOService::waitForService( | |
102 | IOService::resourceMatching("IONVRAM"), &t ); | |
103 | #endif | |
104 | ||
0b4e3aa0 A |
105 | if (calend_sleep_wake_call == NULL) { |
106 | calend_sleep_wake_call = thread_call_allocate( | |
107 | calend_wakeup_resynch, NULL); | |
108 | ||
9bccf70c | 109 | registerSleepWakeInterest((void *)calend_sleep_wake_notif, NULL, NULL); |
0b4e3aa0 A |
110 | } |
111 | ||
1c79356b A |
112 | clock_initialize_calendar(); |
113 | } | |
114 | ||
115 | ||
116 | void StartIOKit( void * p1, void * p2, void * p3, void * p4 ) | |
117 | { | |
118 | IOPlatformExpertDevice * rootNub; | |
119 | int debugFlags; | |
120 | IORegistryEntry * root; | |
121 | OSObject * obj; | |
122 | extern const char * gIOKernelKmods; | |
123 | OSString * errorString = NULL; // must release | |
124 | OSDictionary * fakeKmods; // must release | |
125 | OSCollectionIterator * kmodIter; // must release | |
126 | OSString * kmodName; // don't release | |
127 | ||
128 | IOLog( iokit_version ); | |
129 | ||
130 | if( PE_parse_boot_arg( "io", &debugFlags )) | |
131 | gIOKitDebug = debugFlags; | |
132 | // | |
133 | // Have to start IOKit environment before we attempt to start | |
134 | // the C++ runtime environment. At some stage we have to clean up | |
135 | // the initialisation path so that OS C++ can initialise independantly | |
136 | // of iokit basic service initialisation, or better we have IOLib stuff | |
137 | // initialise as basic OS services. | |
138 | // | |
139 | IOLibInit(); | |
140 | OSlibkernInit(); | |
141 | ||
142 | IOLog("_cppInit done\n"); | |
143 | ||
de355530 | 144 | |
1c79356b A |
145 | /***** |
146 | * Declare the fake kmod_info structs for built-in components | |
147 | * that must be tracked as independent units for dependencies. | |
148 | */ | |
149 | fakeKmods = OSDynamicCast(OSDictionary, | |
150 | OSUnserialize(gIOKernelKmods, &errorString)); | |
151 | ||
152 | if (!fakeKmods) { | |
153 | if (errorString) { | |
154 | panic("Kernel kmod list syntax error: %s\n", | |
155 | errorString->getCStringNoCopy()); | |
156 | errorString->release(); | |
157 | } else { | |
158 | panic("Error loading kernel kmod list.\n"); | |
159 | } | |
160 | } | |
161 | ||
162 | kmodIter = OSCollectionIterator::withCollection(fakeKmods); | |
163 | if (!kmodIter) { | |
164 | panic("Can't declare in-kernel kmods.\n"); | |
165 | } | |
166 | while ((kmodName = OSDynamicCast(OSString, kmodIter->getNextObject()))) { | |
167 | ||
168 | OSString * kmodVersion = OSDynamicCast(OSString, | |
169 | fakeKmods->getObject(kmodName)); | |
170 | if (!kmodVersion) { | |
171 | panic("Can't declare in-kernel kmod; \"%s\" has " | |
172 | "an invalid version.\n", | |
173 | kmodName->getCStringNoCopy()); | |
174 | } | |
175 | if (KERN_SUCCESS != kmod_create_fake(kmodName->getCStringNoCopy(), | |
176 | kmodVersion->getCStringNoCopy())) { | |
177 | panic("Failure declaring in-kernel kmod \"%s\".\n", | |
178 | kmodName->getCStringNoCopy()); | |
179 | } | |
180 | } | |
181 | ||
182 | kmodIter->release(); | |
183 | fakeKmods->release(); | |
184 | ||
185 | ||
186 | ||
187 | root = IORegistryEntry::initialize(); | |
188 | assert( root ); | |
189 | IOService::initialize(); | |
190 | IOCatalogue::initialize(); | |
191 | IOUserClient::initialize(); | |
192 | IOMemoryDescriptor::initialize(); | |
1c79356b A |
193 | |
194 | obj = OSString::withCString( iokit_version ); | |
195 | assert( obj ); | |
196 | if( obj ) { | |
197 | root->setProperty( kIOKitBuildVersionKey, obj ); | |
198 | obj->release(); | |
199 | } | |
200 | obj = IOKitDiagnostics::diagnostics(); | |
201 | if( obj ) { | |
202 | root->setProperty( kIOKitDiagnosticsKey, obj ); | |
203 | obj->release(); | |
204 | } | |
205 | ||
1c79356b A |
206 | rootNub = new IOPlatformExpertDevice; |
207 | ||
208 | if( rootNub && rootNub->initWithArgs( p1, p2, p3, p4)) { | |
209 | rootNub->attach( 0 ); | |
210 | ||
211 | /* Enter into the catalogue the drivers | |
212 | * provided by BootX. | |
213 | */ | |
214 | gIOCatalogue->recordStartupExtensions(); | |
215 | ||
216 | rootNub->registerService(); | |
217 | } | |
218 | } | |
219 | ||
220 | }; /* extern "C" */ |