]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOStartIOKit.cpp
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1998,1999 Apple Computer, Inc. All rights reserved.
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>
40 #include <IOKit/assert.h>
44 extern void OSlibkernInit (void);
45 extern void IOLibInit(void);
47 #include <kern/clock.h>
49 void IOKitResetTime( void )
55 IOService::waitForService(
56 IOService::resourceMatching("IORTC"), &t
);
58 IOService::waitForService(
59 IOService::resourceMatching("IONVRAM"), &t
);
62 clock_initialize_calendar();
65 // From <osfmk/kern/debug.c>
66 extern int debug_mode
;
68 void StartIOKit( void * p1
, void * p2
, void * p3
, void * p4
)
70 IOPlatformExpertDevice
* rootNub
;
72 IORegistryEntry
* root
;
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
80 IOLog( iokit_version
);
82 if( PE_parse_boot_arg( "io", &debugFlags
))
83 gIOKitDebug
= debugFlags
;
85 // Check for the log synchronous bit set in io
86 if (gIOKitDebug
& kIOLogSynchronous
)
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.
100 * Declare the fake kmod_info structs for built-in components
101 * that must be tracked as independent units for dependencies.
103 fakeKmods
= OSDynamicCast(OSDictionary
,
104 OSUnserialize(gIOKernelKmods
, &errorString
));
108 panic("Kernel kmod list syntax error: %s\n",
109 errorString
->getCStringNoCopy());
110 errorString
->release();
112 panic("Error loading kernel kmod list.\n");
116 kmodIter
= OSCollectionIterator::withCollection(fakeKmods
);
118 panic("Can't declare in-kernel kmods.\n");
120 while ((kmodName
= OSDynamicCast(OSString
, kmodIter
->getNextObject()))) {
122 OSString
* kmodVersion
= OSDynamicCast(OSString
,
123 fakeKmods
->getObject(kmodName
));
125 panic("Can't declare in-kernel kmod; \"%s\" has "
126 "an invalid version.\n",
127 kmodName
->getCStringNoCopy());
129 if (KERN_SUCCESS
!= kmod_create_fake(kmodName
->getCStringNoCopy(),
130 kmodVersion
->getCStringNoCopy())) {
131 panic("Failure declaring in-kernel kmod \"%s\".\n",
132 kmodName
->getCStringNoCopy());
137 fakeKmods
->release();
141 root
= IORegistryEntry::initialize();
143 IOService::initialize();
144 IOCatalogue::initialize();
145 IOUserClient::initialize();
146 IOMemoryDescriptor::initialize();
148 obj
= OSString::withCString( iokit_version
);
151 root
->setProperty( kIOKitBuildVersionKey
, obj
);
154 obj
= IOKitDiagnostics::diagnostics();
156 root
->setProperty( kIOKitDiagnosticsKey
, obj
);
160 rootNub
= new IOPlatformExpertDevice
;
162 if( rootNub
&& rootNub
->initWithArgs( p1
, p2
, p3
, p4
)) {
163 rootNub
->attach( 0 );
165 /* Enter into the catalogue the drivers
168 gIOCatalogue
->recordStartupExtensions();
170 rootNub
->registerService();