Chameleon

Chameleon Commit Details

Date:2011-07-22 10:05:43 (7 years 10 months ago)
Author:Sergey Slice
Commit:1207
Parents: 1206
Message:bug with CPU speed; Nr of args in modules
Changes:
A/branches/slice/trunkM/i386/modules/RamDiskLoader/ramdisk.c
A/branches/slice/trunkM/i386/modules/RamDiskLoader/Makefile
A/branches/slice/trunkM/i386/modules/RamDiskLoader/ramdisk.h
A/branches/slice/trunkM/i386/modules/RamDiskLoader
A/branches/slice/trunkM/i386/modules/RamDiskLoader/RamDiskLoader.c
A/branches/slice/trunkM/i386/modules/RamDiskLoader/Cconfig
M/branches/slice/trunkM/revision
M/branches/slice/trunkM/i386/modules/KernelPatcher/kernel_patcher.c
M/branches/slice/trunkM/i386/modules/KernelPatcher/Cconfig
M/branches/slice/trunkM/i386/boot2/boot.c
M/branches/slice/trunkM/Chameleon.xcodeproj/slice.mode1v3
M/branches/slice/trunkM/Chameleon.xcodeproj/slice.pbxuser
M/branches/slice/trunkM/i386/modules/Makefile
M/branches/slice/trunkM/i386/libsaio/smbios_getters.c
M/branches/slice/trunkM/i386/modules/KernelPatcher/include/kernel_patcher.h
M/branches/slice/trunkM/i386/libsaio/smbios.c
M/branches/slice/trunkM/i386/libsaio/smbios_decode.c

File differences

branches/slice/trunkM/Chameleon.xcodeproj/slice.pbxuser
22
33
44
5
6
7
5
6
7
88
99
1010
1111
12
13
14
12
13
14
1515
1616
1717
......
2323
2424
2525
26
26
2727
28
28
2929
3030
3131
......
6363
6464
6565
66
67
66
67
6868
6969
7070
......
8383
8484
8585
86
8786
8887
8988
......
9392
9493
9594
95
96
97
98
9699
97100
98101
99
100
101102
102103
103104
......
277278
278279
279280
280
281
282
283
284
285
286
287
288
289
290281
291282
292283
......
377368
378369
379370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
380411
381412
382413
......
407438
408439
409440
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430441
431442
432
433
434
443
444
445
435446
436447
448
449
450
451
452
453
454
437455
438456
439457
......
507525
508526
509527
510
511
512
528
529
530
513531
514532
515533
......
542560
543561
544562
545
546
547
563
564
565
548566
549567
550568
{
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 */ = {
};
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}}";
};
};
PBXFileDataSource_Target_ColumnID,
);
};
PBXPerProjectTemplateStateSaveDate = 332963545;
PBXWorkspaceStateSaveDate = 332963545;
PBXPerProjectTemplateStateSaveDate = 333013407;
PBXWorkspaceStateSaveDate = 333013407;
};
perUserProjectItems = {
1208BED013D70B8900694228 /* PBXTextBookmark */ = 1208BED013D70B8900694228 /* PBXTextBookmark */;
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 */;
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 = {
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 */;
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 */;
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}}";
};
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 */ = {
};
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 */ = {
branches/slice/trunkM/Chameleon.xcodeproj/slice.mode1v3
216216
217217
218218
219
220219
221220
222221
......
299298
300299
301300
302
301
303302
304303
305304
......
310309
311310
312311
313
314
315312
316313
317314
318315
319316
320
317
321318
322319
323320
......
325322
326323
327324
328
325
329326
330327
331328
332
329
333330
334331
335332
......
357354
358355
359356
360
361357
362358
363359
364
360
361
362
365363
366364
367365
......
373371
374372
375373
376
374
377375
378
376
379377
380378
381379
382380
383
381
384382
385383
384
385
386386
387387
388388
......
393393
394394
395395
396
396
397397
398
398
399399
400400
401401
402402
403
403
404404
405405
406406
......
419419
420420
421421
422
422
423423
424
424
425425
426426
427427
......
559559
560560
561561
562
562563
563
564
564565
565566
566
567
567568
568569
569570
......
593594
594595
595596
596
597
597598
598599
599600
......
617618
618619
619620
620
621
621622
622623
623624
......
640641
641642
642643
643
644
644645
645646
646647
......
649650
650651
651652
652
653
653654
654655
655656
......
773774
774775
775776
776
777
778777
779778
780779
781780
782781
783
782
784783
785784
786785
......
789788
790789
791790
792
791
793792
794793
795794
......
801800
802801
803802
803
804
804805
805806
806807
......
813814
814815
815816
816
817
817818
818819
819820
......
836837
837838
838839
839
840
840
841
841842
842843
843844
844845
845
846
846847
847848
848849
<string>servicesModulefind</string>
<string>com.apple.ide.PBXToolbarStopButton</string>
<string>get-info</string>
<string>go</string>
<string>NSToolbarFlexibleSpaceItem</string>
<string>com.apple.pbx.toolbar.searchfield</string>
</array>
<real>186</real>
</array>
<key>RubberWindowFrame</key>
<string>134 119 1146 659 0 0 1280 778 </string>
<string>294 219 1146 659 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXSmartGroupTreeModule</string>
<key>Dock</key>
<array>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
<string>1CE0B20306471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
<string>modules.c</string>
<string>modules.h</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
<key>PBXProjectModuleGUID</key>
<string>1CE0B20406471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
<string>modules.c</string>
<string>modules.h</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>12FBE8FC13D89F1700E385CB</string>
<string>12E9C0F013D961D90096128F</string>
<key>history</key>
<array>
<string>122A5BCA1375C49300795FF0</string>
<string>1237561D13D823130027F8A5</string>
<string>12375A2913D82FD80027F8A5</string>
<string>12375A3C13D831AB0027F8A5</string>
<string>1272D14713D860AF00EDABD3</string>
<string>120E55C813D8694A00E2D592</string>
<string>12EE45C013D896210092C48C</string>
<string>12FBE8FA13D89F1700E385CB</string>
<string>12FBE8FB13D89F1700E385CB</string>
<string>12E9C0AA13D95C2F0096128F</string>
<string>12E9C0BD13D95F8F0096128F</string>
<string>12E9C0BF13D95F8F0096128F</string>
</array>
</dict>
<key>SplitCount</key>
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {938, 360}}</string>
<string>{{0, 0}, {938, 333}}</string>
<key>RubberWindowFrame</key>
<string>134 119 1146 659 0 0 1280 778 </string>
<string>294 219 1146 659 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
<string>360pt</string>
<string>333pt</string>
</dict>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 365}, {938, 253}}</string>
<string>{{0, 338}, {938, 280}}</string>
<key>RubberWindowFrame</key>
<string>134 119 1146 659 0 0 1280 778 </string>
<string>294 219 1146 659 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
<key>Proportion</key>
<string>253pt</string>
<string>280pt</string>
</dict>
</array>
<key>Proportion</key>
</array>
<key>TableOfContents</key>
<array>
<string>12FBE8FD13D89F1700E385CB</string>
<string>12E9C0F113D961D90096128F</string>
<string>1CE0B1FE06471DED0097A5F4</string>
<string>12FBE8FE13D89F1700E385CB</string>
<string>12E9C0F213D961D90096128F</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
<integer>5</integer>
<key>WindowOrderList</key>
<array>
<string>1C530D57069F1CE1000CFCEE</string>
<string>122A5BB81375BA4700795FF0</string>
<string>/Developer/Projects/Chameleons/slice/trunkM/Chameleon.xcodeproj</string>
<string>/Users/slice/Projects/Chameleons/chameleon/branches/slice/trunkM/Chameleon.xcodeproj</string>
</array>
<key>WindowString</key>
<string>134 119 1146 659 0 0 1280 778 </string>
<string>294 219 1146 659 0 0 1440 878 </string>
<key>WindowToolsV3</key>
<array>
<dict>
<key>Frame</key>
<string>{{0, 0}, {500, 218}}</string>
<key>RubberWindowFrame</key>
<string>91 232 500 500 0 0 1280 778 </string>
<string>110 311 500 500 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Frame</key>
<string>{{0, 223}, {500, 236}}</string>
<key>RubberWindowFrame</key>
<string>91 232 500 500 0 0 1280 778 </string>
<string>110 311 500 500 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXBuildResultsModule</string>
<key>TableOfContents</key>
<array>
<string>122A5BB81375BA4700795FF0</string>
<string>12FBE8FF13D89F1700E385CB</string>
<string>12E9C0EC13D961D60096128F</string>
<string>1CD0528F0623707200166675</string>
<string>XCMainBuildResultsModuleGUID</string>
</array>
<key>WindowContentMinSize</key>
<string>486 300</string>
<key>WindowString</key>
<string>91 232 500 500 0 0 1280 778 </string>
<string>110 311 500 500 0 0 1440 878 </string>
<key>WindowToolGUID</key>
<string>122A5BB81375BA4700795FF0</string>
<key>WindowToolIsVisible</key>
<key>Dock</key>
<array>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
<string>1CDD528C0622207200134675</string>
<key>PBXProjectModuleLabel</key>
<string>smbios_getters.c</string>
<string></string>
<key>StatusBarVisibility</key>
<true/>
</dict>
<key>Frame</key>
<string>{{0, 0}, {843, 431}}</string>
<key>RubberWindowFrame</key>
<string>420 68 843 689 0 0 1280 778 </string>
<string>574 144 843 689 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<string>431pt</string>
</dict>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
<key>Frame</key>
<string>{{0, 436}, {843, 212}}</string>
<key>RubberWindowFrame</key>
<string>420 68 843 689 0 0 1280 778 </string>
<string>574 144 843 689 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXProjectFindModule</string>
<key>TableOfContents</key>
<array>
<string>1C530D57069F1CE1000CFCEE</string>
<string>12EE45BE13D896190092C48C</string>
<string>12EE45BF13D896190092C48C</string>
<string>12E9C0EE13D961D60096128F</string>
<string>12E9C0EF13D961D60096128F</string>
<string>1CDD528C0622207200134675</string>
<string>1CD0528E0623707200166675</string>
</array>
<key>WindowString</key>
<string>420 68 843 689 0 0 1280 778 </string>
<string>574 144 843 689 0 0 1440 878 </string>
<key>WindowToolGUID</key>
<string>1C530D57069F1CE1000CFCEE</string>
<key>WindowToolIsVisible</key>
branches/slice/trunkM/i386/libsaio/smbios.c
1111
1212
1313
14
14
1515
1616
1717
......
918918
919919
920920
921
921922
922923
923924
#include "smbios_getters.h"
#ifndef DEBUG_SMBIOS
#define DEBUG_SMBIOS 0
#define DEBUG_SMBIOS 1
#endif
#if DEBUG_SMBIOS
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:
branches/slice/trunkM/i386/libsaio/smbios_decode.c
99
1010
1111
12
12
1313
1414
1515
16
16
1717
18
18
1919
2020
2121
......
228228
229229
230230
231
232
233
231234
232235
#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
structHeader = (SMBStructHeader *)ptr;
}
DBG("\n");
#if DEBUG_SMBIOS
getchar();
#endif
}
branches/slice/trunkM/i386/libsaio/smbios_getters.c
2727
2828
2929
30
30
3131
3232
3333
3434
3535
36
36
3737
3838
3939
......
475475
476476
477477
478
478479
479480
480481
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;
}
}
#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
branches/slice/trunkM/i386/boot2/boot.c
585585
586586
587587
588
588
589589
590590
591591
if (ret == 0 && kerneltime > exttime) {
exttime = kerneltime;
}
if (ret == 0 && cachetime < exttime) {
if (ret == 0 && cachetime != (exttime + 1)) {
trycache = 0;
break;
}
branches/slice/trunkM/i386/modules/RamDiskLoader/ramdisk.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 */
branches/slice/trunkM/i386/modules/RamDiskLoader/RamDiskLoader.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* RamDiskLoader.c
* Chameleon
*
* Created by cparm on 05/12/10. <armelcadetpetit@gmail.com>
* 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);
}
}
branches/slice/trunkM/i386/modules/RamDiskLoader/Cconfig
1
2
3
4
5
6
7
8
9
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.
branches/slice/trunkM/i386/modules/RamDiskLoader/ramdisk.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
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 <filename> - 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;
}
branches/slice/trunkM/i386/modules/RamDiskLoader/Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
branches/slice/trunkM/i386/modules/KernelPatcher/include/kernel_patcher.h
1212
1313
1414
15
16
17
18
19
20
21
22
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2329
2430
2531
#define CPUID_MODEL_ANY0x00
#define CPUID_MODEL_UNKNOWN0x01
#define CPUID_MODEL_YONAH14
#define CPUID_MODEL_MEROM15
#define CPUID_MODEL_PENRYN23
#define CPUID_MODEL_NEHALEM26
#define CPUID_MODEL_ATOM28
#define CPUID_MODEL_FIELDS30/* Lynnfield, Clarksfield, Jasper */
#define CPUID_MODEL_DALES31/* Havendale, Auburndale */
#define CPUID_MODEL_NEHALEM_EX46
#define CPU_MODEL_PENTIUM_M0x0D
#define CPU_MODEL_YONAH0x0E// Sossaman, Yonah
#define CPU_MODEL_MEROM0x0F// Allendale, Conroe, Kentsfield, Woodcrest, Clovertown, Tigerton, Merom
#define CPU_MODEL_PENRYN0x17// Wolfdale, Yorkfield, Harpertown, Penryn
#define CPU_MODEL_NEHALEM0x1A// Bloomfield. Nehalem-EP, Nehalem-WS, Gainestown
#define CPU_MODEL_ATOM0x1C// Atom
#define CPU_MODEL_FIELDS0x1E// Lynnfield, Clarksfield, Jasper Forest
#define CPU_MODEL_DALES0x1F// Havendale, Auburndale
#define CPU_MODEL_DALES_32NM0x25// Clarkdale, Arrandale
#define CPU_MODEL_SANDY0x2A// Sandy Bridge
#define CPU_MODEL_WESTMERE0x2C// Gulftown, Westmere-EP, Westmere-WS
#define CPU_MODEL_SANDY_XEON0x2D// Sandy Bridge Xeon
#define CPU_MODEL_NEHALEM_EX0x2E// Beckton
#define CPU_MODEL_WESTMERE_EX0x2F
#define KERNEL_ANY0x00
#define KERNEL_640x01
branches/slice/trunkM/i386/modules/KernelPatcher/kernel_patcher.c
1212
1313
1414
15
1516
1617
1718
......
2425
2526
2627
27
2828
2929
3030
......
3535
3636
3737
38
38
3939
4040
4141
4242
43
44
4543
46
47
44
4845
46
47
4948
5049
5150
......
6867
6968
7069
71
72
73
74
75
76
77
78
70
71
72
73
74
75
76
77
7978
8079
8180
......
8483
8584
8685
87
8886
8987
9088
......
9290
9391
9492
95
9693
9794
9895
......
127124
128125
129126
130
127
128
131129
132130
133131
......
160158
161159
162160
163
164161
165162
166163
167164
168165
169166
170
171167
172168
173169
......
191187
192188
193189
190
194191
195192
196193
......
201198
202199
203200
204
205201
206202
207203
......
209205
210206
211207
212
208
213209
214
210
215211
216212
217213
......
227223
228224
229225
230
231226
232227
233228
......
236231
237232
238233
239
234
240235
241236
242
237
243238
244239
245240
246
247
241
248242
249243
250244
251
245
252246
253
247
248
249
254250
255
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
256274
257
258
259
260
261
262
275
276
263277
264278
279
265280
266281
267282
......
270285
271286
272287
273
274
275
288
276289
277
278
290
279291
280292
281293
282294
283
284295
285296
286297
287298
288299
289300
290
301
291302
292303
293304
294
295
296
305
297306
298307
299308
......
306315
307316
308317
309
318
310319
311320
312321
......
314323
315324
316325
317
318
319
326
320327
321328
322329
323
324330
325331
326332
......
328334
329335
330336
331
332
337
333338
334339
335
336
340
337341
338342
339343
......
347351
348352
349353
350
351
354
352355
353356
354357
......
357360
358361
359362
360
361
362
363
363
364
364365
365366
366367
......
378379
379380
380381
381
382
382
383383
384384
385
386
385
386
387387
388
389
390388
391389
392
393
394
395
396390
397
391
398392
399393
400394
401395
402396
403397
404
405
406398
407
408
409
399
400
410401
411402
412403
413404
414
415405
416406
417407
418408
419409
420410
421
411
422412
423413
424414
425415
426
427
428416
429417
430418
......
432420
433421
434422
435
423
436424
437425
438426
......
444432
445433
446434
447
448
435
449436
450437
451438
452439
453
440
454441
455442
456443
457444
445
458446
459
447
448
460449
461450
451
462452
463453
464454
465455
466456
467
468
457
469458
470459
471
472
473
474
460
461
462
463
475464
476
477
478
479
465
466
467
480468
481469
482470
......
492480
493481
494482
483
484
485
486
495487
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519488
520489
521490
522491
523492
524
493
525494
526495
527496
528
529497
530498
531499
......
568536
569537
570538
571
572
573
574
575
576539
540
541
577542
578543
579544
......
589554
590555
591556
592
593557
594558
595559
......
603567
604568
605569
606
570
607571
608572
609573
610574
611
612
613
575
614576
615577
616578
......
632594
633595
634596
635
597
636598
637
638599
639600
640601
641602
642603
643604
644
605
645606
646607
647608
648609
649610
650611
651
652
653
654612
655613
656614
......
660618
661619
662620
663
621
664622
665623
666624
......
674632
675633
676634
677
678
679635
680636
681
682637
683638
684639
......
693648
694649
695650
696
697651
698652
699653
700
654
701655
702656
703657
......
711665
712666
713667
714
668
715669
716670
717671
......
723677
724678
725679
726
727
728680
729681
730682
731683
732684
733685
734
686
735687
736688
737689
738
690
739691
740
741692
742
693
743694
744
745
695
746696
747697
748698
749
699
750700
751701
752702
......
772722
773723
774724
775
776
777725
778726
779
780727
781728
782729
......
788735
789736
790737
791
738
792739
793740
794741
......
796743
797744
798745
799
746
800747
801748
802749
803750
804
805751
806752
807753
808
754
809755
810756
811757
......
813759
814760
815761
816
817762
818763
819764
......
828773
829774
830775
831
776
832777
833778
834779
......
868813
869814
870815
871
816
872817
873818
874819
......
946891
947892
948893
949
950894
951895
952896
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()
{
// 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");
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);
}
/*
{
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;
// CPU not in supported list, so we are going to add
// The patch will be applied
break;
}
}
else
// Invalid cpuid for current cpu. Ignoring patch
return;
}
}
}
kernelSymbols->symbol = (char*)name;
kernelSymbols->addr = 0;
}
else {
else
{
kernSymbols_t *symbol = kernelSymbols;
while(symbol->next != NULL)
{
{
return symbol;
}
}
void patch_kernel(void* kernelData, void* arg2, void* arg3, void *arg4)
{
patchRoutine_t* entry = patches;
int arch = determineKernelArchitecture(kernelData);
locate_symbols(kernelData);
{
return KERNEL_32;
}
if(((struct mach_header*)kernelData)->magic == MH_MAGIC_64)
{
return KERNEL_64;
}
}
/**
**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
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)
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.
{
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;
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) ||
patchLocation++;
}
patchLocation--;
// Remove panic just in ca se
// The panic instruction is exactly 5 bytes long.
bytes[patchLocation + 0] = 0x90;
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 |
// 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
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;
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
// 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) ||
bytes[patchLocation + 1] << 8 |
bytes[patchLocation + 2] << 16 |
bytes[patchLocation + 3] << 24)))
)
)
{
patchLocation++;
}
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, impersonateFamilycpuid_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;
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;
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
{
}
}
/**
** SleepEnabler.kext replacement (for those that need it)
** Located the KERN_INVALID_ARGUMENT return and replace it with KERN_SUCCESS
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
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
{
bytes[patchLocation + 1] << 8 |
bytes[patchLocation + 2] << 16 |
bytes[patchLocation + 3] << 24)))
)
)
{
patchLocation++;
}
bytes[++patchLocation] = 0x90;
bytes[++patchLocation] = 0x90;
bytes[++patchLocation] = 0x90;
}
void patch_commpage_stuff_routine(void* kernelData)
{
UInt8* bytes = (UInt8*)kernelData;
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;
bytes[patchLocation + 1] << 8 |
bytes[patchLocation + 2] << 16 |
bytes[patchLocation + 3] << 24)))
)
)
{
patchLocation++;
}
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;
bytes[patchLocation + 2] = 0x90;
bytes[patchLocation + 3] = 0x90;
bytes[patchLocation + 4] = 0x90;
}
void patch_lapic_configure(void* kernelData)
{
UInt8* bytes = (UInt8*)kernelData;
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;
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;
lapicStart -= (UInt32)kernelData;
lapicInterruptBase -= (UInt32)kernelData;
// Looking for the following:
//movl _lapic_start,%e_x
//addl $0x00000320,%e_x
bytes[patchLocation + 3] << 24
)
)
) ||
) ||
(bytes[patchLocation + 4 ] != 0x81) ||
//(bytes[patchLocation + 5 ] != 0Cx2) ||// register
(bytes[patchLocation + 6 ] != 0x20) ||
bytes[patchLocation++];// = 0x00;
bytes[patchLocation++];// = 0x00;
*/
patchLocation += 3;
patchLocation += 3;
// c7 02 00 04 00 00 -> movl $0x00000400,(%edx)
bytes[patchLocation++] = 0xC7;
// Replace remaining with nops
bytes[patchLocation++] = 0x90;
bytes[patchLocation++] = 0x90;
bytes[patchLocation++] = 0x90;
branches/slice/trunkM/i386/modules/KernelPatcher/Cconfig
44
55
66
7
7
88
99
1010
config KernelPatcher_MODULE
tristate "KernelPatcher Module"
default n
default m
---help---
Say Y here if you want to enable the use of this module.
branches/slice/trunkM/i386/modules/Makefile
1111
1212
1313
14
15
14
15
1616
1717
1818
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
branches/slice/trunkM/revision
1
1
1200
1206

Archive Download the corresponding diff file

Revision: 1207