]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOStartIOKit.cpp
913ee417078d7b72a62d9c5e63ab71f927bc7877
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 * Copyright (c) 1998,1999 Apple Computer, Inc. All rights reserved.
30 #include <libkern/c++/OSUnserialize.h>
31 #include <libkern/version.h>
32 #include <IOKit/IORegistryEntry.h>
33 #include <IOKit/IODeviceTreeSupport.h>
34 #include <IOKit/IOCatalogue.h>
35 #include <IOKit/IOUserClient.h>
36 #include <IOKit/IOMemoryDescriptor.h>
37 #include <IOKit/IOPlatformExpert.h>
38 #include <IOKit/IOLib.h>
39 #include <IOKit/IOKitKeys.h>
40 #include <IOKit/IOKitDebug.h>
42 #include <IOKit/assert.h>
44 #include "IOKitKernelInternal.h"
48 extern void OSlibkernInit (void);
50 #include <kern/clock.h>
52 void IOKitResetTime( void )
58 IOService::waitForService(
59 IOService::resourceMatching("IORTC"), &t
);
61 IOService::waitForService(
62 IOService::resourceMatching("IONVRAM"), &t
);
65 clock_initialize_calendar();
68 // From <osfmk/kern/debug.c>
69 extern int debug_mode
;
71 void StartIOKit( void * p1
, void * p2
, void * p3
, void * p4
)
73 IOPlatformExpertDevice
* rootNub
;
75 IORegistryEntry
* root
;
77 extern const char * gIOKernelKmods
;
78 OSString
* errorString
= NULL
; // must release
79 OSDictionary
* fakeKmods
; // must release
80 OSCollectionIterator
* kmodIter
; // must release
81 OSString
* kmodName
; // don't release
83 if( PE_parse_boot_arg( "io", &debugFlags
))
84 gIOKitDebug
= debugFlags
;
86 // Check for the log synchronous bit set in io
87 if (gIOKitDebug
& kIOLogSynchronous
)
91 // Have to start IOKit environment before we attempt to start
92 // the C++ runtime environment. At some stage we have to clean up
93 // the initialisation path so that OS C++ can initialise independantly
94 // of iokit basic service initialisation, or better we have IOLib stuff
95 // initialise as basic OS services.
101 * Declare the fake kmod_info structs for built-in components
102 * that must be tracked as independent units for dependencies.
104 fakeKmods
= OSDynamicCast(OSDictionary
,
105 OSUnserialize(gIOKernelKmods
, &errorString
));
109 panic("Kernel kmod list syntax error: %s\n",
110 errorString
->getCStringNoCopy());
111 errorString
->release();
113 panic("Error loading kernel kmod list.\n");
117 kmodIter
= OSCollectionIterator::withCollection(fakeKmods
);
119 panic("Can't declare in-kernel kmods.\n");
121 while ((kmodName
= OSDynamicCast(OSString
, kmodIter
->getNextObject()))) {
123 OSString
* kmodVersion
= OSDynamicCast(OSString
,
124 fakeKmods
->getObject(kmodName
));
126 panic("Can't declare in-kernel kmod; \"%s\" has "
127 "an invalid version.\n",
128 kmodName
->getCStringNoCopy());
131 // empty version strings get replaced with current kernel version
132 const char *vers
= (strlen(kmodVersion
->getCStringNoCopy())
133 ? kmodVersion
->getCStringNoCopy()
136 if (KERN_SUCCESS
!= kmod_create_fake(kmodName
->getCStringNoCopy(), vers
)) {
137 panic("Failure declaring in-kernel kmod \"%s\".\n",
138 kmodName
->getCStringNoCopy());
143 fakeKmods
->release();
147 root
= IORegistryEntry::initialize();
149 IOService::initialize();
150 IOCatalogue::initialize();
151 IOUserClient::initialize();
152 IOMemoryDescriptor::initialize();
154 obj
= OSString::withCString( version
);
157 root
->setProperty( kIOKitBuildVersionKey
, obj
);
160 obj
= IOKitDiagnostics::diagnostics();
162 root
->setProperty( kIOKitDiagnosticsKey
, obj
);
166 rootNub
= new IOPlatformExpertDevice
;
168 if( rootNub
&& rootNub
->initWithArgs( p1
, p2
, p3
, p4
)) {
169 rootNub
->attach( 0 );
171 /* Enter into the catalogue the drivers
174 gIOCatalogue
->recordStartupExtensions();
176 rootNub
->registerService();