]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
e5568f75 A |
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. | |
1c79356b | 11 | * |
e5568f75 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
e5568f75 A |
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. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * Copyright (c) 1998,1999 Apple Computer, Inc. All rights reserved. | |
24 | * | |
25 | * HISTORY | |
26 | * | |
27 | */ | |
28 | ||
29 | #include <libkern/c++/OSUnserialize.h> | |
30 | #include <IOKit/IORegistryEntry.h> | |
31 | #include <IOKit/IODeviceTreeSupport.h> | |
32 | #include <IOKit/IOCatalogue.h> | |
33 | #include <IOKit/IOUserClient.h> | |
34 | #include <IOKit/IOMemoryDescriptor.h> | |
35 | #include <IOKit/IOPlatformExpert.h> | |
36 | #include <IOKit/IOLib.h> | |
37 | #include <IOKit/IOKitKeys.h> | |
38 | #include <IOKit/IOKitDebug.h> | |
1c79356b A |
39 | |
40 | #include <IOKit/assert.h> | |
41 | ||
42 | extern "C" { | |
43 | ||
44 | extern void OSlibkernInit (void); | |
45 | extern void IOLibInit(void); | |
46 | ||
47 | #include <kern/clock.h> | |
48 | ||
1c79356b A |
49 | void IOKitResetTime( void ) |
50 | { | |
55e303ae | 51 | mach_timespec_t t; |
1c79356b | 52 | |
55e303ae A |
53 | t.tv_sec = 30; |
54 | t.tv_nsec = 0; | |
55 | IOService::waitForService( | |
56 | IOService::resourceMatching("IORTC"), &t ); | |
1c79356b | 57 | #ifndef i386 |
55e303ae A |
58 | IOService::waitForService( |
59 | IOService::resourceMatching("IONVRAM"), &t ); | |
1c79356b A |
60 | #endif |
61 | ||
62 | clock_initialize_calendar(); | |
63 | } | |
64 | ||
55e303ae A |
65 | // From <osfmk/kern/debug.c> |
66 | extern int debug_mode; | |
1c79356b A |
67 | |
68 | void StartIOKit( void * p1, void * p2, void * p3, void * p4 ) | |
69 | { | |
70 | IOPlatformExpertDevice * rootNub; | |
71 | int debugFlags; | |
72 | IORegistryEntry * root; | |
73 | OSObject * obj; | |
74 | extern const char * gIOKernelKmods; | |
75 | OSString * errorString = NULL; // must release | |
76 | OSDictionary * fakeKmods; // must release | |
77 | OSCollectionIterator * kmodIter; // must release | |
78 | OSString * kmodName; // don't release | |
79 | ||
80 | IOLog( iokit_version ); | |
81 | ||
82 | if( PE_parse_boot_arg( "io", &debugFlags )) | |
83 | gIOKitDebug = debugFlags; | |
55e303ae A |
84 | |
85 | // Check for the log synchronous bit set in io | |
86 | if (gIOKitDebug & kIOLogSynchronous) | |
87 | debug_mode = true; | |
88 | ||
1c79356b A |
89 | // |
90 | // Have to start IOKit environment before we attempt to start | |
91 | // the C++ runtime environment. At some stage we have to clean up | |
92 | // the initialisation path so that OS C++ can initialise independantly | |
93 | // of iokit basic service initialisation, or better we have IOLib stuff | |
94 | // initialise as basic OS services. | |
95 | // | |
96 | IOLibInit(); | |
97 | OSlibkernInit(); | |
98 | ||
1c79356b A |
99 | /***** |
100 | * Declare the fake kmod_info structs for built-in components | |
101 | * that must be tracked as independent units for dependencies. | |
102 | */ | |
103 | fakeKmods = OSDynamicCast(OSDictionary, | |
104 | OSUnserialize(gIOKernelKmods, &errorString)); | |
105 | ||
106 | if (!fakeKmods) { | |
107 | if (errorString) { | |
108 | panic("Kernel kmod list syntax error: %s\n", | |
109 | errorString->getCStringNoCopy()); | |
110 | errorString->release(); | |
111 | } else { | |
112 | panic("Error loading kernel kmod list.\n"); | |
113 | } | |
114 | } | |
115 | ||
116 | kmodIter = OSCollectionIterator::withCollection(fakeKmods); | |
117 | if (!kmodIter) { | |
118 | panic("Can't declare in-kernel kmods.\n"); | |
119 | } | |
120 | while ((kmodName = OSDynamicCast(OSString, kmodIter->getNextObject()))) { | |
121 | ||
122 | OSString * kmodVersion = OSDynamicCast(OSString, | |
123 | fakeKmods->getObject(kmodName)); | |
124 | if (!kmodVersion) { | |
125 | panic("Can't declare in-kernel kmod; \"%s\" has " | |
126 | "an invalid version.\n", | |
127 | kmodName->getCStringNoCopy()); | |
128 | } | |
129 | if (KERN_SUCCESS != kmod_create_fake(kmodName->getCStringNoCopy(), | |
130 | kmodVersion->getCStringNoCopy())) { | |
131 | panic("Failure declaring in-kernel kmod \"%s\".\n", | |
132 | kmodName->getCStringNoCopy()); | |
133 | } | |
134 | } | |
135 | ||
136 | kmodIter->release(); | |
137 | fakeKmods->release(); | |
138 | ||
139 | ||
140 | ||
141 | root = IORegistryEntry::initialize(); | |
142 | assert( root ); | |
143 | IOService::initialize(); | |
144 | IOCatalogue::initialize(); | |
145 | IOUserClient::initialize(); | |
146 | IOMemoryDescriptor::initialize(); | |
1c79356b A |
147 | |
148 | obj = OSString::withCString( iokit_version ); | |
149 | assert( obj ); | |
150 | if( obj ) { | |
151 | root->setProperty( kIOKitBuildVersionKey, obj ); | |
152 | obj->release(); | |
153 | } | |
154 | obj = IOKitDiagnostics::diagnostics(); | |
155 | if( obj ) { | |
156 | root->setProperty( kIOKitDiagnosticsKey, obj ); | |
157 | obj->release(); | |
158 | } | |
159 | ||
1c79356b A |
160 | rootNub = new IOPlatformExpertDevice; |
161 | ||
162 | if( rootNub && rootNub->initWithArgs( p1, p2, p3, p4)) { | |
163 | rootNub->attach( 0 ); | |
164 | ||
165 | /* Enter into the catalogue the drivers | |
166 | * provided by BootX. | |
167 | */ | |
168 | gIOCatalogue->recordStartupExtensions(); | |
169 | ||
170 | rootNub->registerService(); | |
171 | } | |
172 | } | |
173 | ||
174 | }; /* extern "C" */ |