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