Chameleon

Chameleon Commit Details

Date:2015-03-10 07:09:17 (9 years 1 month ago)
Author:ErmaC
Commit:2604
Parents: 2603
Message:Fix instant restart after kexts are being force loaded (Introduced from commit 2561)
Changes:
M/trunk/i386/boot2/drivers.c
M/trunk/i386/boot2/boot.c
M/trunk/i386/libsaio/bootstruct.c
M/trunk/i386/boot2/boot.h

File differences

trunk/i386/libsaio/bootstruct.c
119119
120120
121121
122
122
123123
124
125
126
127
128
129
130
124131
125132
126133
127134
128135
129
130
131
132
133
134
135
136136
137137
138138
void reserveKernBootStruct(void)
{
if ( MacOSVerCurrent >= MacOSVer2Int("10.7") ) // OS X 10.7 and newer
if ( TIGER || LEOPARD || SNOW_LEOPARD )
{
// for 10.4 10.5 10.6
void *oldAddr = bootArgsPreLion;
bootArgsPreLion = (boot_args_pre_lion *)AllocateKernelMemory(sizeof(boot_args_pre_lion));
bcopy(oldAddr, bootArgsPreLion, sizeof(boot_args_pre_lion));
}
else
{
// for 10.7 10.8 10.9 10.10
void *oldAddr = bootArgs;
bootArgs = (boot_args *)AllocateKernelMemory(sizeof(boot_args));
bcopy(oldAddr, bootArgs, sizeof(boot_args));
}
else
{
// for 10.4 10.5 10.6
void *oldAddr = bootArgsPreLion;
bootArgsPreLion = (boot_args_pre_lion *)AllocateKernelMemory(sizeof(boot_args_pre_lion));
bcopy(oldAddr, bootArgsPreLion, sizeof(boot_args_pre_lion));
}
}
//==============================================================================
trunk/i386/boot2/drivers.c
250250
251251
252252
253
253
254254
255255
256256
}
else
{
if (MacOSVerCurrent >= MacOSVer2Int("10.9")) // issue 352
if ( MAVERICKS || YOSEMITE ) // issue 352
{
strlcpy(gExtensionsSpec, dirSpec, 4087); /* 4096 - sizeof("Library/") */
strcat(gExtensionsSpec, "Library/");
trunk/i386/boot2/boot.c
227227
228228
229229
230
230
231231
232232
233
234
235
236
237
238
239
233240
234241
235242
......
238245
239246
240247
241
242
243
244
245248
246
247
248
249249
250250
251251
......
253253
254254
255255
256
256
257257
258258
259259
......
275275
276276
277277
278
279
278
279
280280
281
282
281
282
283
284
285
286
287
283288
284289
285
290
286291
287
288
289
290
292
293
291294
292
293
294
295
296
297
295298
296
299
297300
298
299
301
302
303
304
300305
301
306
307
302308
303
304
305
306
307
308
309
310
309311
310
311312
312
313
313314
314
315
316
317
318
319
320
321
322
323
315
324316
317
318
319
320
321
322
323
324
325325
326326
327327
......
759759
760760
761761
762
762
763763
764
764
765765
766766
767767
768
768
769769
770770
771771
finalizeBootStruct();
// Jump to kernel's entry point. There's no going back now.
if (MacOSVerCurrent >= MacOSVer2Int("10.7"))
if ( TIGER || LEOPARD || SNOW_LEOPARD )
{
// Notify modules that the kernel is about to be started
execute_hook("Kernel Start", (void *)kernelEntry, (void *)bootArgsPreLion, NULL, NULL);
startprog( kernelEntry, bootArgsPreLion );
}
else
{
// Notify modules that the kernel is about to be started
execute_hook("Kernel Start", (void *)kernelEntry, (void *)bootArgs, NULL, NULL);
// Masking out so that Lion doesn't doublefault
startprog( kernelEntry, bootArgs );
}
else
{
// Notify modules that the kernel is about to be started
execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgsPreLion, NULL, NULL);
startprog( kernelEntry, bootArgsPreLion );
}
// Not reached
__builtin_unreachable();
}
//==========================================================================
// LoadKernelCache - Try to load Kernel Cache.
// return the length of the loaded cache file or -1 on error
long LoadKernelCache(const char* cacheFile, void **binary)
long LoadKernelCache(const char *cacheFile, void **binary)
{
charkernelCacheFile[512];
charkernelCachePath[512];
}
else
{
// Lion, Mountain Lion, Mavericks and Yosemite prelink kernel cache file
if (MacOSVerCurrent >= MacOSVer2Int("10.7")) // OSX is Lion (10.7) or newer
// Leopard prelink kernel cache file
if ( TIGER || LEOPARD ) // OSX is 10.4 or 10.5
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCachePathSnow);
verbose("Kernel Cache file path (Mac OS X 10.7 and newer): %s\n", kernelCacheFile);
// Reset cache name.
bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
snprintf(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64, "%s,%s", gRootDevice, bootInfo->bootFile);
adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler));
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s.%08lX", kDefaultCachePathLeo, adler32);
verbose("Reseted kernel cache file path: %s\n", kernelCacheFile);
}
// Snow Leopard prelink kernel cache file
else
else if ( SNOW_LEOPARD )
{
if (MacOSVerCurrent >= MacOSVer2Int("10.6")) // OSX is Snow (10.6)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "kernelcache_%s",
(archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "kernelcache_%s",
(archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");
intlnam = strlen(kernelCacheFile) + 9; //with adler32
char*name;
u_int32_t prev_time = 0;
intlnam = strlen(kernelCacheFile) + 9; //with adler32
char*name;
u_int32_tprev_time = 0;
struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow);
struct dirstuff *cacheDir = opendir(kDefaultCachePathSnow);
/* TODO: handle error? */
if (cacheDir)
/* TODO: handle error? */
if (cacheDir)
{
while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0)
{
while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0)
if (((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time
&& strstr(name, kernelCacheFile) && (name[lnam] != '.'))
{
if (((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time
&& strstr(name, kernelCacheFile) && (name[lnam] != '.'))
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s%s", kDefaultCachePathSnow, name);
prev_time = time;
}
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s%s", kDefaultCachePathSnow, name);
prev_time = time;
}
verbose("Kernel Cache file path (Mac OS X 10.6.X): %s\n", kernelCacheFile);
}
closedir(cacheDir);
verbose("Kernel Cache file path (Mac OS X 10.6.X): %s\n", kernelCacheFile);
}
else
{
// Leopard prelink kernel cache file
// Reset cache name.
bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
snprintf(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64, "%s,%s", gRootDevice, bootInfo->bootFile);
adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler));
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s.%08lX", kDefaultCachePathLeo, adler32);
verbose("Reseted kernel cache file path: %s\n", kernelCacheFile);
}
closedir(cacheDir);
}
else
{
// Lion, Mountain Lion, Mavericks and Yosemite prelink kernel cache file
// for 10.7 10.8 10.9 10.10
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCachePathSnow);
verbose("Kernel Cache file path (Mac OS X 10.7 and newer): %s\n", kernelCacheFile);
}
}
// Check if the kernel cache file exists
// bootFile must start with a / if it not start with a device name
if (!bootFileWithDevice && (bootInfo->bootFile)[0] != '/')
{
if (MacOSVerCurrent >= MacOSVer2Int("10.10")) // OSX is 10.10 or newer
if ( !YOSEMITE ) // Is not Yosemite 10.10
{
snprintf(bootFile, sizeof(bootFile), kDefaultKernelPathForYos "%s", bootInfo->bootFile); // Yosemite
snprintf(bootFile, sizeof(bootFile), "/%s", bootInfo->bootFile); // append a leading /
}
else
{
snprintf(bootFile, sizeof(bootFile), "/%s", bootInfo->bootFile); // append a leading '/'
snprintf(bootFile, sizeof(bootFile), kDefaultKernelPathForYos"%s", bootInfo->bootFile); // Yosemite
}
}
else
trunk/i386/boot2/boot.h
3030
3131
3232
33
34
35
36
37
38
39
33
34
35
36
37
38
39
40
4041
4142
4243
#include "libsaio.h"
// OS X Versions
//#define YOSEMITE checkOSVersion("10.10") // Yosemite
//#define MAVERICKS checkOSVersion("10.9") // Mavericks
//#define MOUNTAIN_LION checkOSVersion("10.8") // Mountain Lion
//#define LION checkOSVersion("10.7") // Lion
//#define SNOW_LEOPARD checkOSVersion("10.6") // Snow Leopard
//#define LEOPARD checkOSVersion("10.5") // Leopard
//#define TIGER checkOSVersion("10.4") // Tiger
//#define GALA checkOSVersion("10.11") // Gala
#define YOSEMITE checkOSVersion("10.10") // Yosemite
#define MAVERICKS checkOSVersion("10.9") // Mavericks
#define MOUNTAIN_LION checkOSVersion("10.8") // Mountain Lion
#define LION checkOSVersion("10.7") // Lion
#define SNOW_LEOPARD checkOSVersion("10.6") // Snow Leopard
#define LEOPARD checkOSVersion("10.5") // Leopard
#define TIGER checkOSVersion("10.4") // Tiger
/*
* Paths used by chameleon

Archive Download the corresponding diff file

Revision: 2604