]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
6d2010ae | 2 | * Copyright (c) 1998-2010 Apple Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b | 27 | */ |
1c79356b A |
28 | |
29 | #include <libkern/c++/OSUnserialize.h> | |
b0d623f7 | 30 | #include <libkern/c++/OSKext.h> |
91447636 | 31 | #include <libkern/version.h> |
1c79356b A |
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> | |
6d2010ae | 41 | #include <IOKit/pwr_mgt/RootDomain.h> |
0c530ab8 | 42 | #include <IOKit/pwr_mgt/IOPMinformeeList.h> |
6d2010ae A |
43 | #include <IOKit/IOStatisticsPrivate.h> |
44 | #include <IOKit/IOKitKeysPrivate.h> | |
fe8ab488 | 45 | #include <IOKit/IOInterruptAccountingPrivate.h> |
1c79356b A |
46 | |
47 | #include <IOKit/assert.h> | |
48 | ||
91447636 A |
49 | #include "IOKitKernelInternal.h" |
50 | ||
fe8ab488 A |
51 | const OSSymbol * gIOProgressBackbufferKey; |
52 | OSSet * gIORemoveOnReadProperties; | |
53 | ||
1c79356b A |
54 | extern "C" { |
55 | ||
56 | extern void OSlibkernInit (void); | |
1c79356b | 57 | |
39236c6e | 58 | void iokit_post_constructor_init(void); |
b0d623f7 | 59 | |
1c79356b | 60 | #include <kern/clock.h> |
2d21ac55 | 61 | #include <sys/time.h> |
1c79356b | 62 | |
2d21ac55 | 63 | void IOKitInitializeTime( void ) |
1c79356b | 64 | { |
55e303ae | 65 | mach_timespec_t t; |
1c79356b | 66 | |
55e303ae A |
67 | t.tv_sec = 30; |
68 | t.tv_nsec = 0; | |
69 | IOService::waitForService( | |
70 | IOService::resourceMatching("IORTC"), &t ); | |
6d2010ae | 71 | #if defined(__i386__) || defined(__x86_64__) |
55e303ae A |
72 | IOService::waitForService( |
73 | IOService::resourceMatching("IONVRAM"), &t ); | |
1c79356b A |
74 | #endif |
75 | ||
76 | clock_initialize_calendar(); | |
77 | } | |
78 | ||
2d21ac55 A |
79 | void IOKitResetTime( void ) |
80 | { | |
b0d623f7 A |
81 | clock_sec_t secs; |
82 | clock_usec_t microsecs; | |
2d21ac55 A |
83 | |
84 | clock_initialize_calendar(); | |
85 | ||
86 | clock_get_calendar_microtime(&secs, µsecs); | |
87 | gIOLastWakeTime.tv_sec = secs; | |
88 | gIOLastWakeTime.tv_usec = microsecs; | |
6d2010ae A |
89 | |
90 | IOService::updateConsoleUsers(NULL, kIOMessageSystemHasPoweredOn); | |
2d21ac55 A |
91 | } |
92 | ||
b0d623f7 | 93 | void iokit_post_constructor_init(void) |
1c79356b | 94 | { |
1c79356b A |
95 | IORegistryEntry * root; |
96 | OSObject * obj; | |
1c79356b A |
97 | |
98 | root = IORegistryEntry::initialize(); | |
99 | assert( root ); | |
100 | IOService::initialize(); | |
101 | IOCatalogue::initialize(); | |
6d2010ae A |
102 | IOStatistics::initialize(); |
103 | OSKext::initialize(); | |
1c79356b A |
104 | IOUserClient::initialize(); |
105 | IOMemoryDescriptor::initialize(); | |
6d2010ae | 106 | IORootParent::initialize(); |
1c79356b | 107 | |
0c530ab8 A |
108 | // Initializes IOPMinformeeList class-wide shared lock |
109 | IOPMinformeeList::getSharedRecursiveLock(); | |
110 | ||
91447636 | 111 | obj = OSString::withCString( version ); |
1c79356b A |
112 | assert( obj ); |
113 | if( obj ) { | |
114 | root->setProperty( kIOKitBuildVersionKey, obj ); | |
115 | obj->release(); | |
116 | } | |
117 | obj = IOKitDiagnostics::diagnostics(); | |
118 | if( obj ) { | |
119 | root->setProperty( kIOKitDiagnosticsKey, obj ); | |
120 | obj->release(); | |
121 | } | |
b0d623f7 A |
122 | } |
123 | ||
124 | // From <osfmk/kern/debug.c> | |
125 | extern int debug_mode; | |
126 | ||
127 | /***** | |
128 | * Pointer into bootstrap KLD segment for functions never used past startup. | |
129 | */ | |
130 | void (*record_startup_extensions_function)(void) = 0; | |
131 | ||
132 | void StartIOKit( void * p1, void * p2, void * p3, void * p4 ) | |
133 | { | |
134 | IOPlatformExpertDevice * rootNub; | |
135 | int debugFlags; | |
136 | ||
137 | if( PE_parse_boot_argn( "io", &debugFlags, sizeof (debugFlags) )) | |
6d2010ae A |
138 | gIOKitDebug = debugFlags; |
139 | ||
060df5ea A |
140 | if( PE_parse_boot_argn( "iotrace", &debugFlags, sizeof (debugFlags) )) |
141 | gIOKitTrace = debugFlags; | |
142 | ||
143 | // Compat for boot-args | |
144 | gIOKitTrace |= (gIOKitDebug & kIOTraceCompatBootArgs); | |
060df5ea | 145 | |
b0d623f7 A |
146 | // Check for the log synchronous bit set in io |
147 | if (gIOKitDebug & kIOLogSynchronous) | |
148 | debug_mode = true; | |
6d2010ae | 149 | |
b0d623f7 A |
150 | // |
151 | // Have to start IOKit environment before we attempt to start | |
152 | // the C++ runtime environment. At some stage we have to clean up | |
153 | // the initialisation path so that OS C++ can initialise independantly | |
154 | // of iokit basic service initialisation, or better we have IOLib stuff | |
155 | // initialise as basic OS services. | |
156 | // | |
157 | IOLibInit(); | |
158 | OSlibkernInit(); | |
159 | ||
fe8ab488 A |
160 | gIOProgressBackbufferKey = OSSymbol::withCStringNoCopy(kIOProgressBackbufferKey); |
161 | gIORemoveOnReadProperties = OSSet::withObjects((const OSObject **) &gIOProgressBackbufferKey, 1); | |
162 | ||
163 | interruptAccountingInit(); | |
164 | ||
1c79356b A |
165 | rootNub = new IOPlatformExpertDevice; |
166 | ||
167 | if( rootNub && rootNub->initWithArgs( p1, p2, p3, p4)) { | |
168 | rootNub->attach( 0 ); | |
169 | ||
b0d623f7 A |
170 | /* If the bootstrap segment set up a function to record startup |
171 | * extensions, call it now. | |
1c79356b | 172 | */ |
b0d623f7 A |
173 | if (record_startup_extensions_function) { |
174 | record_startup_extensions_function(); | |
175 | } | |
1c79356b A |
176 | |
177 | rootNub->registerService(); | |
2d21ac55 A |
178 | |
179 | #if !NO_KEXTD | |
180 | /* Add a busy count to keep the registry busy until kextd has | |
181 | * completely finished launching. This is decremented when kextd | |
182 | * messages the kernel after the in-kernel linker has been | |
183 | * removed and personalities have been sent. | |
184 | */ | |
185 | IOService::getServiceRoot()->adjustBusy(1); | |
186 | #endif | |
1c79356b A |
187 | } |
188 | } | |
189 | ||
2d21ac55 A |
190 | void |
191 | IORegistrySetOSBuildVersion(char * build_version) | |
192 | { | |
193 | IORegistryEntry * root = IORegistryEntry::getRegistryRoot(); | |
194 | ||
195 | if (root) { | |
196 | if (build_version) { | |
197 | root->setProperty(kOSBuildVersionKey, build_version); | |
198 | } else { | |
199 | root->removeProperty(kOSBuildVersionKey); | |
200 | } | |
201 | } | |
202 | ||
203 | return; | |
204 | } | |
205 | ||
fe8ab488 A |
206 | void |
207 | IORecordProgressBackbuffer(void * buffer, size_t size, uint32_t theme) | |
208 | { | |
209 | IORegistryEntry * chosen; | |
210 | if ((chosen = IORegistryEntry::fromPath(kIODeviceTreePlane ":/chosen"))) | |
211 | { | |
212 | chosen->setProperty(kIOProgressBackbufferKey, buffer, size); | |
213 | chosen->setProperty(kIOProgressColorThemeKey, theme, 32); | |
214 | ||
215 | chosen->release(); | |
216 | } | |
217 | } | |
218 | ||
1c79356b | 219 | }; /* extern "C" */ |