Index: branches/azimutz/Chazi/i386/libsaio/asm.s =================================================================== --- branches/azimutz/Chazi/i386/libsaio/asm.s (revision 839) +++ branches/azimutz/Chazi/i386/libsaio/asm.s (revision 840) @@ -339,7 +339,8 @@ jmp _halt // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// disableIRQs() - Azi: DHP (see boot.c/ExecKernel) +// disableIRQs() - Azi: DHP +// http://www.insanelymac.com/forum/index.php?s=&showtopic=255866&view=findpost&p=1677779 // // Port of original patch by: CPARM (who basically did this in boot.c) Thanks! // @@ -347,20 +348,20 @@ // must be disabled (that is, masked) when enabling the ACPI APIC operation // but this isn't done (apparently) on all mobo's and thus we do that here. // -//LABEL(_disableIRQs) +LABEL(_disableIRQs) -// push %eax // Saving register data + push %eax // Saving register data -// movb $0x80, %al // Block NMI -// outb %al, $0x70 + movb $0x80, %al // Block NMI + outb %al, $0x70 -// movb $0xff, %al // Load mask -// outb %al, $0x21 // Disable IRQ's 0-7 on Master PIC -// outb %al, $0xa1 // Disable IRQ's 8-15 on Slave PIC + movb $0xff, %al // Load mask + outb %al, $0x21 // Disable IRQ's 0-7 on Master PIC + outb %al, $0xa1 // Disable IRQ's 8-15 on Slave PIC -// popl %eax // Restore register data + popl %eax // Restore register data -// ret + ret #ifndef BOOT1 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -369,7 +370,7 @@ // Passes arg to the program in %eax. // LABEL(_startprog) -// call _disableIRQs // Taking care of a ACPI bug. (Azi: calling the above - disabled for now) + call _disableIRQs // Taking care of a ACPI bug. (Azi: calling the above) push %ebp mov %esp, %ebp Index: branches/azimutz/Chazi/i386/libsaio/bootstruct.c =================================================================== --- branches/azimutz/Chazi/i386/libsaio/bootstruct.c (revision 839) +++ branches/azimutz/Chazi/i386/libsaio/bootstruct.c (revision 840) @@ -40,9 +40,10 @@ Node *gMemoryMapNode; //Node *efiPlatformNode; //Azi: test -//static Azi: modules ?????????????????????? +//static Azi: modules ?? doesn't seem so. static char platformName[64]; +//Azi: bootargs - we can't retrive OS version at this point... void initKernBootStruct( void ) { Node *node; @@ -107,26 +108,26 @@ } - -/* Copy boot args after kernel and record address. */ - +//Azi: ... but here we can... (done) +/** Copy boot args after kernel and record address. */ void reserveKernBootStruct(void) { - if ((gMacOSVersion[0] == '1') && (gMacOSVersion[1] == '0') && (gMacOSVersion[2] == '.') && (gMacOSVersion[3] == '7')) + if (gMacOSVersion[3] <= '6') { + void *oldAddr = bootArgsPreLion; + bootArgsPreLion = (boot_args_pre_lion *)AllocateKernelMemory(sizeof(boot_args_pre_lion)); + bcopy(oldAddr, bootArgsPreLion, sizeof(boot_args_pre_lion)); + } + else { void *oldAddr = bootArgs; bootArgs = (boot_args *)AllocateKernelMemory(sizeof(boot_args)); bcopy(oldAddr, bootArgs, sizeof(boot_args)); } - else { - void *oldAddr = bootArgsPreLion; - bootArgsPreLion = (boot_args_pre_lion *)AllocateKernelMemory(sizeof(boot_args_pre_lion)); - bcopy(oldAddr, bootArgsPreLion, sizeof(boot_args_pre_lion)); - } } +//Azi: ... and here too. void finalizeBootStruct(void) { @@ -190,7 +191,7 @@ bootArgs->deviceTreeLength = size; // Copy BootArgs values to older structure - +//Azi: Ok, stuff that uses same naming for both bootargs versions... neat ;) memcpy(&bootArgsPreLion->CommandLine, &bootArgs->CommandLine, BOOT_LINE_LENGTH); memcpy(&bootArgsPreLion->Video, &bootArgs->Video, sizeof(Boot_Video)); Index: branches/azimutz/Chazi/i386/libsaio/bootstruct.h =================================================================== --- branches/azimutz/Chazi/i386/libsaio/bootstruct.h (revision 839) +++ branches/azimutz/Chazi/i386/libsaio/bootstruct.h (revision 840) @@ -28,11 +28,11 @@ //Azi: this is acting now as a mini libsaio.h :P //#include "libsaio.h" //#include "bios.h" +//#include "bootargs.h" - included on saio_types.h #include "libsa.h" #include "saio_types.h" #include "saio_internal.h" #include "device_tree.h" -#include "bootargs.h" /*! Kernel boot args global also used by booter for its own data. Index: branches/azimutz/Chazi/i386/libsaio/bootargs.h =================================================================== --- branches/azimutz/Chazi/i386/libsaio/bootargs.h (revision 839) +++ branches/azimutz/Chazi/i386/libsaio/bootargs.h (revision 840) @@ -188,6 +188,6 @@ } boot_args_pre_lion; -extern char gMacOSVersion[8]; +extern char gMacOSVersion[8]; // options.c #endif /* _PEXPERT_I386_BOOT_H */ Index: branches/azimutz/Chazi/i386/libsaio/bios.h =================================================================== --- branches/azimutz/Chazi/i386/libsaio/bios.h (revision 839) +++ branches/azimutz/Chazi/i386/libsaio/bios.h (revision 840) @@ -29,7 +29,7 @@ #ifndef __LIBSAIO_BIOS_H #define __LIBSAIO_BIOS_H -#include "bootargs.h" +//#include "bootargs.h" typedef union { unsigned int rx; Index: branches/azimutz/Chazi/i386/libsaio/stringTable.c =================================================================== --- branches/azimutz/Chazi/i386/libsaio/stringTable.c (revision 839) +++ branches/azimutz/Chazi/i386/libsaio/stringTable.c (revision 840) @@ -493,7 +493,7 @@ const char *overrideVal; int overrideSize; bool override, ret; - +//Azi: bootargs if (getValueForBootKey(bootArgs->CommandLine, key, val, size)) return true; @@ -666,7 +666,7 @@ // Take in account user overriding the override :P // Damn thing doesn't work anymore ?????? :-/ - if (getValueForKey(kAltConfigKey, &override_pathname, &len, config)) + if (getValueForKey(kAltConfigKey, &override_pathname, &len, config)) // config ?? { // Specify a path to a file, e.g. config=/Extra/test.plist strcpy(dirSpecBplist, override_pathname); @@ -693,7 +693,7 @@ // "/Extra/com.apple.Boot.plist" // "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" - // These i have no way to test, need advice. + //Azi: RESTORE THESE PATHS! // "/com.apple.boot.P/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" // "/com.apple.boot.R/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" // "/com.apple.boot.S/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" @@ -726,6 +726,7 @@ */ int loadHelperConfig(config_file_t *config) { + //Azi: UPDATE WITH MEK'S CODE! char *dirspec[] = { "/com.apple.boot.P/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", "/com.apple.boot.R/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", Index: branches/azimutz/Chazi/i386/libsaio/biosfn.c =================================================================== --- branches/azimutz/Chazi/i386/libsaio/biosfn.c (revision 839) +++ branches/azimutz/Chazi/i386/libsaio/biosfn.c (revision 840) @@ -782,7 +782,7 @@ } #endif - +//Azi: Advanced Power Management #ifdef APM_SUPPORT #define APM_INTNO 0x15 @@ -800,6 +800,7 @@ (bb.ebx.r.h == 'P') && (bb.ebx.r.l == 'M')) { /* Success */ +//Azi: apmConfig not on boot_args bootArgs->apmConfig.major_vers = bb.eax.r.h; bootArgs->apmConfig.minor_vers = bb.eax.r.l; bootArgs->apmConfig.flags.data = bb.ecx.rr; Index: branches/azimutz/Chazi/i386/libsaio/saio_types.h =================================================================== --- branches/azimutz/Chazi/i386/libsaio/saio_types.h (revision 839) +++ branches/azimutz/Chazi/i386/libsaio/saio_types.h (revision 840) @@ -31,6 +31,7 @@ #include "bios.h" #include "nbp_cmd.h" #include "bootargs.h" + //Azi: shouldn't this be on disk.c ?? #if DEBUG #define DEBUG_DISK(x) printf x Index: branches/azimutz/Chazi/i386/libsaio/fake_efi.c =================================================================== --- branches/azimutz/Chazi/i386/libsaio/fake_efi.c (revision 839) +++ branches/azimutz/Chazi/i386/libsaio/fake_efi.c (revision 840) @@ -262,6 +262,7 @@ // -------------------------------------------------------------------- // Finish filling in the rest of the boot args that we need. +//Azi: bootargs bootArgs->efiSystemTable = (uint32_t)efiSystemTable; bootArgs->efiMode = kBootArgsEfiMode32; @@ -371,6 +372,7 @@ // -------------------------------------------------------------------- // Finish filling in the rest of the boot args that we need. +//Azi: bootargs bootArgs->efiSystemTable = (uint32_t)efiSystemTable; bootArgs->efiMode = kBootArgsEfiMode64; Index: branches/azimutz/Chazi/i386/boot2/boot.c =================================================================== --- branches/azimutz/Chazi/i386/boot2/boot.c (revision 839) +++ branches/azimutz/Chazi/i386/boot2/boot.c (revision 840) @@ -102,10 +102,10 @@ /* * Default path to kernel cache file */ -// OS X 10.5 & 10.4 -#define kDefaultCachePath "/System/Library/Caches/com.apple.kernelcaches/kernelcache" +// OS X 10.4 & 10.5 +#define kCachePathTigerLeopard "/System/Library/Caches/com.apple.kernelcaches/kernelcache" // OS X 10.6 -#define kDefaultCachePathSnow "/System/Library/Caches/com.apple.kext.caches/Startup/kernelcache" +#define kCachePathSnowLion "/System/Library/Caches/com.apple.kext.caches/Startup/kernelcache" //========================================================================== // Zero the BSS. @@ -128,7 +128,7 @@ } //========================================================================== -//Initializes the runtime. Right now this means zeroing the BSS and initializing malloc. +//Initializes the runtime. Right now this means zeroing the BSS and initializing malloc. // void initialize_runtime(void) { @@ -149,7 +149,9 @@ int ret; bootArgs->kaddr = bootArgs->ksize = 0; - //Azi: here we get to know if we have a kernel or a prelinked kernel + execute_hook("ExecKernel", (void*)binary, NULL, NULL, NULL); + + //Azi: gHaveKernelCache is set here ret = DecodeKernel(binary, &kernelEntry, (char **) &bootArgs->kaddr, @@ -207,7 +209,6 @@ // we can't check the plist here if we have AutoResolution=n there and we anabled it // at boot prompt...????? // getBoolForKey(kAutoResolutionKey, &gAutoResolution, &bootInfo->bootConfig); - finishAutoRes(); //Azi: closing Vbios after "if (gVerboseMode)" stuff eliminates the need for setting @@ -219,7 +220,11 @@ // Notify modules that the kernel is about to be started // testing... - execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL); + + if (gMacOSVersion[3] <= '6') + execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgsPreLion, NULL, NULL); + else + execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL); // If we were in text mode, switch to graphics mode. // This will draw the boot graphics unless we are in @@ -233,16 +238,18 @@ setupBooterLog(); finalizeBootStruct(); - - // Jump to kernel's entry point. There's no going back now. -//Azi: Lion - http://netkas.org/?p=745 -// see asm.s - same stuff by DHP http://www.insanelymac.com/forum/index.php?s=&showtopic=255866&view=findpost&p=1677779 + +//Azi: see asm.s LABEL(_disableIRQs) // outb(0x21, 0xff); // outb(0xa1, 0xff); - startprog( kernelEntry, bootArgs ); + // Jump to kernel's entry point. There's no going back now. + if (gMacOSVersion[3] <= '6') + startprog( kernelEntry, bootArgsPreLion ); + else + startprog( kernelEntry, bootArgs ); + // Not reached - return 0; } @@ -328,6 +335,8 @@ loadPrebootRAMDisk(); // Load boot.plist config file + //Azi: on this first check, boot.plist acts as both "booter config file" + // and bootargs/options "carrier".***** status = loadSystemConfig(&bootInfo->bootConfig); if (getBoolForKey(kQuietBootKey, &quiet, &bootInfo->bootConfig) && quiet) { @@ -554,21 +563,28 @@ } //Azi:kernelcache stuff + bool patchKernel = false; + getBoolForKey(kKPatcherKey, &patchKernel, &bootInfo->bootConfig); //Azi: avoiding having to use -f to ignore kernel cache //Azi: ignore kernel cache but still use kext cache (E/E.mkext & S/L/E.mkext). - explain... - getBoolForKey(kIgnoreKCKey, &ignoreKC, &bootInfo->bootConfig); + getBoolForKey(kIgnoreKCKey, &ignoreKC, &bootInfo->bootConfig); // equivalent to UseKernelCache if (ignoreKC) { verbose("KC: cache ignored by user.\n"); - // make sure the damn thing get's cleaned, just in case... :)* + // make sure the damn thing get's zeroed, just in case... :)* bzero(gBootKernelCacheFile, sizeof(gBootKernelCacheFile)); } + else if (patchKernel) // to be moved..? + { + verbose("KC: kernel patcher enabled, ignore cache.\n"); + bzero(gBootKernelCacheFile, sizeof(gBootKernelCacheFile)); + } else if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) { strlcpy(gBootKernelCacheFile, val, len + 1); verbose("KC: path set by user = %s\n", gBootKernelCacheFile); //Azi: bypass time check when user sets path ??? - // cache is still ignored if time doesn't match... (e.g. usb stick) + // cache is still ignored if time doesn't match... (e.g. booter on usb stick) } else { @@ -581,7 +597,9 @@ const char *ProductName = getStringForKey("SMproductname", &bootInfo->smbiosConfig); sprintf(gCacheNameAdler, ProductName); // well, at least the smbios.plist can be loaded this early... // to set/get "ProductName" this early, booter needs complete rewrite!! + // see DHP's Revolution booter rework example! verbose("KC: gCacheNameAdler 1 = %s\n", gCacheNameAdler); + //Azi: check the validity of this, e.g. on Helper Partitions sprintf(gCacheNameAdler + 64, "%s", "\\System\\Library\\CoreServices\\boot.efi"); verbose("KC: gCacheNameAdler 2 = %s\n", gCacheNameAdler + 64); sprintf(gCacheNameAdler + (64 + 38), "%s", bootInfo->bootFile); @@ -590,16 +608,16 @@ // generate adler adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler)); verbose("KC: Adler32 = %08X\n", adler32); - +//Azi: no check for OS version here ?? - yes there is :) // append arch and/or adler (checksum) to kc path... - if (gMacOSVersion[3] < '6') // change to >= for Lion? + if (gMacOSVersion[3] <= '5') { - sprintf(gBootKernelCacheFile, "%s.%08lX", kDefaultCachePath, adler32); + sprintf(gBootKernelCacheFile, "%s.%08lX", kCachePathTigerLeopard, adler32); verbose("KC: adler added to path = %s\n", gBootKernelCacheFile); } else { - sprintf(gBootKernelCacheFile, "%s_%s.%08X", kDefaultCachePathSnow, + sprintf(gBootKernelCacheFile, "%s_%s.%08X", kCachePathSnowLion, (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64", adler32); verbose("KC: arch & adler added to path = %s\n", gBootKernelCacheFile); } @@ -741,9 +759,6 @@ else { // Won't return if successful. - // Notify modules that ExecKernel is about to be called - execute_hook("ExecKernel", binary, NULL, NULL, NULL); - ret = ExecKernel(binary); } } // while (1) Index: branches/azimutz/Chazi/i386/boot2/boot.h =================================================================== --- branches/azimutz/Chazi/i386/boot2/boot.h (revision 839) +++ branches/azimutz/Chazi/i386/boot2/boot.h (revision 840) @@ -100,8 +100,9 @@ // it's to be passed via "kernel Flags" ?? - "man com.apple.Boot.plist" #define kKernelNameKey "Kernel" // options.c getValFK - kFlag*** bFlag ? #define kKernelCacheKey "Kernel Cache" // boot.c getValFK - kFlag +#define kKernelFlagsKey "Kernel Flags" // options.c getValFK - kFlags*** #define kIgnoreKCKey "ignoreKC" // boot.c getBoolFK - testing*** -#define kKernelFlagsKey "Kernel Flags" // options.c getValFK - kFlags*** + #define kKPatcherKey "PatchKernel" // kernel_patcher.c getBoolFK #define kAltExtensionsKey "kext" // drivers.c getValFK #define kMKextCacheKey "MKext Cache" // options.c getValFK - kFlag @@ -187,7 +188,6 @@ extern bool gOverrideKernel; extern char *gPlatformName; // disabled ?? extern char gMKextName[]; -extern char gMacOSVersion[]; extern char gRootDevice[]; extern bool gEnableCDROMRescan; extern bool gScanSingleDrive; Index: branches/azimutz/Chazi/i386/boot2/modules.c =================================================================== --- branches/azimutz/Chazi/i386/boot2/modules.c (revision 839) +++ branches/azimutz/Chazi/i386/boot2/modules.c (revision 840) @@ -4,7 +4,7 @@ */ #ifndef DEBUG_MODULES -#define DEBUG_MODULES 1 +#define DEBUG_MODULES 0 #endif //#include "boot.h" @@ -340,6 +340,7 @@ } else { + //Azi: this is double printing when using kernelcache - that's new! verbose("Invalid mach magic 0x%X\n", ((struct mach_header*)binary)->magic); //getc(); return NULL; Index: branches/azimutz/Chazi/i386/boot2/options.c =================================================================== --- branches/azimutz/Chazi/i386/boot2/options.c (revision 839) +++ branches/azimutz/Chazi/i386/boot2/options.c (revision 840) @@ -41,7 +41,7 @@ //extern int menucount; //extern int gDeviceCount; //Azi: header -char gMacOSVersion[8]; //Azi: moved from boot.c ??? declared on boot.h as extern :-/ +char gMacOSVersion[8]; //Azi: moved from boot.c - extern on boot.h/bootargs.h static bool getOSVersion(char *str); // || int selectIndex = 0; @@ -164,7 +164,7 @@ } //========================================================================== - +//Azi: bootargs reminder static char gBootArgs[BOOT_STRING_LEN]; static char * gBootArgsPtr = gBootArgs; static char * gBootArgsEnd = gBootArgs + BOOT_STRING_LEN - 1; @@ -1213,7 +1213,7 @@ // Moved here to enable search for override Boot.plist on OS specific folders. // Find out which Mac OS version we're booting. - // make sure the damn thing get's cleaned, just in case... :)* + // make sure the damn thing get's zeroed, just in case... :)* bzero(gMacOSVersion, sizeof(gMacOSVersion)); // do this to argP ??... check it***** getOSVersion(gMacOSVersion); @@ -1373,7 +1373,7 @@ } strncpy(&argP[cnt], cp, userCnt); verbose("BootArgs = %s\n", argP); //Azi: checking... - argP[cnt+userCnt] = '\0'; + argP[cnt+userCnt] = '\0'; // shouldn't this null argP ?? see getOSVersion*** verbose("BootArgs check = %s\n", argP); // || if (!shouldboot) Index: branches/azimutz/Chazi/i386/modules/Makefile =================================================================== --- branches/azimutz/Chazi/i386/modules/Makefile (revision 839) +++ branches/azimutz/Chazi/i386/modules/Makefile (revision 840) @@ -1,19 +1,22 @@ # Makefile for i386 modules # The order of building is important. -SUBDIRS = klibc uClibc++ GraphicsEnablerLegacy KernelPatcher HPET +SUBDIRS = klibc uClibc++ GraphicsEnablerLegacy KernelPatcher Memory HPET #SUBDIRS = HelloWorld # - - Resolution (only tested on Meklort's branch, never did any good for my resolution; # conflicts with AutoResolution) # - - GraphicsEnabler (no support for ATI legacy cards, e.g. 1000 series) +# testing = http://www.insanelymac.com/forum/index.php?s=&showtopic=231075&view=findpost&p=1683785 # - - Memory ("Attempting to execute hook ScanMemory" # Divide by 0 # "This is a non recoverable error! System HALTED!!!") -# (Based on previous tests whith Meklort's branch; here just instant reboots. XCode 4 specific) +# (Based on previous tests whith Meklort's branch; here just instant reboots. XCode 4 SPECIFIC!!) +# - - KernelPatcher (hangs right after loading the kernel. XCode 4 SPECIFIC!!) + CFLAGS= -O $(MORECPP) -arch i386 -g -static DEFINES= CONFIG = hd Property changes on: branches/azimutz/Chazi ___________________________________________________________________ Modified: svn:ignore - obj sym build revision + obj sym revision build