Chameleon

Chameleon Commit Details

Date:2010-07-26 02:25:56 (8 years 3 months ago)
Author:Evan Lojewski
Commit:256
Parents: 255
Message:Addid support for loading an md0 ramdisk and passing it to xnu
Changes:
M/trunk/i386/boot2/ramdisk.h
M/trunk/i386/boot2/boot.c
M/trunk/i386/boot2/boot.h
M/trunk/CHANGES
M/trunk/i386/boot2/ramdisk.c

File differences

trunk/CHANGES
1
12
23
34
- md0 code. Notified xnu when an md ramdisk is specified
- Optimized memory detection speed
- Added displaying source device and partition number for file read operations.
- Increased boot2's maximum size from 383.5k to 447.5k.
trunk/i386/boot2/ramdisk.h
88
99
1010
11
12
1113
14
15
16
17
18
19
1220
1321
1422
#define __BOOT_RAMDISK_H
#define RAMDISKCONFIG_FILENAME "rd(0,0)/RAMDisk.plist"
//#define kPostbootRamdisk
void md0Ramdisk();
typedef struct RAMDiskParam
{
ppnum_t base;
unsigned int size;
} RAMDiskParam;
/* mboot.c */
extern struct multiboot_info *gMI;
extern int multibootRamdiskReadBytes( int biosdev, unsigned int blkno,
trunk/i386/boot2/boot.c
162162
163163
164164
165
166
165167
166168
167169
setupFakeEfi();
md0Ramdisk();
verbose("Starting Darwin %s\n",( archCpuType == CPU_TYPE_I386 ) ? "x86" : "x86_64");
// Cleanup the PXE base code.
trunk/i386/boot2/boot.h
9292
9393
9494
95
9596
9697
9798
#define kLegacyOff"USBLegacyOff"/* usb.c */
#define kEHCIhard"EHCIhard"/* usb.c */
#define kDefaultPartition"Default Partition"/* sys.c */
#define kMD0Image"md0"/* ramdisk.h */
/*
* Flags to the booter or kernel
trunk/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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
19102
20103
21104
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[512];
const char* override_filename = 0;
int fh = -1;
int len;
if(getValueForKey(kMD0Image, &override_filename, &len,
&bootInfo->bootConfig))
{
// Use user specified md0 file
sprintf(filename, "%s", override_filename);
fh = open(filename, 0);
if(fh < 0)
{
sprintf(filename, "rd(0,0)/Extra/%s", override_filename);
if((fh = open(filename, 0)) < 0)
{
sprintf(filename, "/Extra/%s", override_filename);
fh = open(filename, 0);
}
}
}
if(fh < 0)
{
// Fallback to Postboot.img
sprintf(filename, "rd(0,0)/Extra/Postboot.img");
fh = open(filename, 0);
if(fh < 0)
{
sprintf(filename, "/Extra/Postboot.img");// Check /Extra if not in rd(0,0)
fh = open(filename, 0);
}
}
if (fh >= 0)
{
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 md0 image %s.\n", filename);
}
} else {
verbose("md0 image %s is empty.\n", filename);
}
close(fh);
}
}
void umountRAMDisk()
{
if (gRAMDiskMI != NULL)

Archive Download the corresponding diff file

Revision: 256