#include <libkern/c++/OSUnserialize.h>
#include <libkern/c++/OSKext.h>
#include <libkern/version.h>
#include <IOKit/IORegistryEntry.h>
#include <IOKit/IODeviceTreeSupport.h>
#include <IOKit/IOCatalogue.h>
#include <IOKit/IOUserClient.h>
#include <IOKit/IOMemoryDescriptor.h>
#include <IOKit/IOPlatformExpert.h>
#include <IOKit/IOLib.h>
#include <IOKit/IOKitKeys.h>
#include <IOKit/IOKitDebug.h>
#include <IOKit/pwr_mgt/RootDomain.h>
#include <IOKit/pwr_mgt/IOPMinformeeList.h>
#include <IOKit/IOStatisticsPrivate.h>
#include <IOKit/IOKitKeysPrivate.h>
#include <IOKit/assert.h>
#include "IOKitKernelInternal.h"
extern "C" {
extern void OSlibkernInit (void);
void iokit_post_constructor_init(void) __attribute__((section("__TEXT, initcode")));
#include <kern/clock.h>
#include <sys/time.h>
void IOKitInitializeTime( void )
{
mach_timespec_t t;
t.tv_sec = 30;
t.tv_nsec = 0;
IOService::waitForService(
IOService::resourceMatching("IORTC"), &t );
#if defined(__i386__) || defined(__x86_64__)
IOService::waitForService(
IOService::resourceMatching("IONVRAM"), &t );
#endif
clock_initialize_calendar();
}
void IOKitResetTime( void )
{
clock_sec_t secs;
clock_usec_t microsecs;
clock_initialize_calendar();
clock_get_calendar_microtime(&secs, µsecs);
gIOLastWakeTime.tv_sec = secs;
gIOLastWakeTime.tv_usec = microsecs;
IOService::updateConsoleUsers(NULL, kIOMessageSystemHasPoweredOn);
}
void iokit_post_constructor_init(void)
{
IORegistryEntry * root;
OSObject * obj;
root = IORegistryEntry::initialize();
assert( root );
IOService::initialize();
IOCatalogue::initialize();
IOStatistics::initialize();
OSKext::initialize();
IOUserClient::initialize();
IOMemoryDescriptor::initialize();
IORootParent::initialize();
IOPMinformeeList::getSharedRecursiveLock();
obj = OSString::withCString( version );
assert( obj );
if( obj ) {
root->setProperty( kIOKitBuildVersionKey, obj );
obj->release();
}
obj = IOKitDiagnostics::diagnostics();
if( obj ) {
root->setProperty( kIOKitDiagnosticsKey, obj );
obj->release();
}
}
extern int debug_mode;
void (*record_startup_extensions_function)(void) = 0;
void StartIOKit( void * p1, void * p2, void * p3, void * p4 )
{
IOPlatformExpertDevice * rootNub;
int debugFlags;
if( PE_parse_boot_argn( "io", &debugFlags, sizeof (debugFlags) ))
gIOKitDebug = debugFlags;
if( PE_parse_boot_argn( "iotrace", &debugFlags, sizeof (debugFlags) ))
gIOKitTrace = debugFlags;
gIOKitTrace |= (gIOKitDebug & kIOTraceCompatBootArgs);
if (gIOKitDebug & kIOLogSynchronous)
debug_mode = true;
IOLibInit();
OSlibkernInit();
rootNub = new IOPlatformExpertDevice;
if( rootNub && rootNub->initWithArgs( p1, p2, p3, p4)) {
rootNub->attach( 0 );
if (record_startup_extensions_function) {
record_startup_extensions_function();
}
rootNub->registerService();
#if !NO_KEXTD
IOService::getServiceRoot()->adjustBusy(1);
#endif
}
}
void
IORegistrySetOSBuildVersion(char * build_version)
{
IORegistryEntry * root = IORegistryEntry::getRegistryRoot();
if (root) {
if (build_version) {
root->setProperty(kOSBuildVersionKey, build_version);
} else {
root->removeProperty(kOSBuildVersionKey);
}
}
return;
}
};