]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOStartIOKit.cpp
2 * Copyright (c) 1998-2005 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);
56 extern void ml_hpet_cfg(uint32_t, uint32_t);
58 #include <kern/clock.h>
60 void IOKitResetTime( void )
66 IOService::waitForService(
67 IOService::resourceMatching("IORTC"), &t
);
69 IOService::waitForService(
70 IOService::resourceMatching("IONVRAM"), &t
);
74 clock_initialize_calendar();
77 // From <osfmk/kern/debug.c>
78 extern int debug_mode
;
80 void StartIOKit( void * p1
, void * p2
, void * p3
, void * p4
)
82 IOPlatformExpertDevice
* rootNub
;
84 IORegistryEntry
* root
;
86 extern const char * gIOKernelKmods
;
87 OSString
* errorString
= NULL
; // must release
88 OSDictionary
* fakeKmods
; // must release
89 OSCollectionIterator
* kmodIter
; // must release
90 OSString
* kmodName
; // don't release
92 if( PE_parse_boot_arg( "io", &debugFlags
))
93 gIOKitDebug
= debugFlags
;
95 // Check for the log synchronous bit set in io
96 if (gIOKitDebug
& kIOLogSynchronous
)
100 // Have to start IOKit environment before we attempt to start
101 // the C++ runtime environment. At some stage we have to clean up
102 // the initialisation path so that OS C++ can initialise independantly
103 // of iokit basic service initialisation, or better we have IOLib stuff
104 // initialise as basic OS services.
110 * Declare the fake kmod_info structs for built-in components
111 * that must be tracked as independent units for dependencies.
113 fakeKmods
= OSDynamicCast(OSDictionary
,
114 OSUnserialize(gIOKernelKmods
, &errorString
));
118 panic("Kernel kmod list syntax error: %s\n",
119 errorString
->getCStringNoCopy());
120 errorString
->release();
122 panic("Error loading kernel kmod list.\n");
126 kmodIter
= OSCollectionIterator::withCollection(fakeKmods
);
128 panic("Can't declare in-kernel kmods.\n");
130 while ((kmodName
= OSDynamicCast(OSString
, kmodIter
->getNextObject()))) {
132 OSString
* kmodVersion
= OSDynamicCast(OSString
,
133 fakeKmods
->getObject(kmodName
));
135 panic("Can't declare in-kernel kmod; \"%s\" has "
136 "an invalid version.\n",
137 kmodName
->getCStringNoCopy());
140 // empty version strings get replaced with current kernel version
141 const char *vers
= (strlen(kmodVersion
->getCStringNoCopy())
142 ? kmodVersion
->getCStringNoCopy()
145 if (KERN_SUCCESS
!= kmod_create_fake(kmodName
->getCStringNoCopy(), vers
)) {
146 panic("Failure declaring in-kernel kmod \"%s\".\n",
147 kmodName
->getCStringNoCopy());
152 fakeKmods
->release();
156 root
= IORegistryEntry::initialize();
158 IOService::initialize();
159 IOCatalogue::initialize();
160 IOUserClient::initialize();
161 IOMemoryDescriptor::initialize();
163 obj
= OSString::withCString( version
);
166 root
->setProperty( kIOKitBuildVersionKey
, obj
);
169 obj
= IOKitDiagnostics::diagnostics();
171 root
->setProperty( kIOKitDiagnosticsKey
, obj
);
175 rootNub
= new IOPlatformExpertDevice
;
177 if( rootNub
&& rootNub
->initWithArgs( p1
, p2
, p3
, p4
)) {
178 rootNub
->attach( 0 );
180 /* Enter into the catalogue the drivers
183 gIOCatalogue
->recordStartupExtensions();
185 rootNub
->registerService();