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