Chameleon

Chameleon Commit Details

Date:2010-05-15 19:47:52 (9 years 2 months ago)
Author:Evan Lojewski
Commit:152
Parents: 151
Message:Load a ramdisk if it exists, and notify XNU of the ramdisk
Changes:
M/branches/meklort/i386/boot2/boot.c
M/branches/meklort/i386/boot2/ramdisk.c

File differences

branches/meklort/i386/boot2/boot.c
7272
7373
7474
75
75
7676
7777
7878
......
8686
8787
8888
89
9089
9190
9291
......
162161
163162
164163
164
165
165166
166167
167168
bool gScanSingleDrive;
int bvCount = 0;
//intmenucount = 0;
//intmenucount = 0;
int gDeviceCount = 0;
BVRef bvr;
static bool gUnloadPXEOnExit = false;
extern int usb_loop();
/*
* How long to wait (in seconds) to load the
* kernel after displaying the "boot:" prompt.
sleep(kBootErrorTimeout);
}
md0Ramdisk();
setupFakeEfi();
verbose("Starting Darwin %s\n",( archCpuType == CPU_TYPE_I386 ) ? "x86" : "x86_64");
branches/meklort/i386/boot2/ramdisk.c
1616
1717
1818
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
1980
2081
2182
bool gRAMDiskBTAliased = false;
char gRAMDiskFile[512];
// Notify OS X that a ramdisk has been setup. XNU with attach this to /dev/md0
void md0Ramdisk()
{
RAMDiskParam ramdiskPtr;
char* filename = 0;
int fh = 0;
// Look for a ramdisk at Postboot.img (TODO: make configurable)
filename = "rd(0,0)/Extra/Postboot.img";
if((fh = open(filename, 0)) == -1)
{
filename = "/Extra/Postboot.img";// Check /Extra if not in rd(0,0)
fh = open(filename, 0);
}
if (fh != -1)
{
verbose("Enabling ramdisk %s\n", filename);
ramdiskPtr.size = file_size(fh);
ramdiskPtr.base = AllocateKernelMemory(ramdiskPtr.size);
if(ramdiskPtr.size && ramdiskPtr.base)
{
// Read new ramdisk image contents in kernel memory.
if (read(fh, (char*) ramdiskPtr.base, ramdiskPtr.size) == ramdiskPtr.size)
{
AllocateMemoryRange("RAMDisk", ramdiskPtr.base, ramdiskPtr.size, kBootDriverTypeInvalid);
Node* node = DT__FindNode("/chosen/memory-map", false);
if(node != NULL)
{
DT__AddProperty(node, "RAMDisk", sizeof(RAMDiskParam), (void*)&ramdiskPtr);
}
else
{
verbose("Unable to notify Mac OS X of the ramdisk %s.\n", filename);
}
}
else {
verbose("Unable to read ramdisk %s\n", filename);
}
} else {
verbose("Ramdisk %s is empty.\n", filename);
}
close(fh);
}
else {
verbose("Unable to open %s\n", filename);
}
}
void umountRAMDisk()
{
if (gRAMDiskMI != NULL)

Archive Download the corresponding diff file

Revision: 152