Index: branches/blackosx/doc/BootHelp.txt =================================================================== --- branches/blackosx/doc/BootHelp.txt (revision 214) +++ branches/blackosx/doc/BootHelp.txt (revision 215) @@ -47,7 +47,8 @@ "Instant Menu"=Yes Force displaying the partition selection menu. "Default Partition" Sets the default boot partition, - =hd(x,y) where 'x' & 'y' are the disk and partition numbers. + =hd(x,y)| where 'x' & 'y' are the disk and partition numbers + = or specify the selected volume UUID string. "Hide Partition" Remove unwanted partition(s) from the boot menu. =hd(x,y) [hd(m,n)] only non mac osx boot partitions can be hidden. @@ -70,9 +71,11 @@ EthernetBuiltIn=Yes|No Automatic "built-in"=yes device-properties generation for ethernet interfaces. - USBBusFix=Yes Enable the EHCI and UHCI fixes (disabled by default). + USBBusFix=Yes Enable all USB fixes below: EHCIacquire=Yes Enable the EHCI fix (disabled by default). UHCIreset=Yes Enable the UHCI fix (disabled by default). + USBLegacyOff=Yes Enable the USB Legacy fix (disabled by default). + ForceHPET=Yes|No Force Enable HPET. Wake=No Disable wake up after hibernation (default: enabled). Index: branches/blackosx/version =================================================================== --- branches/blackosx/version (revision 214) +++ branches/blackosx/version (revision 215) @@ -1 +1 @@ -2.0-RC5 (blackosx_GUI_editv2) \ No newline at end of file +2.0-RC5 (blackosx_GUI_edit_v3) \ No newline at end of file Index: branches/blackosx/CHANGES =================================================================== --- branches/blackosx/CHANGES (revision 214) +++ branches/blackosx/CHANGES (revision 215) @@ -1,7 +1,9 @@ -- Revised the rollover theme functionality as it was drawing both the normal device image as well as the rollover image. -- Added Conti's fix for overcoming a potential fail with deadbeef error due to a non standard specified resolution, or in my case of testing - on an empty value for the screen_width / screen_height in a theme.plist. -- Added rollover theme functionality while retaining compatibility with existing themes. Note: Compiling with an embedded theme currently fails as I haven't added _o.pngs in to artwork folder. But then if I do, the filesize will exceed the limit. - +- Optimized memory detection speed +- Added displaying source device and partition number for file read operations. +- Increased boot2's maximum size from 383.5k to 447.5k. + Updated stage 1 loaders for handling the new size limit. +- Added alternate format for setting the default partition. The user can specify the selected + volume UUID for the "Default Partition" key. - Implemented SPD memory automatic detection and injection,seems to work really great ... - Factorized code to prepare a dynamic memory detection algorithm ... - Optimized smbios table address search Index: branches/blackosx/artwork/themes/default/device_fat32.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/device_fat16.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/device_ext3.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/menu_single_user.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/device_hfsplus.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/menu_ignore_caches_disabled.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/device_selection.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/menu_ignore_caches.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/menu_verbose_disabled.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/device_cdrom.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/device_ntfs.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/menu_verbose.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/menu_single_user_disabled.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/artwork/themes/default/device_generic.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/blackosx/i386/libsaio/hfs.c =================================================================== --- branches/blackosx/i386/libsaio/hfs.c (revision 214) +++ branches/blackosx/i386/libsaio/hfs.c (revision 215) @@ -264,10 +264,11 @@ long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length) { char entry[512]; + char devStr[12]; long dirID, result, flags; if (HFSInitPartition(ih) == -1) return -1; - + dirID = kHFSRootFolderID; // Skip a lead '\'. Start in the system folder if there are two. if (filePath[0] == '/') { @@ -298,8 +299,9 @@ return -1; } - verbose("Loaded HFS%s file: [%s] %d bytes from %x.\n", - (gIsHFSPlus ? "+" : ""), filePath, (uint32_t)length, ih); + getDeviceStringFromBVR(ih, devStr); + verbose("Read HFS%s file: [%s/%s] %d bytes.\n", + (gIsHFSPlus ? "+" : ""), devStr, filePath, (uint32_t)length); return length; } Index: branches/blackosx/i386/libsaio/spd.c =================================================================== --- branches/blackosx/i386/libsaio/spd.c (revision 214) +++ branches/blackosx/i386/libsaio/spd.c (revision 215) @@ -1,6 +1,9 @@ /* * spd.c - serial presence detect memory information - * (restored from pcefi10.5) + * + * Originally restored from pcefi10.5 + * Dynamic mem detection original impl. by Rekursor + * System profiler fix and other fixes by Mozodojo. */ #include "libsaio.h" @@ -85,35 +88,64 @@ while (!( inb(base + SMBHSTSTS) & 0x02)) // wait til command finished { rdtsc(l2, h2); - t = ((h2 - h1) * 0xffffffff + (l2 - l1)) / (Platform.CPU.TSCFrequency / 40); - if (t > 10) - break; // break after 10ms + t = ((h2 - h1) * 0xffffffff + (l2 - l1)) / (Platform.CPU.TSCFrequency / 100); + if (t > 5) + break; // break after 5ms } return inb(base + SMBHSTDAT); } +/* SPD i2c read optimization: prefetch only what we need, read non prefetcheable bytes on the fly */ +#define READ_SPD(spd, base, slot, x) spd[x] = smb_read_byte_intel(base, 0x50 + slot, x) + +int spd_indexes[] = { + SPD_MEMORY_TYPE, + SPD_DDR3_MEMORY_BANK, + SPD_DDR3_MEMORY_CODE, + SPD_NUM_ROWS, + SPD_NUM_COLUMNS, + SPD_NUM_DIMM_BANKS, + SPD_NUM_BANKS_PER_SDRAM, + 4,7,8,9,12,64, /* TODO: give names to these values */ + 95,96,97,98, 122,123,124,125 /* UIS */ +}; +#define SPD_INDEXES_SIZE (sizeof(spd_indexes) / sizeof(int)) + +/** Read from spd *used* values only*/ +static void init_spd(char * spd, uint32_t base, int slot) +{ + int i; + for (i=0; i< SPD_INDEXES_SIZE; i++) { + READ_SPD(spd, base, slot, spd_indexes[i]); + } +} + /** Get Vendor Name from spd, 2 cases handled DDR3 and DDR2, have different formats, always return a valid ptr.*/ -const char * getVendorName(RamSlotInfo_t* slot) +const char * getVendorName(RamSlotInfo_t* slot, uint32_t base, int slot_num) { uint8_t bank = 0; uint8_t code = 0; int i = 0; - const char * spd = slot->spd; + char * spd = slot->spd; if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) { // DDR3 - bank = spd[0x75]; - code = spd[0x76]; + bank = spd[SPD_DDR3_MEMORY_BANK]; + code = spd[SPD_DDR3_MEMORY_CODE]; for (i=0; i < VEN_MAP_SIZE; i++) if (bank==vendorMap[i].bank && code==vendorMap[i].code) return vendorMap[i].name; } else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2) { - if(spd[0x40]==0x7f) { - for (i=0x40; i<0x48 && spd[i]==0x7f;i++) bank++; + if(spd[64]==0x7f) { + for (i=64; i<72 && spd[i]==0x7f;i++) { + bank++; + READ_SPD(spd, base, slot_num,i+1); // prefetch next spd byte to read for next loop + } + READ_SPD(spd, base, slot_num,i); code = spd[i]; } else { - code = spd[0x40]; + code = spd[64]; bank = 0; } for (i=0; i < VEN_MAP_SIZE; i++) @@ -175,44 +207,47 @@ } if (!ret) sprintf(asciiSerial, "10000000%d", serialnum++); - else sprintf(asciiSerial, "%d", ret); + else sprintf(asciiSerial, "%X", ret); - return asciiSerial; + return strdup(asciiSerial); } /** Get DDR3 or DDR2 Part Number, always return a valid ptr */ -const char * getDDRPartNum(const char* spd) +const char * getDDRPartNum(char* spd, uint32_t base, int slot) { - const char * sPart = NULL; - int i; - bool bZero = false; + static char asciiPartNo[32]; + int i, start=0, index = 0; - if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) - sPart = &spd[128]; - else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2) - sPart = &spd[73]; - if (sPart) { // Check that the spd part name is zero terminated and that it is ascii: - for (i=0; i<32; i++) { - if (sPart[i]==0) { - bZero = true; - break; - } - else if ( !isascii(sPart[i]) ) { - sPart = NULL; - break; - } - } - } - return ( sPart==NULL || !(*sPart) || !bZero ) ? - "N/A" : sPart; + if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) { + start = 128; + } + else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2) { + start = 73; + } + + // Check that the spd part name is zero terminated and that it is ascii: + bzero(asciiPartNo, 32); + char c; + for (i=start; ispd = malloc(spd_size); - if (slot->spd == NULL) continue; + slot->spd = spdbuf; slot->InUse = true; bzero(slot->spd, spd_size); // Copy spd data into buffer - for (x = 0; x < spd_size; x++) - slot->spd[x] = smb_read_byte_intel(base, 0x50 + i, x); + //for (x = 0; x < spd_size; x++) slot->spd[x] = smb_read_byte_intel(base, 0x50 + i, x); + init_spd(slot->spd, base, i); + switch (slot->spd[SPD_MEMORY_TYPE]) { case SPD_MEMORY_TYPE_SDRAM_DDR2: @@ -260,15 +296,14 @@ spd_type = (slot->spd[SPD_MEMORY_TYPE] < ((char) 12) ? slot->spd[SPD_MEMORY_TYPE] : 0); slot->Type = spd_mem_to_smbios[spd_type]; - slot->PartNo = strdup(getDDRPartNum(slot->spd) ); - slot->Vendor = strdup(getVendorName(slot) ); - slot->SerialNo = strdup(getDDRSerial(slot->spd)); + slot->PartNo = getDDRPartNum(slot->spd, base, i); + slot->Vendor = getVendorName(slot, base, i); + slot->SerialNo = getDDRSerial(slot->spd); // determine spd speed speed = getDDRspeedMhz(slot->spd); - if (speed > slot->Frequency) slot->Frequency = speed; // just in case dmi wins on spd - if(dump) { - printf("Slot %d Type %d %dMB (%s) %dMHz Vendor=%s, PartNo=%s SerialNo=%s\n", + if (slot->FrequencyFrequency = speed; // should test the mem controller to get potential overclocking info ? + printf("Slot: %d Type %d %dMB (%s) %dMHz Vendor=%s\n PartNo=%s SerialNo=%s\n", i, (int)slot->Type, slot->ModuleSize, @@ -277,7 +312,8 @@ slot->Vendor, slot->PartNo, slot->SerialNo); - dumpPhysAddr("spd content: ",slot->spd, spd_size); + if(DEBUG_SPD) { + dumpPhysAddr("spd content: ",slot->spd, spd_size); getc(); } } @@ -287,10 +323,7 @@ i>0 && Platform.RAM.DIMM[1].InUse==false && fullBanks && Platform.DMI.MaxMemorySlots==2 ? mapping[i] : i; // for laptops case, mapping setup would need to be more generic than this - if (slot->spd) { - free(slot->spd); - slot->spd = NULL; - } + slot->spd = NULL; } // for } @@ -320,7 +353,7 @@ int i; while (current) { -#if DEBUG_SPD +#if 0 printf("%02x:%02x.%x [%04x] [%04x:%04x] :: %s\n", current->dev.bits.bus, current->dev.bits.dev, current->dev.bits.func, current->class_id, current->vendor_id, current->device_id, @@ -343,5 +376,7 @@ void scan_spd(PlatformInfo_t *p) { + printf("\n--> Start of mem detect:\n"); find_and_read_smbus_controller(root_pci_dev); + printf("\n<-- End of mem detect.\n"); } Index: branches/blackosx/i386/libsaio/spd.h =================================================================== --- branches/blackosx/i386/libsaio/spd.h (revision 214) +++ branches/blackosx/i386/libsaio/spd.h (revision 215) @@ -94,6 +94,8 @@ #define SPD_MANUFACTURER_SPECIFIC_DATA 99 /* Manufacturer specific data (bytes 99-125) */ #define SPD_INTEL_SPEC_FOR_FREQUENCY 126 /* Intel specification for frequency */ #define SPD_INTEL_SPEC_100_MHZ 127 /* Intel specification details for 100MHz support */ +#define SPD_DDR3_MEMORY_BANK 0x75 +#define SPD_DDR3_MEMORY_CODE 0x76 /* DRAM specifications use the following naming conventions for SPD locations */ #define SPD_tRP SPD_MIN_ROW_PRECHARGE_TIME Index: branches/blackosx/i386/libsaio/Makefile =================================================================== --- branches/blackosx/i386/libsaio/Makefile (revision 214) +++ branches/blackosx/i386/libsaio/Makefile (revision 215) @@ -39,11 +39,11 @@ ufs.o ufs_byteorder.o \ vbe.o nbp.o hfs.o hfs_compare.o \ xml.o ntfs.o msdos.o md5c.o device_tree.o \ - cpu.o platform.o dsdt_patcher.o \ + cpu.o platform.o acpi_patcher.o \ smbios_patcher.o fake_efi.o ext2fs.o \ hpet.o spd.o usb.o pci_setup.o \ device_inject.o nvidia.o ati.o pci_root.o \ - convert.o mem.o + convert.o mem.o aml_generator.o SAIO_EXTERN_OBJS = console.o Index: branches/blackosx/i386/libsaio/smbios_patcher.c =================================================================== --- branches/blackosx/i386/libsaio/smbios_patcher.c (revision 214) +++ branches/blackosx/i386/libsaio/smbios_patcher.c (revision 215) @@ -142,17 +142,52 @@ return Platform.CPU.CPUFrequency/1000000; } +static int sm_get_simplecputype() +{ + if (Platform.CPU.NoCores >= 4) + { + return 0x0501; // Quad-Core Xeon + } + else if (Platform.CPU.NoCores == 1) + { + return 0x0201; // Core Solo + }; + + return 0x0301; // Core 2 Duo +} + static int sm_get_cputype (const char *name, int table_num) { - if (Platform.CPU.NoCores == 1) { - return 0x0101; // <01 01> Intel Core Solo? - } else if (Platform.CPU.NoCores == 2) { - return 0x0301; // <01 03> Intel Core 2 Duo - } else if (Platform.CPU.NoCores >= 4) { - return 0x0501; // <01 05> Quad-Core Intel Xeon - } else { - return 0x0301; // Default to Core 2 Duo + if (Platform.CPU.Vendor == 0x756E6547) // Intel + { + verbose("CPU is Intel, family 0x%x, model 0x%x, ext.model 0x%x\n", Platform.CPU.Family, Platform.CPU.Model, Platform.CPU.ExtModel); + + switch (Platform.CPU.Family) + { + case 0x06: + { + switch (Platform.CPU.Model) + { + case 0x0F: // Intel Core (65nm) + case 0x17: // Intel Core (45nm) + case 0x1C: // Intel Atom (45nm) + return sm_get_simplecputype(); + case 0x1A: // Intel Core i7 LGA1366 (45nm) + return 0x0701; + case 0x1E: // Intel Core i5, i7 LGA1156 (45nm) + case 0x1F: // Intel Core i5, i7 LGA1156 (45nm) ??? + return 0x0601; + case 0x25: // Intel Core i3, i5, i7 LGA1156 (32nm) + return 0x0301; + case 0x2C: // Intel Core i7 LGA1366 (32nm) 6 Core + case 0x2E: // Intel Core i7 LGA1366 (45nm) 6 Core ??? + return 0x0601; + } + } + } } + + return sm_get_simplecputype(); } static int sm_get_memtype (const char *name, int table_num) @@ -166,6 +201,7 @@ return Platform.RAM.DIMM[map].Type; } } + return SMB_MEM_TYPE_DDR2; } @@ -777,7 +813,7 @@ DmiTablePairCount++; } else { - printf("DMI table entries list is full! next entries won't be stored\n"); + printf("DMI table entries list is full! Next entries won't be stored.\n"); } #if DEBUG_SMBIOS printf("DMI header found for table type %d, length = %d\n", dmihdr->type, dmihdr->length); Index: branches/blackosx/i386/libsaio/usb.c =================================================================== --- branches/blackosx/i386/libsaio/usb.c (revision 214) +++ branches/blackosx/i386/libsaio/usb.c (revision 215) @@ -22,6 +22,182 @@ #define DBG(x...) #endif + +struct pciList +{ + pci_dt_t* pciDev; + struct pciList* next; +}; + +struct pciList* usbList = NULL; + +int legacy_off (pci_dt_t *pci_dev); +int ehci_acquire (pci_dt_t *pci_dev); +int uhci_reset (pci_dt_t *pci_dev); + +// Add usb device to the list +void notify_usb_dev(pci_dt_t *pci_dev) +{ + + struct pciList* current = usbList; + if(!usbList) + { + usbList = (struct pciList*)malloc(sizeof(struct pciList)); + usbList->next = NULL; + usbList->pciDev = pci_dev; + + } + else + { + while(current != NULL && current->next != NULL) + { + current = current->next; + } + current->next = (struct pciList*)malloc(sizeof(struct pciList)); + current = current->next; + + current->pciDev = pci_dev; + current->next = NULL; + } +} + +// Loop through the list and call the apropriate patch function +int usb_loop() +{ + int retVal = 1; + bool fix_ehci, fix_uhci, fix_usb, fix_legacy; + fix_ehci = fix_uhci = fix_usb = fix_legacy = false; + + if (getBoolForKey(kUSBBusFix, &fix_usb, &bootInfo->bootConfig)) + { + fix_ehci = fix_uhci = fix_legacy = fix_usb; // Disable all if none set + } + else + { + getBoolForKey(kEHCIacquire, &fix_ehci, &bootInfo->bootConfig); + getBoolForKey(kUHCIreset, &fix_uhci, &bootInfo->bootConfig); + getBoolForKey(kLegacyOff, &fix_legacy, &bootInfo->bootConfig); + } + + struct pciList* current = usbList; + + while(current && current->next) + { + switch (pci_config_read8(current->pciDev->dev.addr, PCI_CLASS_PROG)) + { + // EHCI + case 0x20: + if(fix_ehci) retVal &= ehci_acquire(current->pciDev); + if(fix_legacy) retVal &= legacy_off(current->pciDev); + + break; + + // UHCI + case 0x00: + if (fix_uhci) retVal &= uhci_reset(current->pciDev); + + break; + } + + current = current->next; + } + return retVal; +} + +int legacy_off (pci_dt_t *pci_dev) +{ + // Set usb legacy off modification by Signal64 + // NOTE: This *must* be called after the last file is loaded from the drive in the event that we are booting form usb. + // NOTE2: This should be called after any getc() call. (aka, after the Wait=y keyworkd is used) + // AKA: Make this run immediatly before the kernel is called + uint32_t capaddr, opaddr; + uint8_t eecp; + uint32_t usbcmd, usbsts, usbintr; + uint32_t usblegsup, usblegctlsts; + + int isOSowned; + int isBIOSowned; + + verbose("Setting Legacy USB Off on controller [%04x:%04x] at %02x:%2x.%x\n", + pci_dev->vendor_id, pci_dev->device_id, + pci_dev->dev.bits.bus, pci_dev->dev.bits.dev, pci_dev->dev.bits.func); + + + // capaddr = Capability Registers = dev.addr + offset stored in dev.addr + 0x10 (USBBASE) + capaddr = pci_config_read32(pci_dev->dev.addr, 0x10); + + // opaddr = Operational Registers = capaddr + offset (8bit CAPLENGTH in Capability Registers + offset 0) + opaddr = capaddr + *((unsigned char*)(capaddr)); + + // eecp = EHCI Extended Capabilities offset = capaddr HCCPARAMS bits 15:8 + eecp=*((unsigned char*)(capaddr + 9)); + + DBG("capaddr=%x opaddr=%x eecp=%x\n", capaddr, opaddr, eecp); + + usbcmd = *((unsigned int*)(opaddr)); // Command Register + usbsts = *((unsigned int*)(opaddr + 4)); // Status Register + usbintr = *((unsigned int*)(opaddr + 8)); // Interrupt Enable Register + + DBG("usbcmd=%08x usbsts=%08x usbintr=%08x\n", usbcmd, usbsts, usbintr); + + // read PCI Config 32bit USBLEGSUP (eecp+0) + usblegsup = pci_config_read32(pci_dev->dev.addr, eecp); + + // informational only + isBIOSowned = !!((usblegsup) & (1 << (16))); + isOSowned = !!((usblegsup) & (1 << (24))); + + // read PCI Config 32bit USBLEGCTLSTS (eecp+4) + usblegctlsts = pci_config_read32(pci_dev->dev.addr, eecp + 4); + + DBG("usblegsup=%08x isOSowned=%d isBIOSowned=%d usblegctlsts=%08x\n", usblegsup, isOSowned, isBIOSowned, usblegctlsts); + + // Reset registers to Legacy OFF + DBG("Clearing USBLEGCTLSTS\n"); + pci_config_write32(pci_dev->dev.addr, eecp + 4, 0); //usblegctlsts + + // if delay value is in milliseconds it doesn't appear to work. + // setting value to anything up to 65535 does not add the expected delay here. + delay(100); + + usbcmd = *((unsigned int*)(opaddr)); + usbsts = *((unsigned int*)(opaddr + 4)); + usbintr = *((unsigned int*)(opaddr + 8)); + + DBG("usbcmd=%08x usbsts=%08x usbintr=%08x\n", usbcmd, usbsts, usbintr); + + DBG("Clearing Registers\n"); + + // clear registers to default + usbcmd = (usbcmd & 0xffffff00); + *((unsigned int*)(opaddr)) = usbcmd; + *((unsigned int*)(opaddr + 8)) = 0; //usbintr - clear interrupt registers + *((unsigned int*)(opaddr + 4)) = 0x1000; //usbsts - clear status registers + pci_config_write32(pci_dev->dev.addr, eecp, 1); //usblegsup + + // get the results + usbcmd = *((unsigned int*)(opaddr)); + usbsts = *((unsigned int*)(opaddr + 4)); + usbintr = *((unsigned int*)(opaddr + 8)); + + DBG("usbcmd=%08x usbsts=%08x usbintr=%08x\n", usbcmd, usbsts, usbintr); + + // read 32bit USBLEGSUP (eecp+0) + usblegsup = pci_config_read32(pci_dev->dev.addr, eecp); + + // informational only + isBIOSowned = !!((usblegsup) & (1 << (16))); + isOSowned = !!((usblegsup) & (1 << (24))); + + // read 32bit USBLEGCTLSTS (eecp+4) + usblegctlsts = pci_config_read32(pci_dev->dev.addr, eecp + 4); + + DBG("usblegsup=%08x isOSowned=%d isBIOSowned=%d usblegctlsts=%08x\n", usblegsup, isOSowned, isBIOSowned, usblegctlsts); + + verbose("Legacy USB Off Done\n"); + return 1; +} + int ehci_acquire (pci_dt_t *pci_dev) { int j, k; Index: branches/blackosx/i386/libsaio/nvidia.c =================================================================== --- branches/blackosx/i386/libsaio/nvidia.c (revision 214) +++ branches/blackosx/i386/libsaio/nvidia.c (revision 215) @@ -337,10 +337,11 @@ { 0x10DE06F9, "Quadro FX 370 LP" }, { 0x10DE06FA, "Quadro NVS 450" }, { 0x10DE06FD, "Quadro NVS 295" }, - { 0x10DE087D, "ION 9400M" }, - { 0x10DE087E, "ION LE" }, + { 0x10DE087D, "ION 9400M" }, + { 0x10DE087E, "ION LE" }, { 0x10DE0A20, "GeForce GT220" }, { 0x10DE0A23, "GeForce 210" }, + { 0x10DE0A28, "GeForce GT 230M" }, { 0x10DE0A2A, "GeForce GT 230M" }, { 0x10DE0A34, "GeForce GT 240M" }, { 0x10DE0A60, "GeForce G210" }, @@ -352,7 +353,18 @@ { 0x10DE0A78, "Quadro FX 380 LP" }, { 0x10DE0CA3, "GeForce GT 240" }, { 0x10DE0CA8, "GeForce GTS 260M" }, - { 0x10DE0CA9, "GeForce GTS 250M" } + { 0x10DE0CA9, "GeForce GTS 250M" }, + { 0x10DE0CA3, "GeForce GT240" }, + { 0x10DE06C0, "GeForce GTX 480" }, + { 0x10DE06CD, "GeForce GTX 470" }, + { 0x10DE06C4, "GeForce GTX 465" }, + { 0x10DE06CA, "GeForce GTX 480M" }, + { 0x10DE0E22, "GeForce GTX 460" }, + { 0x10DE0E24, "GeForce GTX 460" }, + { 0x10DE06D1, "Tesla C2050" }, // TODO: sub-device id: 0x0771 + { 0x10DE06D1, "Tesla C2070" }, // TODO: sub-device id: 0x0772 + { 0x10DE06DE, "Tesla M2050" }, // TODO: sub-device id: 0x0846 + { 0x10DE06DE, "Tesla M2070" } // TODO: sub-device id: ? }; static uint16_t swap16(uint16_t x) @@ -680,6 +692,22 @@ videoRam = (REG32(0x10020c) & 0xfff00000) >> 10; 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, Index: branches/blackosx/i386/libsaio/sys.c =================================================================== --- branches/blackosx/i386/libsaio/sys.c (revision 214) +++ branches/blackosx/i386/libsaio/sys.c (revision 215) @@ -87,12 +87,11 @@ int type; }; +// Device entries must be ordered by bios device numbers. static struct devsw devsw[] = { - { "sd", 0x80, kBIOSDevTypeHardDrive }, /* DEV_SD */ - { "hd", 0x80, kBIOSDevTypeHardDrive }, /* DEV_HD */ - { "fd", 0x00, kBIOSDevTypeFloppy }, /* DEV_FD */ - { "en", 0xE0, kBIOSDevTypeNetwork }, /* DEV_EN */ + { "hd", 0x80, kBIOSDevTypeHardDrive }, /* DEV_HD */ + { "en", 0xE0, kBIOSDevTypeNetwork }, /* DEV_EN */ { "rd", 0x100, kBIOSDevTypeHardDrive }, { "bt", 0x101, kBIOSDevTypeHardDrive }, // turbo - type for booter partition { 0, 0 } @@ -403,7 +402,6 @@ return io; } -#if UNUSED //========================================================================== // openmem() @@ -425,7 +423,6 @@ return fdesc; } -#endif //========================================================================== // open() - Open the file specified by 'path' for reading. @@ -602,6 +599,62 @@ } //========================================================================== +// write() - Write up to 'count' bytes of data to the file descriptor +// from the buffer pointed to by buf. + +int write(int fdesc, const char * buf, int count) +{ + struct iob * io; + + if ((io = iob_from_fdesc(fdesc)) == NULL) + return (-1); + + if ((io->i_offset + count) > (unsigned int)io->i_filesize) + count = io->i_filesize - io->i_offset; + + if (count <= 0) + return 0; // end of file + + bcopy(buf, io->i_buf + io->i_offset, count); + + io->i_offset += count; + + return count; +} + +int writebyte(int fdesc, char value) +{ + struct iob * io; + + if ((io = iob_from_fdesc(fdesc)) == NULL) + return (-1); + + if ((io->i_offset + 1) > (unsigned int)io->i_filesize) + return 0; // end of file + + io->i_buf[io->i_offset++] = value; + + return 1; +} + +int writeint(int fdesc, int value) +{ + struct iob * io; + + if ((io = iob_from_fdesc(fdesc)) == NULL) + return (-1); + + if ((io->i_offset + 4) > (unsigned int)io->i_filesize) + return 0; // end of file + + bcopy(&value, io->i_buf + io->i_offset, 4); + + io->i_offset += 4; + + return 4; +} + +//========================================================================== // file_size() - Returns the size of the file described by the file // descriptor. @@ -762,9 +815,9 @@ BVRef selectBootVolume( BVRef chain ) { - bool filteredChain = false; + bool filteredChain = false; bool foundPrimary = false; - BVRef bvr, bvr1 = 0, bvr2 = 0; + BVRef bvr, bvr1 = 0, bvr2 = 0; if (chain->filtered) filteredChain = true; @@ -774,54 +827,58 @@ return bvr; /* - * Checking "Default Partition" key in system configuration - use format: hd(x,y) - + * Checking "Default Partition" key in system configuration - use format: hd(x,y) or the volume UUID - * to override the default selection. * We accept only kBVFlagSystemVolume or kBVFlagForeignBoot volumes. */ - const char * val; - char testStr[64]; - int cnt; - - if (getValueForKey(kDefaultPartition, &val, &cnt, &bootInfo->bootConfig) && cnt >= 7 && filteredChain) - { - for ( bvr = chain; bvr; bvr = bvr->next ) - { - *testStr = '\0'; - if ( bvr->biosdev >= 0x80 && bvr->biosdev < 0x100 - && ( bvr->flags & ( kBVFlagSystemVolume|kBVFlagForeignBoot ) ) ) - { - sprintf(testStr, "hd(%d,%d)", bvr->biosdev - 0x80, bvr->part_no); - if (strcmp(testStr, val) == 0) - return bvr; - } - } - } - + const char * val; + char testStr[64]; + int cnt; + + if (getValueForKey(kDefaultPartition, &val, &cnt, &bootInfo->bootConfig) && cnt >= 7 && filteredChain) + { + for ( bvr = chain; bvr; bvr = bvr->next ) + { + if ( bvr->biosdev >= 0x80 && bvr->biosdev < 0x100 + && ( bvr->flags & ( kBVFlagSystemVolume|kBVFlagForeignBoot ) ) ) + { + // Trying to match hd(x,y) format. + sprintf(testStr, "hd(%d,%d)", bvr->biosdev - 0x80, bvr->part_no); + if (strcmp(testStr, val) == 0) + return bvr; + + // Trying to match volume UUID. + if (bvr->fs_getuuid && bvr->fs_getuuid(bvr, testStr) == 0 && strcmp(testStr, val) == 0) + return bvr; + } + } + } + /* * Scannig the volume chain backwards and trying to find * a HFS+ volume with valid boot record signature. * If not found any active partition then we will * select this volume as the boot volume. */ - for ( bvr = chain; bvr; bvr = bvr->next ) - { - if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) foundPrimary = true; - // zhell -- Undo a regression that was introduced from r491 to 492. - // if gBIOSBootVolume is set already, no change is required - if ( bvr->flags & (kBVFlagBootable|kBVFlagSystemVolume) - && gBIOSBootVolume - && (!filteredChain || (filteredChain && bvr->visible)) - && bvr->biosdev == gBIOSDev ) - bvr2 = bvr; - // zhell -- if gBIOSBootVolume is NOT set, we use the "if" statement - // from r491, - if ( bvr->flags & kBVFlagBootable - && ! gBIOSBootVolume - && bvr->biosdev == gBIOSDev ) - bvr2 = bvr; - } - - + for ( bvr = chain; bvr; bvr = bvr->next ) + { + if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) foundPrimary = true; + // zhell -- Undo a regression that was introduced from r491 to 492. + // if gBIOSBootVolume is set already, no change is required + if ( bvr->flags & (kBVFlagBootable|kBVFlagSystemVolume) + && gBIOSBootVolume + && (!filteredChain || (filteredChain && bvr->visible)) + && bvr->biosdev == gBIOSDev ) + bvr2 = bvr; + // zhell -- if gBIOSBootVolume is NOT set, we use the "if" statement + // from r491, + if ( bvr->flags & kBVFlagBootable + && ! gBIOSBootVolume + && bvr->biosdev == gBIOSDev ) + bvr2 = bvr; + } + + /* * Use the standrad method for selecting the boot volume. */ @@ -832,12 +889,12 @@ if ( bvr->flags & kBVFlagNativeBoot && bvr->biosdev == gBIOSDev ) bvr1 = bvr; if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) bvr2 = bvr; } - } - - bvr = bvr2 ? bvr2 : - bvr1 ? bvr1 : chain; - - return bvr; + } + + bvr = bvr2 ? bvr2 : + bvr1 ? bvr1 : chain; + + return bvr; } //========================================================================== @@ -1018,3 +1075,21 @@ return bvr ? bvr : bvr1; } + +int getDeviceStringFromBVR(const BVRef bvr, char *str) +{ + const struct devsw *dp; + + if (bvr) + { + *str = '\0'; + + for (dp = devsw; dp->name && bvr->biosdev >= dp->biosdev; dp++); + dp--; + if (dp->name) sprintf(str, "%s(%d,%d)", dp->name, bvr->biosdev - dp->biosdev, bvr->part_no); + + return true; + } + + return false; +} Index: branches/blackosx/i386/libsaio/acpi.h =================================================================== --- branches/blackosx/i386/libsaio/acpi.h (revision 214) +++ branches/blackosx/i386/libsaio/acpi.h (revision 215) @@ -59,6 +59,32 @@ } __attribute__((packed)); // TODO Migrate +struct acpi_2_ssdt { + char Signature[4]; + uint32_t Length; + uint8_t Revision; + uint8_t Checksum; + char OEMID[6]; + char OEMTableId[8]; + uint32_t OEMRevision; + uint32_t CreatorId; + uint32_t CreatorRevision; +} __attribute__((packed)); + +// TODO Migrate +struct acpi_2_dsdt { + char Signature[4]; + uint32_t Length; + uint8_t Revision; + uint8_t Checksum; + char OEMID[6]; + char OEMTableId[8]; + uint32_t OEMRevision; + uint32_t CreatorId; + uint32_t CreatorRevision; +} __attribute__((packed)); + +// TODO Migrate struct acpi_2_fadt { char Signature[4]; uint32_t Length; @@ -73,8 +99,39 @@ uint32_t DSDT; uint8_t Model; // JrCs uint8_t PM_Profile; // JrCs - /*We absolutely don't care about theese fields*/ - uint8_t notimp1[66]; + uint16_t SCI_Interrupt; + uint32_t SMI_Command_Port; + uint8_t ACPI_Enable; + uint8_t ACPI_Disable; + uint8_t S4BIOS_Command; + uint8_t PState_Control; + uint32_t PM1A_Event_Block_Address; + uint32_t PM1B_Event_Block_Address; + uint32_t PM1A_Control_Block_Address; + uint32_t PM1B_Control_Block_Address; + uint32_t PM2_Control_Block_Address; + uint32_t PM_Timer_Block_Address; + uint32_t GPE0_Block_Address; + uint32_t GPE1_Block_Address; + uint8_t PM1_Event_Block_Length; + uint8_t PM1_Control_Block_Length; + uint8_t PM2_Control_Block_Length; + uint8_t PM_Timer_Block_Length; + uint8_t GPE0_Block_Length; + uint8_t GPE1_Block_Length; + uint8_t GPE1_Base_Offset; + uint8_t CST_Support; + uint16_t C2_Latency; + uint16_t C3_Latency; + uint16_t CPU_Cache_Size; + uint16_t Cache_Flush_Stride; + uint8_t Duty_Cycle_Offset; + uint8_t Duty_Cycle_Width; + uint8_t RTC_Day_Alarm_Index; + uint8_t RTC_Month_Alarm_Index; + uint8_t RTC_Century_Index; + uint16_t Boot_Flags; + uint8_t Reserved0; /* Begin Asere */ //Reset Fix uint32_t Flags; Index: branches/blackosx/i386/libsaio/platform.c =================================================================== --- branches/blackosx/i386/libsaio/platform.c (revision 214) +++ branches/blackosx/i386/libsaio/platform.c (revision 215) @@ -37,13 +37,17 @@ /** scan mem for memory autodection purpose */ void scan_mem() { - bool useAutodetection = false; + static bool done = false; + if (done) return; + + bool useAutodetection = true; getBoolForKey(kUseMemDetect, &useAutodetection, &bootInfo->bootConfig); if (useAutodetection) { - scan_memory(&Platform); + scan_memory(&Platform); // unfortunately still necesary for some comp where spd cant read correct speed scan_spd(&Platform); } + done = true; } /** @@ -52,11 +56,9 @@ */ void scan_platform(void) { - memset(&Platform, 0, sizeof(Platform)); build_pci_dt(); scan_cpu(&Platform); - // disabled for now as options can't be read yet here: - // scan_mem(); - + // It's working after some changes in strdup + scan_mem(); } Index: branches/blackosx/i386/libsaio/cpu.c =================================================================== --- branches/blackosx/i386/libsaio/cpu.c (revision 214) +++ branches/blackosx/i386/libsaio/cpu.c (revision 215) @@ -17,105 +17,7 @@ #define DBG(x...) #endif - -static inline uint64_t rdtsc64(void) -{ - uint64_t ret; - __asm__ volatile("rdtsc" : "=A" (ret)); - return ret; -} - -static inline uint64_t rdmsr64(uint32_t msr) -{ - uint64_t ret; - __asm__ volatile("rdmsr" : "=A" (ret) : "c" (msr)); - return ret; -} - -static inline void do_cpuid(uint32_t selector, uint32_t *data) -{ - asm volatile ("cpuid" - : "=a" (data[0]), - "=b" (data[1]), - "=c" (data[2]), - "=d" (data[3]) - : "a" (selector)); -} - -static inline void do_cpuid2(uint32_t selector, uint32_t selector2, uint32_t *data) -{ - asm volatile ("cpuid" - : "=a" (data[0]), - "=b" (data[1]), - "=c" (data[2]), - "=d" (data[3]) - : "a" (selector), "c" (selector2)); -} - -// DFE: enable_PIT2 and disable_PIT2 come from older xnu - /* - * Enable or disable timer 2. - * Port 0x61 controls timer 2: - * bit 0 gates the clock, - * bit 1 gates output to speaker. - */ -static inline void enable_PIT2(void) -{ - /* Enable gate, disable speaker */ - __asm__ volatile( - " inb $0x61,%%al \n\t" - " and $0xFC,%%al \n\t" /* & ~0x03 */ - " or $1,%%al \n\t" - " outb %%al,$0x61 \n\t" - : : : "%al" ); -} - -static inline void disable_PIT2(void) -{ - /* Disable gate and output to speaker */ - __asm__ volatile( - " inb $0x61,%%al \n\t" - " and $0xFC,%%al \n\t" /* & ~0x03 */ - " outb %%al,$0x61 \n\t" - : : : "%al" ); -} - -// DFE: set_PIT2_mode0, poll_PIT2_gate, and measure_tsc_frequency are -// roughly based on Linux code - -/* Set the 8254 channel 2 to mode 0 with the specified value. - In mode 0, the counter will initially set its gate low when the - timer expires. For this to be useful, you ought to set it high - before calling this function. The enable_PIT2 function does this. - */ -static inline void set_PIT2_mode0(uint16_t value) -{ - __asm__ volatile( - " movb $0xB0,%%al \n\t" - " outb %%al,$0x43 \n\t" - " movb %%dl,%%al \n\t" - " outb %%al,$0x42 \n\t" - " movb %%dh,%%al \n\t" - " outb %%al,$0x42" - : : "d"(value) /*: no clobber */ ); -} - -/* Returns the number of times the loop ran before the PIT2 signaled */ -static inline unsigned long poll_PIT2_gate(void) -{ - unsigned long count = 0; - unsigned char nmi_sc_val; - do { - ++count; - __asm__ volatile( - "inb $0x61,%0" - : "=q"(nmi_sc_val) /*:*/ /* no input */ /*:*/ /* no clobber */); - } while( (nmi_sc_val & 0x20) == 0); - return count; -} - -/* * DFE: Measures the TSC frequency in Hz (64-bit) using the ACPI PM timer */ static uint64_t measure_tsc_frequency(void) @@ -249,6 +151,9 @@ if ((bit(29) & p->CPU.CPUID[CPUID_81][3]) != 0) { p->CPU.Features |= CPU_FEATURE_EM64T; } + if ((bit(5) & p->CPU.CPUID[CPUID_1][3]) != 0) { + p->CPU.Features |= CPU_FEATURE_MSR; + } //if ((bit(28) & p->CPU.CPUID[CPUID_1][3]) != 0) { if (p->CPU.NoThreads > p->CPU.NoCores) { p->CPU.Features |= CPU_FEATURE_HTT; @@ -261,7 +166,8 @@ if ((p->CPU.Vendor == 0x756E6547 /* Intel */) && ((p->CPU.Family == 0x06) || (p->CPU.Family == 0x0f))) { if ((p->CPU.Family == 0x06 && p->CPU.Model >= 0x0c) || (p->CPU.Family == 0x0f && p->CPU.Model >= 0x03)) { /* Nehalem CPU model */ - if (p->CPU.Family == 0x06 && (p->CPU.Model == 0x1a || p->CPU.Model == 0x1e)) { + if (p->CPU.Family == 0x06 && (p->CPU.Model == 0x1a || p->CPU.Model == 0x1e + || p->CPU.Model == 0x1f || p->CPU.Model == 0x25 || p->CPU.Model == 0x2c)) { msr = rdmsr64(MSR_PLATFORM_INFO); DBG("msr(%d): platform_info %08x\n", __LINE__, msr & 0xffffffff); currcoef = (msr >> 8) & 0xff; @@ -279,7 +185,7 @@ } cpuFrequency = tscFrequency; } else { - msr = rdmsr64(IA32_PERF_STATUS); + msr = rdmsr64(MSR_IA32_PERF_STATUS); DBG("msr(%d): ia32_perf_stat 0x%08x\n", __LINE__, msr & 0xffffffff); currcoef = (msr >> 8) & 0x1f; /* Non-integer bus ratio for the max-multi*/ Index: branches/blackosx/i386/libsaio/platform.h =================================================================== --- branches/blackosx/i386/libsaio/platform.h (revision 214) +++ branches/blackosx/i386/libsaio/platform.h (revision 215) @@ -33,6 +33,7 @@ #define CPU_FEATURE_EM64T 0x00000040 // 64Bit Support #define CPU_FEATURE_HTT 0x00000080 // HyperThreading #define CPU_FEATURE_MOBILE 0x00000100 // Mobile CPU +#define CPU_FEATURE_MSR 0x00000200 // MSR Support /* SMBIOS Memory Types */ #define SMB_MEM_TYPE_UNDEFINED 0 @@ -75,16 +76,16 @@ #define UUID_LEN 16 typedef struct _RamSlotInfo_t { - uint32_t ModuleSize; // Size of Module in MB - uint32_t Frequency; // in Mhz + uint32_t ModuleSize; // Size of Module in MB + uint32_t Frequency; // in Mhz const char* Vendor; const char* PartNo; const char* SerialNo; - char* spd; // SPD Dump - bool InUse; - uint8_t Type; - uint8_t BankConnections; // table type 6, see (3.3.7) - uint8_t BankConnCnt; + char* spd; // SPD Dump + bool InUse; + uint8_t Type; + uint8_t BankConnections; // table type 6, see (3.3.7) + uint8_t BankConnCnt; } RamSlotInfo_t; Index: branches/blackosx/i386/libsaio/pci_setup.c =================================================================== --- branches/blackosx/i386/libsaio/pci_setup.c (revision 214) +++ branches/blackosx/i386/libsaio/pci_setup.c (revision 215) @@ -6,26 +6,19 @@ #include "ati.h" extern void set_eth_builtin(pci_dt_t *eth_dev); -extern int ehci_acquire(pci_dt_t *pci_dev); -extern int uhci_reset(pci_dt_t *pci_dev); +extern void notify_usb_dev(pci_dt_t *pci_dev); extern void force_enable_hpet(pci_dt_t *lpc_dev); void setup_pci_devs(pci_dt_t *pci_dt) { char *devicepath; - bool do_eth_devprop, do_gfx_devprop, fix_ehci, fix_uhci, fix_usb, do_enable_hpet; + bool do_eth_devprop, do_gfx_devprop, do_enable_hpet; pci_dt_t *current = pci_dt; - do_eth_devprop = do_gfx_devprop = fix_ehci = fix_uhci = fix_usb = do_enable_hpet = false; + do_eth_devprop = do_gfx_devprop = do_enable_hpet = false; getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->bootConfig); getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->bootConfig); - if (getBoolForKey(kUSBBusFix, &fix_usb, &bootInfo->bootConfig) && fix_usb) { - fix_ehci = fix_uhci = true; - } else { - getBoolForKey(kEHCIacquire, &fix_ehci, &bootInfo->bootConfig); - getBoolForKey(kUHCIreset, &fix_uhci, &bootInfo->bootConfig); - } getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->bootConfig); while (current) @@ -62,20 +55,7 @@ break; case PCI_CLASS_SERIAL_USB: - switch (pci_config_read8(current->dev.addr, PCI_CLASS_PROG)) - { - /* EHCI */ - case 0x20: - if (fix_ehci) - ehci_acquire(current); - break; - - /* UHCI */ - case 0x00: - if (fix_uhci) - uhci_reset(current); - break; - } + notify_usb_dev(current); break; case PCI_CLASS_BRIDGE_ISA: Index: branches/blackosx/i386/libsaio/cpu.h =================================================================== --- branches/blackosx/i386/libsaio/cpu.h (revision 214) +++ branches/blackosx/i386/libsaio/cpu.h (revision 215) @@ -14,11 +14,13 @@ #define bitmask(h,l) ((bit(h)|(bit(h)-1)) & ~(bit(l)-1)) #define bitfield(x,h,l) (((x) & bitmask(h,l)) >> l) -#define IA32_PERF_STATUS 0x198 -#define MSR_FLEX_RATIO 0x194 -#define MSR_PLATFORM_INFO 0xCE -#define K8_FIDVID_STATUS 0xC0010042 -#define K10_COFVID_STATUS 0xC0010071 +#define MSR_IA32_PERF_STATUS 0x198 +#define MSR_IA32_PERF_CONTROL 0x199 +#define MSR_IA32_EXT_CONFIG 0x00EE +#define MSR_FLEX_RATIO 0x194 +#define MSR_PLATFORM_INFO 0xCE +#define K8_FIDVID_STATUS 0xC0010042 +#define K10_COFVID_STATUS 0xC0010071 #define DEFAULT_FSB 100000 /* for now, hardcoding 100MHz for old CPUs */ @@ -29,4 +31,111 @@ #define CALIBRATE_TIME_MSEC 30 /* 30 msecs */ #define CALIBRATE_LATCH ((CLKNUM * CALIBRATE_TIME_MSEC + 1000/2)/1000) +static inline uint64_t rdtsc64(void) +{ + uint64_t ret; + __asm__ volatile("rdtsc" : "=A" (ret)); + return ret; +} + +static inline uint64_t rdmsr64(uint32_t msr) +{ + uint64_t ret; + __asm__ volatile("rdmsr" : "=A" (ret) : "c" (msr)); + return ret; +} + +static inline void wrmsr64(uint32_t msr, uint64_t val) +{ + __asm__ volatile("wrmsr" : : "c" (msr), "A" (val)); +} + +static inline void intel_waitforsts(void) { + uint32_t inline_timeout = 100000; + while (rdmsr64(MSR_IA32_PERF_STATUS) & (1 << 21)) { if (!inline_timeout--) break; } +} + +static inline void do_cpuid(uint32_t selector, uint32_t *data) +{ + asm volatile ("cpuid" + : "=a" (data[0]), + "=b" (data[1]), + "=c" (data[2]), + "=d" (data[3]) + : "a" (selector)); +} + +static inline void do_cpuid2(uint32_t selector, uint32_t selector2, uint32_t *data) +{ + asm volatile ("cpuid" + : "=a" (data[0]), + "=b" (data[1]), + "=c" (data[2]), + "=d" (data[3]) + : "a" (selector), "c" (selector2)); +} + +// DFE: enable_PIT2 and disable_PIT2 come from older xnu + +/* + * Enable or disable timer 2. + * Port 0x61 controls timer 2: + * bit 0 gates the clock, + * bit 1 gates output to speaker. + */ +static inline void enable_PIT2(void) +{ + /* Enable gate, disable speaker */ + __asm__ volatile( + " inb $0x61,%%al \n\t" + " and $0xFC,%%al \n\t" /* & ~0x03 */ + " or $1,%%al \n\t" + " outb %%al,$0x61 \n\t" + : : : "%al" ); +} + +static inline void disable_PIT2(void) +{ + /* Disable gate and output to speaker */ + __asm__ volatile( + " inb $0x61,%%al \n\t" + " and $0xFC,%%al \n\t" /* & ~0x03 */ + " outb %%al,$0x61 \n\t" + : : : "%al" ); +} + +// DFE: set_PIT2_mode0, poll_PIT2_gate, and measure_tsc_frequency are +// roughly based on Linux code + +/* Set the 8254 channel 2 to mode 0 with the specified value. + In mode 0, the counter will initially set its gate low when the + timer expires. For this to be useful, you ought to set it high + before calling this function. The enable_PIT2 function does this. + */ +static inline void set_PIT2_mode0(uint16_t value) +{ + __asm__ volatile( + " movb $0xB0,%%al \n\t" + " outb %%al,$0x43 \n\t" + " movb %%dl,%%al \n\t" + " outb %%al,$0x42 \n\t" + " movb %%dh,%%al \n\t" + " outb %%al,$0x42" + : : "d"(value) /*: no clobber */ ); +} + +/* Returns the number of times the loop ran before the PIT2 signaled */ +static inline unsigned long poll_PIT2_gate(void) +{ + unsigned long count = 0; + unsigned char nmi_sc_val; + do { + ++count; + __asm__ volatile( + "inb $0x61,%0" + : "=q"(nmi_sc_val) /*:*/ /* no input */ /*:*/ /* no clobber */); + } while( (nmi_sc_val & 0x20) == 0); + return count; +} + #endif /* !__LIBSAIO_CPU_H */ Index: branches/blackosx/i386/libsaio/msdos.c =================================================================== --- branches/blackosx/i386/libsaio/msdos.c (revision 214) +++ branches/blackosx/i386/libsaio/msdos.c (revision 215) @@ -720,6 +720,8 @@ char *ptr = (char *)base; struct direntry *dirp; int i; + char devStr[12]; + if (MSDOSInitPartition (ih)<0) return -1; if (filePath[0] == '/') @@ -754,8 +756,10 @@ ptr+=msdosclustersize; toread-=msdosclustersize; } - verbose("Loaded FAT%d file: [%s] %d bytes from %x.\n", - msdosfatbits, filePath, (uint32_t)( toread<0 ) ? wastoread : wastoread-toread, ih); + + getDeviceStringFromBVR(ih, devStr); + verbose("Read FAT%d file: [%s/%s] %d bytes.\n", + msdosfatbits, devStr, filePath, (uint32_t)( toread<0 ) ? wastoread : wastoread-toread); free (buf); if (toread<0) return wastoread; Index: branches/blackosx/i386/libsaio/fake_efi.c =================================================================== --- branches/blackosx/i386/libsaio/fake_efi.c (revision 214) +++ branches/blackosx/i386/libsaio/fake_efi.c (revision 215) @@ -11,7 +11,7 @@ #include "fake_efi.h" #include "efi_tables.h" #include "platform.h" -#include "dsdt_patcher.h" +#include "acpi_patcher.h" #include "smbios_patcher.h" #include "device_inject.h" #include "convert.h" @@ -514,19 +514,19 @@ /* Entrypoint from boot.c */ void setupFakeEfi(void) { - // load smbios.plist file if any - setupSmbiosConfigFile(); + // load smbios.plist file if any + setupSmbiosConfigFile(); - // Generate efi device strings + // Generate efi device strings setupEfiDevices(); // Initialize the base table setupEfiTables(); - // Initialize the device tree - setupEfiDeviceTree(); - - // Add configuration table entries to both the services table and the device tree - setupEfiConfigurationTable(); + // Initialize the device tree + setupEfiDeviceTree(); + + // Add configuration table entries to both the services table and the device tree + setupEfiConfigurationTable(); } Index: branches/blackosx/i386/libsaio/saio_internal.h =================================================================== --- branches/blackosx/i386/libsaio/saio_internal.h (revision 214) +++ branches/blackosx/i386/libsaio/saio_internal.h (revision 215) @@ -183,6 +183,9 @@ extern int close(int fdesc); extern int file_size(int fdesc); extern int read(int fdesc, char *buf, int count); +extern int write(int fdesc, const char *buf, int count); +extern int writebyte(int fdesc, char value); +extern int writeint(int fdesc, int value); extern int b_lseek(int fdesc, int addr, int ptr); extern int tell(int fdesc); extern const char * systemConfigDir(void); @@ -199,6 +202,7 @@ extern void getBootVolumeDescription(BVRef bvr, char *str, long strMaxLen, bool verbose); extern void setRootVolume(BVRef volume); extern void setBootGlobals(BVRef chain); +extern int getDeviceStringFromBVR(const BVRef volume, char *str); extern int gBIOSDev; extern int gBootFileType; Index: branches/blackosx/i386/boot1/boot1f32.s =================================================================== --- branches/blackosx/i386/boot1/boot1f32.s (revision 214) +++ branches/blackosx/i386/boot1/boot1f32.s (revision 215) @@ -75,7 +75,7 @@ kBoot1LoadAddr EQU 0x7C00 ; boot1 load address kBoot1RelocAddr EQU 0xE000 ; boot1 relocated address -kBoot2Sectors EQU (384 * 1024 - 512) / kSectorBytes ; max size of 'boot' file in sectors +kBoot2Sectors EQU (448 * 1024 - 512) / kSectorBytes ; max size of 'boot' file in sectors kBoot2Segment EQU 0x2000 ; boot2 load segment kBoot2Address EQU kSectorBytes ; boot2 load address Index: branches/blackosx/i386/boot1/boot1he.s =================================================================== --- branches/blackosx/i386/boot1/boot1he.s (revision 214) +++ branches/blackosx/i386/boot1/boot1he.s (revision 215) @@ -79,7 +79,7 @@ kBoot1ExtAddr EQU kBoot1RelocAddr + kSectorBytes ; boot1 load address for sector 41-47 kHFSPlusBuffer EQU kBoot1RelocAddr + kBoot1ExtSize ; HFS+ Volume Header address -kBoot2Sectors EQU (384 * 1024 - 512) / kSectorBytes ; max size of 'boot' file in sectors +kBoot2Sectors EQU (448 * 1024 - 512) / kSectorBytes ; max size of 'boot' file in sectors kBoot2Segment EQU 0x2000 ; boot2 load segment kBoot2Address EQU kSectorBytes ; boot2 load address Index: branches/blackosx/i386/boot1/boot1.s =================================================================== --- branches/blackosx/i386/boot1/boot1.s (revision 214) +++ branches/blackosx/i386/boot1/boot1.s (revision 215) @@ -74,7 +74,7 @@ kBoot1Sector1Addr EQU kBoot1RelocAddr + kSectorBytes ; boot1 load address for sector 1 kHFSPlusBuffer EQU kBoot1Sector1Addr + kSectorBytes ; HFS+ Volume Header address -kBoot2Sectors EQU (384 * 1024 - 512) / kSectorBytes ; max size of 'boot' file in sectors +kBoot2Sectors EQU (448 * 1024 - 512) / kSectorBytes ; max size of 'boot' file in sectors kBoot2Segment EQU 0x2000 ; boot2 load segment kBoot2Address EQU kSectorBytes ; boot2 load address Index: branches/blackosx/i386/boot2/boot.c =================================================================== --- branches/blackosx/i386/boot2/boot.c (revision 214) +++ branches/blackosx/i386/boot2/boot.c (revision 215) @@ -175,11 +175,13 @@ } bool dummyVal; - if (getBoolForKey(kWaitForKeypressKey, &dummyVal, &bootInfo->bootConfig) && dummyVal) { - printf("Press any key to continue..."); - getc(); - } + if (getBoolForKey(kWaitForKeypressKey, &dummyVal, &bootInfo->bootConfig) && dummyVal) { + printf("Press any key to continue..."); + getc(); + } + usb_loop(); + // If we were in text mode, switch to graphics mode. // This will draw the boot graphics unless we are in // verbose mode. Index: branches/blackosx/i386/boot2/boot.h =================================================================== --- branches/blackosx/i386/boot2/boot.h (revision 214) +++ branches/blackosx/i386/boot2/boot.h (revision 215) @@ -42,52 +42,55 @@ #define kKernelNameKey "Kernel" #define kKernelCacheKey "Kernel Cache" #define kBootDeviceKey "Boot Device" -#define kTimeoutKey "Timeout" +#define kTimeoutKey "Timeout" #define kRootDeviceKey "rd" #define kBootUUIDKey "boot-uuid" #define kHelperRootUUIDKey "Root UUID" #define kPlatformKey "platform" -#define kACPIKey "acpi" +#define kACPIKey "acpi" #define kCDROMPromptKey "CD-ROM Prompt" #define kCDROMOptionKey "CD-ROM Option Key" #define kRescanPromptKey "Rescan Prompt" -#define kRescanKey "Rescan" +#define kRescanKey "Rescan" #define kScanSingleDriveKey "Scan Single Drive" #define kInsantMenuKey "Instant Menu" #define kDefaultKernel "mach_kernel" -#define kGUIKey "GUI" +#define kGUIKey "GUI" #define kBootBannerKey "Boot Banner" #define kWaitForKeypressKey "Wait" /* AsereBLN: added the other keys */ -#define kUseAtiROM "UseAtiROM" /* ati.c */ -#define kWake "Wake" /* boot.c */ -#define kForceWake "ForceWake" /* boot.c */ -#define kWakeImage "WakeImage" /* boot.c */ +#define kUseAtiROM "UseAtiROM" /* ati.c */ +#define kWake "Wake" /* boot.c */ +#define kForceWake "ForceWake" /* boot.c */ +#define kWakeImage "WakeImage" /* boot.c */ #define kProductVersion "ProductVersion" /* boot.c */ -#define karch "arch" /* boot.c */ -#define kDSDT "DSDT" /* dsdt_patcher.c */ -#define kDropSSDT "DropSSDT" /* dsdt_patcher.c */ -#define kRestartFix "RestartFix" /* dsdt_patcher.c */ -#define kSMBIOS "SMBIOS" /* fake_efi.c */ -#define kSystemID "SystemId" /* fake_efi.c */ -#define kSystemType "SystemType" /* fake_efi.c */ +#define karch "arch" /* boot.c */ +#define kDSDT "DSDT" /* acpi_patcher.c */ +#define kDropSSDT "DropSSDT" /* acpi_patcher.c */ +#define kRestartFix "RestartFix" /* acpi_patcher.c */ +#define kRestartFix "RestartFix" /* acpi_patcher.c */ +#define kGeneratePStates "GeneratePStates" /* acpi_patcher.c */ +#define kGenerateCStates "GenerateCStates" /* acpi_patcher.c */ +#define kDeviceProperties "device-properties" /* device_inject.c */ +#define kHidePartition "Hide Partition" /* disk.c */ +#define kRenamePartition "Rename Partition" /* disk.c */ +#define kSMBIOS "SMBIOS" /* fake_efi.c */ +#define kSystemID "SystemId" /* fake_efi.c */ +#define kSystemType "SystemType" /* fake_efi.c */ #define kUseNvidiaROM "UseNvidiaROM" /* nvidia.c */ -#define kVBIOS "VBIOS" /* nvidia.c */ -#define kPCIRootUID "PCIRootUID" /* pci_root.c */ +#define kVBIOS "VBIOS" /* nvidia.c */ +#define kPCIRootUID "PCIRootUID" /* pci_root.c */ #define kEthernetBuiltIn "EthernetBuiltIn" /* pci_setup.c */ #define kGraphicsEnabler "GraphicsEnabler" /* pci_setup.c */ -#define kUSBBusFix "USBBusFix" /* pci_setup.c */ -#define kEHCIacquire "EHCIacquire" /* pci_setup.c */ -#define kUHCIreset "UHCIreset" /* pci_setup.c */ -#define kForceHPET "ForceHPET" /* pci_setup.c */ +#define kForceHPET "ForceHPET" /* pci_setup.c */ +#define kUseMemDetect "UseMemDetect" /* platform.c */ #define kSMBIOSdefaults "SMBIOSdefaults" /* smbios_patcher.c */ -#define kEHCIhard "EHCIhard" /* usb.c */ +#define kUSBBusFix "USBBusFix" /* usb.c */ +#define kEHCIacquire "EHCIacquire" /* usb.c */ +#define kUHCIreset "UHCIreset" /* usb.c */ +#define kLegacyOff "USBLegacyOff" /* usb.c */ +#define kEHCIhard "EHCIhard" /* usb.c */ #define kDefaultPartition "Default Partition" /* sys.c */ -#define kDeviceProperties "device-properties" /* device_inject.c */ -#define kHidePartition "Hide Partition" /* disk.c */ -#define kRenamePartition "Rename Partition" /* disk.c */ -#define kUseMemDetect "UseMemDetect" /* platform.c */ -#define kRestartFix "RestartFix" /* dsdt_patcher.c */ /* * Flags to the booter or kernel @@ -136,6 +139,11 @@ extern void common_boot(int biosdev); /* + * usb.c + */ +extern int usb_loop(); + +/* * graphics.c */ extern void printVBEModeInfo(); @@ -163,6 +171,7 @@ extern void drawPreview(void *src, uint8_t * saveunder); extern int getVideoMode(void); extern void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or); + /* * drivers.c */ Index: branches/blackosx/i386/boot2/drivers.c =================================================================== --- branches/blackosx/i386/boot2/drivers.c (revision 214) +++ branches/blackosx/i386/boot2/drivers.c (revision 215) @@ -198,26 +198,29 @@ if ( !(gBIOSBootVolume->biosdev == gBootVolume->biosdev && gBIOSBootVolume->part_no == gBootVolume->part_no) || (gRAMDiskVolume && gRAMDiskBTAliased) ) { - // 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); - } - } + // Next 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); + } + } } // Also try to load Extensions from boot helper partitions. - strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/"); - if (FileLoadDrivers(dirSpecExtra, 0) != 0) + if (gBootVolume->flags & kBVFlagBooter) { - strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/"); + strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/"); if (FileLoadDrivers(dirSpecExtra, 0) != 0) { - strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/"); - FileLoadDrivers(dirSpecExtra, 0); + strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/"); + if (FileLoadDrivers(dirSpecExtra, 0) != 0) + { + strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/"); + FileLoadDrivers(dirSpecExtra, 0); + } } } @@ -252,6 +255,31 @@ } //========================================================================== +// FileLoadMKext + +static long +FileLoadMKext( const char * dirSpec, const char * extDirSpec ) +{ + long ret, flags, time, time2; + char altDirSpec[512]; + + sprintf (altDirSpec, "%s%s", dirSpec, extDirSpec); + ret = GetFileInfo(altDirSpec, "Extensions.mkext", &flags, &time); + if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat)) + { + ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2); + if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeDirectory) || + (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1)))) + { + sprintf(gDriverSpec, "%sExtensions.mkext", altDirSpec); + verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec); + if (LoadDriverMKext(gDriverSpec) == 0) return 0; + } + } + return -1; +} + +//========================================================================== // FileLoadDrivers static long @@ -264,38 +292,14 @@ if ( !plugin ) { - long time2; + // First try 10.6's path for loading Extensions.mkext. + if (FileLoadMKext(dirSpec, "Caches/com.apple.kext.caches/Startup/") == 0) + return 0; - // TODO: refactor this part of code. - char altDirSpec[4500]; - sprintf (altDirSpec,"%sCaches/com.apple.kext.caches/Startup/",dirSpec); - ret = GetFileInfo(altDirSpec, "Extensions.mkext", &flags, &time); - if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat)) - { - ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2); - if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeDirectory) || - (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1)))) - { - sprintf(gDriverSpec, "%sExtensions.mkext", altDirSpec); - verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec); - if (LoadDriverMKext(gDriverSpec) == 0) return 0; - } - } - // + // Next try the legacy path. + else if (FileLoadMKext(dirSpec, "") == 0) + return 0; - ret = GetFileInfo(dirSpec, "Extensions.mkext", &flags, &time); - if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat)) - { - ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2); - if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeDirectory) || - (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1)))) - { - sprintf(gDriverSpec, "%sExtensions.mkext", dirSpec); - verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec); - if (LoadDriverMKext(gDriverSpec) == 0) return 0; - } - } - strcat(dirSpec, "Extensions"); } @@ -330,7 +334,7 @@ result = ret; if (!plugin) - result = FileLoadDrivers(gDriverSpec, 1); + FileLoadDrivers(gDriverSpec, 1); } return result; Index: branches/blackosx/i386/boot2/gui.c =================================================================== --- branches/blackosx/i386/boot2/gui.c (revision 214) +++ branches/blackosx/i386/boot2/gui.c (revision 215) @@ -13,14 +13,13 @@ #include "vers.h" #define THEME_NAME_DEFAULT "Default" -static const char *theme_name = THEME_NAME_DEFAULT; +static const char *theme_name = ""; //THEME_NAME_DEFAULT; +static bool rolloverfail = false; -static bool rolloverfail = false; // blackosx added to this as a flag to be raised if one or more rollover images are missing in the theme folder. - #ifdef EMBED_THEME #include "art.h" #define LOADPNG(img) \ -if (loadThemeImage(#img) != 0) \ +if (loadThemeImage(#img) == 2) \ if (loadEmbeddedThemeImage(#img, __## img ##_png, __## img ##_png_len) != 0) \ return 1; #else @@ -42,7 +41,6 @@ /* * ATTENTION: the enum and the following array images[] MUST match !!! */ -//blackosx - added extra variables to match rollover device images (with _o). enum { iBackground = 0, iLogo, @@ -87,7 +85,6 @@ iFontSmall, }; -//blackosx - added extra rollover device image (with _o) to images array after each normal device image. image_t images[] = { {.name = "background", .image = NULL}, {.name = "logo", .image = NULL}, @@ -165,7 +162,7 @@ static bool infoMenuNativeBoot = false; -static unsigned long screen_params[4] = {0, 0, 0, 0}; // here we store the used screen resolution +static unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0}; // here we store the used screen resolution #ifdef EMBED_THEME static int loadEmbeddedThemeImage(const char *image, unsigned char *image_data, unsigned int image_size) @@ -183,14 +180,15 @@ width = 0; height = 0; imagedata = NULL; - if ((loadEmbeddedPngImage(image_data, image_size, &width, &height, &imagedata)) != 0) { - return 1; + if ((loadEmbeddedPngImage(image_data, image_size, &width, &height, &imagedata)) == 0) { + images[i].image->width = width; + images[i].image->height = height; + images[i].image->pixels = (pixel_t *)imagedata; + flipRB(images[i].image); + return 0; } - images[i].image->width = width; - images[i].image->height = height; - images[i].image->pixels = (pixel_t *)imagedata; - flipRB(images[i].image); - return 0; + else + return 1; } } return 1; @@ -205,6 +203,9 @@ uint8_t *imagedata; char *cptr; // blackosx added + if (strlen(theme_name)==0) // blackosx - No theme asked for in com.apple.Boot.plist + return 2; + if ((strlen(image) + strlen(theme_name) + 20 ) > sizeof(dirspec)) { return 1; } @@ -233,8 +234,6 @@ return 1; // This means we have to drop out of using the GUI. } else { // We have a match for '_o' in image name, which means a rollover graphic is missing. - //printf("ERROR: GUI: ROLLOVER: could not open '%s/%s.png'!\n", theme_name, image); - //sleep(2); rolloverfail=true; return 0; } @@ -245,7 +244,6 @@ } -// blackosx added extra rollover devices. static int loadGraphics(void) { LOADPNG(background); @@ -615,25 +613,13 @@ #endif } // parse display size parameters - if (getIntForKey("screen_width", &val, &bootInfo->themeConfig)) { + if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && val > 0) { screen_params[0] = val; } - if (getIntForKey("screen_height", &val, &bootInfo->themeConfig)) { + if (getIntForKey("screen_height", &val, &bootInfo->themeConfig) && val > 0) { screen_params[1] = val; } - screen_params[2] = 32; - // blackosx - This solved an issue when the theme.plist had blank values for screen_height and screen_width. - // Thanks to Al Schar for pointing out Conti's fix and thanks to Conti for the fix. - /* Fix for "Memory allocation error! Addr=0xdeadbeef, Size=0x0" - if no VESA resolution defined in com.apple.Boot.plist */ - - if(!screen_params[0]) { - screen_params[0] = DEFAULT_SCREEN_WIDTH; - screen_params[1] = DEFAULT_SCREEN_HEIGHT; - } - - /* End Fix ~ Conti */ - // Initalizing GUI strucutre. bzero(&gui, sizeof(gui_t)); @@ -645,6 +631,7 @@ gui.screen.height = screen_params[1]; // load graphics otherwise fail and return + if (loadGraphics() == 0) { loadThemeValues(&bootInfo->themeConfig, true); colorFont(&font_small, gui.screen.font_small_color); @@ -673,7 +660,7 @@ return 1; } -void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool rollover) //blackosx - accept extra BOOLEAN variable 'rollover' to check for rollover image +void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool rollover) // blackosx - accept extra BOOLEAN variable { int devicetype; @@ -783,10 +770,9 @@ if(gui.menu.draw) drawInfoMenuItems(); - blend( images[iSelection].image, gui.devicelist.pixmap, centeredAt( images[iSelection].image, p ) ); - if (rolloverfail == false) // blackosx - if ALL the rollover graphics are in the theme folder - drawDeviceIcon( param, gui.devicelist.pixmap, p, true ); //blackosx - then draw the rollover image. - + blend( images[iSelection].image, gui.devicelist.pixmap, centeredAt( images[iSelection].image, p ) ); + if (rolloverfail == false) + drawDeviceIcon( param, gui.devicelist.pixmap, p, true ); #if DEBUG gui.debug.cursor = pos( 10, 100); dprintf( &gui.screen, "label %s\n", param->label ); @@ -805,11 +791,10 @@ #endif } else if (rolloverfail ==false) - drawDeviceIcon( param, gui.devicelist.pixmap, p, false ); //blackosx - draw non-highlighted normal device icon - - if (rolloverfail == true) // blackosx - draw the device icon on top of the device_selection only if we're not using rollover image. - drawDeviceIcon( param, gui.devicelist.pixmap, p, false ); //blackosx - added false to draw normal icon if it's not selected. - + drawDeviceIcon( param, gui.devicelist.pixmap, p, false ); + if (rolloverfail == true) + drawDeviceIcon( param, gui.devicelist.pixmap, p, false ); + if (gui.layout == HorizontalLayout) { p.x += images[iSelection].image->width + gui.devicelist.iconspacing; @@ -1730,12 +1715,16 @@ return; } sprintf(dirspec, "/Extra/Themes/%s/boot.png", theme_name); - if (loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0) { + + #ifdef EMBED_THEME if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) != 0) -#endif usePngImage = false; - } +#else + if (loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0) + usePngImage = false; +#endif + } //========================================================================== @@ -1755,23 +1744,16 @@ } // parse screen size parameters - // blackosx - Thanks to Al Schar for pointing out Conti's fix and thanks to Conti for the fix. - /* Fix for "Memory allocation error! Addr=0xdeadbeef, Size=0x0" - if no VESA resolution defined in com.apple.Boot.plist */ - - if (getIntForKey("boot_width", &pos, &bootInfo->themeConfig)) { + if (getIntForKey("boot_width", &pos, &bootInfo->themeConfig) && pos > 0) { screen_params[0] = pos; + } else { + screen_params[0] = DEFAULT_SCREEN_WIDTH; } - if (getIntForKey("boot_height", &pos, &bootInfo->themeConfig)) { + if (getIntForKey("boot_height", &pos, &bootInfo->themeConfig) && pos > 0) { screen_params[1] = pos; - } - screen_params[2] = 32; - - if(!screen_params[0]) { - screen_params[0] = DEFAULT_SCREEN_WIDTH; + } else { screen_params[1] = DEFAULT_SCREEN_HEIGHT; } - - /* End Fix ~ Conti */ gui.screen.width = screen_params[0]; gui.screen.height = screen_params[1]; Index: branches/blackosx/i386/boot2/gui.h =================================================================== --- branches/blackosx/i386/boot2/gui.h (revision 214) +++ branches/blackosx/i386/boot2/gui.h (revision 215) @@ -144,7 +144,7 @@ int dprintf( window_t * window, const char * fmt, ...); int gprintf( window_t * window, const char * fmt, ...); -int vprf(const char * fmt, va_list ap); +int vprf(const char * fmt, va_list ap); int drawInfoMenu(); int updateInfoMenu(int key); Index: branches/blackosx/i386/boot2/options.c =================================================================== --- branches/blackosx/i386/boot2/options.c (revision 214) +++ branches/blackosx/i386/boot2/options.c (revision 215) @@ -108,11 +108,11 @@ } else { - position_t p = pos( gui.screen.width / 2 + 1 , ( gui.devicelist.pos.y + 3 ) + ( ( gui.devicelist.height - gui.devicelist.iconspacing ) / 2 ) ); + position_t p = pos( gui.screen.width / 2 , ( gui.devicelist.pos.y ) + ( ( gui.devicelist.height - gui.devicelist.iconspacing ) / 2 ) ); // blackosx changed (though not sure as different resolutions show different results) char dummy[80]; getBootVolumeDescription( gBootVolume, dummy, 80, true ); - drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, false ); // blackosx added extra variable to pass. Usage: false = normal image + drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, false ); drawStrCenteredAt( (char *) msg, &font_small, gui.screen.pixmap, gui.countdown.pos ); // make this screen the new background Index: branches/blackosx/i386/boot2/Makefile =================================================================== --- branches/blackosx/i386/boot2/Makefile (revision 214) +++ branches/blackosx/i386/boot2/Makefile (revision 215) @@ -54,7 +54,7 @@ $(HFILES) $(OTHERFILES) DIRS_NEEDED = $(OBJROOT) $(SYMROOT) BOOT2ADDR = 20200 -MAXBOOTSIZE = 392704 +MAXBOOTSIZE = 458240 all: $(DIRS_NEEDED) boot Index: branches/blackosx/i386/cdboot/cdboot.s =================================================================== --- branches/blackosx/i386/cdboot/cdboot.s (revision 214) +++ branches/blackosx/i386/cdboot/cdboot.s (revision 215) @@ -114,7 +114,7 @@ ; at build time. kSectorBytes EQU 2048 ; sector size in bytes kBoot2Size EQU 65024 ; default load size for boot2 -kBoot2MaxSize EQU 392704 ; max size for boot2 +kBoot2MaxSize EQU 458240 ; max size for boot2 kBoot2Address EQU 0x0200 ; boot2 load address kBoot2Segment EQU 0x2000 ; boot2 load segment Index: branches/blackosx/i386/libsa/libsa.h =================================================================== --- branches/blackosx/i386/libsa/libsa.h (revision 214) +++ branches/blackosx/i386/libsa/libsa.h (revision 215) @@ -70,6 +70,11 @@ return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')); } +//Azi: TODO - add more ponctuation characters as needed; at least these two, i need for PartNo. +static inline int ispunct(char c) +{ + return (c == '.' || c == '-'); +} /* * string.c Index: branches/blackosx/i386/libsa/memory.h =================================================================== --- branches/blackosx/i386/libsa/memory.h (revision 214) +++ branches/blackosx/i386/libsa/memory.h (revision 215) @@ -48,7 +48,7 @@ # define BASE_SEG BOOT2_SEG #endif -#define STACK_SEG 0x8000 // zef: old STACK_SEG 0x5000 +#define STACK_SEG 0x1000 // zef: old STACK_SEG 0x5000 #define STACK_OFS 0xFFF0 // stack pointer #define BOOT1U_SEG 0x1000 @@ -57,7 +57,7 @@ #define BOOT2_SEG 0x2000 #define BOOT2_OFS 0x0200 // 512 byte disk sector offset -#define BIOS_ADDR 0x8000 // BIOS disk I/O buffer +#define BIOS_ADDR 0x9000 // BIOS disk I/O buffer #define BIOS_LEN 0x8000 // 32K - divisible by 512 and 2048 #define BOOT0_ADDR 0x7E00 // boot0 gets loaded here @@ -78,24 +78,24 @@ #define BOOT2_ADDR ADDR32(BOOT2_SEG, BOOT2_OFS) // TODO: BOOT_ADDR ? -#define HIB_ADDR 0x00040000 // special hibernation area +#define HIB_ADDR 0x00040000 // special hibernation area #define HIB_LEN 0x00060000 -#define VIDEO_ADDR 0x000A0000 // unusable space +#define VIDEO_ADDR 0x000A0000 // unusable space #define VIDEO_LEN 0x00060000 -#define KERNEL_ADDR 0x00100000 // 64M kernel + drivers -#define KERNEL_LEN 0x04000000 +#define KERNEL_ADDR 0x00100000 // 128M kernel + drivers +#define KERNEL_LEN 0x08000000 -#define ZALLOC_ADDR 0x04100000 // 256M zalloc area +#define ZALLOC_ADDR 0x08100000 // 256M zalloc area #define ZALLOC_LEN 0x10000000 -#define LOAD_ADDR 0x14100000 // 95M File load buffer -#define LOAD_LEN 0x05F80000 +#define LOAD_ADDR 0x18100000 // 64M File load buffer +#define LOAD_LEN 0x04000000 // Location of data fed to boot2 by the prebooter -#define PREBOOT_DATA 0x1A080000 // Still have enough room for a 95M ramdisk image - // in case of 512MB system memory. +#define PREBOOT_DATA 0x1C100000 // Still have enough room for a 63M ramdisk image + // in case of 512MB system memory. #define TFTP_ADDR LOAD_ADDR // tftp download buffer #define TFTP_LEN LOAD_LEN Index: branches/blackosx/CREDITS =================================================================== --- branches/blackosx/CREDITS (revision 214) +++ branches/blackosx/CREDITS (revision 215) @@ -3,33 +3,35 @@ Developers: ---------- - Crazor - Dense - fassl - iNDi - JrCs - Kabyl - kaitek - mackerintel - mercurysquad - munky - rekursor - Turbo - zef + Crazor + Dense + fassl + iNDi + JrCs + Kabyl + kaitek + mackerintel + mercurysquad + munky + meklort + mozodojo + rekursor + Turbo + valv + zef Thanks to: --------- - asereBLN - bumby - cosmo1t - dfe - Galaxy - kalyway - Krazubu - MasterChief - netkas - sckevyn - smith@@ - THeKiNG - XyZ - \ No newline at end of file + asereBLN + Azimutz + bumby + cosmo1t + dfe + Galaxy + kalyway + Krazubu + MasterChief + netkas + sckevyn + smith@@ + THeKiNG