Index: branches/azimutz/Chazileon/doc/BootHelp.txt =================================================================== --- branches/azimutz/Chazileon/doc/BootHelp.txt (revision 352) +++ branches/azimutz/Chazileon/doc/BootHelp.txt (revision 353) @@ -1,6 +1,5 @@ TODO: - add TAB, change between textmode/gui?? -- add arch & -legacy - add ramdisk stuff The boot: prompt waits for you to type advanced startup options. @@ -19,8 +18,10 @@ kernel: kernel name (e.g. "mach_kernel" - must be in "/" ) - flags: -v (verbose) -s (single user mode), - -x (safe mode) -F (ignore boot configuration file) + flags: -v (verbose) -s (single user mode), + -x (safe mode) -F (ignore boot configuration file) + 32 (i386 arch) -legacy (no 64 bit apps - kernel flag) + 64 (x86_64 arch) "Graphics Mode"="WIDTHxHEIGHTxDEPTH" (e.g. "1024x768x32") Index: branches/azimutz/Chazileon/i386/libsaio/acpi_patcher.c =================================================================== --- branches/azimutz/Chazileon/i386/libsaio/acpi_patcher.c (revision 352) +++ branches/azimutz/Chazileon/i386/libsaio/acpi_patcher.c (revision 353) @@ -94,43 +94,43 @@ /** The following ACPI Table search algo, should be reused anywhere needed: */ int search_and_get_acpi_fd(const char * filename, const char ** outDirspec) //Azi:searchalgo { - char dirSpecExtraDsdt[128] = ""; //Azi:alloc - was 512 - const char *override_pathfile = NULL; + char dirSpecDSDT[128] = ""; //Azi:alloc - was 512 + const char *override_pathname = NULL; int len = 0, fd = 0; extern char gMacOSVersion; // Take in account user overriding - if (getValueForKey(kDSDTKey, &override_pathfile, &len, &bootInfo->bootConfig)) + if (getValueForKey(kDSDTKey, &override_pathname, &len, &bootInfo->bootConfig)) { // Specify a path to a file, e.g. /Extra/test.aml - sprintf(dirSpecExtraDsdt, override_pathfile); - fd = open(dirSpecExtraDsdt, 0); + sprintf(dirSpecDSDT, override_pathname); + fd = open(dirSpecDSDT, 0); if (fd >= 0) goto success_fd; } // Check drivers.c, LoadDrivers, for more comments on these. - sprintf(dirSpecExtraDsdt, "rd(0,0)/%s", filename); - fd = open(dirSpecExtraDsdt, 0); + sprintf(dirSpecDSDT, "rd(0,0)/%s", filename); + fd = open(dirSpecDSDT, 0); if (fd >= 0) goto success_fd; - sprintf(dirSpecExtraDsdt, "bt(0,0)/Extra/%s/%s", &gMacOSVersion, filename); - fd = open(dirSpecExtraDsdt, 0); + sprintf(dirSpecDSDT, "bt(0,0)/Extra/%s/%s", &gMacOSVersion, filename); + fd = open(dirSpecDSDT, 0); if (fd >= 0) goto success_fd; // Removed /Extra path from search algo. If needed can be specified on override key! - sprintf(dirSpecExtraDsdt, "bt(0,0)/Extra/%s", filename); - fd = open(dirSpecExtraDsdt, 0); + sprintf(dirSpecDSDT, "bt(0,0)/Extra/%s", filename); + fd = open(dirSpecDSDT, 0); if (fd >= 0) goto success_fd; // Add helper partitions?? // Azi: ok, one gone.. let's kill this one too? // All "config" files go in Extra! -/* sprintf(dirspec, "/%s", filename); // search root - fd=open (dirspec,0); - if (fd>=0) goto success_fd;*/ + //sprintf(dirspec, "/%s", filename); // search root + //fd=open (dirspec,0); + //if (fd>=0) goto success_fd; // NOT FOUND: //Azi: handling this only on pci_root.c, getPciRootUID() (it's enough to check if .aml file exists), @@ -141,14 +141,14 @@ return -1; // FOUND success_fd: - if (outDirspec) *outDirspec = dirSpecExtraDsdt; + if (outDirspec) *outDirspec = dirSpecDSDT; return fd; } void *loadACPITable (const char * filename) //Azi: called on setupAcpi() { void *tableAddr; - const char * dsdt_filename = NULL; //Azi: = dirSpecExtraDsdt + const char * dsdt_filename = NULL; //Azi: = dirSpecDSDT //Azi:dsdt - call 2; call 1 on pci_root.c (getPciRootUID), changed dirspec to dsdt_filename according (review this!!!). int fd = search_and_get_acpi_fd(filename, &dsdt_filename); @@ -353,7 +353,7 @@ } struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt* dsdt) -{ +{ char ssdt_header[] = { 0x53, 0x53, 0x44, 0x54, 0x7E, 0x00, 0x00, 0x00, /* SSDT.... */ @@ -508,9 +508,10 @@ } } break; case CPU_MODEL_FIELDS: - case CPU_MODEL_NEHALEM: case CPU_MODEL_DALES: case CPU_MODEL_DALES_32NM: + case CPU_MODEL_NEHALEM: + case CPU_MODEL_NEHALEM_EX: case CPU_MODEL_WESTMERE: case CPU_MODEL_WESTMERE_EX: default: Index: branches/azimutz/Chazileon/i386/libsaio/pci_root.c =================================================================== --- branches/azimutz/Chazileon/i386/libsaio/pci_root.c (revision 352) +++ branches/azimutz/Chazileon/i386/libsaio/pci_root.c (revision 353) @@ -57,7 +57,7 @@ if (rootuid < 10) return rootuid; // If user supplied a key... - if (getValueForKey(kPciRootKey, &val, &len, &bootInfo->bootConfig)) + if (getValueForKey(kPCIRootUIDKey, &val, &len, &bootInfo->bootConfig)) { if (isdigit(val[0])) rootuid = val[0] - '0'; @@ -110,7 +110,7 @@ rootuid = 0; // ... default uid to 0. } else - printf("Found UID value on user supplied ACPI Table...\n"); + printf("Found UID value on ACPI Table provided by user...\n"); out: verbose("Using PCI-Root-UID value: %d\n", rootuid); out_out: Index: branches/azimutz/Chazileon/i386/libsaio/nvidia.c =================================================================== --- branches/azimutz/Chazileon/i386/libsaio/nvidia.c (revision 352) +++ branches/azimutz/Chazileon/i386/libsaio/nvidia.c (revision 353) @@ -663,20 +663,43 @@ return 0; } +unsigned long long mem_detect(volatile uint8_t *regs, uint8_t nvCardType, pci_dt_t *nvda_dev) +{ + unsigned long long vram_size = 0; + + if (nvCardType < NV_ARCH_50) { + vram_size = REG32(NV04_PFB_FIFO_DATA); + vram_size &= NV10_PFB_FIFO_DATA_RAM_AMOUNT_MB_MASK; + } + else if (nvCardType >= NV_ARCH_C0) { + vram_size = REG32(NVC0_MEM_CTRLR_COUNT); + vram_size *= REG32(NVC0_MEM_CTRLR_RAM_AMOUNT); + vram_size <<= 20; + } + else { + vram_size = REG32(NV04_PFB_FIFO_DATA); + vram_size |= (vram_size & 0xff) << 32; + vram_size &= 0xffffffff00ll; + } + + return vram_size; +} + bool setup_nvidia_devprop(pci_dt_t *nvda_dev) { struct DevPropDevice *device; - char *devicepath; + char *devicepath; struct pci_rom_pci_header_t *rom_pci_header; - volatile uint8_t *regs; + volatile uint8_t *regs; uint8_t *rom; uint8_t *nvRom; - uint32_t videoRam; + uint8_t nvCardType; + unsigned long long videoRam; uint32_t nvBiosOveride; uint32_t bar[7]; uint32_t boot_display; - int nvPatch; - int len; + int nvPatch; + int len; char biosVersion[32]; char nvFilename[32]; char kNVCAP[12]; @@ -687,31 +710,20 @@ devicepath = get_pci_dev_path(nvda_dev); bar[0] = pci_config_read32(nvda_dev->dev.addr, 0x10 ); regs = (uint8_t *) (bar[0] & ~0x0f); + + delay(50); + + // get card type + nvCardType = (REG32(0) >> 20) & 0x1ff; // Amount of VRAM in kilobytes - videoRam = (REG32(0x10020c) & 0xfff00000) >> 10; + videoRam = mem_detect(regs, nvCardType, nvda_dev); model = get_nvidia_model((nvda_dev->vendor_id << 16) | nvda_dev->device_id); - - // FIXME: dirty fermi hack - if((nvda_dev->device_id & 0xFFE0) == 0x06C0 || - (nvda_dev->device_id & 0xFFE0) == 0x0E20) { - switch (nvda_dev->device_id) { - case 0x06C0: videoRam = 1572864; break; // gtx 480 - case 0x06CD: videoRam = 1310720; break; // gtx 470 - case 0x06C4: videoRam = 1048576; break; // gtx 465 - case 0x06CA: videoRam = 2097152; break; // gtx 480m - case 0x0E22: videoRam = 1048576; break; // gtx 460 - case 0x0E24: videoRam = 1048576; break; // gtx 460 - case 0x06D1: videoRam = 3145728; break; // tesla c2050/c2070 - case 0x06DE: videoRam = 3145728; break; // tesla m2050/m2070 - default: break; - } - } verbose("nVidia %s %dMB NV%02x [%04x:%04x] :: %s\n", - model, (videoRam / 1024), - (REG32(0) >> 20) & 0x1ff, nvda_dev->vendor_id, nvda_dev->device_id, - devicepath); + model, (uint32_t)(videoRam / 1024 / 1024), + (REG32(0) >> 20) & 0x1ff, nvda_dev->vendor_id, nvda_dev->device_id, + devicepath); rom = malloc(NVIDIA_ROM_SIZE); sprintf(nvFilename, "/Extra/%04x_%04x.rom", (uint16_t)nvda_dev->vendor_id, (uint16_t)nvda_dev->device_id); @@ -797,10 +809,41 @@ uint8_t built_in = 0x01; devprop_add_value(device, "@0,built-in", &built_in, 1); } + + // get bios version + const int MAX_BIOS_VERSION_LENGTH = 32; + char* version_str = (char*)malloc(MAX_BIOS_VERSION_LENGTH); + memset(version_str, 0, MAX_BIOS_VERSION_LENGTH); + int i, version_start; + int crlf_count = 0; + // only search the first 384 bytes + for(i = 0; i < 0x180; i++) { + if(rom[i] == 0x0D && rom[i+1] == 0x0A) { + crlf_count++; + // second 0x0D0A was found, extract bios version + if(crlf_count == 2) { + if(rom[i-1] == 0x20) i--; // strip last " " + for(version_start = i; version_start > (i-MAX_BIOS_VERSION_LENGTH); version_start--) { + // find start + if(rom[version_start] == 0x00) { + version_start++; + + // strip "Version " + if(strncmp((const char*)rom+version_start, "Version ", 8) == 0) { + version_start += 8; + } + + strncpy(version_str, (const char*)rom+version_start, i-version_start); + break; + } + } + break; + } + } + } + + sprintf(biosVersion, "%s", (nvBiosOveride > 0) ? nvFilename : version_str); - videoRam *= 1024; - sprintf(biosVersion, "xx.xx.xx - %s", (nvBiosOveride > 0) ? nvFilename : "internal"); - sprintf(kNVCAP, "NVCAP_%04x", nvda_dev->device_id); if (getValueForKey(kNVCAP, &value, &len, &bootInfo->bootConfig) && len == NVCAP_LEN * 2) { uint8_t new_NVCAP[NVCAP_LEN]; Index: branches/azimutz/Chazileon/i386/libsaio/nvidia.h =================================================================== --- branches/azimutz/Chazileon/i386/libsaio/nvidia.h (revision 352) +++ branches/azimutz/Chazileon/i386/libsaio/nvidia.h (revision 353) @@ -67,10 +67,15 @@ uint8_t size; /* Size in multiples of 512 */ }; -#define NV_PROM_OFFSET 0x300000 -#define NV_PROM_SIZE 0x0000ffff -#define NV_PRAMIN_OFFSET 0x00700000 -#define NV_PRAMIN_SIZE 0x00100000 +#define NV_PROM_OFFSET 0x300000 +#define NV_PROM_SIZE 0x0000ffff +#define NV_PRAMIN_OFFSET 0x00700000 +#define NV_PRAMIN_SIZE 0x00100000 +#define NV04_PFB_FIFO_DATA 0x0010020c +#define NV10_PFB_FIFO_DATA_RAM_AMOUNT_MB_MASK 0xfff00000 +#define NV10_PFB_FIFO_DATA_RAM_AMOUNT_MB_SHIFT 20 +#define NVC0_MEM_CTRLR_COUNT 0x00121c74 +#define NVC0_MEM_CTRLR_RAM_AMOUNT 0x0010f20c #define NV_PBUS_PCI_NV_20 0x00001850 #define NV_PBUS_PCI_NV_20_ROM_SHADOW_DISABLED (0 << 0) @@ -87,6 +92,7 @@ #define NV_ARCH_30 0x30 #define NV_ARCH_40 0x40 #define NV_ARCH_50 0x50 +#define NV_ARCH_C0 0xC0 #define CHIPSET_NV03 0x0010 #define CHIPSET_NV04 0x0020 Index: branches/azimutz/Chazileon/i386/libsaio/stringTable.c =================================================================== --- branches/azimutz/Chazileon/i386/libsaio/stringTable.c (revision 352) +++ branches/azimutz/Chazileon/i386/libsaio/stringTable.c (revision 353) @@ -659,7 +659,7 @@ char dirSpecExtraBplist[128] = ""; //Azi:alloc const char *override_pathfile = NULL; const char *filename = "com.apple.Boot.plist"; - int fd, count, ret, len = 0/*???*/; + int count, ret, fd, len = 0; extern char gMacOSVersion; //Azi: This Override stuff messed with my mind a lot of times; was totally unaware of it. Payback time!! :) @@ -671,7 +671,7 @@ // Keys that are not present on the default Boot.plist will be used with existing ones. // Take in account user overriding the override :P - if (getValueForKey(kTestConfigFileKey, &override_pathfile, &len, &bootInfo->bootConfig)) + if (getValueForKey(kTestConfigKey, &override_pathfile, &len, &bootInfo->bootConfig)) { // Specify a path to a file, e.g. /Extra/test.plist strcpy(dirSpecExtraBplist, override_pathfile); Index: branches/azimutz/Chazileon/i386/boot2/boot.c =================================================================== --- branches/azimutz/Chazileon/i386/boot2/boot.c (revision 352) +++ branches/azimutz/Chazileon/i386/boot2/boot.c (revision 353) @@ -380,10 +380,10 @@ } //Azi:autoresolution end - if (useGUI) + if (useGUI && initGUI()) { - /* XXX AsereBLN handle error */ - initGUI(); + // initGUI() returned with an error, disabling GUI. + useGUI = false; } setBootGlobals(bvChain); @@ -413,18 +413,19 @@ firstRun = false; if ( status == -1 ) continue; - //Azi:sysversion related test + //Azi:sysversion related test if( bootArgs->Video.v_display == GRAPHICS_MODE ) { - drawBackground(); //Azi: just seems repeated and less complete than the next!? though to the eye, - updateVRAM(); //the next seems to do exactly the same??! testing + gui.devicelist.draw = false; // Needed for when the verbose flips the screen. + drawBackground(); + updateVRAM(); } // Turn off any GUI elements /*if ( bootArgs->Video.v_display == GRAPHICS_MODE ) { - gui.devicelist.draw = false; // doesn't seem needed - gui.bootprompt.draw = false; // same as above + gui.devicelist.draw = false; + gui.bootprompt.draw = false; // doesn't seem needed gui.menu.draw = false; // same as above gui.infobox.draw = false; // Enter doesn't work with this drawn so... drawBackground(); @@ -527,22 +528,23 @@ // Can't be called only from here! Need advice. Check above. //loadOverrideConfig(&bootInfo->overrideConfig); // call 2 - // If cpu does not understand 64 bit instructions,... - if ( !platformCPUFeature(CPU_FEATURE_EM64T) || - // ... user forced i386 kernel architecture on cpu with em64t... + //Azi: default to x86_64 arch + // If cpu doesn't handle 64 bit instructions,... + if (!platformCPUFeature(CPU_FEATURE_EM64T) || + // ... user forced i386 kernel architecture on cpu with "em64t"... getValueForKey(kArchI386Flag, &val, &len, &bootInfo->bootConfig) || - // ... or forced Legacy Mode... (not needed!) - getValueForKey(kLegacyModeFlag, &val, &len, &bootInfo->bootConfig) ) + // ... or forced Legacy Mode... (not needed! but handy for some processors/situations) + getValueForKey(kLegacyModeFlag, &val, &len, &bootInfo->bootConfig)) { - // ... use i386 kernel arch! + // ... use i386 kernel arch. archCpuType = CPU_TYPE_I386; } else { - // Else use x86_64 kernel arch! + // Else use x86_64 kernel arch. archCpuType = CPU_TYPE_X86_64; } - // Force x86_64 kernel arch if i386/-legacy are flagged on Boot.plist. + // Override i386/-legacy, if flagged on Boot.plist. if (getValueForKey(kArchX86_64Flag, &val, &len, &bootInfo->bootConfig)) { archCpuType = CPU_TYPE_X86_64; Index: branches/azimutz/Chazileon/i386/boot2/boot.h =================================================================== --- branches/azimutz/Chazileon/i386/boot2/boot.h (revision 352) +++ branches/azimutz/Chazileon/i386/boot2/boot.h (revision 353) @@ -116,7 +116,7 @@ // Common: firstrun or secondrun #define kWaitForKeypressKey "Wait" // * boot.c, getBollFK turn this into flag? -#define kTestConfigFileKey "config" // # stringTable.c, getValFK +#define kTestConfigKey "config" // # stringTable.c, getValFK #define kKernelNameKey "Kernel" // * options.c, getValFK, override default name; at boot prompt typing the name is enough. #define kKernelCacheKey "Kernel Cache" // boot.c, getValFK test this #define kKernelFlagsKey "Kernel Flags" // * options.c, getValFK @@ -137,7 +137,7 @@ #define kWakeKey "Wake" // * boot.c, getBollFK firstrun? #define kForceWakeKey "ForceWake" // * boot.c, getBollFK firstrun? #define kWakeImageKey "WakeImage" // * boot.c, getValFK firstrun? -#define kPciRootKey "PciRoot" // * pci_root.c, getValFK, +#define kPCIRootUIDKey "PciRoot" // * pci_root.c, getValFK, #define kUseAtiROMKey "UseAtiROM" // # ati.c, getBollFK firstrun? #define kUseNvidiaROMKey "UseNvidiaROM" // # nvidia.c, getBollFK firstrun? #define kVBIOSKey "VBIOS" // nvidia.c, getBollFK firstrun? Index: branches/azimutz/Chazileon/i386/boot2/drivers.c =================================================================== --- branches/azimutz/Chazileon/i386/boot2/drivers.c (revision 352) +++ branches/azimutz/Chazileon/i386/boot2/drivers.c (revision 353) @@ -186,7 +186,7 @@ else if ( gBootFileType == kBlockDeviceType ) { // Take in account user overriding. - if (getValueForKey( kExtensionsKey, &override_pathfolder, &len, &bootInfo->bootConfig )) + if (getValueForKey(kExtensionsKey, &override_pathfolder, &len, &bootInfo->bootConfig)) { // Specify a path to a folder ending with /, e.g. /Extra/testkext/ strcpy(dirSpecExtra, override_pathfolder);