Chameleon

Chameleon Commit Details

Date:2016-06-18 21:57:18 (4 years 5 months ago)
Author:ErmaC
Commit:2838
Parents: 2837
Message:Implement Micky1979’s patch for allow boot from Recovery, and enchange vanilla installer.
Changes:
M/trunk/i386/boot2/drivers.c
M/trunk/i386/libsaio/saio_types.h
M/trunk/i386/boot2/boot.c
M/trunk/i386/libsa/libsa.h
M/trunk/i386/libsaio/disk.c
M/trunk/i386/boot2/boot.h
M/trunk/i386/boot2/options.c
M/trunk/i386/libsa/string.c
M/trunk/i386/libsaio/stringTable.c

File differences

trunk/i386/libsaio/disk.c
16981698
16991699
17001700
1701
1701
17021702
1703
17031704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
17041715
17051716
17061717
......
17091720
17101721
17111722
1712
1713
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
17141737
1715
1738
1739
1740
1741
17161742
1717
17181743
17191744
17201745
1721
1746
17221747
1723
1724
1725
1726
1748
1749
1750
17271751
1728
1729
1752
17301753
17311754
17321755
1733
1734
1735
1736
1756
1757
1758
17371759
1738
17391760
17401761
1741
1762
17421763
1743
1744
1745
1746
1747
1748
1764
17491765
1750
17511766
1767
17521768
1753
1769
1770
1771
1772
1773
1774
1775
17541776
1755
1756
1757
1758
1759
1777
17601778
1779
1780
17611781
1762
1763
1764
17651782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
17661813
17671814
1768
1815
17691816
17701817
1818
1819
1820
1821
1822
17711823
1772
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
17731837
1774
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
17751848
1776
1777
1778
1849
1850
1851
1852
1853
17791854
1780
1855
1856
1857
1858
1859
17811860
1782
1783
1784
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
17851897
17861898
17871899
1788
1900
17891901
1902
17901903
1904
1905
1906
1907
1908
17911909
1792
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
17931930
1794
1931
17951932
1933
1934
1935
1936
1937
1938
1939
17961940
17971941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
17981976
17991977
1800
1801
18021978
18031979
1804
1980
18051981
18061982
18071983
......
18151991
18161992
18171993
1994
1995
1996
1997
1998
1999
2000
2001
18182002
18192003
18202004
static bool getOSVersion(BVRef bvr, char *str)
{
bool valid = false;
config_file_t systemVersion;
config_file_t configFile;
char dirSpec[512];
const char *val; int len;
const char *fakeOSVersion;
int fakeOSVersionInt;
// our pattern: avoiding to use full path. this help if the app is named as Beta or DP..
char *LionPattern = "Install%20Mac%20OS%20X%20Lion";
char *MLPattern = "Install%20OS%20X%20Mountain%20Lion";
char *MavPattern = "Install%20OS%20X%20Mavericks";
char *YosPattern = "Install%20OS%20X%20Yosemite";
char *ECPattern = "Install%20OS%20X%20El%20Capitan";
char *SierraPattern = "Install%10.12";
/*
* Only look for OS Version on HFS+
*/
return valid;
}
// OS X Recovery
sprintf(dirSpec, "hd(%d,%d)/com.apple.recovery.boot/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
/*
* Micky1979, let it search for the right Version *.plist
*
* NOTE:
* order is important because vanilla installer (createinstallermedia method 10.9 +) has both /.IABootFilesSystemVersion.plist and
* /System/Library/CoreServices/SystemVersion.plist otherwise fail to recognize it as Installer!
*
* OS X Installer made by the Vanilla app for Lion and newer.
* This kind of Installer can be a guest in a already working System, and produces some temporary files:
* 1) ".IABootFiles" folder is created in the root of the same partition where the app reside.
* 2) "Mac OS X Install Data" or "OS X Install Data" in the target partition
* 3) The presence of ".IABootFilesSystemVersion.plist" file if present or not, distinguishes this installer
* by the one create with "createinstallmedia" method (is present), so we know what kind of installer is.
*/
if (!loadConfigFile(dirSpec, &systemVersion))
// is an installer or a system to Upgrade OSX?
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IAProductInfo", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
{
bvr->OSisInstaller = true;
valid = true;
}
if (!valid)
if (valid)
{
// OS X Standard
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/System/Library/CoreServices/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &systemVersion))
// is createinstallmedia?
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IABootFilesSystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
{
bvr->OSisInstaller = false;
valid = true;
valid = false;
}
else
{
// OS X Server
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/System/Library/CoreServices/ServerVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &systemVersion))
// if not exist probably is a vanilla installer made w/o createinstallermedia method
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IABootFiles/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
{
bvr->OSisServer = false;
valid = true;
}
/*else
else
{
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IAProductInfo", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &systemVersion))
{
}
valid = false;
}
*/
}
}
if ( LION )
if (valid)
{
/*
* we don't know the real OS version, but "Kernel Flags" key contain the URL path to the app..
* and we try to see if contain a match for our patterns ("Install%20OS%20X%20El%20Capitan" = 10.11)
*/
if (getValueForKey("Kernel Flags", &val, &len, &configFile))
{
int fh = -1;
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.PhysicalMediaInstall", BIOS_DEV_UNIT(bvr), bvr->part_no);
fh = open(dirSpec, 0);
if (fh >= 0)
if(strstr(val, LionPattern))
{
fakeOSVersion = "10.7";
fakeOSVersionInt = 7;
valid = true;
bvr->OSisInstaller = true;
strcpy(bvr->OSVersion, "10.7"); // 10.7 +
close(fh);
}
else if(strstr(val, MLPattern))
{
fakeOSVersion = "10.8";
fakeOSVersionInt = 8;
valid = true;
}
else if(strstr(val, MavPattern))
{
fakeOSVersion = "10.9";
fakeOSVersionInt = 9;
valid = true;
}
else if(strstr(val, YosPattern))
{
fakeOSVersion = "10.10";
fakeOSVersionInt = 10;
valid = true;
}
else if(strstr(val, ECPattern))
{
fakeOSVersion = "10.11";
fakeOSVersionInt = 11;
valid = true;
}
else if(strstr(val, SierraPattern))
{
fakeOSVersion = "10.12";
fakeOSVersionInt = 12;
valid = true;
}
else
{
close(fh);
valid = false;
}
}
else
{
valid = false;
}
}
//if ( MOUNTAIN_LION ){}
if (valid)
{
/*
* if we are here that is an createinstallmedia Installer!
* fake the OS version so we can find the right path to the kernelcache/prelinked!
* To patch the kernelcache we aquire the "Darwin versionn" later..
*/
strncpy( bvr->OSFullVer, fakeOSVersion, strlen(fakeOSVersion) );
bvr->OSisInstaller = true;
// no SystemVersion.plist ...so no build...
strncpy( bvr->OSBuildVer, "INSTALLER", strlen("INSTALLER") );
return true;
}
if ( MAVERICKS )
/*
* Not valid? But we have the "/.IAProductInfo" in the root so this is not a conventional installer
* and probably this is an Upgrade made by the "Install OS X app"
*/
if (!valid)
{
len = 0; val = 0;
// 10.9 and later use "/OS X Install Data" folder
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/OS X Install Data/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
{
int fh = -1;
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IAPhysicalMedia", BIOS_DEV_UNIT(bvr), bvr->part_no);
fh = open(dirSpec, 0);
/*
* bad is that we can't find what is the exactly Major OS version..
* but what we need is the right path to the kernel cache:
* kernelcache = 10.9 and 10.10
* prelinkedkernel = 10.11 and later
if (fh >= 0)
* so we fake the OS version just to find the correct path!
* .. later the right "Darwin Version" will use to patch the kernel cache!
*/
if (getValueForKey("Kernel Cache", &val, &len, &configFile))
{
valid = true;
bvr->OSisInstaller = true;
strcpy(bvr->OSVersion, "10.9"); // 10.9 +
if(strstr(val, "prelinkedkernel")) // /OS X Install Data/prelinkedkernel
{
fakeOSVersion = "10.11"; // fake OS to find prelinkedkernel on newer OSes
switch (fakeOSVersionInt)
{
case 11:
fakeOSVersion = "10.11";
break;
case 12:
fakeOSVersion = "10.12";
break;
default:
fakeOSVersion = "10.12";
break;
}
valid = true;
}
else if(strstr(val, "kernelcache")) // /OS X Install Data/kernelcache
{
fakeOSVersion = "10.10"; // fake OS to find prelinkedkernel on 10.9 and 10.10
valid = true;
}
else
{
valid = false;
}
if (valid)
{
strncpy( bvr->OSFullVer, fakeOSVersion, strlen(fakeOSVersion) );
bvr->OSisOSXUpgrade = true;
strncpy( bvr->OSBuildVer, "UPGRADE", strlen("UPGRADE") );
return true;
}
}
else
{
close(fh);
valid = false;
}
}
else
{
valid = false;
}
}
//if ( YOSEMITE ){}
if (!valid)
{
/*
* Not valid? 10.8 and older use "/Mac OS X Install Data" folder..
*/
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/Mac OS X Install Data/com.apple.Boot.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
{
fakeOSVersion = "10.8"; // fake the OS version using 10.8.. just to find the kernelcache path for 10.7 and 10.8..
strncpy( bvr->OSFullVer, fakeOSVersion, strlen(fakeOSVersion) );
bvr->OSisMacOSXUpgrade = true;
// again no SystemVersion.plist, so no build version.. but is usefull to know that is a System upgrade..
strncpy( bvr->OSBuildVer, "UPGRADE", strlen("UPGRADE") );
return true;
}
else
{
valid = false;
}
}
//if ( ELCAPITAN ){}
len = 0; val = 0;
// OS X Installer createinstallermedia method for 10.9 and newer.
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/.IABootFilesSystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
{
bvr->OSisInstaller = true;
valid = true;
}
// OS X Standard
if (!valid)
{
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/System/Library/CoreServices/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
{
valid = true;
}
else
{
// OS X Server
snprintf(dirSpec, sizeof(dirSpec), "hd(%d,%d)/System/Library/CoreServices/ServerVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
{
bvr->OSisServer = true;
valid = true;
}
}
}
if (!valid)
{
// OS X Recovery
sprintf(dirSpec, "hd(%d,%d)/com.apple.recovery.boot/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &configFile))
{
bvr->OSisRecovery = true;
valid = true;
}
}
if (valid)
{
const char *val;
int len;
// ProductVersion
if (getValueForKey(kProductVersion, &val, &len, &systemVersion))
if (getValueForKey(kProductVersion, &val, &len, &configFile))
{
// Copy the complete value into OSFullVer
strncpy( bvr->OSFullVer, val, len );
{
str[4] = '\0';
}
// ProductBuildVersion
if (getValueForKey(kProductBuildVersion, &val, &len, &configFile))
{
strncpy( bvr->OSBuildVer, val, len );
bvr->OSBuildVer[len] = '\0'; /* null character manually added */
}
}
else
{
trunk/i386/libsaio/stringTable.c
663663
664664
665665
666
666
667667
668668
669669
"/com.apple.recovery.boot/com.apple.Boot.plist",// OS X Recovery
"/OS X Install Data/com.apple.Boot.plist",// OS X Upgrade (10.8+)
"/Mac OS X Install Data/com.apple.Boot.plist",// OS X Upgrade (Lion 10.7)
//"/.IABootFiles/com.apple.Boot.plist",// OS X Installer
"/.IABootFiles/com.apple.Boot.plist",// OS X Installer
"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"// (Installed System or Installer)
};
trunk/i386/libsaio/saio_types.h
214214
215215
216216
217
218
217
218
219
220
219221
220222
221223
charOSFullVer[OSVERSTRLEN]; /* Null terminated string from '/System/Library/CoreServices/SystemVersion.plist/ProductVersion' */
charOSBuildVer[OSVERSTRLEN];/* Null terminated string from '/System/Library/CoreServices/SystemVersion.plist/ProductBuildVersion' */
boolOSisServer;/* 1 = OS X server , 0 = OS X client */
boolOSisInstaller;/* 1 = OS X Install partition / recovery partition , 0 = OS X Install */
boolOSisInstaller;/* 1 = OS X Installer */
boolOSisMacOSXUpgrade;/* 1 = OS X Installer Upgrade */
boolOSisOSXUpgrade;/* 1 = OS X Installer Upgrade */
boolOSisRecovery;/* 1 = Recovery HD partition */
};
enum
trunk/i386/boot2/drivers.c
9292
9393
9494
95
95
9696
9797
9898
......
119119
120120
121121
122
122
123123
124124
125125
......
202202
203203
204204
205
206
207
208
209
205210
206211
207212
......
10001005
10011006
10021007
1008
10031009
10041010
10051011
......
10141020
10151021
10161022
1023
10171024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
10181055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
10191223
10201224
10211225
long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p);
/*static*/ unsigned long Adler32( unsigned char * buffer, long length );
static inline unsigned long Adler32( unsigned char * buffer, long length );
long FileLoadDrivers(char *dirSpec, long plugin);
long NetLoadDrivers(char *dirSpec);
// Bungo:
char gDarwinBuildVerStr[256] = "Darwin Kernel Version";
/*static*/ unsigned long Adler32( unsigned char *buffer, long length )
static inline unsigned long Adler32( unsigned char *buffer, long length )
{
long cnt;
unsigned long result, lowHalf, highHalf;
}
verbose("Attempting to loading drivers from \"Extra\" repository:\n");
// =====================================================================
// Firstly try to load drivers from Common folder
sprintf(dirSpecExtra, "bt(0,0)/Extra/Common/");
FileLoadDrivers(dirSpecExtra, 0);
// =====================================================================
// Next try to load Extra extensions from the selected root partition.
strlcpy(dirSpecExtra, "/Extra/", sizeof(dirSpecExtra));
}
// Bungo: scan binary for Darwin Kernel Version string
useDarwinVersion = true;
uint32_t offset = 0;
strncpy(gDarwinBuildVerStr, "Darwin Kernel Version", sizeof(gDarwinBuildVerStr));
else
{
strcat(gDarwinBuildVerStr, ": Unknown");
useDarwinVersion = false;
}
// Micky1979 use Bungo gDarwinBuildVerStr and split into gDarwinMajor, gDarwinMinor and gDarwinRev
if (useDarwinVersion)
{
useDarwinVersion = false;
const char *pattern = strstr(gDarwinBuildVerStr, "Darwin Kernel Version ")+22;
const char *until = strstr(pattern, ":");
size_t vlen = until - pattern;
char *ver = (char *)malloc(sizeof(char)*(len+1));
strncpy(ver, pattern, vlen);
ver[vlen] = '\0';
char *delim;
char *temp;
gDarwinMajor = -1; gDarwinMinor = -1; gDarwinRev = -1;
if (ver != NULL)
{
temp = ver;
int count = 1;
while ((delim = strsep_c(&ver, ".")) != NULL)
{
switch (count)
{
case 1: gDarwinMajor = atoi(delim); break;
case 2: gDarwinMinor = atoi(delim); break;
case 3: gDarwinRev = atoi(delim); break;
default: break;
}
count ++;
}
free(temp);
}
if (gDarwinMajor >= 0 && gDarwinMinor >= 0 && gDarwinRev >= 0)
{
useDarwinVersion = true;
}
switch (gDarwinMajor)
{
case 10:
switch (gDarwinMinor)
{
case 0: kernelOSVer = 0xA060000; break;
case 1: kernelOSVer = 0xA060100; break;
case 2: kernelOSVer = 0xA060200; break;
case 3: kernelOSVer = 0xA060300; break;
case 4: kernelOSVer = 0xA060400; break;
case 5: kernelOSVer = 0xA060500; break;
case 6: kernelOSVer = 0xA060600; break;
case 7: kernelOSVer = 0xA060700; break;
case 8: kernelOSVer = 0xA060800; break;
default:kernelOSVer = 0xA060800; break; //Last known kernel
}
break;
case 11:
switch (gDarwinMinor)
{
case 0: kernelOSVer = 0xA070000; break;
case 1: kernelOSVer = 0xA070100; break;
case 2: kernelOSVer = 0xA070200; break;
case 3: kernelOSVer = 0xA070300; break;
case 4:
switch (gDarwinRev)
{
case 0: kernelOSVer = 0xA070400; break;
case 1: kernelOSVer = 0xA070400; break;
case 2: kernelOSVer = 0xA070500; break;
default:kernelOSVer = 0xA070500; break; //Last known kernel
}
default:kernelOSVer = 0xA070500; break; //Last known kernel
}
break;
case 12:
switch (gDarwinMinor)
{
case 0: kernelOSVer = 0xA080000; break;
case 1: kernelOSVer = 0xA080100; break;
case 2: kernelOSVer = 0xA080200; break;
case 3: kernelOSVer = 0xA080300; break;
case 4: kernelOSVer = 0xA080400; break;
case 5: kernelOSVer = 0xA080500; break; // 10.8.5
case 6: kernelOSVer = 0xA080500; break; // 10.8.5 update
default:kernelOSVer = 0xA080500; break; //Last known kernel
}
break;
case 13:
switch (gDarwinMinor)
{
case 0: kernelOSVer = 0xA090000;
switch (gDarwinRev)
{
case 0: kernelOSVer = 0xA090000; break;
case 1: kernelOSVer = 0xA090000; break; // never exist (or released)
case 2: kernelOSVer = 0xA090100; break;
default:kernelOSVer = 0xA090100; break; //Last known kernel
}
break;
case 1: kernelOSVer = 0xA090100; break; // never exist (or released)
case 2: kernelOSVer = 0xA090200; break;
case 3: kernelOSVer = 0xA090300; break;
case 4: kernelOSVer = 0xA090400; break;
case 5: kernelOSVer = 0xA090500; break;
default:kernelOSVer = 0xA090500; break; //Last known kernel
}
break;
case 14:
switch (gDarwinMinor)
{
case 0: kernelOSVer = 0xA0A0000; break; // same kernel of 10.10.1
case 1: kernelOSVer = 0xA0A0100; break; // same kernel of 10.10
case 2: kernelOSVer = 0xA0A0200; break;
case 3: kernelOSVer = 0xA0A0300; break;
case 4: kernelOSVer = 0xA0A0400; break;
case 5: kernelOSVer = 0xA0A0500; break;
default:kernelOSVer = 0xA0A0500; break; //Last known kernel
}
break;
case 15:
switch (gDarwinMinor)
{
case 0: kernelOSVer = 0xA0B0000; break;
case 1: kernelOSVer = 0xA0B0100; break;
case 2: kernelOSVer = 0xA0B0200; break;
case 3: kernelOSVer = 0xA0B0300; break;
case 4: kernelOSVer = 0xA0B0400; break;
case 5: kernelOSVer = 0xA0B0500; break;
case 6: kernelOSVer = 0xA0B0600; break;
default:kernelOSVer = 0xA0B0600; break; //Last known kernel (add here updates)
}
break;
case 16:
switch (gDarwinMinor)
{
case 0: kernelOSVer = 0xA0C0000; break;
default:kernelOSVer = 0xA0C0000; break; //Last known kernel (add here updates)
}
break;
default:
kernelOSVer = 0xA0B0100;
break; //Last known kernel
}
}
else
{
switch (MacOSVerCurrent)
{
// Snow
case 0xA060000: gDarwinMajor = 10; gDarwinMinor = 0; gDarwinRev = 0; break; // 10.6
case 0xA060100: gDarwinMajor = 10; gDarwinMinor = 1; gDarwinRev = 0; break; // 10.6.1
case 0xA060200: gDarwinMajor = 10; gDarwinMinor = 2; gDarwinRev = 0; break; // 10.6.2
case 0xA060300: gDarwinMajor = 10; gDarwinMinor = 3; gDarwinRev = 0; break; // 10.6.3
case 0xA060400: gDarwinMajor = 10; gDarwinMinor = 4; gDarwinRev = 0; break; // 10.6.4
case 0xA060500: gDarwinMajor = 10; gDarwinMinor = 5; gDarwinRev = 0; break; // 10.6.5
case 0xA060600: gDarwinMajor = 10; gDarwinMinor = 6; gDarwinRev = 0; break; // 10.6.6
case 0xA060700: gDarwinMajor = 10; gDarwinMinor = 7; gDarwinRev = 0; break; // 10.6.7
case 0xA060800: gDarwinMajor = 10; gDarwinMinor = 8; gDarwinRev = 0; break; // 10.6.8
// Lion
case 0xA070000: gDarwinMajor = 11; gDarwinMinor = 0; gDarwinRev = 0; break; // 10.7
case 0xA070100: gDarwinMajor = 11; gDarwinMinor = 1; gDarwinRev = 0; break; // 10.7.1
case 0xA070200: gDarwinMajor = 11; gDarwinMinor = 2; gDarwinRev = 0; break; // 10.7.2
case 0xA070300: gDarwinMajor = 11; gDarwinMinor = 3; gDarwinRev = 0; break; // 10.7.3
case 0xA070400: gDarwinMajor = 11; gDarwinMinor = 4; gDarwinRev = 0; break; // 10.7.4
case 0xA070500: gDarwinMajor = 11; gDarwinMinor = 4; gDarwinRev = 2; break; // 10.7.5
// ML
case 0xA080000: gDarwinMajor = 12; gDarwinMinor = 0; gDarwinRev = 0; break; // 10.8
case 0xA080100: gDarwinMajor = 12; gDarwinMinor = 1; gDarwinRev = 0; break; // 10.8.1
case 0xA080200: gDarwinMajor = 12; gDarwinMinor = 2; gDarwinRev = 0; break; // 10.8.2
case 0xA080300: gDarwinMajor = 12; gDarwinMinor = 3; gDarwinRev = 0; break; // 10.8.3
case 0xA080400: gDarwinMajor = 12; gDarwinMinor = 4; gDarwinRev = 0; break; // 10.8.4
case 0xA080500: gDarwinMajor = 12; gDarwinMinor = 5; gDarwinRev = 0; break; // 10.8.5
// Mavericks
case 0xA090000: gDarwinMajor = 13; gDarwinMinor = 0; gDarwinRev = 0; break; // 10.9
case 0xA090100: gDarwinMajor = 13; gDarwinMinor = 1; gDarwinRev = 0; break; // 10.9.1
case 0xA090200: gDarwinMajor = 13; gDarwinMinor = 2; gDarwinRev = 0; break; // 10.9.2
case 0xA090300: gDarwinMajor = 13; gDarwinMinor = 3; gDarwinRev = 0; break; // 10.9.3
case 0xA090400: gDarwinMajor = 13; gDarwinMinor = 4; gDarwinRev = 0; break; // 10.9.4
case 0xA090500: gDarwinMajor = 13; gDarwinMinor = 5; gDarwinRev = 0; break; // 10.9.5
// Yosemite
case 0xA0A0000: gDarwinMajor = 14; gDarwinMinor = 0; gDarwinRev = 0; break; // 10.10
case 0xA0A0100: gDarwinMajor = 14; gDarwinMinor = 0; gDarwinRev = 0; break; // 10.10.1
case 0xA0A0200: gDarwinMajor = 14; gDarwinMinor = 2; gDarwinRev = 0; break; // 10.10.2
case 0xA0A0300: gDarwinMajor = 14; gDarwinMinor = 3; gDarwinRev = 0; break; // 10.10.3
case 0xA0A0400: gDarwinMajor = 14; gDarwinMinor = 4; gDarwinRev = 0; break; // 10.10.4
case 0xA0A0500: gDarwinMajor = 14; gDarwinMinor = 5; gDarwinRev = 0; break; // 10.10.5
// El Capitan
case 0xA0B0000: gDarwinMajor = 15; gDarwinMinor = 0; gDarwinRev = 0; break; // 10.11
case 0xA0B0100: gDarwinMajor = 15; gDarwinMinor = 1; gDarwinRev = 0; break; // 10.11.1
case 0xA0B0200: gDarwinMajor = 15; gDarwinMinor = 2; gDarwinRev = 0; break; // 10.11.2
case 0xA0B0300: gDarwinMajor = 15; gDarwinMinor = 3; gDarwinRev = 0; break; // 10.11.3
case 0xA0B0400: gDarwinMajor = 15; gDarwinMinor = 4; gDarwinRev = 0; break; // 10.11.4
case 0xA0B0500: gDarwinMajor = 15; gDarwinMinor = 5; gDarwinRev = 0; break; // 10.11.5
case 0xA0B0600: gDarwinMajor = 15; gDarwinMinor = 6; gDarwinRev = 0; break; // 10.11.6
// Sierra
case 0xA0C0000: gDarwinMajor = 16; gDarwinMinor = 0; gDarwinRev = 0; break; // 10.12
// default = last known kernel
default: gDarwinMajor = 16; gDarwinMinor = 0; gDarwinRev = 0; break; // 10.12;
}
}
// Notify modules that the kernel has been decompressed, thinned and is about to be decoded
execute_hook("DecodeKernel", (void *)binary, NULL, NULL, NULL);
trunk/i386/boot2/boot.c
8181
8282
8383
84
85
86
87
88
89
8490
8591
8692
......
335341
336342
337343
338
344
339345
340
341
342
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
343373
344374
345375
346
376
347377
348
349
350
351
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
352399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
353446
354447
355448
......
357450
358451
359452
360
361
453
454
455
456
362457
363
458
459
460
461
462
463
464
465
466
467
468
469
364470
365
471
366472
367473
368474
369475
370
476
371477
372478
479
480
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
512
513
514
515
516
517
518
519
373520
374521
375
522
376523
377524
378525
......
403550
404551
405552
406
407
408
409
410
411
553
412554
413
414
415
555
556
557
416558
417
559
560
561
562
563
564
418565
419
420
421
422
423
566
567
568
569
570
571
572
573
424574
425575
426576
......
679829
680830
681831
682
832
683833
684
685
834
686835
687
836
837
688838
689
839
690840
691841
692
842
693843
694
844
695845
696846
697
847
698848
699
700
849
701850
702851
703
852
704853
705
706
707
708
854
855
856
857
858
859
860
861
862
709863
710
711
864
865
866
867
712868
713
714
869
870
871
872
873
715874
716
717
718
875
876
877
878
879
880
719881
720
721
882
883
722884
723
724
885
886
887
888
889
890
891
892
893
894
895
896
725897
726
727
898
899
728900
901
902
903
904
729905
730906
907
731908
732
733
909
910
911
734912
735913
736
737914
738915
739916
......
9491126
9501127
9511128
952
9531129
9541130
9551131
9561132
9571133
9581134
959
1135
9601136
9611137
9621138
9631139
964
1140
1141
1142
1143
9651144
966
967
968
9691145
9701146
9711147
boolgScanSingleDrive;
booluseGUI;
/* recovery or installer ? */
bool isInstaller;
bool isRecoveryHD;
bool isMacOSXUpgrade;
bool isOSXUpgrade;
#if DEBUG_INTERRUPTS
static intinterruptsAvailable = 0;
#endif
}
closedir(cacheDir);
}
else if ( MacOSVerCurrent >= MacOSVer2Int("10.7") && MacOSVerCurrent < MacOSVer2Int("10.10") )
else if ( MacOSVerCurrent >= MacOSVer2Int("10.7") && MacOSVerCurrent < MacOSVer2Int("10.9") )
{
// Lion, Mountain Lion and Mavericks prelink kernel cache file
// for 10.7 10.8 10.9
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCachePathSnow);
// Lion, Mountain Lion
// for 10.7 10.8
if (isMacOSXUpgrade)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", "/Mac OS X Install Data/");
}
else if (isInstaller)
{
if (MacOSVerCurrent >= MacOSVer2Int("10.7") && MacOSVerCurrent < MacOSVer2Int("10.8") )
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kLionInstallerDataFolder);
}
else if ( MacOSVerCurrent >= MacOSVer2Int("10.8") && MacOSVerCurrent < MacOSVer2Int("10.9") )
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kMLionInstallerDataFolder);
}
}
else if (isRecoveryHD)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCacheRecoveryHD);
}
else
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCachePathSnow);
}
verbose("Kernel Cache file path (Mac OS X 10.7 and newer): %s\n", kernelCacheFile);
}
else
else if ( MacOSVerCurrent >= MacOSVer2Int("10.9") && MacOSVerCurrent < MacOSVer2Int("10.10") )
{
// Yosemite and El Capitan prelink kernel cache file
// for 10.10 10.11
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%sprelinkedkernel", kDefaultCachePathYosemite);
verbose("Kernel Cache file path (OS X 10.10 and newer): %s\n", kernelCacheFile);
// Mavericks prelinked cache file
// for 10.9
if (isOSXUpgrade)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", "/OS X Install Data/");
}
else if (isInstaller)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCacheInstallerNew);
}
else if (isRecoveryHD)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCacheRecoveryHD);
}
else
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCachePathSnow);
}
verbose("Kernel Cache file path (OS X 10.9): %s\n", kernelCacheFile);
}
else if ( MacOSVerCurrent >= MacOSVer2Int("10.10") && MacOSVerCurrent < MacOSVer2Int("10.11") )
{
// Yosemite prelink kernel cache file
// for 10.10 and 10.11
if (isOSXUpgrade)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", "/OS X Install Data/");
}
else if (isInstaller)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCacheInstallerNew);
}
else if (isRecoveryHD)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCacheRecoveryHD);
}
else
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%sprelinkedkernel", kDefaultCachePathYosemite);
}
verbose("Kernel Cache file path (OS X 10.10): %s\n", kernelCacheFile);
}
else if ( MacOSVerCurrent >= MacOSVer2Int("10.11") )
{
// El Capitan on prelinked kernel cache file
// for 10.10 and 10.11
if (isOSXUpgrade)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%sprelinkedkernel", "/OS X Install Data/");
}
else if (isInstaller)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%sprelinkedkernel", kDefaultCacheInstallerNew);
}
else if (isRecoveryHD)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%sprelinkedkernel", kDefaultCacheRecoveryHD);
}
else
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%sprelinkedkernel", kDefaultCachePathYosemite);
}
verbose("Kernel Cache file path (OS X 10.11 and newer): %s\n", kernelCacheFile);
}
}
// Check if the kernel cache file exists
if (gBootVolume->flags & kBVFlagBooter)
{
snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.boot.P/%s", kernelCacheFile);
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if (isRecoveryHD)
{
strncpy(kernelCachePath, "/com.apple.recovery.boot/prelinkedkernel", sizeof(kernelCachePath) );
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
{
strncpy(kernelCachePath, "/com.apple.recovery.boot/kernelcache", sizeof(kernelCachePath) );
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((flags & kFileTypeMask) != kFileTypeFlat)
{
ret = -1;
}
}
}
else if (isInstaller)
{
snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.boot.R/%s", kernelCacheFile);
strncpy(kernelCachePath, "/.IABootFiles/prelinkedkernel", sizeof(kernelCachePath) );
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
{
snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.boot.S/%s", kernelCacheFile);
strncpy(kernelCachePath, "/.IABootFiles/kernelcache", sizeof(kernelCachePath) );
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((flags & kFileTypeMask) != kFileTypeFlat)
{
ret = -1;
}
}
}
else if (isMacOSXUpgrade)
{
strncpy(kernelCachePath, "/Mac OS X Install Data/kernelcache", sizeof(kernelCachePath) );
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((flags & kFileTypeMask) != kFileTypeFlat)
{
ret = -1;
}
}
else if (isOSXUpgrade)
{
strncpy(kernelCachePath, "/OS X Install Data/prelinkedkernel", sizeof(kernelCachePath) );
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
{
strncpy(kernelCachePath, "/OS X Install Data/kernelcache", sizeof(kernelCachePath) );
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((flags & kFileTypeMask) != kFileTypeFlat)
{
ret = -1;
}
}
}
else
{
snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.boot.P/%s", kernelCacheFile);
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
{
snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.boot.R/%s", kernelCacheFile);
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
{
strncpy(kernelCachePath, "/com.apple.recovery.boot/kernelcache", sizeof(kernelCachePath) );
snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.boot.S/%s", kernelCacheFile);
ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
if ((flags & kFileTypeMask) != kFileTypeFlat)
return -1;
}
// Check if the kernel cache file is more recent (mtime)
// than the kernel file or the S/L/E directory
ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime);
// Check if the kernel file is more recent than the cache file
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat) && (kerneltime > cachetime))
if ( !isInstaller && !isRecoveryHD && !isMacOSXUpgrade && !isOSXUpgrade )
{
DBG("Kernel file '%s' is more recent than Kernel Cache '%s'! Ignoring Kernel Cache.\n", bootInfo->bootFile, kernelCacheFile);
return -1;
}
// Check if the kernel cache file is more recent (mtime)
// than the kernel file or the S/L/E directory
ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime);
ret = GetFileInfo("/System/Library/", "Extensions", &flags, &exttime);
// Check if the kernel file is more recent than the cache file
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat) && (kerneltime > cachetime))
{
DBG("Kernel file '%s' is more recent than Kernel Cache '%s'! Ignoring Kernel Cache.\n", bootInfo->bootFile, kernelCacheFile);
return -1;
}
// Check if the S/L/E directory time is more recent than the cache file
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory) && (exttime > cachetime))
{
DBG("Folder '/System/Library/Extensions' is more recent than Kernel Cache file '%s'! Ignoring Kernel Cache.\n", kernelCacheFile);
return -1;
ret = GetFileInfo("/System/Library/", "Extensions", &flags, &exttime);
// Check if the S/L/E directory time is more recent than the cache file
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory) && (exttime > cachetime))
{
DBG("Folder '/System/Library/Extensions' is more recent than Kernel Cache file '%s'! Ignoring Kernel Cache.\n", kernelCacheFile);
return -1;
}
}
// Since the kernel cache file exists and is the most recent try to load it
// Notify modules that we are attempting to boot
execute_hook("PreBoot", NULL, NULL, NULL, NULL);
if (!getBoolForKey (kWake, &tryresume, &bootInfo->chameleonConfig))
if (gBootVolume->OSisInstaller)
{
tryresume = true;
tryresumedefault = true;
isInstaller = true;
}
else
if (gBootVolume->OSisMacOSXUpgrade)
{
tryresumedefault = false;
isMacOSXUpgrade = true;
}
if (!getBoolForKey (kForceWake, &forceresume, &bootInfo->chameleonConfig))
if (gBootVolume->OSisOSXUpgrade)
{
forceresume = false;
isOSXUpgrade = true;
}
if (forceresume)
if (gBootVolume->OSisRecovery)
{
tryresume = true;
tryresumedefault = false;
isRecoveryHD = true;
}
while (tryresume)
if ( !isRecoveryHD && !isInstaller && !isMacOSXUpgrade && !isOSXUpgrade )
{
const char *tmp;
BVRef bvr;
if (!getValueForKey(kWakeImage, &val, &len, &bootInfo->chameleonConfig))
val = "/private/var/vm/sleepimage";
if (!getBoolForKey (kWake, &tryresume, &bootInfo->chameleonConfig))
{
tryresume = true;
tryresumedefault = true;
}
else
{
tryresumedefault = false;
}
// Do this first to be sure that root volume is mounted
ret = GetFileInfo(0, val, &flags, &sleeptime);
if (!getBoolForKey (kForceWake, &forceresume, &bootInfo->chameleonConfig))
{
forceresume = false;
}
if ((bvr = getBootVolumeRef(val, &tmp)) == NULL)
break;
if (forceresume)
{
tryresume = true;
tryresumedefault = false;
}
// Can't check if it was hibernation Wake=y is required
if (bvr->modTime == 0 && tryresumedefault)
break;
while (tryresume)
{
const char *tmp;
BVRef bvr;
if (!getValueForKey(kWakeImage, &val, &len, &bootInfo->chameleonConfig))
val = "/private/var/vm/sleepimage";
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat))
break;
// Do this first to be sure that root volume is mounted
ret = GetFileInfo(0, val, &flags, &sleeptime);
if (!forceresume && ((sleeptime+3)<bvr->modTime))
{
if ((bvr = getBootVolumeRef(val, &tmp)) == NULL)
break;
// Can't check if it was hibernation Wake=y is required
if (bvr->modTime == 0 && tryresumedefault)
break;
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat))
break;
if (!forceresume && ((sleeptime+3)<bvr->modTime))
{
#if DEBUG
printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override\n",
bvr->modTime-sleeptime);
printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override\n",
bvr->modTime-sleeptime);
#endif
break;
}
HibernateBoot((char *)val);
break;
}
}
HibernateBoot((char *)val);
break;
if (!isRecoveryHD && !isInstaller && !isMacOSXUpgrade && !isOSXUpgrade )
{
getBoolForKey(kUseKernelCache, &useKernelCache, &bootInfo->chameleonConfig);
}
getBoolForKey(kUseKernelCache, &useKernelCache, &bootInfo->chameleonConfig);
if (useKernelCache)
{
do
verbose("\n");
intcsrValue;
#if 0
/*
* A special BootArgs flag "kBootArgsFlagCSRBoot"
* is set in the Recovery or Installation environment.
* This flag is kind of overkill by turning off all the protections
*/
if (isRecoveryHD)
if (isRecoveryHD || isInstaller || isOSXUpgrade || isMacOSXUpgrade)
{
// SIP can be controlled with or without FileNVRAM.kext (Pike R. Alpha)
bootArgs->flags|=(kBootArgsFlagCSRActiveConfig + kBootArgsFlagCSRConfigMode + kBootArgsFlagCSRBoot);
}
#endif
else
{
bootArgs->flags|= kBootArgsFlagCSRActiveConfig;
}
bootArgs->flags|= kBootArgsFlagCSRActiveConfig;
// Set limit to 7bit
if ( getIntForKey(kCsrActiveConfig, &csrValue, &bootInfo->chameleonConfig) && (csrValue >= 0 && csrValue <= 127) )
{
trunk/i386/boot2/boot.h
4848
4949
5050
51
5152
52
53
5354
54
5555
56
56
5757
58
5958
59
60
61
6062
6163
6264
......
190192
191193
192194
195
193196
197
198
199
194200
195201
196202
......
296302
297303
298304
305
306
307
308
309
310
299311
300312
301313
#define kDefaultCachePathLeo"/System/Library/Caches/com.apple.kernelcaches/"
#define kDefaultCachePathSnow"/System/Library/Caches/com.apple.kext.caches/Startup/"
#define kDefaultCachePathYosemite"/System/Library/PrelinkedKernels/"
#define kDefaultCacheRecoveryHD"/com.apple.recovery.boot/"
// Lion installer
// Lion installer ??
#define kLionInstallerDataFolder"/Mac OS X Install Data/"
#define kLionInstallerPlistkLionInstallerDataFolder "com.apple.Boot.plist"
// Mountain Lion installer
// Mountain Lion installer ??
#define kMLionInstallerDataFolder"/OS X Install Data/"
#define kMLionInstallerPlistkMLionInstallerDataFolder "com.apple.Boot.plist"
// Installer new
#define kDefaultCacheInstallerNew"/.IABootFiles/"
//kernel path
#define kDefaultKernelPathPreYos"/"
#define kDefaultKernelPathForYos"/System/Library/Kernels/" //for Yosemite and El Capitan
#define kHDEFLayoutID"HDEFLayoutID"/* hda.c */
#define kHDAULayoutID"HDAULayoutID"/* hda.c */
#define kCsrActiveConfig"CsrActiveConfig"/* boot.c */
#define kProductBuildVersion"ProductBuildVersion"/* boot.c */
uint32_t kernelOSVer; /* boot.c */
/* Pike R. Alpha: added this key */
#define kBlackMode"BlackMode"
// Bungo:
extern char gDarwinBuildVerStr[256];
// Micky1979
int gDarwinMajor;
int gDarwinMinor;
int gDarwinRev;
bool useDarwinVersion;
/*!
Hookable function pointer called during the driver loading phase that
allows other code to cause additional drivers to be loaded.
trunk/i386/boot2/options.c
13911391
13921392
13931393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
13941450
13951451
13961452
addBootArg("kext-dev-mode=1");
}
// Micky1979 (Recovery HD)
if (gBootVolume->OSisRecovery)
{
const char*rval = 0;
config_file_t ocBplist;
char caBp[1024]; //too large ?. On El capitan is 365 bytes.. but we are testing
snprintf(caBp, sizeof(caBp), "/com.apple.recovery.boot/com.apple.Boot.plist");
loadConfigFile(caBp, &ocBplist);
rval = getStringForKey(kKernelFlagsKey, &ocBplist);
addBootArg(rval);
}
// Micky1979 (Vanilla Installer)
if (gBootVolume->OSisInstaller)
{
const char*rval = 0;
config_file_t ocBplist;
char caBp[2048];
snprintf(caBp, sizeof(caBp), "/.IABootFiles/com.apple.Boot.plist");
loadConfigFile(caBp, &ocBplist);
rval = getStringForKey(kKernelFlagsKey, &ocBplist);
addBootArg(rval);
}
// Micky1979 (old Vanilla upgrade)
if (gBootVolume->OSisMacOSXUpgrade)
{
const char*rval = 0;
config_file_t ocBplist;
char caBp[2048];
snprintf(caBp, sizeof(caBp), "/Mac OS X Install Data/com.apple.Boot.plist");
loadConfigFile(caBp, &ocBplist);
rval = getStringForKey(kKernelFlagsKey, &ocBplist);
addBootArg(rval);
}
// Micky1979 (new Vanilla upgrade)
if (gBootVolume->OSisMacOSXUpgrade)
{
const char*rval = 0;
config_file_t ocBplist;
char caBp[2048];
snprintf(caBp, sizeof(caBp), "/OS X Install Data/com.apple.Boot.plist");
loadConfigFile(caBp, &ocBplist);
rval = getStringForKey(kKernelFlagsKey, &ocBplist);
addBootArg(rval);
}
cntRemaining = BOOT_STRING_LEN - 2; // save 1 for NULL, 1 for space
argP = bootArgs->CommandLine;
trunk/i386/libsa/libsa.h
107107
108108
109109
110
111
112
113
110114
111115
112116
extern char*strncat(char * s1, const char * s2, size_t n);
extern char*strdup(const char *s1);
extern char*strpbrk_c(const char *s, const char *accept);
extern char*strsep_c(char **stringp, const char *delim);
extern size_t__strxspn_c(const char *s, const char *map, int parity);
#if STRNCASECMP
extern int strncasecmp(const char *s1, const char *s2, size_t n);
#endif
trunk/i386/libsa/string.c
411411
412412
413413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
return csum;
}
/*
bsd functions variants (already available in klibc)
strsep, strpbrk and __strxspn
*/
#ifndef UCHAR_MAX
#define UCHAR_MAX255u
#endif
//==========================================================================
char *strsep_c(char **stringp, const char *delim)
{
char *s = *stringp;
char *e;
if (!s)
return NULL;
e = strpbrk_c(s, delim);
if (e)
*e++ = '\0';
*stringp = e;
return s;
}
//==========================================================================
char *strpbrk_c(const char *s, const char *accept)
{
const char *ss = s + __strxspn_c(s, accept, 1);
return *ss ? (char *)ss : NULL;
}
//==========================================================================
size_t __strxspn_c(const char *s, const char *map, int parity)
{
char matchmap[UCHAR_MAX + 1];
size_t n = 0;
/* Create bitmap */
memset(matchmap, 0, sizeof matchmap);
while (*map)
matchmap[(unsigned char)*map++] = 1;
/* Make sure the null character never matches */
matchmap[0] = parity;
/* Calculate span length */
while (matchmap[(unsigned char)*s++] ^ parity)
n++;
return n;
}
//==========================================================================

Archive Download the corresponding diff file

Revision: 2838