Chameleon

Chameleon Commit Details

Date:2011-05-06 06:37:22 (8 years 3 months ago)
Author:mozo
Commit:758
Parents: 757
Message:10.7 Lion support by cpram & others. Kernelcache fixes by netkas, slice and other fixes. Credits going to all involved
Changes:
A/trunk/i386/libsaio/bootargs.h
M/trunk/i386/boot2/drivers.c
M/trunk/i386/libsaio/bios.h
M/trunk/Chameleon.xcodeproj/project.pbxproj
M/trunk/i386/libsaio/saio_types.h
M/trunk/i386/boot2/boot.c
M/trunk/i386/libsaio/bootstruct.c
M/trunk/i386/libsaio/fake_efi.c
M/trunk/i386/boot2/boot.h
M/trunk/i386/libsaio/saio_internal.h
M/trunk/i386/libsaio/bootstruct.h
M/trunk/i386/libsaio/load.c

File differences

trunk/Chameleon.xcodeproj/project.pbxproj
1010
1111
1212
13
1314
1415
1516
......
485486
486487
487488
489
488490
489491
490492
......
913915
914916
915917
918
916919
917920
918921
0172D0DC11FB66820030222E /* dram_controllers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dram_controllers.h; sourceTree = "<group>"; };
0172D0DD11FB66820030222E /* dram_controllers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dram_controllers.c; sourceTree = "<group>"; };
019DFBAF11FB94090013E8CC /* MEMTEST86_LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MEMTEST86_LICENSE; sourceTree = "<group>"; };
1D145307137073F40050C0CD /* bootargs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootargs.h; sourceTree = "<group>"; };
65ED53931204B83200B22507 /* disk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = disk.h; sourceTree = "<group>"; };
B0056CD611F3868000754B65 /* boot */ = {isa = PBXFileReference; lastKnownFileType = text; path = boot; sourceTree = "<group>"; };
B0056CD711F3868000754B65 /* boot.sys */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.preload"; path = boot.sys; sourceTree = "<group>"; };
B0056D2C11F3868000754B65 /* bios.h */,
B0056D2D11F3868000754B65 /* bios.s */,
B0056D2E11F3868000754B65 /* biosfn.c */,
1D145307137073F40050C0CD /* bootargs.h */,
B0056D2F11F3868000754B65 /* bootstruct.c */,
B0056D3011F3868000754B65 /* bootstruct.h */,
B0056D3111F3868000754B65 /* cache.c */,
isa = PBXProject;
buildConfigurationList = 1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "Chameleon" */;
compatibilityVersion = "Xcode 3.1";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
trunk/i386/libsaio/bootstruct.c
3434
3535
3636
37
38
39
37
38
39
40
4041
4142
4243
44
45
46
47
48
4349
4450
4551
......
4955
5056
5157
58
5259
5360
5461
5562
5663
64
5765
5866
5967
......
9199
92100
93101
94
95
102
103
104
105
106
96107
97108
98109
......
104115
105116
106117
107
108
109
118
119
120
121
122
123
124
125
126
127
128
129
110130
111131
112132
......
170190
171191
172192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
173220
* the kernel by the booter.
*/
boot_args *bootArgs;
PrivateBootInfo_t *bootInfo;
Node *gMemoryMapNode;
boot_args*bootArgs;
boot_args_pre_lion*bootArgsPreLion;
PrivateBootInfo_t*bootInfo;
Node*gMemoryMapNode;
static char platformName[64];
bool checkOSVersion(const char * version)
{
return ((gMacOSVersion[0] == version[0]) && (gMacOSVersion[1] == version[1]) && (gMacOSVersion[2] == version[2]) && (gMacOSVersion[3] == version[3]));
}
void initKernBootStruct( void )
{
Node *node;
if ( !init_done )
{
bootArgs = (boot_args *)malloc(sizeof(boot_args));
bootArgsPreLion = (boot_args_pre_lion *)malloc(sizeof(boot_args_pre_lion));
bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t));
if (bootArgs == 0 || bootInfo == 0)
stop("Couldn't allocate boot info\n");
bzero(bootArgs, sizeof(boot_args));
bzero(bootArgsPreLion, sizeof(boot_args_pre_lion));
bzero(bootInfo, sizeof(PrivateBootInfo_t));
// Get system memory map. Also update the size of the
gMemoryMapNode = DT__FindNode("/chosen/memory-map", true);
bootArgs->Version = kBootArgsVersion;
bootArgs->Revision = 5;
bootArgs->Revision = kBootArgsRevision;
bootArgsPreLion->Version = kBootArgsPreLionVersion;
bootArgsPreLion->Revision = kBootArgsPreLionRevision;
init_done = 1;
}
void
reserveKernBootStruct(void)
{
void *oldAddr = bootArgs;
bootArgs = (boot_args *)AllocateKernelMemory(sizeof(boot_args));
bcopy(oldAddr, bootArgs, sizeof(boot_args));
if (checkOSVersion("10.7"))
{
void *oldAddr = bootArgs;
bootArgs = (boot_args *)AllocateKernelMemory(sizeof(boot_args));
bcopy(oldAddr, bootArgs, sizeof(boot_args));
}
else {
void *oldAddr = bootArgsPreLion;
bootArgsPreLion = (boot_args_pre_lion *)AllocateKernelMemory(sizeof(boot_args_pre_lion));
bcopy(oldAddr, bootArgsPreLion, sizeof(boot_args_pre_lion));
}
}
void
DT__FlattenDeviceTree((void **)&addr, &size);
bootArgs->deviceTreeP = (uint32_t)addr;
bootArgs->deviceTreeLength = size;
// Copy BootArgs values to older structure
memcpy(&bootArgsPreLion->CommandLine, &bootArgs->CommandLine, BOOT_LINE_LENGTH);
memcpy(&bootArgsPreLion->Video, &bootArgs->Video, sizeof(Boot_Video));
bootArgsPreLion->MemoryMap = bootArgs->MemoryMap;
bootArgsPreLion->MemoryMapSize = bootArgs->MemoryMapSize;
bootArgsPreLion->MemoryMapDescriptorSize = bootArgs->MemoryMapDescriptorSize;
bootArgsPreLion->MemoryMapDescriptorVersion = bootArgs->MemoryMapDescriptorVersion;
bootArgsPreLion->deviceTreeP = bootArgs->deviceTreeP;
bootArgsPreLion->deviceTreeLength = bootArgs->deviceTreeLength;
bootArgsPreLion->kaddr = bootArgs->kaddr;
bootArgsPreLion->ksize = bootArgs->ksize;
bootArgsPreLion->efiRuntimeServicesPageStart = bootArgs->efiRuntimeServicesPageStart;
bootArgsPreLion->efiRuntimeServicesPageCount = bootArgs->efiRuntimeServicesPageCount;
bootArgsPreLion->efiSystemTable = bootArgs->efiSystemTable;
bootArgsPreLion->efiMode = bootArgs->efiMode;
bootArgsPreLion->performanceDataStart = bootArgs->performanceDataStart;
bootArgsPreLion->performanceDataSize = bootArgs->performanceDataSize;
bootArgsPreLion->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart;
}
trunk/i386/libsaio/bootstruct.h
2525
2626
2727
28
28
2929
3030
3131
......
3434
3535
3636
37
3738
3839
3940
#ifndef __BOOTSTRUCT_H
#define __BOOTSTRUCT_H
#include <pexpert/i386/boot.h>
#include "bootargs.h"
#include "saio_types.h"
#include "bios.h"
#include "device_tree.h"
Kernel boot args global also used by booter for its own data.
*/
extern boot_args *bootArgs;
extern boot_args_pre_lion *bootArgsPreLion;
extern Node *gMemoryMapNode;
#define VGA_TEXT_MODE 0
trunk/i386/libsaio/bootargs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _PEXPERT_I386_BOOT_H
#define _PEXPERT_I386_BOOT_H
#include <stdint.h>
/*
* What the booter leaves behind for the kernel.
*/
/*
* Types of boot driver that may be loaded by the booter.
*/
enum {
kBootDriverTypeInvalid = 0,
kBootDriverTypeKEXT = 1,
kBootDriverTypeMKEXT = 2
};
enum {
kEfiReservedMemoryType= 0,
kEfiLoaderCode= 1,
kEfiLoaderData= 2,
kEfiBootServicesCode= 3,
kEfiBootServicesData= 4,
kEfiRuntimeServicesCode= 5,
kEfiRuntimeServicesData= 6,
kEfiConventionalMemory= 7,
kEfiUnusableMemory= 8,
kEfiACPIReclaimMemory= 9,
kEfiACPIMemoryNVS= 10,
kEfiMemoryMappedIO= 11,
kEfiMemoryMappedIOPortSpace = 12,
kEfiPalCode= 13,
kEfiMaxMemoryType= 14
};
/*
* Memory range descriptor.
*/
typedef struct EfiMemoryRange {
uint32_t Type;
uint32_t Pad;
uint64_t PhysicalStart;
uint64_t VirtualStart;
uint64_t NumberOfPages;
uint64_t Attribute;
} EfiMemoryRange;
#define BOOT_LINE_LENGTH 1024
#define BOOT_STRING_LEN BOOT_LINE_LENGTH
/*
* Video information..
*/
struct Boot_Video {
uint32_tv_baseAddr;/* Base address of video memory */
uint32_tv_display;/* Display Code (if Applicable */
uint32_tv_rowBytes;/* Number of bytes per pixel row */
uint32_tv_width;/* Width */
uint32_tv_height;/* Height */
uint32_tv_depth;/* Pixel Depth */
};
typedef struct Boot_VideoBoot_Video;
/* Values for v_display */
#define GRAPHICS_MODE1
#define FB_TEXT_MODE2
/* Boot argument structure - passed into Mach kernel at boot time.
* "Revision" can be incremented for compatible changes
*/
// Lion
#define kBootArgsRevision0
#define kBootArgsVersion2
// Snow Leopard and older
#define kBootArgsPreLionRevision6
#define kBootArgsPreLionVersion1
/* Snapshot constants of previous revisions that are supported */
#define kBootArgsEfiMode3232
#define kBootArgsEfiMode6464
typedef struct boot_args {
uint16_t Revision;/* Revision of boot_args structure */
uint16_t Version;/* Version of boot_args structure */
uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */
uint8_t debugMode; /* Bit field with behavior changes */
uint8_t __reserved1[2];
char CommandLine[BOOT_LINE_LENGTH];/* Passed in command line */
uint32_t MemoryMap; /* Physical address of memory map */
uint32_t MemoryMapSize;
uint32_t MemoryMapDescriptorSize;
uint32_t MemoryMapDescriptorVersion;
Boot_VideoVideo;/* Video Information */
uint32_t deviceTreeP; /* Physical address of flattened device tree */
uint32_t deviceTreeLength; /* Length of flattened tree */
uint32_t kaddr; /* Physical address of beginning of kernel text */
uint32_t ksize; /* Size of combined kernel text+data+efi */
uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */
uint32_t efiRuntimeServicesPageCount;
uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */
uint32_t efiSystemTable; /* physical address of system table in runtime area */
uint32_t __reserved2;
uint32_t performanceDataStart; /* physical address of log */
uint32_t performanceDataSize;
uint32_t keyStoreDataStart; /* physical address of key store data */
uint32_t keyStoreDataSize;
uint64_tbootMemStart;
uint64_tbootMemSize;
uint64_t PhysicalMemorySize;
uint64_t FSBFrequency;
uint32_t __reserved4[734];
} boot_args;
typedef struct boot_args_pre_lion {
uint16_t Revision;/* Revision of boot_args structure */
uint16_t Version;/* Version of boot_args structure */
char CommandLine[BOOT_LINE_LENGTH];/* Passed in command line */
uint32_t MemoryMap; /* Physical address of memory map */
uint32_t MemoryMapSize;
uint32_t MemoryMapDescriptorSize;
uint32_t MemoryMapDescriptorVersion;
Boot_VideoVideo;/* Video Information */
uint32_t deviceTreeP; /* Physical address of flattened device tree */
uint32_t deviceTreeLength; /* Length of flattened tree */
uint32_t kaddr; /* Physical address of beginning of kernel text */
uint32_t ksize; /* Size of combined kernel text+data+efi */
uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */
uint32_t efiRuntimeServicesPageCount;
uint32_t efiSystemTable; /* physical address of system table in runtime area */
uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */
uint8_t __reserved1[3];
uint32_t __reserved2[1];
uint32_t performanceDataStart; /* physical address of log */
uint32_t performanceDataSize;
uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */
uint32_t __reserved3[2];
} boot_args_pre_lion;
extern char gMacOSVersion[8];
#endif /* _PEXPERT_I386_BOOT_H */
trunk/i386/libsaio/bios.h
2929
3030
3131
32
32
3333
3434
3535
#ifndef __LIBSAIO_BIOS_H
#define __LIBSAIO_BIOS_H
#include <pexpert/i386/boot.h>
#include "bootargs.h"
typedef union {
unsigned int rx;
trunk/i386/libsaio/load.c
248248
249249
250250
251
252
253
251
252
253
254254
255255
256256
(vmaddr + vmsize) <= (HIB_ADDR + HIB_LEN)))) {
stop("Kernel overflows available space");
}
if (vmsize && (strcmp(segname, "__PRELINK") == 0))
gHaveKernelCache = true;
if (vmsize && ((strcmp(segname, "__PRELINK_INFO") == 0) || (strcmp(segname, "__PRELINK") == 0)))
gHaveKernelCache = true;
// Copy from file load area.
if (vmsize>0 && filesize>0)
trunk/i386/libsaio/saio_types.h
3030
3131
3232
33
33
3434
3535
3636
#include <sys/types.h>
#include "bios.h"
#include "nbp_cmd.h"
#include <pexpert/i386/boot.h>
#include "bootargs.h"
#if DEBUG
#define DEBUG_DISK(x) printf x
trunk/i386/libsaio/fake_efi.c
7676
7777
7878
79
80
79
80
81
82
8183
8284
8385
......
437439
438440
439441
442
443
444
440445
441
442446
443447
444448
......
604608
605609
606610
611
612
607613
608614
609615
......
615621
616622
617623
618
624
619625
620626
621627
622628
623629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
624646
625647
626648
......
672694
673695
674696
697
698
675699
676700
677701
*/
/* Identify ourselves as the EFI firmware vendor */
static EFI_CHAR16 const FIRMWARE_VENDOR[] = {'C','h','a','m','e','l','e','o','n','_','2','.','0', 0};
static EFI_UINT32 const FIRMWARE_REVISION = 132; /* FIXME: Find a constant for this. */
static EFI_CHAR16 const FIRMWARE_VENDOR[] = {'A','p','p','l','e'};
static EFI_UINT32 const FIRMWARE_REVISION = 0x0001000a;
//static EFI_CHAR16 const FIRMWARE_VENDOR[] = {'C','h','a','m','e','l','e','o','n','_','2','.','0', 0};
//static EFI_UINT32 const FIRMWARE_REVISION = 132; /* FIXME: Find a constant for this. */
/* Default platform system_id (fix by IntVar) */
static EFI_CHAR8 const SYSTEM_ID[] = "0123456789ABCDEF"; //random value gen by uuidgen
static const char const SYSTEM_SERIAL_PROP[] = "SystemSerialNumber";
static const char const SYSTEM_TYPE_PROP[] = "system-type";
static const char const MODEL_PROP[] = "Model";
static const char const BOARDID_PROP[] = "board-id";
static const char const DEV_PATH_SUP[] = "DevicePathsSupported";
static uint32_t DevPathSup = 1;
/*
* Get an smbios option string option to convert to EFI_CHAR16 string
*/
if (Platform.CPU.CPUFrequency != 0)
DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency);
DT__AddProperty(efiPlatformNode,DEV_PATH_SUP, sizeof(uint32_t), &DevPathSup);
// Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist
if ((ret=getSystemID()))
DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) ret);
// Export Model if present
if ((ret16=getSmbiosChar16("SMproductname", &len)))
DT__AddProperty(efiPlatformNode, MODEL_PROP, len, ret16);
// Fill /efi/device-properties node.
setupDeviceProperties(node);
}
/*
* Must be called AFTER getSmbios
*/
void setupBoardId()
{
Node *node;
node = DT__FindNode("/", false);
if (node == 0) {
stop("Couldn't get root node");
}
const char *boardid = getStringForKey("SMboardproduct", &bootInfo->smbiosConfig);
if (boardid)
DT__AddProperty(node, BOARDID_PROP, strlen(boardid)+1, (EFI_CHAR16*)boardid);
}
/*
* Load the smbios.plist override config file if any
*/
smbios_p = (EFI_PTR32)getSmbios(SMBIOS_PATCHED);
addConfigurationTable(&gEfiSmbiosTableGuid, &smbios_p, NULL);
setupBoardId(); //need to be called after getSmbios
// Setup ACPI with DSDT overrides (mackerintel's patch)
setupAcpi();
trunk/i386/libsaio/saio_internal.h
7575
7676
7777
78
7879
7980
8081
extern void sleep(int n);
/* bootstruct.c */
extern bool checkOSVersion(const char * version);
extern void initKernBootStruct(void);
extern void reserveKernBootStruct(void);
extern void copyKernBootStruct(void);
trunk/i386/boot2/boot.c
9494
9595
9696
97
97
98
99
98100
99101
100102
......
148150
149151
150152
151
152
153
153
154
154155
156
155157
156158
157159
......
196198
197199
198200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
199218
200
201
202
203
219
204220
205221
206222
......
461477
462478
463479
464
465
466480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
467512
468513
469514
......
502547
503548
504549
550
551
552
505553
506554
507555
508556
509
510
511
512
557
558
559
560
561
562
563
564
565
566
567
568
513569
514
570
571
515572
573
516574
517575
518576
......
534592
535593
536594
537
538
539
595
540596
541
542
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
543616
544617
618
545619
546620
547621
/*
* Default path to kernel cache file
*/
#define kDefaultCachePath "/System/Library/Caches/com.apple.kernelcaches/kernelcache"
//Slice - first one for Leopard
#define kDefaultCachePathLeo "/System/Library/Caches/com.apple.kernelcaches/"
#define kDefaultCachePathSnow "/System/Library/Caches/com.apple.kext.caches/Startup/"
//==========================================================================
// Zero the BSS.
// Load boot drivers from the specifed root path.
if (!gHaveKernelCache) {
LoadDrivers("/");
}
if (!gHaveKernelCache)
LoadDrivers("/");
clearActivityIndicator();
if (gErrors) {
setupBooterLog();
finalizeBootStruct();
if (checkOSVersion("10.7")) {
// Masking out so that Lion doesn't doublefault
outb(0x21, 0xff); /* Maskout all interrupts Pic1 */
outb(0xa1, 0xff); /* Maskout all interrupts Pic2 */
// Jump to kernel's entry point. There's no going back now.
startprog( kernelEntry, bootArgs );
}
else {
// Jump to kernel's entry point. There's no going back now.
startprog( kernelEntry, bootArgsPreLion );
}
// Jump to kernel's entry point. There's no going back now.
startprog( kernelEntry, bootArgs );
// Not reached
return 0;
if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) {
strlcpy(gBootKernelCacheFile, val, len+1);
} else {
sprintf(gBootKernelCacheFile, "%s.%08lX", kDefaultCachePath, adler32);
}
else {
//Lion
if (checkOSVersion("10.7")) {
sprintf(gBootKernelCacheFile, "%skernelcache", kDefaultCachePathSnow);
}
// Snow Leopard
else if (checkOSVersion("10.6")) {
sprintf(gBootKernelCacheFile, "kernelcache_%s", (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64"); //, adler32);
int lnam = sizeof(gBootKernelCacheFile) + 9; //with adler32
//Slice - TODO
/*
- but the name is longer .adler32 and more...
kernelcache_i386.E102928C.qSs0
so will opendir and scan for some files
*/
char* name;
long prev_time = 0;
struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow);
while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0)
{
if(((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time && strstr(name, gBootKernelCacheFile) && (name[lnam] != '.'))
{
sprintf(gBootKernelCacheFile, "%s%s", kDefaultCachePathSnow, name);
prev_time = time;
}
}
}
else sprintf(gBootKernelCacheFile, "%s.%08lX", kDefaultCachePathLeo, adler32);
}
// Check for cache file.
trycache = (((gBootMode & kBootModeSafe) == 0) &&
break;
}
} while (0);
if (getValueForKey("-usecache", &val, &len, &bootInfo->bootConfig))
trycache=1;
do {
if (trycache) {
bootFile = gBootKernelCacheFile;
verbose("Loading kernel cache %s\n", bootFile);
ret = LoadFile(bootFile);
binary = (void *)kLoadAddr;
if (ret >= 0) {
verbose("Loading kernel cache %s\n", bootFile);
if (checkOSVersion("10.7")) {
ret = LoadThinFatFile(bootFile, &binary);
}
else {
ret = LoadFile(bootFile);
binary = (void *)kLoadAddr;
}
if (ret >= 0)
break;
}
verbose("Kernel cache did not loaded %s\n ", bootFile);
}
bootFile = bootInfo->bootFile;
// Try to load kernel image from alternate locations on boot helper partitions.
}
}
verbose("Loading kernel %s\n", bootFileSpec);
ret = LoadThinFatFile(bootFileSpec, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64)
if (checkOSVersion("10.7"))
{
archCpuType = CPU_TYPE_I386;
ret = LoadThinFatFile(bootFileSpec, &binary);
//Lion, dont load kernel if haz cache
if (!trycache) {
verbose("Loading kernel %s\n", bootFileSpec);
ret = LoadThinFatFile(bootFileSpec, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64) {
archCpuType = CPU_TYPE_I386;
ret = LoadThinFatFile(bootFileSpec, &binary);
}
}
else ret = 1;
}
else {
//Snow leopard or older
verbose("Loading kernel %s\n", bootFileSpec);
ret = LoadThinFatFile(bootFileSpec, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64) {
archCpuType = CPU_TYPE_I386;
ret = LoadThinFatFile(bootFileSpec, &binary);
}
}
} while (0);
clearActivityIndicator();
trunk/i386/boot2/boot.h
177177
178178
179179
180
180181
181182
182183
/*
* drivers.c
*/
extern long LoadExtraDrivers(char * dirSpec);
extern long LoadDrivers(char * dirSpec);
extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);
trunk/i386/boot2/drivers.c
3939
4040
4141
42
42
4343
4444
4545
#include "xml.h"
#include "ramdisk.h"
extern char gMacOSVersion;
//extern char gMacOSVersion[8];
struct Module {
struct Module *nextModule;

Archive Download the corresponding diff file

Revision: 758