]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
37839358 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 | * |
37839358 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, | |
37839358 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> | |
91447636 | 30 | #include <libkern/version.h> |
1c79356b A |
31 | #include <IOKit/IORegistryEntry.h> |
32 | #include <IOKit/IODeviceTreeSupport.h> | |
33 | #include <IOKit/IOCatalogue.h> | |
34 | #include <IOKit/IOUserClient.h> | |
35 | #include <IOKit/IOMemoryDescriptor.h> | |
36 | #include <IOKit/IOPlatformExpert.h> | |
37 | #include <IOKit/IOLib.h> | |
38 | #include <IOKit/IOKitKeys.h> | |
39 | #include <IOKit/IOKitDebug.h> | |
1c79356b A |
40 | |
41 | #include <IOKit/assert.h> | |
42 | ||
91447636 A |
43 | #include "IOKitKernelInternal.h" |
44 | ||
1c79356b A |
45 | extern "C" { |
46 | ||
47 | extern void OSlibkernInit (void); | |
1c79356b A |
48 | |
49 | #include <kern/clock.h> | |
50 | ||
1c79356b A |
51 | void IOKitResetTime( void ) |
52 | { | |
55e303ae | 53 | mach_timespec_t t; |
1c79356b | 54 | |
55e303ae A |
55 | t.tv_sec = 30; |
56 | t.tv_nsec = 0; | |
57 | IOService::waitForService( | |
58 | IOService::resourceMatching("IORTC"), &t ); | |
1c79356b | 59 | #ifndef i386 |
55e303ae A |
60 | IOService::waitForService( |
61 | IOService::resourceMatching("IONVRAM"), &t ); | |
1c79356b A |
62 | #endif |
63 | ||
64 | clock_initialize_calendar(); | |
65 | } | |
66 | ||
55e303ae A |
67 | // From <osfmk/kern/debug.c> |
68 | extern int debug_mode; | |
1c79356b A |
69 | |
70 | void StartIOKit( void * p1, void * p2, void * p3, void * p4 ) | |
71 | { | |
72 | IOPlatformExpertDevice * rootNub; | |
73 | int debugFlags; | |
74 | IORegistryEntry * root; | |
75 | OSObject * obj; | |
76 | extern const char * gIOKernelKmods; | |
77 | OSString * errorString = NULL; // must release | |
78 | OSDictionary * fakeKmods; // must release | |
79 | OSCollectionIterator * kmodIter; // must release | |
80 | OSString * kmodName; // don't release | |
81 | ||
1c79356b A |
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 | } | |
91447636 A |
129 | |
130 | // empty version strings get replaced with current kernel version | |
131 | const char *vers = (strlen(kmodVersion->getCStringNoCopy()) | |
132 | ? kmodVersion->getCStringNoCopy() | |
133 | : osrelease); | |
134 | ||
135 | if (KERN_SUCCESS != kmod_create_fake(kmodName->getCStringNoCopy(), vers)) { | |
1c79356b A |
136 | panic("Failure declaring in-kernel kmod \"%s\".\n", |
137 | kmodName->getCStringNoCopy()); | |
138 | } | |
139 | } | |
140 | ||
141 | kmodIter->release(); | |
142 | fakeKmods->release(); | |
143 | ||
144 | ||
145 | ||
146 | root = IORegistryEntry::initialize(); | |
147 | assert( root ); | |
148 | IOService::initialize(); | |
149 | IOCatalogue::initialize(); | |
150 | IOUserClient::initialize(); | |
151 | IOMemoryDescriptor::initialize(); | |
1c79356b | 152 | |
91447636 | 153 | obj = OSString::withCString( version ); |
1c79356b A |
154 | assert( obj ); |
155 | if( obj ) { | |
156 | root->setProperty( kIOKitBuildVersionKey, obj ); | |
157 | obj->release(); | |
158 | } | |
159 | obj = IOKitDiagnostics::diagnostics(); | |
160 | if( obj ) { | |
161 | root->setProperty( kIOKitDiagnosticsKey, obj ); | |
162 | obj->release(); | |
163 | } | |
164 | ||
1c79356b A |
165 | rootNub = new IOPlatformExpertDevice; |
166 | ||
167 | if( rootNub && rootNub->initWithArgs( p1, p2, p3, p4)) { | |
168 | rootNub->attach( 0 ); | |
169 | ||
170 | /* Enter into the catalogue the drivers | |
171 | * provided by BootX. | |
172 | */ | |
173 | gIOCatalogue->recordStartupExtensions(); | |
174 | ||
175 | rootNub->registerService(); | |
176 | } | |
177 | } | |
178 | ||
179 | }; /* extern "C" */ |