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