The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/iokit/Kernel/IOStartIOKit.cpp

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
    5  * 
    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 License
   10  * may not be used to create, or enable the creation or redistribution of,
   11  * unlawful or unlicensed copies of an Apple operating system, or to
   12  * circumvent, violate, or enable the circumvention or violation of, any
   13  * terms of an Apple operating system software license agreement.
   14  * 
   15  * Please obtain a copy of the License at
   16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
   17  * 
   18  * The Original Code and all software distributed under the License are
   19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   23  * Please see the License for the specific language governing rights and
   24  * limitations under the License.
   25  * 
   26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
   27  */
   28 /*
   29  * Copyright (c) 1998,1999 Apple Computer, Inc.  All rights reserved. 
   30  *
   31  * HISTORY
   32  *
   33  */
   34 
   35 #include <libkern/c++/OSUnserialize.h>
   36 #include <libkern/version.h>
   37 #include <IOKit/IORegistryEntry.h>
   38 #include <IOKit/IODeviceTreeSupport.h>
   39 #include <IOKit/IOCatalogue.h>
   40 #include <IOKit/IOUserClient.h>
   41 #include <IOKit/IOMemoryDescriptor.h>
   42 #include <IOKit/IOPlatformExpert.h>
   43 #include <IOKit/IOLib.h>
   44 #include <IOKit/IOKitKeys.h>
   45 #include <IOKit/IOKitDebug.h>
   46 #include <IOKit/pwr_mgt/IOPMinformeeList.h>
   47 
   48 #include <IOKit/assert.h>
   49 
   50 #include "IOKitKernelInternal.h"
   51 
   52 extern "C" {
   53 
   54 extern void OSlibkernInit (void);
   55 extern void ml_hpet_cfg(uint32_t, uint32_t);
   56 
   57 #include <kern/clock.h>
   58 #include <sys/time.h>
   59 
   60 void IOKitInitializeTime( void )
   61 {
   62         mach_timespec_t         t;
   63 
   64         t.tv_sec = 30;
   65         t.tv_nsec = 0;
   66         IOService::waitForService(
   67                 IOService::resourceMatching("IORTC"), &t );
   68 #ifdef ppc
   69         IOService::waitForService(
   70                 IOService::resourceMatching("IONVRAM"), &t );
   71 #endif
   72 
   73     clock_initialize_calendar();
   74 }
   75 
   76 void IOKitResetTime( void )
   77 {
   78     uint32_t secs, microsecs;
   79 
   80     clock_initialize_calendar();
   81 
   82     clock_get_calendar_microtime(&secs, &microsecs);
   83     gIOLastWakeTime.tv_sec  = secs;
   84     gIOLastWakeTime.tv_usec = microsecs;
   85 }
   86 
   87 
   88 // From <osfmk/kern/debug.c>
   89 extern int debug_mode;
   90 
   91 void StartIOKit( void * p1, void * p2, void * p3, void * p4 )
   92 {
   93     IOPlatformExpertDevice *    rootNub;
   94     int                         debugFlags;
   95     IORegistryEntry *           root;
   96     OSObject *                  obj;
   97     extern const char *         gIOKernelKmods;
   98     OSString *                  errorString = NULL; // must release
   99     OSDictionary *              fakeKmods;  // must release
  100     OSCollectionIterator *      kmodIter;   // must release
  101     OSString *                  kmodName;   // don't release
  102 
  103     if( PE_parse_boot_arg( "io", &debugFlags ))
  104         gIOKitDebug = debugFlags;
  105 
  106     // Check for the log synchronous bit set in io
  107     if (gIOKitDebug & kIOLogSynchronous)
  108         debug_mode = true;
  109 
  110     //
  111     // Have to start IOKit environment before we attempt to start
  112     // the C++ runtime environment.  At some stage we have to clean up
  113     // the initialisation path so that OS C++ can initialise independantly
  114     // of iokit basic service initialisation, or better we have IOLib stuff
  115     // initialise as basic OS services.
  116     //
  117     IOLibInit(); 
  118     OSlibkernInit();
  119 
  120    /*****
  121     * Declare the fake kmod_info structs for built-in components
  122     * that must be tracked as independent units for dependencies.
  123     */
  124     fakeKmods = OSDynamicCast(OSDictionary,
  125         OSUnserialize(gIOKernelKmods, &errorString));
  126 
  127     if (!fakeKmods) {
  128         if (errorString) {
  129             panic("Kernel kmod list syntax error: %s\n",
  130                     errorString->getCStringNoCopy());
  131             errorString->release();
  132         } else {
  133             panic("Error loading kernel kmod list.\n");
  134         }
  135     }
  136 
  137     kmodIter = OSCollectionIterator::withCollection(fakeKmods);
  138     if (!kmodIter) {
  139         panic("Can't declare in-kernel kmods.\n");
  140     }
  141     while ((kmodName = OSDynamicCast(OSString, kmodIter->getNextObject()))) {
  142 
  143         OSString * kmodVersion = OSDynamicCast(OSString,
  144             fakeKmods->getObject(kmodName));
  145         if (!kmodVersion) {
  146             panic("Can't declare in-kernel kmod; \"%s\" has "
  147                 "an invalid version.\n",
  148                 kmodName->getCStringNoCopy());
  149         }
  150 
  151         // empty version strings get replaced with current kernel version
  152         const char *vers = (strlen(kmodVersion->getCStringNoCopy())
  153                                  ? kmodVersion->getCStringNoCopy()
  154                                  : osrelease);
  155 
  156         if (KERN_SUCCESS != kmod_create_fake(kmodName->getCStringNoCopy(), vers)) {
  157             panic("Failure declaring in-kernel kmod \"%s\".\n",
  158                 kmodName->getCStringNoCopy());
  159         }
  160     }
  161 
  162     kmodIter->release();
  163     fakeKmods->release();
  164 
  165 
  166 
  167     root = IORegistryEntry::initialize();
  168     assert( root );
  169     IOService::initialize();
  170     IOCatalogue::initialize();
  171     IOUserClient::initialize();
  172     IOMemoryDescriptor::initialize();
  173 
  174     // Initializes IOPMinformeeList class-wide shared lock
  175     IOPMinformeeList::getSharedRecursiveLock();
  176 
  177     obj = OSString::withCString( version );
  178     assert( obj );
  179     if( obj ) {
  180         root->setProperty( kIOKitBuildVersionKey, obj );
  181         obj->release();
  182     }
  183     obj = IOKitDiagnostics::diagnostics();
  184     if( obj ) {
  185         root->setProperty( kIOKitDiagnosticsKey, obj );
  186         obj->release();
  187     }
  188 
  189     rootNub = new IOPlatformExpertDevice;
  190 
  191     if( rootNub && rootNub->initWithArgs( p1, p2, p3, p4)) {
  192         rootNub->attach( 0 );
  193 
  194        /* Enter into the catalogue the drivers
  195         * provided by BootX.
  196         */
  197         gIOCatalogue->recordStartupExtensions();
  198 
  199         rootNub->registerService();
  200 
  201 #if !NO_KEXTD
  202        /* Add a busy count to keep the registry busy until kextd has
  203         * completely finished launching. This is decremented when kextd
  204         * messages the kernel after the in-kernel linker has been
  205         * removed and personalities have been sent.
  206         */
  207         IOService::getServiceRoot()->adjustBusy(1);
  208 #endif
  209     }
  210 }
  211 
  212 void
  213 IORegistrySetOSBuildVersion(char * build_version)
  214 {
  215     IORegistryEntry * root = IORegistryEntry::getRegistryRoot();
  216 
  217     if (root) {
  218         if (build_version) {
  219             root->setProperty(kOSBuildVersionKey, build_version);
  220         } else {
  221             root->removeProperty(kOSBuildVersionKey);
  222         }
  223     }
  224 
  225     return;
  226 }
  227 
  228 }; /* extern "C" */

Cache object: d9258a3c6d7288ae4acb4cbce7e09bb3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.