Chameleon

Chameleon Commit Details

Date:2011-02-09 06:01:39 (9 years 3 months ago)
Author:Evan Lojewski
Commit:735
Parents: 734
Message:GUI module bugfixes. Kext Patcher additions.
Changes:
M/branches/meklort/i386/modules/GUI/GUI_module.c
M/branches/meklort/i386/boot2/boot.c
M/branches/meklort/i386/modules/GUI/graphic_utils.c
M/branches/meklort/i386/modules/KextPatcher/kext_patcher.c
M/branches/meklort/i386/boot2/modules.c
M/branches/meklort/i386/modules/Resolution/915resolution.c
M/branches/meklort/i386/util/dyldsymboltool.c
M/branches/meklort/i386/modules/GUI/gui.c

File differences

branches/meklort/i386/boot2/boot.c
193193
194194
195195
196
196
197197
198
199198
200199
201200
201
202
202203
203204
204205
......
319320
320321
321322
322
323
324
325
326
323
324
327325
328
329326
330
331327
332328
333329
execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL);// Notify modules that the kernel is about to be started
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
if (bootArgs->Video.v_display == VGA_TEXT_MODE || gVerboseMode)
{
setVideoMode( GRAPHICS_MODE, 0 );
// Draw gray screen. NOTE: no boot image, that's in the gui module
#ifndef OPTION_ROM
if(!gVerboseMode) drawColorRectangle(0, 0, DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 0x01);
setVideoMode( GRAPHICS_MODE, 0 );
#endif
}
gBootVolume = selectBootVolume(bvChain);
// Intialize module system
if(init_module_system())
{
load_all_modules();
}
// Intialize module system, module sytem will
init_module_system();
execute_hook("ModulesLoaded", NULL, NULL, NULL, NULL);
#ifndef OPTION_ROM
// Loading preboot ramdisk if exists.
loadPrebootRAMDisk();
branches/meklort/i386/boot2/modules.c
7272
7373
7474
75
7576
7677
7778
if((UInt32)lookup_symbol != 0xFFFFFFFF)
{
execute_hook("ModulesLoaded", NULL, NULL, NULL, NULL);
return 1;
}
}
branches/meklort/i386/modules/KextPatcher/kext_patcher.c
4040
4141
4242
43
4344
4445
4546
......
5051
5152
5253
54
5355
5456
5557
5658
57
59
5860
5961
6062
......
396398
397399
398400
401
402
403
404
399405
400406
401407
......
430436
431437
432438
439
440
441
442
433443
434444
435445
......
585595
586596
587597
598
599
600
601
602
603
604
605
606
588607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
589635
590636
591637
......
609655
610656
611657
612
658
659
613660
614661
615662
......
678725
679726
680727
681
682
728
729
730
731
683732
684
685
733
686734
687
688
689
735
736
737
738
690739
691740
692741
bool patch_kext(TagPtr plist, char* plistbuffer, void* start);
bool patch_gma_kexts(TagPtr plist, char* plistbuffer, void* start);
bool patch_bcm_kext(TagPtr plist, char* plistbuffer, void* start);
bool patch_atheros_kext(TagPtr plist, char* plistbuffer, void* start);
bool patch_hda_kext(TagPtr plist, char* plistbuffer, void* start);
bool patch_hda_controller(TagPtr plist, char* plistbuffer, void* start);
uint16_t patch_gma_deviceid = 0;
uint16_t patch_bcm_deviceid = 0;
uint16_t patch_atheros_deviceid = 0;
// TODO: add detection code
uint16_t patch_hda_codec = 0x00;
#define NEEDS_PATCHING(patch_bcm_deviceid || patch_gma_deviceid || patch_hda_codec)
#define NEEDS_PATCHING(patch_bcm_deviceid || patch_gma_deviceid || patch_hda_codec || patch_atheros_deviceid)
typedef struct z_mem {
uint32_t alloc_size;
return patch_hda_controller(plist, plistbuffer, start);
}
else if(patch_atheros_deviceid && strcmp(bundleID, "com.apple.driver.AirPort.Atheros21") == 0)
{
return patch_atheros_kext(plist, plistbuffer, start);
}
return false;
}
{
patch_bcm_deviceid = current->device_id;
}
else if(current->vendor_id == 0x168C && current->device_id == 0x002B)
{
patch_atheros_deviceid = current->device_id;
}
break;
}
}
return true;
}
bool patch_atheros_kext(TagPtr plist, char* plistbuffer, void* start)
{
TagPtr personality;
personality =XMLCastDict(XMLGetProperty(plist, kPropIOKitPersonalities));
personality =XMLGetProperty(personality, (const char*)"Atheros Wireless LAN PCI");
TagPtr match_names =XMLCastArray(XMLGetProperty(personality, (const char*)"IONameMatch"));
char* new_str = malloc(sizeof("pci168c,xxxx"));
sprintf(new_str, "pci168c,%02x", patch_atheros_deviceid);
// Check to see if we *really* need to modify the plist, if not, return false
// so that *if* this were going ot be the only modified kext, the repacking code
// won't need to be executed.
int count = XMLTagCount(match_names);
while(count)
{
count--;
TagPtr replace =XMLGetElement(match_names, count);// Modify the second entry
char* orig_string = XMLCastString(replace);
if(strcmp(orig_string, new_str) == 0) return false;
}
TagPtr replace =XMLGetElement(match_names, 0);// Modify the second entry
char* orig_string = XMLCastString(replace);
verbose("Patching AirPortAtheros21.kext, replacing %s with %s\n", orig_string, new_str);
// TODO: verify string doesn't exist first.
replace_string(orig_string, new_str, plistbuffer + XMLCastStringOffset(replace), 10240);
return true;
}
bool patch_bcm_kext(TagPtr plist, char* plistbuffer, void* start)
{
TagPtr personality;
if(strcmp(orig_string, new_str) == 0) return false;
}
verbose("Patching AppleAirPortBrcm4311.kext with %s\n", new_str);
TagPtr replace =XMLGetElement(match_names, 1);// Modify the second entry
char* orig_string = XMLCastString(replace);
if(XMLGetProperty(personality, (const char*)"Intel915"))
{
verbose("Patching AppleIntelGMA950.kext\n");
//getc();
if((patch_gma_deviceid & 0xFF00) != 0xA000)// GMA3150
{
verbose("Patching AppleIntelGMA950.kext\n");
//getc();
personality =XMLGetProperty(personality, (const char*)"Intel915");
// IOAccelerator kext
personality =XMLGetProperty(personality, (const char*)"Intel915"); // IOAccelerator kext
offset =XMLCastStringOffset(XMLGetProperty(personality, (const char*)"IOPCIPrimaryMatch"));
replace_string("0x27A28086", newstring, plistbuffer + offset, 10240);
replace_word(0x27A28086, 0x8086 | (patch_gma_deviceid << 16), executable, zstream.total_out);
offset =XMLCastStringOffset(XMLGetProperty(personality, (const char*)"IOPCIPrimaryMatch"));
replace_string("0x27A28086", newstring, plistbuffer + offset, 10240);
replace_word(0x27A28086, 0x8086 | (patch_gma_deviceid << 16), executable, zstream.total_out);
}
}
else if(XMLGetProperty(personality, (const char*)"AppleIntelIntegratedFramebuffer"))
branches/meklort/i386/modules/GUI/gui.c
739739
740740
741741
742
742
743743
744744
745745
// set our screen structure with the mode width & height
gui.screen.width = screen_params[0];
gui.screen.height = screen_params[1];
// load graphics otherwise fail and return
if (loadGraphics() == 0) {
loadThemeValues(&bootInfo->themeConfig);
branches/meklort/i386/modules/GUI/GUI_module.c
2121
2222
2323
24
2524
2625
2726
......
7271
7372
7473
75
74
7675
76
7777
78
7978
8079
8180
81
8282
8383
8484
8585
8686
8787
88
88
8989
9090
9191
......
9999
100100
101101
102
103102
104103
105104
......
116115
117116
118117
119
118
120119
121120
122121
......
126125
127126
128127
129
128
129
130
131
132
130133
131134
132135
......
138141
139142
140143
141
142
143144
144145
145146
bool useGUI;
void GUI_Kernel_Start_hook(void* kernelEntry, void* arg2, void* arg3, void* arg4);
void GUI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4);
void GUI_ModulesLoaded_hook(void* arg1, void* arg2, void* arg3, void* arg4);
// Note: shouldn't be needed, but just in case
drawBootGraphics();
}
else
else if(!useGUI)
{
// When gui mode is enabled, this causes a flicker. Do this later, when the display is blanked out
setVideoMode( GRAPHICS_MODE, 0 );
}
}
/**
** A boot option has been selected, disable the graphical elements on screen.
**/
void GUI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4)
{
// Turn off any GUI elements
if( bootArgs->Video.v_display == GRAPHICS_MODE )
if( useGUI )
{
gui.devicelist.draw = false;
gui.bootprompt.draw = false;
{
// Disable outputs, they will still show in the boot log.
replace_function("_printf", &GUI_verbose);
drawBootGraphics();
}
}
// initGUI() returned with an error, disabling GUI.
useGUI = false;
}
else
else if(useGUI)
{
replace_function("_initGraphicsMode", &GUI_initGraphicsMode);
replace_function("_getBootOptions", &GUI_getBootOptions);
replace_function("_printf", &GUI_printf);
replace_function("_verbose", &GUI_verbose);
replace_function("_error", &GUI_error);
replace_function("_stop", &GUI_stop);
replace_function("_stop", &GUI_stop);
setVideoMode( GRAPHICS_MODE, 0 );
drawBackground();
}
}
**/
void GUI_start()
{
// Hoot for the boot screen
//ExecKernel register_hook_callback("Kernel Start", &GUI_Kernel_Start_hook);
register_hook_callback("ExecKernel", &GUI_ExecKernel_hook);
register_hook_callback("PreBoot", &GUI_PreBoot_hook);
register_hook_callback("ModulesLoaded", &GUI_ModulesLoaded_hook);
branches/meklort/i386/modules/GUI/graphic_utils.c
312312
313313
314314
315
315
316316
317317
318318
unsigned short vesaVersion;
unsigned short mode = modeEndOfList;
getNumberArrayFromProperty( kGraphicsModeKey, params, 4);
mode = getVESAModeWithProperties( params[0], params[1], params[2],
branches/meklort/i386/modules/Resolution/915resolution.c
4040
4141
4242
43
44
43
4544
4645
4746
close_vbios(map);
}
}
}
}
branches/meklort/i386/util/dyldsymboltool.c
1717
1818
1919
20
20
2121
2222
2323
#define DYLIB_NAME "Symbols"
#define VOID_SYMBOL "dyld_void_start"
#define VOID_SYMBOL "_load_all_modules"
#define START_SYMBOL "start"
typedef struct symbols_dylib

Archive Download the corresponding diff file

Revision: 735