Chameleon

Chameleon Commit Details

Date:2010-06-04 22:29:58 (13 years 10 months ago)
Author:valv
Commit:172
Parents: 171
Message:added 18seven's Quick-args macro, merged meklort's effort on ramdisk..
Changes:
A/branches/valv/i386/boot1/boot1f32-install.sh
M/branches/valv/i386/libsaio/nvidia.c
M/branches/valv/i386/boot2/ramdisk.c
M/branches/valv/i386/boot2/options.c
M/branches/valv/i386/boot2/ramdisk.h
M/branches/valv/i386/libsaio/915resolution.c
M/branches/valv/i386/libsaio/smbios_patcher.c
M/branches/valv/i386/boot0/boot0.s
M/branches/valv/doc/README
M/branches/valv/i386/boot1/boot1.s
M/branches/valv/i386/boot2/boot.c

File differences

branches/valv/doc/README
1818
1919
2020
21
22
21
2322
2423
2524
......
3130
3231
3332
34
33
3534
3635
3736
......
5251
5352
5453
55
56
54
55
5756
5857
5958
......
6766
6867
6968
70
71
72
73
74
75
76
7769
7870
7971
......
9385
9486
9587
96
97
- automatic FSB detection code even for recent AMD CPUs.
- Apple Software RAID support.
- stage2 loader (boot) can be placed as a regular file in the boot
partition's root folder. It has precedence over the embedded
startupfile.
partition's root folder.
Installation
Suppose that your installation is on /dev/disk0s2
- Install boot0 to the MBR:
sudo fdisk -f boot0 -u -y /dev/rdisk0
sudo ./fdisk440 -f boot0 -u -y /dev/rdisk0
- Install boot1h to the partition's bootsector:
sudo dd if=boot1h of=/dev/rdisk0s2
namely /dev/disk0s3 and /dev/disk1s3
- Install boot0 to the MBR of both disks:
sudo fdisk -f boot0 -u -y /dev/rdisk0
sudo fdisk -f boot0 -u -y /dev/rdisk1
sudo ./fdisk440 -f boot0 -u -y /dev/rdisk0
sudo ./fdisk440 -f boot0 -u -y /dev/rdisk1
- Install boot1h to the bootsector of each boot partition:
sudo dd if=boot1h of=/dev/rdisk0s3
cp boot /Volumes/Boot\ OSX
diskutil unmount disk1s3
- Add "rd=uuid boot-uuid=506D8F03-0596-32D8-BE0B-E3A4E7D5C72A" to your kernel flags
(replace with your root volume's UUID; find out using "Disk Utility.app", right
click on your root volume, then Get Info"):
nano /Library/Preferences/SystemConfiguration/com.apple.Boot.plist
touch /System/Library/Extensions
Support:
--------
Chameleon is released under the terms and conditions of
Apple Public Source License (see APPLE_LICENSE).
To use "Chameleon" for commercial purposes please contact us at:
http://chameleon.osx86.hu/contact
branches/valv/i386/libsaio/smbios_patcher.c
240240
241241
242242
243
244
245
243
244
245
246246
247247
248
249
250
251
252
253
248
249
250
251
252
253
254254
255255
256
257
258
256
257
258
259259
260260
261261
{.name="SMmanufacter",.table_type= 1,.value_type=SMSTRING,.offset=0x04,.auto_str=sm_get_defstr},
{.name="SMproductname",.table_type= 1,.value_type=SMSTRING,.offset=0x05,.auto_str=sm_get_defstr},
{.name="SMsystemversion",.table_type= 1,.value_type=SMSTRING,.offset=0x06,.auto_str=sm_get_defstr},
{.name="SMserial",.table_type= 1,.value_type=SMSTRING,.offset=0x07,.auto_str=sm_get_defstr},
{.name="SMUUID",.table_type= 1, .value_type=SMOWORD,.offset=0x08,.auto_oword=0},
{.name="SMfamily",.table_type= 1,.value_type=SMSTRING,.offset=0x1a,.auto_str=sm_get_defstr},
{.name="SMserial",.table_type= 1,.value_type=SMSTRING,.offset=0x07,.auto_str=sm_get_defstr},
{.name="SMUUID",.table_type= 1, .value_type=SMOWORD,.offset=0x08,.auto_oword=0},
{.name="SMfamily",.table_type= 1,.value_type=SMSTRING,.offset=0x1a,.auto_str=sm_get_defstr},
{.name="SMboardmanufacter",.table_type= 2, .value_type=SMSTRING,.offset=0x04,.auto_str=sm_get_defstr},
{.name="SMboardproduct",.table_type= 2, .value_type=SMSTRING,.offset=0x05,.auto_str=sm_get_defstr},
{.name="SMexternalclock",.table_type= 4,.value_type=SMWORD,.offset=0x12,.auto_int=sm_get_fsb},
{.name="SMmaximalclock",.table_type= 4,.value_type=SMWORD,.offset=0x14,.auto_int=sm_get_cpu},
{.name="SMmemdevloc",.table_type=17,.value_type=SMSTRING,.offset=0x10,.auto_str=0},
{.name="SMmembankloc",.table_type=17,.value_type=SMSTRING,.offset=0x11,.auto_str=0},
{.name="SMmemtype",.table_type=17,.value_type=SMBYTE,.offset=0x12,.auto_int=sm_get_memtype},
{.name="SMmemspeed",.table_type=17,.value_type=SMWORD,.offset=0x15,.auto_int=sm_get_memspeed},
{.name="SMexternalclock",.table_type= 4,.value_type=SMWORD,.offset=0x12,.auto_int=sm_get_fsb},
{.name="SMmaximalclock",.table_type= 4,.value_type=SMWORD,.offset=0x14,.auto_int=sm_get_cpu},
{.name="SMmemdevloc",.table_type=17,.value_type=SMSTRING,.offset=0x10,.auto_str=0},
{.name="SMmembankloc",.table_type=17,.value_type=SMSTRING,.offset=0x11,.auto_str=0},
{.name="SMmemtype",.table_type=17,.value_type=SMBYTE,.offset=0x12,.auto_int=sm_get_memtype},
{.name="SMmemspeed",.table_type=17,.value_type=SMWORD,.offset=0x15,.auto_int=sm_get_memspeed},
{.name="SMmemmanufacter",.table_type=17,.value_type=SMSTRING,.offset=0x17,.auto_str=sm_get_memvendor},
{.name="SMmemserial",.table_type=17,.value_type=SMSTRING,.offset=0x18,.auto_str=sm_get_memserial},
{.name="SMmempart",.table_type=17,.value_type=SMSTRING,.offset=0x1A,.auto_str=sm_get_mempartno},
{.name="SMcputype",.table_type=131,.value_type=SMWORD,.offset=0x04,.auto_int=sm_get_cputype},
{.name="SMbusspeed",.table_type=132,.value_type=SMWORD,.offset=0x04,.auto_str=0}
{.name="SMmempart",.table_type=17,.value_type=SMSTRING,.offset=0x1A,.auto_str=sm_get_mempartno},
{.name="SMcputype",.table_type=131,.value_type=SMWORD,.offset=0x04,.auto_int=sm_get_cputype},
{.name="SMbusspeed",.table_type=132,.value_type=SMWORD,.offset=0x04,.auto_str=0}
};
struct smbios_table_description smbios_table_descriptions[]=
branches/valv/i386/libsaio/nvidia.c
267267
268268
269269
270
270271
271272
272273
{ 0x10DE05E2, "GeForce GTX 260" },
{ 0x10DE05E3, "GeForce GTX 285" },
{ 0x10DE05E6, "GeForce GTX 275" },
{ 0x10DE05EA, "GeForce GTX 260" },
{ 0x10DE05EB, "GeForce GTX 295" },
{ 0x10DE05F9, "Quadro CX" },
{ 0x10DE05FD, "Quadro FX 5800" },
branches/valv/i386/libsaio/915resolution.c
210210
211211
212212
213
213214
214215
215216
216
217
217218
218219
219220
*/
if (map->chipset == CT_UNKWN) {
/*
printf("Unknown chipset type and unrecognized bios.\n");
printf("915resolution only works with Intel 800/900 series graphic chipsets.\n");
*/
printf("Chipset Id: %x\n", map->chipset_id);
close_vbios(map);
return 0;
branches/valv/i386/boot0/boot0.s
5555
5656
5757
58
58
5959
6060
6161
......
313313
314314
315315
316
317
318
319
320
321
322
316323
317
324
325
318326
319327
328
329
320330
321331
322332
323
324
325
333
334
335
336
337
338
339
340
341
342
343
326344
345
327346
328347
329348
......
755774
756775
757776
758
777
759778
760779
761780
......
773792
774793
775794
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797795
798796
799797
;
; Set to 1 to enable verbose mode
;
VERBOSEEQU 0
VERBOSEEQU 1
;
; Various constants.
jne .Pass2
.Pass1:
%ifdef HFSFIRST
cmp BYTE [si + part.type], kPartTypeHFS; In pass 1 we're going to find a HFS+ partition
; equipped with boot1h in its boot record
; regardless if it's active or not.
jne .continue
mov dh, 1 ; Argument for loadBootSector to check HFS+ partition signature.
%else
cmp BYTE [si + part.bootid], kPartActive; In pass 1 we are walking on the standard path
jne .continue; by trying to hop on the active partition.
; by trying to hop on the active partition.
jne .continue
xordh, dh; Argument for loadBootSector to skip HFS+ partition
; signature check.
%endif
jmp .tryToBoot
.Pass2:
; cmp BYTE [si + part.type], kPartTypeHFS; In pass 2 we're going to find a HFS+ partition
; jne .continue; equipped with boot1h in its boot record
;; regardless if it's active or not.
%ifdef HFSFIRST
cmp BYTE [si + part.bootid], kPartActive; In pass 2 we are walking on the standard path
; by trying to hop on the active partition.
jne .continue
xor dh, dh ; Argument for loadBootSector to skip HFS+ partition
; signature check.
%else
cmp BYTE [si + part.type], kPartTypeHFS; In pass 2 we're going to find a HFS+ partition
; equipped with boot1h in its boot record
; regardless if it's active or not.
jne .continue
movdh, 1; Argument for loadBootSector to check HFS+ partition signature.
%endif
DebugChar('*')
%if VERBOSE
gpt_strdb 'GPT', 0
test_strdb 'testing', 0
test_strdb 'test', 0
done_strdb 'done', 0
%endif
pad_boot:
times 440-($-$$) db 0
%ifdef FLOPPY
;--------------------------------------------------------------------------
; Put fake partition entries for the bootable floppy image
;
part1bootid db 0x80 ; first partition active
part1head db 0x00 ; head #
part1sect db 0x02 ; sector # (low 6 bits)
part1cyl db 0x00 ; cylinder # (+ high 2 bits of above)
part1systid db 0xab ; Apple boot partition
times 3 db 0x00 ; ignore head/cyl/sect #'s
part1relsect dd 0x00000001 ; start at sector 1
part1numsect dd 0x00000080 ; 64K for booter
part2bootid db 0x00 ; not active
times 3 db 0x00 ; ignore head/cyl/sect #'s
part2systid db 0xa8 ; Apple UFS partition
times 3 db 0x00 ; ignore head/cyl/sect #'s
part2relsect dd 0x00000082 ; start after booter
; part2numsect dd 0x00000abe ; 1.44MB - 65K
part2numsect dd 0x000015fe ; 2.88MB - 65K
%endif
pad_table_and_sig:
times 510-($-$$) db 0
dw kBootSignature
branches/valv/i386/boot1/boot1.s
5252
5353
5454
55
55
5656
5757
5858
;
; Set to 1 to enable verbose mode.
;
VERBOSEEQU0
VERBOSEEQU1
;
; Various constants.
branches/valv/i386/boot1/boot1f32-install.sh
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
#!/bin/sh
# boot1f32-install.sh
#
# Created by mackerintel on 2/2/09.
# Copyright 2009 mackerintel. All rights reserved.
if [[ x$1 == x ]]; then
echo Usage: $0 disknumber;
exit 0;
fi
if [[ `dd if=/dev/disk${1}s1 count=8 bs=1 skip=82 | uuencode -m -|head -n 2|tail -n 1` != "RkFUMzIgICA=" ]]; then
echo "/dev/disk${1}s1" "isn't" a FAT32 partition;
exit 1;
fi
if [ ! -f boot1f32 ]; then
echo "boot1f32 not found";
exit 1;
fi
dd if=/dev/disk${1}s1 count=1 bs=512 of=/tmp/origbs
cp boot1f32 /tmp/newbs
dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
dd of=/dev/disk${1}s1 count=1 bs=512 if=/tmp/newbs
branches/valv/i386/boot2/ramdisk.h
77
88
99
10
10
11
12
1113
14
15
16
17
18
19
1220
1321
1422
#ifndef __BOOT_RAMDISK_H
#define __BOOT_RAMDISK_H
#define RAMDISKCONFIG_FILENAME "rd(0,0)/RAMDisk.plist"
#define RAMDISKCONFIG_FILENAME "bt(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,
branches/valv/i386/boot2/boot.c
162162
163163
164164
165
166
165167
166168
167169
......
479481
480482
481483
482
484
483485
484486
485487
sleep(kBootErrorTimeout);
}
md0Ramdisk();
setupFakeEfi();
verbose("Starting Darwin %s\n",( archCpuType == CPU_TYPE_I386 ) ? "x86" : "x86_64");
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat))
break;
if (!forceresume && sleeptime+3<bvr->modTime) {
if (!forceresume && ((sleeptime+3)<bvr->modTime)) {
printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override\n",bvr->modTime-sleeptime);
break;
}
branches/valv/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 loaded. XNU will attach this to /dev/md0
void md0Ramdisk()
{
RAMDiskParam ramdiskPtr;
char* filename = 0;
int fh = 0;
// Look for ramdisk at Postboot.img
filename = "bt(0,0)/Postboot.img";
if((fh = open(filename, 0)) == -1)
{
filename = "/Postboot.img";// Check rd(0,0) if not in bt(0,0)
fh = open(filename, 0);
}
if (fh != -1)
{
verbose("Loading 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)
branches/valv/i386/boot2/options.c
724724
725725
726726
727
727
728
728729
729
730
731
732
730733
731734
732735
733
734
735
736
737
738
739
740
741
742
743
736744
737
745
738746
739747
740748
741
749
742750
743751
744
752
753
754
755
756
757
745758
746
759
747760
748761
749762
750763
764
765
766
767
751768
752
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
753790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
754806
755807
756808
gBootMode |= kBootModeSafe;
}
// If user typed F8, abort quiet mode, and display the menu.
#define QUICK_KEYS_ENABLED 1
#if QUICK_KEYS_ENABLED
{
bool f8press = false, spress = false, vpress = false;
/* 18seven's Quick-args macro */
bool f8 = false, altf = false, shiftf = false, alts = false,
altv = false, x32 = false, x64 = false, altx = false;
int key;
while (readKeyboardStatus()) {
key = bgetc ();
if (key == 0x4200) f8press = true;
if ((key & 0xff) == 's' || (key & 0xff) == 'S') spress = true;
if ((key & 0xff) == 'v' || (key & 0xff) == 'V') vpress = true;
if (key == 0x4200) f8 = true;
if (key == 0x2100) altf = true;
if (key == 0x2146) shiftf = true;
if (key == 0x1F00) alts = true;
if (key == 0x2F00) altv = true;
if (key == 0x2D00) altx = true;
if (key == 0x0403) x32 = true;
if (key == 0x0705) x64 = true;
}
if (f8press) {
if (f8) {
gBootMode &= ~kBootModeQuiet;
timeout = 0;
}
if ((gBootMode & kBootModeQuiet) && firstRun && vpress && (gBootArgsPtr + 3 < gBootArgsEnd)) {
if ((altf) && (gBootArgsPtr + 3 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'v';
*(gBootArgsPtr++) = 'f';
}
if ((shiftf) && (gBootArgsPtr + 3 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'F';
}
if ((gBootMode & kBootModeQuiet) && firstRun && spress && (gBootArgsPtr + 3 < gBootArgsEnd)) {
if ((alts) && (gBootArgsPtr + 3 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 's';
}
if ((altv) && (gBootArgsPtr + 3 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'v';
}
clearBootArgs();
if ((altx) && (gBootArgsPtr + 3 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'x';
}
if ((x32) && (gBootArgsPtr + 5 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'x';
*(gBootArgsPtr++) = '3';
*(gBootArgsPtr++) = '2';
}
if ((x64) && (gBootArgsPtr + 5 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'x';
*(gBootArgsPtr++) = '6';
*(gBootArgsPtr++) = '4';
}
}
#else
{
bool f8 = false;
int key;
while (readKeyboardStatus()) {
key = bgetc ();
if (key == 0x4200) f8 = true;
}
if (f8) {
gBootMode &= ~kBootModeQuiet;
timeout = 0;
}
}
#endif
if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
setCursorPosition(0, 0, 0);
clearScreenRows(0, kScreenLastRow);

Archive Download the corresponding diff file

Revision: 172