]>
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  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved. 
   8  * This file contains Original Code and/or Modifications of Original Code 
   9  * as defined in and that are subject to the Apple Public Source License 
  10  * Version 2.0 (the 'License'). You may not use this file except in 
  11  * compliance with the License. Please obtain a copy of the License at 
  12  * http://www.opensource.apple.com/apsl/ and read it before using this 
  15  * The Original Code and all software distributed under the License are 
  16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
  19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  20  * Please see the License for the specific language governing rights and 
  21  * limitations under the License. 
  23  * @APPLE_LICENSE_HEADER_END@ 
  26  * Copyright (c) 1998,1999 Apple Computer, Inc.  All rights reserved.  
  32 #include <libkern/c++/OSUnserialize.h> 
  33 #include <IOKit/IORegistryEntry.h> 
  34 #include <IOKit/IODeviceTreeSupport.h> 
  35 #include <IOKit/IOCatalogue.h> 
  36 #include <IOKit/IOUserClient.h> 
  37 #include <IOKit/IOMemoryDescriptor.h> 
  38 #include <IOKit/IOPlatformExpert.h> 
  39 #include <IOKit/IOLib.h> 
  40 #include <IOKit/IOKitKeys.h> 
  41 #include <IOKit/IOKitDebug.h> 
  43 #include <IOKit/assert.h> 
  47 extern void OSlibkernInit (void); 
  48 extern void IOLibInit(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     IOLog( iokit_version 
); 
  85     if( PE_parse_boot_arg( "io", &debugFlags 
)) 
  86         gIOKitDebug 
= debugFlags
; 
  88     // Check for the log synchronous bit set in io 
  89     if (gIOKitDebug 
& kIOLogSynchronous
) 
  93     // Have to start IOKit environment before we attempt to start 
  94     // the C++ runtime environment.  At some stage we have to clean up 
  95     // the initialisation path so that OS C++ can initialise independantly 
  96     // of iokit basic service initialisation, or better we have IOLib stuff 
  97     // initialise as basic OS services. 
 103     * Declare the fake kmod_info structs for built-in components 
 104     * that must be tracked as independent units for dependencies. 
 106     fakeKmods 
= OSDynamicCast(OSDictionary
, 
 107         OSUnserialize(gIOKernelKmods
, &errorString
)); 
 111             panic("Kernel kmod list syntax error: %s\n", 
 112                     errorString
->getCStringNoCopy()); 
 113             errorString
->release(); 
 115             panic("Error loading kernel kmod list.\n"); 
 119     kmodIter 
= OSCollectionIterator::withCollection(fakeKmods
); 
 121         panic("Can't declare in-kernel kmods.\n"); 
 123     while ((kmodName 
= OSDynamicCast(OSString
, kmodIter
->getNextObject()))) { 
 125         OSString 
* kmodVersion 
= OSDynamicCast(OSString
, 
 126             fakeKmods
->getObject(kmodName
)); 
 128             panic("Can't declare in-kernel kmod; \"%s\" has " 
 129                 "an invalid version.\n", 
 130                 kmodName
->getCStringNoCopy()); 
 132         if (KERN_SUCCESS 
!= kmod_create_fake(kmodName
->getCStringNoCopy(), 
 133                 kmodVersion
->getCStringNoCopy())) { 
 134             panic("Failure declaring in-kernel kmod \"%s\".\n", 
 135                 kmodName
->getCStringNoCopy()); 
 140     fakeKmods
->release(); 
 144     root 
= IORegistryEntry::initialize(); 
 146     IOService::initialize(); 
 147     IOCatalogue::initialize(); 
 148     IOUserClient::initialize(); 
 149     IOMemoryDescriptor::initialize(); 
 151     obj 
= OSString::withCString( iokit_version 
); 
 154         root
->setProperty( kIOKitBuildVersionKey
, obj 
); 
 157     obj 
= IOKitDiagnostics::diagnostics(); 
 159         root
->setProperty( kIOKitDiagnosticsKey
, obj 
); 
 163     rootNub 
= new IOPlatformExpertDevice
; 
 165     if( rootNub 
&& rootNub
->initWithArgs( p1
, p2
, p3
, p4
)) { 
 166         rootNub
->attach( 0 ); 
 168        /* Enter into the catalogue the drivers 
 171         gIOCatalogue
->recordStartupExtensions(); 
 173         rootNub
->registerService();