]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOStartIOKit.cpp
eab0c1972b40c2c1ef3cac7b93e4481925cf27a5
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Copyright (c) 1998,1999 Apple Computer, Inc. All rights reserved.
37 #include <libkern/c++/OSUnserialize.h>
38 #include <libkern/version.h>
39 #include <IOKit/IORegistryEntry.h>
40 #include <IOKit/IODeviceTreeSupport.h>
41 #include <IOKit/IOCatalogue.h>
42 #include <IOKit/IOUserClient.h>
43 #include <IOKit/IOMemoryDescriptor.h>
44 #include <IOKit/IOPlatformExpert.h>
45 #include <IOKit/IOLib.h>
46 #include <IOKit/IOKitKeys.h>
47 #include <IOKit/IOKitDebug.h>
49 #include <IOKit/assert.h>
51 #include "IOKitKernelInternal.h"
55 extern void OSlibkernInit (void);
57 #include <kern/clock.h>
59 void IOKitResetTime( void )
65 IOService::waitForService(
66 IOService::resourceMatching("IORTC"), &t
);
68 IOService::waitForService(
69 IOService::resourceMatching("IONVRAM"), &t
);
72 clock_initialize_calendar();
75 // From <osfmk/kern/debug.c>
76 extern int debug_mode
;
78 void StartIOKit( void * p1
, void * p2
, void * p3
, void * p4
)
80 IOPlatformExpertDevice
* rootNub
;
82 IORegistryEntry
* root
;
84 extern const char * gIOKernelKmods
;
85 OSString
* errorString
= NULL
; // must release
86 OSDictionary
* fakeKmods
; // must release
87 OSCollectionIterator
* kmodIter
; // must release
88 OSString
* kmodName
; // don't release
90 if( PE_parse_boot_arg( "io", &debugFlags
))
91 gIOKitDebug
= debugFlags
;
93 // Check for the log synchronous bit set in io
94 if (gIOKitDebug
& kIOLogSynchronous
)
98 // Have to start IOKit environment before we attempt to start
99 // the C++ runtime environment. At some stage we have to clean up
100 // the initialisation path so that OS C++ can initialise independantly
101 // of iokit basic service initialisation, or better we have IOLib stuff
102 // initialise as basic OS services.
108 * Declare the fake kmod_info structs for built-in components
109 * that must be tracked as independent units for dependencies.
111 fakeKmods
= OSDynamicCast(OSDictionary
,
112 OSUnserialize(gIOKernelKmods
, &errorString
));
116 panic("Kernel kmod list syntax error: %s\n",
117 errorString
->getCStringNoCopy());
118 errorString
->release();
120 panic("Error loading kernel kmod list.\n");
124 kmodIter
= OSCollectionIterator::withCollection(fakeKmods
);
126 panic("Can't declare in-kernel kmods.\n");
128 while ((kmodName
= OSDynamicCast(OSString
, kmodIter
->getNextObject()))) {
130 OSString
* kmodVersion
= OSDynamicCast(OSString
,
131 fakeKmods
->getObject(kmodName
));
133 panic("Can't declare in-kernel kmod; \"%s\" has "
134 "an invalid version.\n",
135 kmodName
->getCStringNoCopy());
138 // empty version strings get replaced with current kernel version
139 const char *vers
= (strlen(kmodVersion
->getCStringNoCopy())
140 ? kmodVersion
->getCStringNoCopy()
143 if (KERN_SUCCESS
!= kmod_create_fake(kmodName
->getCStringNoCopy(), vers
)) {
144 panic("Failure declaring in-kernel kmod \"%s\".\n",
145 kmodName
->getCStringNoCopy());
150 fakeKmods
->release();
154 root
= IORegistryEntry::initialize();
156 IOService::initialize();
157 IOCatalogue::initialize();
158 IOUserClient::initialize();
159 IOMemoryDescriptor::initialize();
161 obj
= OSString::withCString( version
);
164 root
->setProperty( kIOKitBuildVersionKey
, obj
);
167 obj
= IOKitDiagnostics::diagnostics();
169 root
->setProperty( kIOKitDiagnosticsKey
, obj
);
173 rootNub
= new IOPlatformExpertDevice
;
175 if( rootNub
&& rootNub
->initWithArgs( p1
, p2
, p3
, p4
)) {
176 rootNub
->attach( 0 );
178 /* Enter into the catalogue the drivers
181 gIOCatalogue
->recordStartupExtensions();
183 rootNub
->registerService();