Index: branches/slice/trunkM/Chameleon.xcodeproj/slice.pbxuser
===================================================================
--- branches/slice/trunkM/Chameleon.xcodeproj/slice.pbxuser (revision 1206)
+++ branches/slice/trunkM/Chameleon.xcodeproj/slice.pbxuser (revision 1207)
@@ -2,16 +2,16 @@
{
012E60F8137AC68F00E35218 /* smbios_decode.c */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {873, 3094}}";
- sepNavSelRange = "{787, 16}";
- sepNavVisRange = "{269, 1564}";
+ sepNavIntBoundsRect = "{{0, 0}, {887, 3068}}";
+ sepNavSelRange = "{10086, 0}";
+ sepNavVisRange = "{5590, 1333}";
};
};
012E60F9137AC68F00E35218 /* smbios_getters.c */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {782, 6591}}";
- sepNavSelRange = "{143, 13}";
- sepNavVisRange = "{0, 896}";
+ sepNavIntBoundsRect = "{{0, 0}, {1454, 6214}}";
+ sepNavSelRange = "{13004, 0}";
+ sepNavVisRange = "{12611, 1105}";
};
};
012E60FA137AC68F00E35218 /* smbios_getters.h */ = {
@@ -23,9 +23,9 @@
};
012E60FB137AC68F00E35218 /* smbios.c */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {782, 12792}}";
+ sepNavIntBoundsRect = "{{0, 0}, {1076, 12012}}";
sepNavSelRange = "{259, 0}";
- sepNavVisRange = "{0, 749}";
+ sepNavVisRange = "{0, 772}";
sepNavWindowFrame = "{{15, 60}, {889, 813}}";
};
};
@@ -63,8 +63,8 @@
PBXFileDataSource_Target_ColumnID,
);
};
- PBXPerProjectTemplateStateSaveDate = 332963545;
- PBXWorkspaceStateSaveDate = 332963545;
+ PBXPerProjectTemplateStateSaveDate = 333013407;
+ PBXWorkspaceStateSaveDate = 333013407;
};
perUserProjectItems = {
1208BED013D70B8900694228 /* PBXTextBookmark */ = 1208BED013D70B8900694228 /* PBXTextBookmark */;
@@ -83,7 +83,6 @@
1237561D13D823130027F8A5 /* PBXTextBookmark */ = 1237561D13D823130027F8A5 /* PBXTextBookmark */;
12375A2913D82FD80027F8A5 /* PBXTextBookmark */ = 12375A2913D82FD80027F8A5 /* PBXTextBookmark */;
12375A3C13D831AB0027F8A5 /* PBXTextBookmark */ = 12375A3C13D831AB0027F8A5 /* PBXTextBookmark */;
- 1272D14713D860AF00EDABD3 /* PBXTextBookmark */ = 1272D14713D860AF00EDABD3 /* PBXTextBookmark */;
1284EEE713D6F35E00A6BE87 /* PBXTextBookmark */ = 1284EEE713D6F35E00A6BE87 /* PBXTextBookmark */;
1284EEF913D6F95000A6BE87 /* PBXTextBookmark */ = 1284EEF913D6F95000A6BE87 /* PBXTextBookmark */;
128EB70A13D31D3900E0DA4B /* PBXTextBookmark */ = 128EB70A13D31D3900E0DA4B /* PBXTextBookmark */;
@@ -93,11 +92,13 @@
12BFD73713D6E2DD00065808 /* PBXTextBookmark */ = 12BFD73713D6E2DD00065808 /* PBXTextBookmark */;
12D15FC013D35DFB00ABAAF4 /* PBXTextBookmark */ = 12D15FC013D35DFB00ABAAF4 /* PBXTextBookmark */;
12D15FE813D3634F00ABAAF4 /* PBXTextBookmark */ = 12D15FE813D3634F00ABAAF4 /* PBXTextBookmark */;
+ 12E9C0AA13D95C2F0096128F /* PBXTextBookmark */ = 12E9C0AA13D95C2F0096128F /* PBXTextBookmark */;
+ 12E9C0BD13D95F8F0096128F /* PBXTextBookmark */ = 12E9C0BD13D95F8F0096128F /* PBXTextBookmark */;
+ 12E9C0BF13D95F8F0096128F /* PBXTextBookmark */ = 12E9C0BF13D95F8F0096128F /* PBXTextBookmark */;
+ 12E9C0F013D961D90096128F /* PBXTextBookmark */ = 12E9C0F013D961D90096128F /* PBXTextBookmark */;
12EDC2D91376FCB300937D70 /* PBXTextBookmark */ = 12EDC2D91376FCB300937D70 /* PBXTextBookmark */;
12EE45C013D896210092C48C /* PBXTextBookmark */ = 12EE45C013D896210092C48C /* PBXTextBookmark */;
12FBE8FA13D89F1700E385CB /* PBXTextBookmark */ = 12FBE8FA13D89F1700E385CB /* PBXTextBookmark */;
- 12FBE8FB13D89F1700E385CB /* PBXTextBookmark */ = 12FBE8FB13D89F1700E385CB /* PBXTextBookmark */;
- 12FBE8FC13D89F1700E385CB /* PBXTextBookmark */ = 12FBE8FC13D89F1700E385CB /* PBXTextBookmark */;
};
sourceControlManager = 122A5BB51375B61C00795FF0 /* Source Control */;
userBuildSettings = {
@@ -277,16 +278,6 @@
vrLen = 1037;
vrLoc = 20605;
};
- 1272D14713D860AF00EDABD3 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 012E60F9137AC68F00E35218 /* smbios_getters.c */;
- name = "smbios_getters.c: 460";
- rLen = 0;
- rLoc = 12199;
- rType = 0;
- vrLen = 1029;
- vrLoc = 12658;
- };
1284EEE713D6F35E00A6BE87 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = B0056D6111F3868000754B65 /* platform.h */;
@@ -377,6 +368,46 @@
vrLen = 453;
vrLoc = 1863;
};
+ 12E9C0AA13D95C2F0096128F /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 6DBAFD1413B0D21E0047ED33 /* modules.c */;
+ name = "modules.c: 7";
+ rLen = 0;
+ rLoc = 143;
+ rType = 0;
+ vrLen = 445;
+ vrLoc = 0;
+ };
+ 12E9C0BD13D95F8F0096128F /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 012E60F9137AC68F00E35218 /* smbios_getters.c */;
+ name = "smbios_getters.c: 478";
+ rLen = 0;
+ rLoc = 13004;
+ rType = 0;
+ vrLen = 1105;
+ vrLoc = 12611;
+ };
+ 12E9C0BF13D95F8F0096128F /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 6DBAFD1513B0D21E0047ED33 /* modules.h */;
+ name = "modules.h: 90";
+ rLen = 10;
+ rLoc = 2190;
+ rType = 0;
+ vrLen = 1133;
+ vrLoc = 1781;
+ };
+ 12E9C0F013D961D90096128F /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 6DBAFD1513B0D21E0047ED33 /* modules.h */;
+ name = "modules.h: 90";
+ rLen = 10;
+ rLoc = 2190;
+ rType = 0;
+ vrLen = 1132;
+ vrLoc = 1781;
+ };
12EDC2D91376FCB300937D70 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = B0056D3911F3868000754B65 /* device_tree.c */;
@@ -407,33 +438,20 @@
vrLen = 517;
vrLoc = 0;
};
- 12FBE8FB13D89F1700E385CB /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 6DBAFD1413B0D21E0047ED33 /* modules.c */;
- name = "modules.c: 255";
- rLen = 7;
- rLoc = 6994;
- rType = 0;
- vrLen = 556;
- vrLoc = 6146;
- };
- 12FBE8FC13D89F1700E385CB /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 6DBAFD1413B0D21E0047ED33 /* modules.c */;
- name = "modules.c: 7";
- rLen = 0;
- rLoc = 143;
- rType = 0;
- vrLen = 493;
- vrLoc = 0;
- };
6DBAFD1413B0D21E0047ED33 /* modules.c */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {877, 14950}}";
- sepNavSelRange = "{143, 0}";
- sepNavVisRange = "{0, 493}";
+ sepNavIntBoundsRect = "{{0, 0}, {922, 14664}}";
+ sepNavSelRange = "{8839, 10}";
+ sepNavVisRange = "{10472, 1003}";
};
};
+ 6DBAFD1513B0D21E0047ED33 /* modules.h */ = {
+ uiCtxt = {
+ sepNavIntBoundsRect = "{{0, 0}, {877, 1547}}";
+ sepNavSelRange = "{2190, 10}";
+ sepNavVisRange = "{1781, 1132}";
+ };
+ };
6DBAFD6C13B0D4590047ED33 /* IOAudioDebug.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {782, 728}}";
@@ -507,9 +525,9 @@
};
B0056D3511F3868000754B65 /* cpu.c */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {943, 5525}}";
- sepNavSelRange = "{12156, 0}";
- sepNavVisRange = "{11619, 895}";
+ sepNavIntBoundsRect = "{{0, 0}, {908, 7306}}";
+ sepNavSelRange = "{19660, 16}";
+ sepNavVisRange = "{19109, 1455}";
};
};
B0056D3611F3868000754B65 /* cpu.h */ = {
@@ -542,9 +560,9 @@
};
B0056D3F11F3868000754B65 /* fake_efi.c */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {782, 11037}}";
- sepNavSelRange = "{384, 0}";
- sepNavVisRange = "{66, 1303}";
+ sepNavIntBoundsRect = "{{0, 0}, {1321, 10959}}";
+ sepNavSelRange = "{30123, 16}";
+ sepNavVisRange = "{29334, 1164}";
};
};
B0056D4011F3868000754B65 /* fake_efi.h */ = {
Index: branches/slice/trunkM/Chameleon.xcodeproj/slice.mode1v3
===================================================================
--- branches/slice/trunkM/Chameleon.xcodeproj/slice.mode1v3 (revision 1206)
+++ branches/slice/trunkM/Chameleon.xcodeproj/slice.mode1v3 (revision 1207)
@@ -216,7 +216,6 @@
servicesModulefind
com.apple.ide.PBXToolbarStopButton
get-info
- go
NSToolbarFlexibleSpaceItem
com.apple.pbx.toolbar.searchfield
@@ -299,7 +298,7 @@
186
RubberWindowFrame
- 134 119 1146 659 0 0 1280 778
+ 294 219 1146 659 0 0 1440 878
Module
PBXSmartGroupTreeModule
@@ -310,14 +309,12 @@
Dock
- BecomeActive
-
ContentConfiguration
PBXProjectModuleGUID
1CE0B20306471E060097A5F4
PBXProjectModuleLabel
- modules.c
+ modules.h
PBXSplitModuleInNavigatorKey
Split0
@@ -325,11 +322,11 @@
PBXProjectModuleGUID
1CE0B20406471E060097A5F4
PBXProjectModuleLabel
- modules.c
+ modules.h
_historyCapacity
0
bookmark
- 12FBE8FC13D89F1700E385CB
+ 12E9C0F013D961D90096128F
history
122A5BCA1375C49300795FF0
@@ -357,11 +354,12 @@
1237561D13D823130027F8A5
12375A2913D82FD80027F8A5
12375A3C13D831AB0027F8A5
- 1272D14713D860AF00EDABD3
120E55C813D8694A00E2D592
12EE45C013D896210092C48C
12FBE8FA13D89F1700E385CB
- 12FBE8FB13D89F1700E385CB
+ 12E9C0AA13D95C2F0096128F
+ 12E9C0BD13D95F8F0096128F
+ 12E9C0BF13D95F8F0096128F
SplitCount
@@ -373,16 +371,18 @@
GeometryConfiguration
Frame
- {{0, 0}, {938, 360}}
+ {{0, 0}, {938, 333}}
RubberWindowFrame
- 134 119 1146 659 0 0 1280 778
+ 294 219 1146 659 0 0 1440 878
Module
PBXNavigatorGroup
Proportion
- 360pt
+ 333pt
+ BecomeActive
+
ContentConfiguration
PBXProjectModuleGUID
@@ -393,14 +393,14 @@
GeometryConfiguration
Frame
- {{0, 365}, {938, 253}}
+ {{0, 338}, {938, 280}}
RubberWindowFrame
- 134 119 1146 659 0 0 1280 778
+ 294 219 1146 659 0 0 1440 878
Module
XCDetailModule
Proportion
- 253pt
+ 280pt
Proportion
@@ -419,9 +419,9 @@
TableOfContents
- 12FBE8FD13D89F1700E385CB
+ 12E9C0F113D961D90096128F
1CE0B1FE06471DED0097A5F4
- 12FBE8FE13D89F1700E385CB
+ 12E9C0F213D961D90096128F
1CE0B20306471E060097A5F4
1CE0B20506471E060097A5F4
@@ -559,11 +559,12 @@
5
WindowOrderList
+ 1C530D57069F1CE1000CFCEE
122A5BB81375BA4700795FF0
- /Developer/Projects/Chameleons/slice/trunkM/Chameleon.xcodeproj
+ /Users/slice/Projects/Chameleons/chameleon/branches/slice/trunkM/Chameleon.xcodeproj
WindowString
- 134 119 1146 659 0 0 1280 778
+ 294 219 1146 659 0 0 1440 878
WindowToolsV3
@@ -593,7 +594,7 @@
Frame
{{0, 0}, {500, 218}}
RubberWindowFrame
- 91 232 500 500 0 0 1280 778
+ 110 311 500 500 0 0 1440 878
Module
PBXNavigatorGroup
@@ -617,7 +618,7 @@
Frame
{{0, 223}, {500, 236}}
RubberWindowFrame
- 91 232 500 500 0 0 1280 778
+ 110 311 500 500 0 0 1440 878
Module
PBXBuildResultsModule
@@ -640,7 +641,7 @@
TableOfContents
122A5BB81375BA4700795FF0
- 12FBE8FF13D89F1700E385CB
+ 12E9C0EC13D961D60096128F
1CD0528F0623707200166675
XCMainBuildResultsModuleGUID
@@ -649,7 +650,7 @@
WindowContentMinSize
486 300
WindowString
- 91 232 500 500 0 0 1280 778
+ 110 311 500 500 0 0 1440 878
WindowToolGUID
122A5BB81375BA4700795FF0
WindowToolIsVisible
@@ -773,14 +774,12 @@
Dock
- BecomeActive
-
ContentConfiguration
PBXProjectModuleGUID
1CDD528C0622207200134675
PBXProjectModuleLabel
- smbios_getters.c
+
StatusBarVisibility
@@ -789,7 +788,7 @@
Frame
{{0, 0}, {843, 431}}
RubberWindowFrame
- 420 68 843 689 0 0 1280 778
+ 574 144 843 689 0 0 1440 878
Module
PBXNavigatorGroup
@@ -801,6 +800,8 @@
431pt
+ BecomeActive
+
ContentConfiguration
PBXProjectModuleGUID
@@ -813,7 +814,7 @@
Frame
{{0, 436}, {843, 212}}
RubberWindowFrame
- 420 68 843 689 0 0 1280 778
+ 574 144 843 689 0 0 1440 878
Module
PBXProjectFindModule
@@ -836,13 +837,13 @@
TableOfContents
1C530D57069F1CE1000CFCEE
- 12EE45BE13D896190092C48C
- 12EE45BF13D896190092C48C
+ 12E9C0EE13D961D60096128F
+ 12E9C0EF13D961D60096128F
1CDD528C0622207200134675
1CD0528E0623707200166675
WindowString
- 420 68 843 689 0 0 1280 778
+ 574 144 843 689 0 0 1440 878
WindowToolGUID
1C530D57069F1CE1000CFCEE
WindowToolIsVisible
Index: branches/slice/trunkM/i386/libsaio/smbios.c
===================================================================
--- branches/slice/trunkM/i386/libsaio/smbios.c (revision 1206)
+++ branches/slice/trunkM/i386/libsaio/smbios.c (revision 1207)
@@ -11,7 +11,7 @@
#include "smbios_getters.h"
#ifndef DEBUG_SMBIOS
-#define DEBUG_SMBIOS 0
+#define DEBUG_SMBIOS 1
#endif
#if DEBUG_SMBIOS
@@ -918,6 +918,7 @@
Platform->CPU.FSBFrequency = tmp * MEGA + (tmp & 7) * 110000; //According to Intel 133->133.33MHz
tmp = ((SMBProcessorInformation *)structHeader)->currentClock;
Platform->CPU.CPUFrequency = tmp * MEGA + (tmp & 7) * 110000;
+ DBG("From SMBIOS: FSB=%d CPU=%d\n", Platform->CPU.FSBFrequency, Platform->CPU.CPUFrequency);
break;
case kSMBTypePhysicalMemoryArray:
Index: branches/slice/trunkM/i386/libsaio/smbios_decode.c
===================================================================
--- branches/slice/trunkM/i386/libsaio/smbios_decode.c (revision 1206)
+++ branches/slice/trunkM/i386/libsaio/smbios_decode.c (revision 1207)
@@ -9,13 +9,13 @@
#include "smbios.h"
#ifndef DEBUG_SMBIOS
-#define DEBUG_SMBIOS 0
+#define DEBUG_SMBIOS 1
#endif
#if DEBUG_SMBIOS
-#define DBG(x...) printf(x)
+#define DBG(x...) verbose(x)
#else
-#define DBG(x...) msglog(x)
+#define DBG(x...) msglog(x)
#endif
@@ -228,5 +228,8 @@
structHeader = (SMBStructHeader *)ptr;
}
DBG("\n");
+#if DEBUG_SMBIOS
+ getchar();
+#endif
}
Index: branches/slice/trunkM/i386/libsaio/smbios_getters.c
===================================================================
--- branches/slice/trunkM/i386/libsaio/smbios_getters.c (revision 1206)
+++ branches/slice/trunkM/i386/libsaio/smbios_getters.c (revision 1207)
@@ -27,13 +27,13 @@
bool getProcessorInformationExternalClock(returnType *value)
{
- value->word = Platform->CPU.FSBFrequency/1000000;
+ value->word = Platform->CPU.FSBFrequency/MEGA;
return true;
}
bool getProcessorInformationMaximumClock(returnType *value)
{
- value->word = Platform->CPU.CPUFrequency/1000000;
+ value->word = Platform->CPU.CPUFrequency/MEGA;
return true;
}
@@ -475,6 +475,7 @@
}
#endif
maxClock = cpuInfo->maximumClock;
+ Platform->CPU.CPUFrequency = cpuInfo->currentClock * MEGA;
msglog("DMI CPU Info:\n FSB=%d\n MaxSpeed=%d\n CurrentSpeed=%d\n", cpuInfo->externalClock, maxClock, cpuInfo->currentClock);
msglog("DMI CPU Info 2:\n Family=%x\n Socket=%x\n Cores=%d Enabled=%d Threads=%d\n", cpuInfo->processorFamily, cpuInfo->processorUpgrade, cpuInfo->coreCount, cpuInfo->coreEnabled, cpuInfo->Threads);
#if 1 //NOTYET
Index: branches/slice/trunkM/i386/boot2/boot.c
===================================================================
--- branches/slice/trunkM/i386/boot2/boot.c (revision 1206)
+++ branches/slice/trunkM/i386/boot2/boot.c (revision 1207)
@@ -585,7 +585,7 @@
if (ret == 0 && kerneltime > exttime) {
exttime = kerneltime;
}
- if (ret == 0 && cachetime < exttime) {
+ if (ret == 0 && cachetime != (exttime + 1)) {
trycache = 0;
break;
}
Index: branches/slice/trunkM/i386/modules/RamDiskLoader/ramdisk.h
===================================================================
--- branches/slice/trunkM/i386/modules/RamDiskLoader/ramdisk.h (revision 0)
+++ branches/slice/trunkM/i386/modules/RamDiskLoader/ramdisk.h (revision 1207)
@@ -0,0 +1,46 @@
+/*
+ * Supplemental ramdisk functions for the multiboot ramdisk driver
+ * Copyright 2009 Tamas Kosarszky. All rights reserved.
+ *
+ */
+
+#ifndef __BOOT_RAMDISK_H
+#define __BOOT_RAMDISK_H
+
+#include "drivers.h"
+#include "boot.h"
+//#include "mboot.h"
+
+#define RAMDISKCONFIG_FILENAME "rd(0,0)/RAMDisk.plist"
+#define kMD0Image "md0" /* ramdisk.h */
+
+//#define kPostbootRamdisk
+extern void md0Ramdisk();
+
+typedef struct RAMDiskParam
+{
+ ppnum_t base;
+ unsigned int size;
+} RAMDiskParam;
+
+/* mboot.c */
+extern struct multiboot_info *gMI;
+
+//
+extern int (*p_get_ramdisk_info)(int biosdev, struct driveInfo *dip);
+extern long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p);
+extern int (*p_ramdiskReadBytes)( int biosdev, unsigned int blkno,
+ unsigned int byteoff,
+ unsigned int byteCount, void * buffer );
+extern BVRef gRAMDiskVolume;
+extern bool gRAMDiskBTAliased;
+
+extern char gMacOSVersion;
+extern long FileLoadDrivers(char *dirSpec, long plugin);
+
+extern void setRAMDiskBTHook(bool mode);
+extern int mountRAMDisk(const char * param);
+extern void processRAMDiskCommand(char ** argPtr, const char * cmd);
+extern int loadPrebootRAMDisk();
+
+#endif /* !__BOOT_RAMDISK_H */
Index: branches/slice/trunkM/i386/modules/RamDiskLoader/RamDiskLoader.c
===================================================================
--- branches/slice/trunkM/i386/modules/RamDiskLoader/RamDiskLoader.c (revision 0)
+++ branches/slice/trunkM/i386/modules/RamDiskLoader/RamDiskLoader.c (revision 1207)
@@ -0,0 +1,145 @@
+/*
+ * RamDiskLoader.c
+ * Chameleon
+ *
+ * Created by cparm on 05/12/10.
+ * Copyright 2010. All rights reserved.
+ *
+ */
+
+#include "boot.h"
+#include "libsaio.h"
+#include "bootstruct.h"
+#include "modules.h"
+#include "ramdisk.h"
+#include "drivers.h"
+#include "disk.h"
+
+
+#define kEnableEDL "EnableRamDiskLoader"
+
+
+enum {
+ kPseudoBIOSDevRAMDisk = 0x100,
+ kPseudoBIOSDevBooter = 0x101
+};
+
+void loadPrebootRAMDisk_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
+{
+ loadPrebootRAMDisk();
+}
+
+void md0Ramdisk_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
+{
+ md0Ramdisk();
+}
+
+void processRAMDiskCommand_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
+{
+ char * argPtr = (char *)arg1;
+ const char*bp = (const char *)arg2;
+ processRAMDiskCommand(&argPtr, bp);
+}
+
+void ramDiskLoadDrivers_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
+{
+ char dirSpecExtra[1024];
+ int step = *(int*)arg1;
+ switch (step) {
+ case 0:
+ if (LoadExtraDrivers_p != NULL)
+ {
+ (*LoadExtraDrivers_p)(&FileLoadDrivers);
+ }
+ break;
+ case 1:
+ // First try a specfic OS version folder ie 10.5
+ sprintf(dirSpecExtra, "rd(0,0)/Extra/%s/", &gMacOSVersion);
+ if (FileLoadDrivers(dirSpecExtra, 0) != 0)
+ {
+ // Next we'll try the base
+ strcpy(dirSpecExtra, "rd(0,0)/Extra/");
+ FileLoadDrivers(dirSpecExtra, 0);
+ }
+ break;
+ case 2:
+ // First try a specfic OS version folder ie 10.5
+ sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
+ if (FileLoadDrivers(dirSpecExtra, 0) != 0)
+ {
+ // Next we'll try the base
+ strcpy(dirSpecExtra, "bt(0,0)/Extra/");
+ FileLoadDrivers(dirSpecExtra, 0);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void newRamDisk_BVR_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
+{
+ int biosdev = *(int*)arg1;
+ BVRef *bvr1 = (BVRef*)arg2;
+ if (biosdev == kPseudoBIOSDevRAMDisk)
+ {
+ if (gRAMDiskVolume)
+ *bvr1 = gRAMDiskVolume;
+ }
+ else if (biosdev == kPseudoBIOSDevBooter)
+ {
+ if (gRAMDiskVolume != NULL && gRAMDiskBTAliased)
+ *bvr1 = gRAMDiskVolume;
+ }
+}
+
+void p_get_ramdisk_info_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
+{
+ int cc;
+ int biosdev = *(int *)arg1;
+ struct driveInfo *dip = (struct driveInfo *)arg2;
+ int *ret = (int *)arg3;
+ if(p_get_ramdisk_info != NULL)
+ cc = (*p_get_ramdisk_info)(biosdev, dip);
+ else
+ cc = -1;
+ if(cc < 0)
+ {
+ dip->valid = 0;
+ *ret = -1;
+ }
+}
+
+void p_ramdiskReadBytes_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
+{
+ int biosdev = *(int*)arg1;
+ unsigned long long blkno = *(unsigned long long*)arg2;
+ unsigned int byteoff = *(unsigned int*)arg3;
+ unsigned int byteCount = *(unsigned int*)arg4;
+ void * buffer = (void*)arg5;
+ int *ret = (int*)arg6;
+
+ if(p_ramdiskReadBytes != NULL && biosdev >= 0x100)
+ *ret = (*p_ramdiskReadBytes)(biosdev, blkno, byteoff, byteCount, buffer);
+}
+
+void is_Ram_Disk_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){}
+
+
+void RamDiskLoader_start()
+{
+ bool enable = true;
+ getBoolForKey(kEnableEDL, &enable, &bootInfo->bootConfig) ;
+
+ if (enable) {
+ register_hook_callback("loadPrebootRAMDisk", &loadPrebootRAMDisk_hook);
+ register_hook_callback("md0Ramdisk", &md0Ramdisk_hook);
+ register_hook_callback("processRAMDiskCommand", &processRAMDiskCommand_hook);
+ register_hook_callback("ramDiskLoadDrivers", &ramDiskLoadDrivers_hook);
+ register_hook_callback("newRamDisk_BVR", &newRamDisk_BVR_hook);
+ register_hook_callback("p_get_ramdisk_info", &p_get_ramdisk_info_hook);
+ register_hook_callback("p_ramdiskReadBytes", &p_ramdiskReadBytes_hook);
+ register_hook_callback("isRamDiskRegistred", &is_Ram_Disk_Registred_Hook);
+ }
+
+}
\ No newline at end of file
Index: branches/slice/trunkM/i386/modules/RamDiskLoader/Cconfig
===================================================================
--- branches/slice/trunkM/i386/modules/RamDiskLoader/Cconfig (revision 0)
+++ branches/slice/trunkM/i386/modules/RamDiskLoader/Cconfig (revision 1207)
@@ -0,0 +1,10 @@
+#
+# Chameleon Modules
+#
+
+config RamDiskLoader_MODULE
+ tristate "RamDiskLoader Module"
+ default m
+ ---help---
+ Say Y here if you want to enable the use of this module.
+
Index: branches/slice/trunkM/i386/modules/RamDiskLoader/ramdisk.c
===================================================================
--- branches/slice/trunkM/i386/modules/RamDiskLoader/ramdisk.c (revision 0)
+++ branches/slice/trunkM/i386/modules/RamDiskLoader/ramdisk.c (revision 1207)
@@ -0,0 +1,413 @@
+/*
+ * Supplemental ramdisk functions for the multiboot ramdisk driver.
+ * Copyright 2009 Tamas Kosarszky. All rights reserved.
+ *
+ */
+
+#include "boot.h"
+#include "bootstruct.h"
+#include "multiboot.h"
+#include "ramdisk.h"
+
+struct multiboot_info * gRAMDiskMI = NULL;
+
+// gRAMDiskVolume holds the bvr for the mounted ramdisk image.
+BVRef gRAMDiskVolume = NULL;
+bool gRAMDiskBTAliased = false;
+char gRAMDiskFile[512];
+
+long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p) = NULL;
+int (*p_ramdiskReadBytes)( int biosdev, unsigned int blkno,
+ unsigned int byteoff,
+ unsigned int byteCount, void * buffer ) = NULL;
+int (*p_get_ramdisk_info)(int biosdev, struct driveInfo *dip) = NULL;
+
+int multibootRamdiskReadBytes( int biosdev, unsigned int blkno,
+ unsigned int byteoff,
+ unsigned int byteCount, void * buffer );
+int multiboot_get_ramdisk_info(int biosdev, struct driveInfo *dip);
+static long multiboot_LoadExtraDrivers(FileLoadDrivers_t FileLoadDrivers_p);
+
+
+// Notify OS X that a ramdisk has been setup. XNU with attach this to /dev/md0
+void md0Ramdisk()
+{
+ RAMDiskParam ramdiskPtr;
+ char filename[512];
+ const char* override_filename = 0;
+ int fh = -1;
+ int len;
+
+ if(getValueForKey(kMD0Image, &override_filename, &len,
+ &bootInfo->bootConfig))
+ {
+ // Use user specified md0 file
+ sprintf(filename, "%s", override_filename);
+ fh = open(filename);
+
+ if(fh < 0)
+ {
+ sprintf(filename, "bt(0,0)/Extra/%s", override_filename);
+ fh = open(filename);
+
+ if(fh < 0)
+ {
+ sprintf(filename, "rd(0,0)/Extra/%s", override_filename);
+ fh = open(filename);
+
+ if(fh < 0)
+ {
+ sprintf(filename, "/Extra/%s", override_filename);
+ fh = open(filename);
+ }
+ }
+ }
+ }
+
+ if(fh < 0)
+ {
+ sprintf(filename, "bt(0,0)/Extra/Postboot.img");
+ fh = open(filename);
+
+ if(fh < 0)
+ {
+ sprintf(filename, "rd(0,0)/Extra/Postboot.img");
+ fh = open(filename);
+
+ if(fh < 0)
+ {
+ sprintf(filename, "/Extra/Postboot.img"); // Check /Extra if not in rd(0,0)
+ fh = open(filename);
+ }
+ }
+ }
+
+ if (fh >= 0)
+ {
+ verbose("Enabling ramdisk %s\n", filename);
+
+ ramdiskPtr.size = file_size(fh);
+ ramdiskPtr.base = AllocateKernelMemory(ramdiskPtr.size);
+
+ if(ramdiskPtr.size && ramdiskPtr.base)
+ {
+ // Read new ramdisk image contents in kernel memory.
+ if (read(fh, (char*) ramdiskPtr.base, ramdiskPtr.size) == ramdiskPtr.size)
+ {
+#if UNUSED
+ AllocateMemoryRange("RAMDisk", ramdiskPtr.base, ramdiskPtr.size, kBootDriverTypeInvalid);
+#else
+ AllocateMemoryRange("RAMDisk", ramdiskPtr.base, ramdiskPtr.size);
+#endif
+ Node* node = DT__FindNode("/chosen/memory-map", false);
+ if(node != NULL)
+ {
+ DT__AddProperty(node, "RAMDisk", sizeof(RAMDiskParam), (void*)&ramdiskPtr);
+ }
+ else
+ {
+ verbose("Unable to notify Mac OS X of the ramdisk %s.\n", filename);
+ }
+ }
+ else
+ {
+ verbose("Unable to read md0 image %s.\n", filename);
+ }
+ }
+ else
+ {
+ verbose("md0 image %s is empty.\n", filename);
+ }
+
+ close(fh);
+
+ }
+}
+
+void umountRAMDisk()
+{
+ if (gRAMDiskMI != NULL)
+ {
+ // Release ramdisk BVRef and DiskBVMap.
+ struct DiskBVMap *oldMap = diskResetBootVolumes(0x100);
+ CacheReset();
+ diskFreeMap(oldMap);
+
+ // Free multiboot info and module structures.
+ if ((void *)gRAMDiskMI->mi_mods_addr != NULL) free((void *)gRAMDiskMI->mi_mods_addr);
+ if (gRAMDiskMI != NULL) free(gRAMDiskMI);
+
+ // Reset multiboot structures.
+ gRAMDiskMI = NULL;
+ gMI = gRAMDiskMI;
+
+ *gRAMDiskFile = '\0';
+
+ // Release ramdisk driver hooks.
+ p_get_ramdisk_info = NULL;
+ p_ramdiskReadBytes = NULL;
+ LoadExtraDrivers_p = NULL;
+
+ // Reset ramdisk bvr
+ gRAMDiskVolume = NULL;
+ printf("\nunmounting: done");
+ }
+}
+
+int mountRAMDisk(const char * param)
+{
+ int fh = 0, ramDiskSize;
+ int error = 0;
+
+ // Get file handle for ramdisk file.
+ fh = open(param);
+ if (fh != -1)
+ {
+ printf("\nreading ramdisk image: %s\n", param);
+
+ ramDiskSize = file_size(fh);
+ if (ramDiskSize > 0)
+ {
+ // Unmount previously mounted image if exists.
+ umountRAMDisk();
+
+ // Read new ramdisk image contents into PREBOOT_DATA area.
+ if (read(fh, (char *)PREBOOT_DATA, ramDiskSize) != ramDiskSize) error = -1;
+ }
+ else error = -1;
+
+ close(fh);
+ }
+ else error = -1;
+
+ if (error == 0)
+ {
+ // Save filename in gRAMDiskFile to display information.
+ strcpy(gRAMDiskFile, param);
+
+ // Set gMI as well for the multiboot ramdisk driver hook.
+ gRAMDiskMI = malloc(sizeof(multiboot_info));
+ gMI = gRAMDiskMI;
+
+ struct multiboot_module * ramdisk_module = malloc(sizeof(multiboot_module));
+
+ // Fill in multiboot info and module structures.
+ if (gRAMDiskMI != NULL && ramdisk_module != NULL)
+ {
+ gRAMDiskMI->mi_mods_count = 1;
+ gRAMDiskMI->mi_mods_addr = (uint32_t)ramdisk_module;
+ ramdisk_module->mm_mod_start = PREBOOT_DATA;
+ ramdisk_module->mm_mod_end = PREBOOT_DATA + ramDiskSize;
+
+ // Set ramdisk driver hooks.
+ p_get_ramdisk_info = &multiboot_get_ramdisk_info;
+ p_ramdiskReadBytes = &multibootRamdiskReadBytes;
+ LoadExtraDrivers_p = &multiboot_LoadExtraDrivers;
+
+ int partCount; // unused
+ // Save bvr of the mounted image.
+ gRAMDiskVolume = diskScanBootVolumes(0x100, &partCount);
+ if(gRAMDiskVolume == NULL)
+ {
+ umountRAMDisk();
+ printf("\nRamdisk contains no partitions.\n");
+ pause();
+
+ }
+ else
+ {
+ char dirSpec[128];
+
+ // Reading ramdisk configuration.
+ strcpy(dirSpec, RAMDISKCONFIG_FILENAME);
+
+ if (loadConfigFile(dirSpec, &bootInfo->ramdiskConfig) == 0)
+ {
+ getBoolForKey("BTAlias", &gRAMDiskBTAliased, &bootInfo->ramdiskConfig);
+ }
+ else
+ {
+ verbose("\nno ramdisk config...\n");
+ }
+
+ printf("\nmounting: done");
+ }
+ }
+ }
+ return error;
+}
+
+void setRAMDiskBTHook(bool mode)
+{
+ gRAMDiskBTAliased = mode;
+ if (mode)
+ {
+ printf("\nEnabled bt(0,0) alias.");
+ }
+ else
+ {
+ printf("\nDisabled bt(0,0) alias.");
+ }
+}
+
+void showInfoRAMDisk(void)
+{
+ int len;
+ const char *val;
+
+ if (gRAMDiskMI != NULL)
+ {
+ struct multiboot_module * ramdisk_module = (void *)gRAMDiskMI->mi_mods_addr;
+
+ printf("\nfile: %s %d", gRAMDiskFile,
+ ramdisk_module->mm_mod_end - ramdisk_module->mm_mod_start);
+ printf("\nalias: %s", gRAMDiskBTAliased ? "enabled" : "disabled");
+
+ // Display ramdisk information if available.
+ if (getValueForKey("Info", &val, &len, &bootInfo->ramdiskConfig))
+ {
+ printf("\ninfo: %s", val);
+ }
+ else
+ {
+ printf("\nramdisk info not available.");
+ }
+ }
+ else
+ {
+ printf("\nNo ramdisk mounted.");
+ }
+}
+
+int loadPrebootRAMDisk()
+{
+ mountRAMDisk("bt(0,0)/Extra/Preboot.dmg");
+ if (gRAMDiskMI != NULL)
+ {
+ printf("\n");
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+void processRAMDiskCommand(char ** argPtr, const char * cmd)
+{
+ char * ptr = *argPtr;
+ char param[1024];
+ getNextArg(&ptr, param);
+
+ if (strcmp(cmd, "m") == 0)
+ {
+ mountRAMDisk(param);
+ sleep(2);
+ }
+ else if (strcmp(cmd, "u") == 0)
+ {
+ umountRAMDisk();
+ sleep(2);
+ }
+ else if (strcmp(cmd, "e") == 0)
+ {
+ setRAMDiskBTHook(true);
+ sleep(2);
+ }
+ else if (strcmp(cmd, "d") == 0)
+ {
+ setRAMDiskBTHook(false);
+ sleep(2);
+ }
+ else if (strcmp(cmd, "i") == 0)
+ {
+ setActiveDisplayPage(1);
+ clearScreenRows(0, 24);
+ setCursorPosition(0, 0, 1);
+ showInfoRAMDisk();
+ printf("\n\nPress any key to continue.\n");
+ getc();
+ setActiveDisplayPage(0);
+ }
+ else
+ {
+ setActiveDisplayPage(1);
+ clearScreenRows(0, 24);
+ setCursorPosition(0, 0, 1);
+ printf("\nusage:\n");
+ printf("\n?rd i - display ramdisk information");
+ printf("\n?rd m - mount ramdisk image\n?rd u - unmount ramdisk image");
+ printf("\n?rd e - enable bt(0,0) alias\n?rd d - disable bt(0,0) alias");
+ printf("\n\nPress any key to continue.\n");
+ getc();
+ setActiveDisplayPage(0);
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Ramdisk multiboot support
+
+int multibootRamdiskReadBytes( int biosdev, unsigned int blkno,
+ unsigned int byteoff,
+ unsigned int byteCount, void * buffer )
+{
+ int module_count = gMI->mi_mods_count;
+ struct multiboot_module *modules = (void*)gMI->mi_mods_addr;
+ if(biosdev < 0x100)
+ return -1;
+ if(biosdev >= (0x100 + module_count))
+ return -1;
+ struct multiboot_module *module = modules + (biosdev - 0x100);
+
+ void *p_initrd = (void*)module->mm_mod_start;
+ bcopy(p_initrd + blkno*512 + byteoff, buffer, byteCount);
+ return 0;
+}
+
+int multiboot_get_ramdisk_info(int biosdev, struct driveInfo *dip)
+{
+ int module_count = gMI->mi_mods_count;
+ struct multiboot_module *modules = (void*)gMI->mi_mods_addr;
+ if(biosdev < 0x100)
+ return -1;
+ if(biosdev >= (0x100 + module_count))
+ return -1;
+ struct multiboot_module *module = modules + (biosdev - 0x100);
+ dip->biosdev = biosdev;
+ dip->uses_ebios = true; // XXX aserebln uses_ebios isn't a boolean at all
+ dip->di.params.phys_sectors = (module->mm_mod_end - module->mm_mod_start + 511) / 512;
+ dip->valid = true;
+ return 0;
+}
+
+static long multiboot_LoadExtraDrivers(FileLoadDrivers_t FileLoadDrivers_p)
+{
+ char extensionsSpec[1024];
+ int ramdiskUnit;
+ for(ramdiskUnit = 0; ramdiskUnit < gMI->mi_mods_count; ++ramdiskUnit)
+ {
+ int partCount; // unused
+ BVRef ramdiskChain = diskScanBootVolumes(0x100 + ramdiskUnit, &partCount);
+ if(ramdiskChain == NULL)
+ {
+ verbose("Ramdisk contains no partitions\n");
+ continue;
+ }
+ for(; ramdiskChain != NULL; ramdiskChain = ramdiskChain->next)
+ {
+ sprintf(extensionsSpec, "rd(%d,%d)/Extra/", ramdiskUnit, ramdiskChain->part_no);
+ struct dirstuff *extradir = opendir(extensionsSpec);
+ closedir(extradir);
+ if(extradir != NULL)
+ {
+ int ret = FileLoadDrivers_p(extensionsSpec, 0 /* this is a kext root dir, not a kext with plugins */);
+ if(ret != 0)
+ {
+ verbose("FileLoadDrivers failed on a ramdisk\n");
+ return ret;
+ }
+ }
+ }
+ }
+ return 0;
+}
Index: branches/slice/trunkM/i386/modules/RamDiskLoader/Makefile
===================================================================
--- branches/slice/trunkM/i386/modules/RamDiskLoader/Makefile (revision 0)
+++ branches/slice/trunkM/i386/modules/RamDiskLoader/Makefile (revision 1207)
@@ -0,0 +1,42 @@
+
+MODULE_NAME = RamDiskLoader
+MODULE_VERSION = "1.0.0"
+MODULE_COMPAT_VERSION = "1.0.0"
+MODULE_START = _$(MODULE_NAME)_start
+MODULE_DEPENDENCIES =
+
+DIR = RamDiskLoader
+
+#MODULE_OBJS = RamDiskLoader.o
+
+OPTIM = -Os
+DEBUG = -DNOTHING
+CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost \
+ -D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \
+ -DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \
+ -fno-builtin $(OMIT_FRAME_POINTER_CFLAG) \
+ -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \
+ -march=pentium4 -msse2 -mfpmath=sse -msoft-float -fno-common
+
+DEFINES=
+CONFIG = hd
+INC = -I. -I.. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(BOOT2DIR)
+LIBS=
+
+VPATH = $(OBJROOT):$(SYMROOT)
+
+MODULE_OBJS = ramdisk.o RamDiskLoader.o
+
+SFILES =
+CFILES =
+HFILES =
+EXPORTED_HFILES =
+INSTALLED_HFILES =
+OTHERFILES = Makefile
+ALLSRC = $(SFILES) $(CFILES) \
+ $(HFILES) $(OTHERFILES)
+DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
+
+all embedtheme optionrom: dylib
+
+include ../MakeInc.dir
\ No newline at end of file
Index: branches/slice/trunkM/i386/modules/KernelPatcher/include/kernel_patcher.h
===================================================================
--- branches/slice/trunkM/i386/modules/KernelPatcher/include/kernel_patcher.h (revision 1206)
+++ branches/slice/trunkM/i386/modules/KernelPatcher/include/kernel_patcher.h (revision 1207)
@@ -12,14 +12,20 @@
#define CPUID_MODEL_ANY 0x00
#define CPUID_MODEL_UNKNOWN 0x01
-#define CPUID_MODEL_YONAH 14
-#define CPUID_MODEL_MEROM 15
-#define CPUID_MODEL_PENRYN 23
-#define CPUID_MODEL_NEHALEM 26
-#define CPUID_MODEL_ATOM 28
-#define CPUID_MODEL_FIELDS 30 /* Lynnfield, Clarksfield, Jasper */
-#define CPUID_MODEL_DALES 31 /* Havendale, Auburndale */
-#define CPUID_MODEL_NEHALEM_EX 46
+#define CPU_MODEL_PENTIUM_M 0x0D
+#define CPU_MODEL_YONAH 0x0E // Sossaman, Yonah
+#define CPU_MODEL_MEROM 0x0F // Allendale, Conroe, Kentsfield, Woodcrest, Clovertown, Tigerton, Merom
+#define CPU_MODEL_PENRYN 0x17 // Wolfdale, Yorkfield, Harpertown, Penryn
+#define CPU_MODEL_NEHALEM 0x1A // Bloomfield. Nehalem-EP, Nehalem-WS, Gainestown
+#define CPU_MODEL_ATOM 0x1C // Atom
+#define CPU_MODEL_FIELDS 0x1E // Lynnfield, Clarksfield, Jasper Forest
+#define CPU_MODEL_DALES 0x1F // Havendale, Auburndale
+#define CPU_MODEL_DALES_32NM 0x25 // Clarkdale, Arrandale
+#define CPU_MODEL_SANDY 0x2A // Sandy Bridge
+#define CPU_MODEL_WESTMERE 0x2C // Gulftown, Westmere-EP, Westmere-WS
+#define CPU_MODEL_SANDY_XEON 0x2D // Sandy Bridge Xeon
+#define CPU_MODEL_NEHALEM_EX 0x2E // Beckton
+#define CPU_MODEL_WESTMERE_EX 0x2F
#define KERNEL_ANY 0x00
#define KERNEL_64 0x01
Index: branches/slice/trunkM/i386/modules/KernelPatcher/kernel_patcher.c
===================================================================
--- branches/slice/trunkM/i386/modules/KernelPatcher/kernel_patcher.c (revision 1206)
+++ branches/slice/trunkM/i386/modules/KernelPatcher/kernel_patcher.c (revision 1207)
@@ -12,6 +12,7 @@
patchRoutine_t* patches = NULL;
kernSymbols_t* kernelSymbols = NULL;
+void kernel_patcher_ignore_cache(void* arg1, void* arg2, void* arg3, void *arg4, void* arg5, void* arg6){}
void KernelPatcher_start()
{
@@ -24,7 +25,6 @@
// NOTE: following is currently 32bit only
register_kernel_patch(patch_lapic_configure, KERNEL_32, CPUID_MODEL_ANY);
-
register_kernel_symbol(KERNEL_ANY, "_panic");
register_kernel_symbol(KERNEL_ANY, "_cpuid_set_info");
register_kernel_symbol(KERNEL_ANY, "_pmCPUExitHaltToOff");
@@ -35,17 +35,16 @@
register_kernel_symbol(KERNEL_ANY, "_lapic_configure");
register_kernel_symbol(KERNEL_ANY, "_lapic_start");
register_kernel_symbol(KERNEL_ANY, "_lapic_interrupt_base");
-
+
// lapic_interrup symbols
//register_kernel_patch(patch_lapic_interrupt, KERNEL_ANY, CPUID_MODEL_ANY);
//register_kernel_symbol(KERNEL_ANY, "_lapic_interrupt");
-
-
// TODO: register needed symbols
-
-
+
register_hook_callback("ExecKernel", &patch_kernel);
+
+ replace_function("_getKernelCachePath", &kernel_patcher_ignore_cache);
}
/*
@@ -68,14 +67,14 @@
{
switch(Platform->CPU.Model)
{
- case 13:
- case CPUID_MODEL_YONAH:
- case CPUID_MODEL_MEROM:
- case CPUID_MODEL_PENRYN:
- case CPUID_MODEL_NEHALEM:
- case CPUID_MODEL_FIELDS:
- case CPUID_MODEL_DALES:
- case CPUID_MODEL_NEHALEM_EX:
+ case CPU_MODEL_PENTIUM_M:
+ case CPU_MODEL_YONAH:
+ case CPU_MODEL_MEROM:
+ case CPU_MODEL_PENRYN:
+ case CPU_MODEL_NEHALEM:
+ case CPU_MODEL_FIELDS:
+ case CPU_MODEL_DALES:
+ case CPU_MODEL_NEHALEM_EX:
// Known cpu's we don't want to add the patch
return;
break;
@@ -84,7 +83,6 @@
// CPU not in supported list, so we are going to add
// The patch will be applied
break;
-
}
}
else
@@ -92,7 +90,6 @@
// Invalid cpuid for current cpu. Ignoring patch
return;
}
-
}
}
@@ -127,7 +124,8 @@
kernelSymbols->symbol = (char*)name;
kernelSymbols->addr = 0;
}
- else {
+ else
+ {
kernSymbols_t *symbol = kernelSymbols;
while(symbol->next != NULL)
{
@@ -160,14 +158,12 @@
{
return symbol;
}
-
}
void patch_kernel(void* kernelData, void* arg2, void* arg3, void *arg4)
{
patchRoutine_t* entry = patches;
-
int arch = determineKernelArchitecture(kernelData);
locate_symbols(kernelData);
@@ -191,6 +187,7 @@
{
return KERNEL_32;
}
+
if(((struct mach_header*)kernelData)->magic == MH_MAGIC_64)
{
return KERNEL_64;
@@ -201,7 +198,6 @@
}
}
-
/**
** This functions located the requested symbols in the mach-o file.
** as well as determines the start of the __TEXT segment and __TEXT,__text sections
@@ -209,9 +205,9 @@
int locate_symbols(void* kernelData)
{
char is64 = 1;
- parse_mach(kernelData, NULL, symbol_handler);
+ parse_mach(kernelData, NULL, symbol_handler, NULL);
//handle_symtable((UInt32)kernelData, symtableData, &symbol_handler, determineKernelArchitecture(kernelData) == KERNEL_64);
- return 1 << is64;
+ return 1ull << is64;
}
long long symbol_handler(char* symbolName, long long addr, char is64)
@@ -227,7 +223,6 @@
return 0xFFFFFFFF; // fixme
}
-
/**
** Locate the fisrt instance of _panic inside of _cpuid_set_info, and either remove it
** Or replace it so that the cpuid is set to a valid value.
@@ -236,32 +231,52 @@
{
switch(Platform->CPU.Model)
{
- case CPUID_MODEL_ATOM:
+ case CPU_MODEL_ATOM:
if(determineKernelArchitecture(kernelData) == KERNEL_32)
{
- patch_cpuid_set_info_32(kernelData, CPUFAMILY_INTEL_PENRYN, CPUID_MODEL_PENRYN);
+ patch_cpuid_set_info_32(kernelData, CPUFAMILY_INTEL_PENRYN, CPU_MODEL_PENRYN);
}
else
{
- patch_cpuid_set_info_64(kernelData, CPUFAMILY_INTEL_PENRYN, CPUID_MODEL_PENRYN);
-
+ patch_cpuid_set_info_64(kernelData, CPUFAMILY_INTEL_PENRYN, CPU_MODEL_PENRYN);
}
break;
-
+
default:
- if(determineKernelArchitecture(kernelData) == KERNEL_32)
+ {
+ // AnV: Extra cpuid fix for spoofing Nehalem CPU for i5/i9
+ switch(Platform->CPU.Family)
{
- patch_cpuid_set_info_32(kernelData, 0, 0);
+ case CPU_MODEL_FIELDS: /* Intel i5 */
+ case CPU_MODEL_WESTMERE: /* Intel i9 */
+ if(determineKernelArchitecture(kernelData) == KERNEL_32)
+ {
+ patch_cpuid_set_info_32(kernelData, CPUFAMILY_INTEL_NEHALEM, CPU_MODEL_NEHALEM);
+ }
+ else
+ {
+ patch_cpuid_set_info_64(kernelData, CPUFAMILY_INTEL_NEHALEM, CPU_MODEL_NEHALEM);
+ }
+
+ break;
+
+ default:
+ if(determineKernelArchitecture(kernelData) == KERNEL_32)
+ {
+ patch_cpuid_set_info_32(kernelData, 0, 0);
+ }
+ else
+ {
+ patch_cpuid_set_info_64(kernelData, 0, 0);
+ }
+ break;
}
- else
- {
- patch_cpuid_set_info_64(kernelData, 0, 0);
- }
-
- break;
+ break;
+ }
}
}
+
void patch_cpuid_set_info_64(void* kernelData, UInt32 impersonateFamily, UInt8 impersonateModel)
{
UInt8* bytes = (UInt8*)kernelData;
@@ -270,30 +285,24 @@
UInt32 patchLocation = symbol ? symbol->addr - textAddress + textSection: 0; // (kernelSymbolAddresses[SYMBOL_CPUID_SET_INFO] - textAddress + textSection);
patchLocation -= (UInt32)kernelData; // Remove offset
-
-
-
+
//UInt32 jumpLocation = 0;
-
-
+
if(symbol == 0 || symbol->addr == 0)
{
verbose("Unable to locate _cpuid_set_info\n");
return;
-
}
symbol = lookup_kernel_symbol("_panic");
UInt32 panicAddr = symbol ? symbol->addr - textAddress: 0; //kernelSymbolAddresses[SYMBOL_PANIC] - textAddress;
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate _panic\n");
+ printf("Unable to locate _panic\n");
return;
}
panicAddr -= (UInt32)kernelData;
-
-
-
+
//TODO: don't assume it'll always work (Look for *next* function address in symtab and fail once it's been reached)
while(
(bytes[patchLocation -1] != 0xE8) ||
@@ -306,7 +315,7 @@
patchLocation++;
}
patchLocation--;
-
+
// Remove panic just in ca se
// The panic instruction is exactly 5 bytes long.
bytes[patchLocation + 0] = 0x90;
@@ -314,13 +323,10 @@
bytes[patchLocation + 2] = 0x90;
bytes[patchLocation + 3] = 0x90;
bytes[patchLocation + 4] = 0x90;
-
-
-
+
// Check for a 10.2.0+ kernel
if(bytes[patchLocation - 19] == 0xC7 && bytes[patchLocation - 18] == 0x05)
{
-
UInt32 cpuid_cpufamily_addr = bytes[patchLocation - 17] << 0 |
bytes[patchLocation - 16] << 8 |
bytes[patchLocation - 15] << 16 |
@@ -328,12 +334,10 @@
// NOTE: may change, determined based on cpuid_info struct
UInt32 cpuid_model_addr = cpuid_cpufamily_addr - 310;
-
-
+
//ffffff8000228b3b -> 0x00490e8b
//ffffff8000228c28 -> -237 -> 0x490D9E -> -310
-
-
+
// The mov is 10 bytes
/*
bytes[patchLocation - 19] = 0x90; // c7
@@ -347,8 +351,7 @@
bytes[patchLocation - 12] = (impersonateFamily & 0x0000FF00) >> 8;
bytes[patchLocation - 11] = (impersonateFamily & 0x00FF0000) >> 16;
bytes[patchLocation - 10] = (impersonateFamily & 0xFF000000) >> 24;
-
-
+
// The lea (%rip),%rip is 7 bytes
bytes[patchLocation - 9] = 0xC7;
bytes[patchLocation - 8] = 0x05;
@@ -357,10 +360,8 @@
bytes[patchLocation - 5] = ((cpuid_model_addr -10) & 0x00FF0000) >> 16;
bytes[patchLocation - 4] = ((cpuid_model_addr -10) & 0xFF000000) >> 24;
bytes[patchLocation - 3] = impersonateModel; // cpuid_model
-
-
-
- // The xor eax eax is 2 bytes
+
+ // The xor eax eax is 2 bytes
bytes[patchLocation - 2] = 0x01; // cpuid_extmodel
bytes[patchLocation - 1] = 0x00; // cpuid_extfamily
@@ -378,53 +379,40 @@
// Total: 24 bytes
verbose("Running on a 10.2.0+ kernel\n");
- getc();
-
+// getchar();
}
else {
- verbose("Running on a 10.0.0 kernel, patch unsupported\n");
- getc();
+ printf("Running on a 10.0.0 kernel, patch unsupported\n");
+ pause();
}
-
-
}
-
-
-
-
void patch_cpuid_set_info_32(void* kernelData, UInt32 impersonateFamily, UInt8 impersonateModel)
-{
+{
UInt8* bytes = (UInt8*)kernelData;
kernSymbols_t *symbol = lookup_kernel_symbol("_cpuid_set_info");
UInt32 patchLocation = symbol ? symbol->addr - textAddress + textSection: 0; // (kernelSymbolAddresses[SYMBOL_CPUID_SET_INFO] - textAddress + textSection);
patchLocation -= (UInt32)kernelData; // Remove offset
- UInt32 addrLocation = patchLocation;
-
- UInt32 jumpLocation = 0;
-
-
+ UInt32 jumpLocation = 0;
+
if(symbol == 0 || symbol->addr == 0)
{
verbose("Unable to locate _cpuid_set_info\n");
return;
-
}
symbol = lookup_kernel_symbol("_panic");
UInt32 panicAddr = symbol ? symbol->addr - textAddress: 0; //kernelSymbolAddresses[SYMBOL_PANIC] - textAddress;
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate _panic\n");
+ printf("Unable to locate _panic\n");
return;
}
panicAddr -= (UInt32)kernelData;
-
-
//TODO: don't assume it'll always work (Look for *next* function address in symtab and fail once it's been reached)
while(
(bytes[patchLocation -1] != 0xE8) ||
@@ -432,7 +420,7 @@
bytes[patchLocation + 1] << 8 |
bytes[patchLocation + 2] << 16 |
bytes[patchLocation + 3] << 24)))
- )
+ )
{
patchLocation++;
}
@@ -444,39 +432,39 @@
bytes[patchLocation + 2] = 0x90;
bytes[patchLocation + 3] = 0x90;
bytes[patchLocation + 4] = 0x90;
-
-
+
// Locate the jump call, so that 10 bytes can be reclamed.
// NOTE: This will *NOT* be located on pre 10.6.2 kernels
jumpLocation = patchLocation - 15;
while((bytes[jumpLocation - 1] != 0x77 ||
- bytes[jumpLocation] != (patchLocation - jumpLocation - 18)) &&
+ bytes[jumpLocation] != (patchLocation - jumpLocation - -8)) &&
(patchLocation - jumpLocation) < 0xF0)
{
jumpLocation--;
}
+
// If found... AND we want to impersonate a specific cpumodel / family...
- if(impersonateFamily && impersonateModel &&
+ if(impersonateFamily &&
+ impersonateModel &&
((patchLocation - jumpLocation) < 0xF0))
{
+
bytes[jumpLocation] -= 10; // sizeof(movl $0x6b5a4cd2,0x00872eb4) = 10bytes
/*
* Inpersonate the specified CPU FAMILY and CPU Model
*/
- // cpuid_cpufamily_addr, impersonateFamily cpuid_model_addr impersonateModel
- //char new_bytes[] = {0xC7, 0x05, 0x__, 0x__, 0x__, 0x__, 0x__, 0x__, 0x__, 0x__, 0x90, 0x90, 0xC7, 0x05, 0x__, 0x__, 0x__, 0x__, 0x__, 0x01, 0x00, 0x02};
+
// bytes[patchLocation - 17] = 0xC7; // already here... not needed to be done
// bytes[patchLocation - 16] = 0x05; // see above
- //UInt32 cpuid_cpufamily_addr = bytes[patchLocation - 15] << 0 |
- // bytes[patchLocation - 14] << 8 |
- // bytes[patchLocation - 13] << 16 |
- // bytes[patchLocation - 12] << 24;
+ UInt32 cpuid_cpufamily_addr = bytes[patchLocation - 15] << 0 |
+ bytes[patchLocation - 14] << 8 |
+ bytes[patchLocation - 13] << 16 |
+ bytes[patchLocation - 12] << 24;
- // NOTE: may change, determined based on cpuid_info struct: TODO: read from binary
- //UInt32 cpuid_model_addr = cpuid_cpufamily_addr - 295;
-
-
+ // NOTE: may change, determined based on cpuid_info struct
+ UInt32 cpuid_model_addr = cpuid_cpufamily_addr - 299;
+
// cpufamily
bytes[patchLocation - 11] = (impersonateFamily & 0x000000FF) >> 0;
bytes[patchLocation - 10] = (impersonateFamily & 0x0000FF00) >> 8;
@@ -492,40 +480,20 @@
bytes[patchLocation - 5] = 0xC7;
bytes[patchLocation - 4] = 0x05;
+ bytes[patchLocation - 3] = (cpuid_model_addr & 0x000000FF) >> 0;
+ bytes[patchLocation - 2] = (cpuid_model_addr & 0x0000FF00) >> 8;
+ bytes[patchLocation - 1] = (cpuid_model_addr & 0x00FF0000) >> 16;
+ bytes[patchLocation - 0] = (cpuid_model_addr & 0xFF000000) >> 24;
- // Locate cpuid_addr_addr -> first four bytes after 8b 45 d8 25 f0 00 00 00 c1 e8 04 a2
- while(bytes[addrLocation -12] != 0x8B ||
- bytes[addrLocation -11] != 0x45 ||
- bytes[addrLocation -10] != 0xD8 ||
- bytes[addrLocation -9] != 0x25 ||
- bytes[addrLocation -8] != 0xF0 ||
- bytes[addrLocation -7] != 0x00 ||
- bytes[addrLocation -6] != 0x00 ||
- bytes[addrLocation -5] != 0x00 ||
- bytes[addrLocation -4] != 0xC1 ||
- bytes[addrLocation -3] != 0xE8 ||
- bytes[addrLocation -2] != 0x04 ||
- bytes[addrLocation -1] != 0xA2)
- {
- // TODO: break if location is too large
- addrLocation++;
- }
-
- bytes[patchLocation - 3] = bytes[addrLocation];
- bytes[patchLocation - 2] = bytes[addrLocation+1];
- bytes[patchLocation - 1] = bytes[addrLocation+2];
- bytes[patchLocation - 0] = bytes[addrLocation+3];
-
// Note: I could have just copied the 8bit cpuid_model in and saved about 4 bytes
// so if this function need a different patch it's still possible. Also, about ten bytes previous can be freed.
bytes[patchLocation + 1] = impersonateModel; // cpuid_model
bytes[patchLocation + 2] = 0x01; // cpuid_extmodel
bytes[patchLocation + 3] = 0x00; // cpuid_extfamily
- bytes[patchLocation + 4] = 0x02; // cpuid_stepping
+ bytes[patchLocation + 4] = 0x02; // cpuid_stepping
}
else if(impersonateFamily && impersonateModel)
{
-
// pre 10.6.2 kernel
// Locate the jump to directly *after* the panic call,
jumpLocation = patchLocation - 4;
@@ -568,12 +536,9 @@
bytes[patchLocation + 2] = 0x01; // cpuid_extmodel
bytes[patchLocation + 3] = 0x00; // cpuid_extfamily
bytes[patchLocation + 4] = 0x02; // cpuid_stepping
-
-
-
- //patchLocation = jumpLocation;
- // We now have 14 bytes available for a patch
+ patchLocation = jumpLocation;
+ // We now have 14 bytes available for a patch
}
else
{
@@ -589,7 +554,6 @@
}
}
-
/**
** SleepEnabler.kext replacement (for those that need it)
** Located the KERN_INVALID_ARGUMENT return and replace it with KERN_SUCCESS
@@ -603,14 +567,12 @@
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate _pmCPUExitHaltToOff\n");
+ printf("Unable to locate _pmCPUExitHaltToOff\n");
return;
}
patchLocation -= (UInt32)kernelData; // Remove offset
-
-
-
+
while(bytes[patchLocation - 1] != 0xB8 ||
bytes[patchLocation] != 0x04 || // KERN_INVALID_ARGUMENT (0x00000004)
bytes[patchLocation + 1] != 0x00 || // KERN_INVALID_ARGUMENT
@@ -632,25 +594,21 @@
UInt32 patchLocation = symbol ? symbol->addr - textAddress + textSection: 0;
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate %s\n", "_lapic_init");
+ printf("Unable to locate %s\n", "_lapic_init");
return;
-
}
symbol = lookup_kernel_symbol("_panic");
UInt32 panicAddr = symbol ? symbol->addr - textAddress: 0;
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate %s\n", "_panic");
+ printf("Unable to locate %s\n", "_panic");
return;
}
patchLocation -= (UInt32)kernelData; // Remove offset
panicAddr -= (UInt32)kernelData; // Remove offset
-
-
-
// Locate the (panicIndex + 1) panic call
while(panicIndex < 3) // Find the third panic call
{
@@ -660,7 +618,7 @@
bytes[patchLocation + 1] << 8 |
bytes[patchLocation + 2] << 16 |
bytes[patchLocation + 3] << 24)))
- )
+ )
{
patchLocation++;
}
@@ -674,11 +632,8 @@
bytes[++patchLocation] = 0x90;
bytes[++patchLocation] = 0x90;
bytes[++patchLocation] = 0x90;
-
-
}
-
void patch_commpage_stuff_routine(void* kernelData)
{
UInt8* bytes = (UInt8*)kernelData;
@@ -693,11 +648,10 @@
UInt32 patchLocation = symbol->addr - textAddress + textSection;
-
symbol = lookup_kernel_symbol("_panic");
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate %s\n", "_panic");
+ printf("Unable to locate %s\n", "_panic");
return;
}
UInt32 panicAddr = symbol->addr - textAddress;
@@ -711,7 +665,7 @@
bytes[patchLocation + 1] << 8 |
bytes[patchLocation + 2] << 16 |
bytes[patchLocation + 3] << 24)))
- )
+ )
{
patchLocation++;
}
@@ -723,30 +677,26 @@
bytes[patchLocation + 2] = 0x90;
bytes[patchLocation + 3] = 0x90;
bytes[patchLocation + 4] = 0x90;
-
-
}
void patch_lapic_interrupt(void* kernelData)
{
// NOTE: this is a hack untill I finish patch_lapic_configure
UInt8* bytes = (UInt8*)kernelData;
-
+
kernSymbols_t *symbol = lookup_kernel_symbol("_lapic_interrupt");
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate %s\n", "_lapic_interrupt");
+ printf("Unable to locate %s\n", "_lapic_interrupt");
return;
-
}
-
+
UInt32 patchLocation = symbol->addr - textAddress + textSection;
-
-
+
symbol = lookup_kernel_symbol("_panic");
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate %s\n", "_panic");
+ printf("Unable to locate %s\n", "_panic");
return;
}
UInt32 panicAddr = symbol->addr - textAddress;
@@ -772,11 +722,8 @@
bytes[patchLocation + 2] = 0x90;
bytes[patchLocation + 3] = 0x90;
bytes[patchLocation + 4] = 0x90;
-
-
}
-
void patch_lapic_configure(void* kernelData)
{
UInt8* bytes = (UInt8*)kernelData;
@@ -788,7 +735,7 @@
kernSymbols_t *symbol = lookup_kernel_symbol("_lapic_configure");
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate %s\n", "_lapic_configure");
+ printf("Unable to locate %s\n", "_lapic_configure");
return;
}
patchLocation = symbol->addr - textAddress + textSection;
@@ -796,16 +743,15 @@
symbol = lookup_kernel_symbol("_lapic_start");
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate %s\n", "_lapic_start");
+ printf("Unable to locate %s\n", "_lapic_start");
return;
}
lapicStart = symbol->addr;
-
symbol = lookup_kernel_symbol("_lapic_interrupt_base");
if(symbol == 0 || symbol->addr == 0)
{
- verbose("Unable to locate %s\n", "_lapic_interrupt_base");
+ printf("Unable to locate %s\n", "_lapic_interrupt_base");
return;
}
lapicInterruptBase = symbol->addr;
@@ -813,7 +759,6 @@
lapicStart -= (UInt32)kernelData;
lapicInterruptBase -= (UInt32)kernelData;
-
// Looking for the following:
//movl _lapic_start,%e_x
//addl $0x00000320,%e_x
@@ -828,7 +773,7 @@
bytes[patchLocation + 3] << 24
)
)
- ) ||
+ ) ||
(bytes[patchLocation + 4 ] != 0x81) ||
//(bytes[patchLocation + 5 ] != 0Cx2) || // register
(bytes[patchLocation + 6 ] != 0x20) ||
@@ -868,7 +813,7 @@
bytes[patchLocation++];// = 0x00;
bytes[patchLocation++];// = 0x00;
*/
- patchLocation += 3;
+ patchLocation += 3;
// c7 02 00 04 00 00 -> movl $0x00000400,(%edx)
bytes[patchLocation++] = 0xC7;
@@ -946,7 +891,6 @@
// Replace remaining with nops
-
bytes[patchLocation++] = 0x90;
bytes[patchLocation++] = 0x90;
bytes[patchLocation++] = 0x90;
Index: branches/slice/trunkM/i386/modules/KernelPatcher/Cconfig
===================================================================
--- branches/slice/trunkM/i386/modules/KernelPatcher/Cconfig (revision 1206)
+++ branches/slice/trunkM/i386/modules/KernelPatcher/Cconfig (revision 1207)
@@ -4,7 +4,7 @@
config KernelPatcher_MODULE
tristate "KernelPatcher Module"
- default n
+ default m
---help---
Say Y here if you want to enable the use of this module.
Index: branches/slice/trunkM/i386/modules/Makefile
===================================================================
--- branches/slice/trunkM/i386/modules/Makefile (revision 1206)
+++ branches/slice/trunkM/i386/modules/Makefile (revision 1207)
@@ -11,8 +11,8 @@
include ${SRCROOT}/Make.rules
# The order of building is important.
-SUBDIRS = klibc uClibcxx Resolution
-#HelloWorld Memory NetbookInstaller KernelPatcher KextPatcher Networking NVRAM HPET USBFix
+SUBDIRS = klibc uClibcxx Resolution KernelPatcher
+#HelloWorld Memory NetbookInstaller KextPatcher Networking NVRAM HPET USBFix RamDiskLoader
CFLAGS= -Os $(MORECPP) -arch i386 -g -static
Index: branches/slice/trunkM/revision
===================================================================
--- branches/slice/trunkM/revision (revision 1206)
+++ branches/slice/trunkM/revision (revision 1207)
@@ -1 +1 @@
-1200
\ No newline at end of file
+1206
\ No newline at end of file