Chameleon

Chameleon Commit Details

Date:2016-06-18 21:46:36 (1 year 11 months ago)
Author:ErmaC
Commit:2837
Parents: 2836
Message:Implement Micky1979’s patch for allow boot from Recovery, and enchange vacilla installer.
Changes:
M/branches/ErmaC/Enoch/i386/boot2/options.c
M/branches/ErmaC/Enoch/i386/libsa/string.c
M/branches/ErmaC/Enoch/i386/libsaio/stringTable.c
M/branches/ErmaC/Enoch/i386/boot2/drivers.c
M/branches/ErmaC/Enoch/i386/libsaio/saio_types.h
M/branches/ErmaC/Enoch/i386/boot2/boot.c
M/branches/ErmaC/Enoch/i386/libsa/libsa.h
M/branches/ErmaC/Enoch/i386/libsaio/disk.c
M/branches/ErmaC/Enoch/i386/boot2/boot.h

File differences

branches/ErmaC/Enoch/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
{
branches/ErmaC/Enoch/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)
};
branches/ErmaC/Enoch/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
branches/ErmaC/Enoch/i386/boot2/drivers.c
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
}
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);
branches/ErmaC/Enoch/i386/boot2/boot.c
8181
8282
8383
84
85
86
87
88
89
8490
8591
8692
......
331337
332338
333339
334
340
335341
336
337
338
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
339369
340370
341371
342
372
343373
344
345
346
347
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
348395
396
397
398
399
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
349442
350443
351444
......
353446
354447
355448
356
357
449
450
451
452
358453
359
454
455
456
457
458
459
460
461
462
463
464
465
360466
361
467
362468
363469
364470
365471
366
472
367473
368474
475
476
477
478
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
369516
370517
371
518
372519
373520
374521
......
399546
400547
401548
402
403
404
405
406
407
549
408550
409
410
411
551
552
553
412554
413
555
556
557
558
559
560
414561
415
416
417
418
419
562
563
564
565
566
567
568
569
420570
421571
422572
......
675825
676826
677827
678
828
679829
680
681
830
682831
683
832
833
684834
685
835
686836
687837
688
838
689839
690
840
691841
692842
693
843
694844
695
696
845
697846
698847
699
848
700849
701
702
703
704
850
851
852
853
854
855
856
857
858
705859
706
707
860
861
862
863
708864
709
710
865
866
867
868
869
711870
712
713
714
871
872
873
874
875
876
715877
716
717
878
879
718880
719
720
881
882
883
884
885
886
887
888
889
890
891
892
721893
722
723
894
895
724896
897
898
899
900
725901
726902
903
727904
728
729
905
906
907
730908
731909
732
733910
734911
735912
......
9451122
9461123
9471124
948
9491125
9501126
9511127
9521128
9531129
9541130
955
1131
9561132
9571133
9581134
9591135
960
1136
1137
1138
1139
9611140
962
963
964
9651141
9661142
9671143
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) )
{
branches/ErmaC/Enoch/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
......
209211
210212
211213
214
212215
216
217
218
213219
214220
215221
......
309315
310316
311317
318
319
320
321
322
323
312324
313325
314326
#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 kDropMCFG"DropMCFG"/* acpi_patcher.c */
#define kDropAPIC"DropAPIC"/* acpi_patcher.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.
branches/ErmaC/Enoch/i386/boot2/options.c
13941394
13951395
13961396
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
1450
1451
1452
13971453
13981454
13991455
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;
branches/ErmaC/Enoch/i386/libsa/libsa.h
108108
109109
110110
111
112
113
114
111115
112116
113117
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
branches/ErmaC/Enoch/i386/libsa/string.c
432432
433433
434434
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
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: 2837