Index: trunk/i386/libsaio/console.c =================================================================== --- trunk/i386/libsaio/console.c (revision 2538) +++ trunk/i386/libsaio/console.c (revision 2539) @@ -177,6 +177,7 @@ int printf(const char * fmt, ...) { va_list ap; + va_start(ap, fmt); if (bootArgs->Video.v_display == VGA_TEXT_MODE) { Index: trunk/i386/libsaio/device_tree.c =================================================================== --- trunk/i386/libsaio/device_tree.c (revision 2538) +++ trunk/i386/libsaio/device_tree.c (revision 2539) @@ -256,6 +256,7 @@ for (prop = allocedProperties; prop != NULL; prop = prop->next) { + free((void *)(prop->name)); free(prop->value); } Index: trunk/i386/libsaio/acpi_patcher.c =================================================================== --- trunk/i386/libsaio/acpi_patcher.c (revision 2538) +++ trunk/i386/libsaio/acpi_patcher.c (revision 2539) @@ -157,8 +157,8 @@ return NULL; } -uint8_t acpi_cpu_count = 0; -uint32_t acpi_cpu_p_blk = 0; +uint8_t acpi_cpu_count = 0; +uint32_t acpi_cpu_p_blk = 0; char *acpi_cpu_name[32]; void get_acpi_cpu_names(unsigned char *dsdt, uint32_t length) Index: trunk/i386/libsaio/spd.c =================================================================== --- trunk/i386/libsaio/spd.c (revision 2538) +++ trunk/i386/libsaio/spd.c (revision 2539) @@ -69,6 +69,19 @@ #define SMBHSTDAT 5 #define SBMBLKDAT 7 +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 one byte from the intel i2c, used for reading SPD on intel chipsets only. */ unsigned char smb_read_byte_intel(uint32_t base, uint8_t adr, uint8_t cmd) @@ -111,19 +124,6 @@ /* 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) { @@ -134,8 +134,8 @@ } } -/** Get Vendor Name from spd, 2 cases handled DDR3 and DDR2, - have different formats, always return a valid ptr.*/ +// 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, uint32_t base, int slot_num) { uint8_t bank = 0; @@ -143,29 +143,39 @@ int i = 0; uint8_t * spd = (uint8_t *) slot->spd; - if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) - { // DDR3 + if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) // DDR3 + { bank = (spd[SPD_DDR3_MEMORY_BANK] & 0x07f); // constructors like Patriot use b7=1 code = spd[SPD_DDR3_MEMORY_CODE]; - for (i=0; i < VEN_MAP_SIZE; i++) { - if (bank==vendorMap[i].bank && code==vendorMap[i].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 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) { - if(spd[64]==0x7f) { - for (i=64; i<72 && spd[i]==0x7f;i++) { + } + else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) + { + if(spd[64]==0x7f) + { + for (i=64; i<72 && spd[i]==0x7f;i++) + { bank++; READ_SPD(spd, base, slot_num, (uint8_t)(i+1)); // prefetch next spd byte to read for next loop } READ_SPD(spd, base, slot_num,(uint8_t)i); code = spd[i]; - } else { - code = spd[64]; + } + else + { + code = spd[64]; bank = 0; } - for (i=0; i < VEN_MAP_SIZE; i++) { - if (bank==vendorMap[i].bank && code==vendorMap[i].code) { + for (i=0; i < VEN_MAP_SIZE; i++) + { + if (bank==vendorMap[i].bank && code==vendorMap[i].code) + { return vendorMap[i].name; } } @@ -180,20 +190,11 @@ /* Get Default Memory Module Speed (no overclocking handled) */ int getDDRspeedMhz(const char * spd) { - if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) { - switch(spd[12]) { - case 0x0f: - return 1066; - case 0x0c: - return 1333; - case 0x0a: - return 1600; - case 0x14: - default: - return 800; - } - } else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) { - switch(spd[9]) { + + if ((spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR2) || (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR)) + { + switch(spd[9]) + { case 0x50: return 400; case 0x3d: @@ -207,6 +208,21 @@ return 1066; } } + else if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR3) + { + switch(spd[12]) + { + case 0x0f: + return 1066; + case 0x0c: + return 1333; + case 0x0a: + return 1600; + case 0x14: + default: + return 800; + } + } return 800; // default freq for unknown types } @@ -216,32 +232,35 @@ /* Get DDR3 or DDR2 serial number, 0 most of the times, always return a valid ptr */ const char *getDDRSerial(const char* spd) { - static char asciiSerial[16]; + static char asciiSerial[17]; - if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) // DDR3 + if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR3) // DDR3 { - snprintf(asciiSerial, sizeof(asciiSerial), "%X%X%X%X%X%X%X%X", SMST(122) /*& 0x7*/, SLST(122), SMST(123), SLST(123), SMST(124), SLST(124), SMST(125), SLST(125)); + snprintf(asciiSerial, sizeof(asciiSerial), "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(122) /*& 0x7*/, SLST(122), SMST(123), SLST(123), SMST(124), SLST(124), SMST(125), SLST(125)); } - else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) // DDR2 or DDR + else if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR) // DDR2 or DDR { - snprintf(asciiSerial, sizeof(asciiSerial), "%X%X%X%X%X%X%X%X", SMST(95) /*& 0x7*/, SLST(95), SMST(96), SLST(96), SMST(97), SLST(97), SMST(98), SLST(98)); - } else { - sprintf(asciiSerial, "000000000000000"); + snprintf(asciiSerial, sizeof(asciiSerial), "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(95) /*& 0x7*/, SLST(95), SMST(96), SLST(96), SMST(97), SLST(97), SMST(98), SLST(98)); } + else + { + sprintf(asciiSerial, "0000000000000000"); + } return strdup(asciiSerial); } /* Get DDR3 or DDR2 Part Number, always return a valid ptr */ -const char * getDDRPartNum(char* spd, uint32_t base, int slot) +const char *getDDRPartNum(char *spd, uint32_t base, int slot) { static char asciiPartNo[32]; int i, start=0, index = 0; - if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) { + if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR3) + { start = 128; } - else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) + else if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR) { start = 73; } @@ -249,13 +268,17 @@ // Check that the spd part name is zero terminated and that it is ascii: bzero(asciiPartNo, sizeof(asciiPartNo)); char c; - for (i=start; i < start + sizeof(asciiPartNo); i++) { - READ_SPD(spd, base, slot, i); // only read once the corresponding model part (ddr3 or ddr2) + for (i = start; i < start + sizeof(asciiPartNo); i++) + { + READ_SPD(spd, base, slot, (uint8_t)i); // only read once the corresponding model part (ddr3 or ddr2) c = spd[i]; - if (isalpha(c) || isdigit(c) || ispunct(c)) { + if (isalpha(c) || isdigit(c) || ispunct(c)) + { // It seems that System Profiler likes only letters and digits... asciiPartNo[index++] = c; - } else if (!isascii(c)) { + } + else if (!isascii(c)) + { break; } } @@ -265,7 +288,6 @@ int mapping []= {0,2,1,3,4,6,5,7,8,10,9,11}; - /* Read from smbus the SPD content and interpret it for detecting memory attributes */ static void read_smb_intel(pci_dt_t *smbus_dev) { int i, speed; @@ -281,9 +303,10 @@ mmio = pci_config_read32(smbus_dev->dev.addr, 0x10);// & ~0x0f; base = pci_config_read16(smbus_dev->dev.addr, 0x20) & 0xFFFE; hostc = pci_config_read8(smbus_dev->dev.addr, 0x40); - verbose("Scanning SMBus [%04x:%04x], mmio: 0x%x, ioport: 0x%x, hostc: 0x%x\n", - smbus_dev->vendor_id, smbus_dev->device_id, mmio, base, hostc); + verbose("Scanning SMBus [%04x:%04x], mmio: 0x%x, ioport: 0x%x, hostc: 0x%x\n", + smbus_dev->vendor_id, smbus_dev->device_id, mmio, base, hostc); + //Azi: no use for this! // getBoolForKey("DumpSPD", &dump, &bootInfo->chameleonConfig); // needed at least for laptops @@ -296,8 +319,8 @@ spd_size = smb_read_byte_intel(base, 0x50 + i, 0); DBG("SPD[0] (size): %d @0x%x\n", spd_size, 0x50 + i); // Check spd is present - if (spd_size && (spd_size != 0xff)) { - + if (spd_size && (spd_size != 0xff)) + { slot->spd = spdbuf; slot->InUse = true; @@ -308,13 +331,14 @@ //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]) { + switch (slot->spd[SPD_MEMORY_TYPE]) + { case SPD_MEMORY_TYPE_SDRAM_DDR: slot->ModuleSize = (((1 << ((slot->spd[SPD_NUM_ROWS] & 0x0f) - + (slot->spd[SPD_NUM_COLUMNS] & 0x0f) - 17)) * - ((slot->spd[SPD_NUM_DIMM_BANKS] & 0x7) + 1) * - slot->spd[SPD_NUM_BANKS_PER_SDRAM])/3)*2; + + (slot->spd[SPD_NUM_COLUMNS] & 0x0f) - 17)) * + ((slot->spd[SPD_NUM_DIMM_BANKS] & 0x7) + 1) * + slot->spd[SPD_NUM_BANKS_PER_SDRAM])/3)*2; break; case SPD_MEMORY_TYPE_SDRAM_DDR2: @@ -330,11 +354,17 @@ slot->ModuleSize = ((1 << slot->ModuleSize) * (((slot->spd[7] >> 3) & 0x1f) + 1)); break; + + default: + slot->ModuleSize = 0; + break; + } spd_type = (slot->spd[SPD_MEMORY_TYPE] < ((char) 12) ? slot->spd[SPD_MEMORY_TYPE] : 0); slot->Type = spd_mem_to_smbios[spd_type]; - if (slot->Type == UNKNOWN_MEM_TYPE) { + if (slot->Type == UNKNOWN_MEM_TYPE) + { continue; } slot->PartNo = getDDRPartNum(slot->spd, base, i); @@ -342,17 +372,20 @@ slot->SerialNo = getDDRSerial(slot->spd); // determine spd speed - speed = getDDRspeedMhz(slot->spd); - if (slot->Frequency < speed) { + speed = (uint16_t)getDDRspeedMhz(slot->spd); + if (slot->Frequency < speed) + { slot->Frequency = speed; } // pci memory controller if available, is more reliable - if (Platform.RAM.Frequency > 0) { + if (Platform.RAM.Frequency > 0) + { uint32_t freq = (uint32_t)Platform.RAM.Frequency / 500000; // now round off special cases uint32_t fmod100 = freq %100; - switch(fmod100) { + switch(fmod100) + { case 1: freq--; break; case 32: freq++; break; case 65: freq++; break; @@ -362,22 +395,22 @@ slot->Frequency = freq; } - verbose("Slot: %d Type %d %dMB (%s) %dMHz Vendor=%s\n PartNo=%s SerialNo=%s\n", - i, - (int)slot->Type, - slot->ModuleSize, - spd_memory_types[spd_type], - slot->Frequency, - slot->Vendor, - slot->PartNo, - slot->SerialNo); - slot->InUse = true; + verbose("Slot: %d Type %d %dMB (%s) %dMHz Vendor=%s\n PartNo=%s SerialNo=%s\n", + i, + (int)slot->Type, + slot->ModuleSize, + spd_memory_types[spd_type], + slot->Frequency, + slot->Vendor, + slot->PartNo, + slot->SerialNo); + slot->InUse = true; } // laptops sometimes show slot 0 and 2 with slot 1 empty when only 2 slots are presents so: Platform.DMI.DIMM[i]= - (uint32_t)((i>0 && Platform.RAM.DIMM[1].InUse==false && fullBanks && Platform.DMI.CntMemorySlots == 2) ? - mapping[i] : i); // for laptops case, mapping setup would need to be more generic than this + (uint32_t)((i > 0 && Platform.RAM.DIMM[1].InUse == false && fullBanks && Platform.DMI.CntMemorySlots == 2) ? mapping[i] : i); // for laptops case, mapping setup would need to be more generic than this + slot->spd = NULL; } // for @@ -423,15 +456,18 @@ pci_dt_t *current = pci_dt; int i; - while (current) { + while (current) + { #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, get_pci_dev_path(current)); #endif - for ( i = 0; i < sizeof(smbus_controllers) / sizeof(smbus_controllers[0]); i++ ) { - if (current->vendor_id == smbus_controllers[i].vendor && current->device_id == smbus_controllers[i].device) { + for ( i = 0; i < sizeof(smbus_controllers) / sizeof(smbus_controllers[0]); i++ ) + { + if (current->vendor_id == smbus_controllers[i].vendor && current->device_id == smbus_controllers[i].device) + { smbus_controllers[i].read_smb(current); // read smb return true; } Index: trunk/i386/libsaio/pci_root.c =================================================================== --- trunk/i386/libsaio/pci_root.c (revision 2538) +++ trunk/i386/libsaio/pci_root.c (revision 2539) @@ -53,24 +53,40 @@ const char * dsdt_filename = NULL; extern int search_and_get_acpi_fd(const char *, const char **); - if (rootuid < 10) return rootuid; + if (rootuid < 10) + { + return rootuid; + } + rootuid = 0; /* default uid = 0 */ - if (getValueForKey(kPCIRootUID, &val, &len, &bootInfo->chameleonConfig)) { - if (isdigit(val[0])) rootuid = val[0] - '0'; + if (getValueForKey(kPCIRootUID, &val, &len, &bootInfo->chameleonConfig)) + { + if (isdigit(val[0])) + { + rootuid = val[0] - '0'; + } + goto out; } /* Chameleon compatibility */ - else if (getValueForKey("PciRoot", &val, &len, &bootInfo->chameleonConfig)) { - if (isdigit(val[0])) rootuid = val[0] - '0'; + else if (getValueForKey("PciRoot", &val, &len, &bootInfo->chameleonConfig)) + { + if (isdigit(val[0])) + { + rootuid = val[0] - '0'; + } + goto out; } /* PCEFI compatibility */ - else if (getValueForKey("-pci0", &val, &len, &bootInfo->chameleonConfig)) { + else if (getValueForKey("-pci0", &val, &len, &bootInfo->chameleonConfig)) + { rootuid = 0; goto out; } - else if (getValueForKey("-pci1", &val, &len, &bootInfo->chameleonConfig)) { + else if (getValueForKey("-pci1", &val, &len, &bootInfo->chameleonConfig)) + { rootuid = 1; goto out; } @@ -84,17 +100,17 @@ { sprintf(dsdt_dirSpec, "DSDT.aml"); } - + int fd = search_and_get_acpi_fd(dsdt_dirSpec, &dsdt_filename); // Check booting partition if (fd<0) { - verbose("No DSDT found, using 0 as uid value.\n"); - rootuid = 0; - goto out; + verbose("No DSDT found, using 0 as uid value.\n"); + rootuid = 0; + goto out; } - + fsize = file_size(fd); if (!(new_dsdt = malloc(fsize))) @@ -116,7 +132,10 @@ free(new_dsdt); // make sure it really works: - if (rootuid == 11) rootuid=0; //usually when _UID isnt present, it means uid is zero + if (rootuid == 11) + { + rootuid=0; //usually when _UID isnt present, it means uid is zero + } else if (rootuid < 0 || rootuid > 9) { printf("PciRoot uid value wasnt found, using 0, if you want it to be 1, use -PciRootUID flag"); Index: trunk/i386/libsaio/device_inject.c =================================================================== --- trunk/i386/libsaio/device_inject.c (revision 2538) +++ trunk/i386/libsaio/device_inject.c (revision 2539) @@ -23,11 +23,11 @@ #define DBG(x...) msglog(x) #endif -uint32_t devices_number = 1; -uint32_t builtin_set = 0; -DevPropString *string = 0; -uint8_t *stringdata = 0; -uint32_t stringlength = 0; +uint32_t devices_number = 1; +uint32_t builtin_set = 0; +DevPropString *string = 0; +uint8_t *stringdata = 0; +uint32_t stringlength = 0; char *efi_inject_get_devprop_string(uint32_t *len) { @@ -55,14 +55,17 @@ /* Use the static "device-properties" boot config key contents if available, * otheriwse use the generated one. */ - if (!getValueForKey(kDeviceProperties, &val, &cnt, &bootInfo->chameleonConfig) && string) { + if (!getValueForKey(kDeviceProperties, &val, &cnt, &bootInfo->chameleonConfig) && string) + { val = (const char*)string; cnt = strlength * 2; } - if (cnt > 1) { + if (cnt > 1) + { binStr = convertHexStr2Binary(val, &cnt2); - if (cnt2 > 0) { + if (cnt2 > 0) + { DT__AddProperty(node, DEVICE_PROPERTIES_PROP, cnt2, binStr); DBG("Adding device-properties string to DT"); } @@ -73,7 +76,8 @@ { string = (struct DevPropString *)malloc(sizeof(struct DevPropString)); - if(string == NULL) { + if(string == NULL) + { return NULL; } @@ -85,20 +89,24 @@ DevPropDevice *devprop_add_device(DevPropString *string, char *path) { - DevPropDevice *device = NULL; - const char pciroot_string[] = "PciRoot(0x"; - const char pci_device_string[] = "Pci(0x"; + DevPropDevice *device = NULL; + const char pciroot_string[] = "PciRoot(0x"; + const char pci_device_string[] = "Pci(0x"; - if (string == NULL || path == NULL) { + if (string == NULL || path == NULL) + { printf("ERROR null device path\n"); return NULL; } - if (strncmp(path, pciroot_string, strlen(pciroot_string))) { + if (strncmp(path, pciroot_string, strlen(pciroot_string))) + { printf("ERROR parsing device path\n"); return NULL; } - if (!(device = malloc(sizeof(DevPropDevice)))) { + + if (!(device = malloc(sizeof(DevPropDevice)))) + { printf("ERROR malloc failed\n"); return NULL; } @@ -110,16 +118,23 @@ int x, curr = 0; char buff[] = "00"; - for (x = 0; x < strlen(path); x++) { - if (!strncmp(&path[x], pci_device_string, strlen(pci_device_string))) { + for (x = 0; x < strlen(path); x++) + { + if (!strncmp(&path[x], pci_device_string, strlen(pci_device_string))) + { x+=strlen(pci_device_string); curr=x; while(path[++x] != ','); - if(x-curr == 2) { + if(x-curr == 2) + { sprintf(buff, "%c%c", path[curr], path[curr+1]); - } else if(x-curr == 1) { + } + else if(x-curr == 1) + { sprintf(buff, "%c", path[curr]); - } else { + } + else + { printf("ERROR parsing device path\n"); numpaths = 0; break; @@ -129,11 +144,16 @@ x += 3; // 0x curr = x; while(path[++x] != ')'); - if(x-curr == 2) { + if(x-curr == 2) + { sprintf(buff, "%c%c", path[curr], path[curr+1]); - } else if(x-curr == 1) { + } + else if(x-curr == 1) + { sprintf(buff, "%c", path[curr]); - } else { + } + else + { printf("ERROR parsing device path\n"); numpaths = 0; break; @@ -144,24 +164,26 @@ } } - if(!numpaths) { + if(!numpaths) + { free(device); return NULL; } device->numentries = 0x00; - device->acpi_dev_path.length = 0x0c; - device->acpi_dev_path.type = 0x02; - device->acpi_dev_path.subtype = 0x01; - device->acpi_dev_path._HID = 0xd041030a; + device->acpi_dev_path.length = 0x0c; + device->acpi_dev_path.type = 0x02; + device->acpi_dev_path.subtype = 0x01; + device->acpi_dev_path._HID = 0xd041030a; device->num_pci_devpaths = numpaths; device->length = 24 + (6*numpaths); int i; - for(i = 0; i < numpaths; i++) { + for(i = 0; i < numpaths; i++) + { device->pci_dev_path[i].length = 0x06; device->pci_dev_path[i].type = 0x01; device->pci_dev_path[i].subtype = 0x01; @@ -174,8 +196,10 @@ device->string = string; device->data = NULL; - if(!string->entries) { - if (!(string->entries = (struct DevPropDevice**) malloc(sizeof(device) * DEV_PROP_DEVICE_MAX_ENTRIES))) { + if(!string->entries) + { + if (!(string->entries = (struct DevPropDevice**) malloc(sizeof(device) * DEV_PROP_DEVICE_MAX_ENTRIES))) + { free(device); return NULL; } @@ -192,24 +216,27 @@ int devprop_add_value(DevPropDevice *device, char *nm, uint8_t *vl, uint32_t len) { - if(!nm || !vl || !len) { + if(!nm || !vl || !len) + { return 0; } - uint32_t length = ((strlen(nm) * 2) + len + (2 * sizeof(uint32_t)) + 2); - uint8_t *data = (uint8_t*)malloc(length); + uint32_t length = ((strlen(nm) * 2) + len + (2 * sizeof(uint32_t)) + 2); + uint8_t *data = (uint8_t*)malloc(length); - if(!data) { + if(!data) + { return 0; } memset(data, 0, length); - uint32_t off= 0; + uint32_t off = 0; data[off+1] = ((strlen(nm) * 2) + 6) >> 8; data[off] = ((strlen(nm) * 2) + 6) & 0x00FF; off += 4; uint32_t i=0, l = strlen(nm); - for(i = 0 ; i < l ; i++, off += 2) { + for(i = 0 ; i < l ; i++, off += 2) + { data[off] = *nm++; } @@ -218,31 +245,39 @@ uint32_t *datalength = (uint32_t*)&data[off]; *datalength = (uint32_t)(l + 4); off += 4; - for(i = 0 ; i < l ; i++, off++) { + for(i = 0 ; i < l ; i++, off++) + { data[off] = *vl++; } uint32_t offset = device->length - (24 + (6 * device->num_pci_devpaths)); uint8_t *newdata = (uint8_t*)malloc((length + offset)); - if(!newdata) { + if(!newdata) + { return 0; } - if(device->data) { - if(offset > 1) { + + if(device->data) + { + if(offset > 1) + { memcpy(newdata, device->data, offset); } } memcpy(newdata + offset, data, length); - + device->length += length; device->string->length += length; device->numentries++; - if(!device->data) { + if(!device->data) + { device->data = (uint8_t*)malloc(sizeof(uint8_t)); - } else { + } + else + { free(device->data); } @@ -345,9 +380,12 @@ } int i; - for(i = 0; i < string->numentries; i++) { - if(string->entries[i]) { - if(string->entries[i]->data) { + for(i = 0; i < string->numentries; i++) + { + if(string->entries[i]) + { + if(string->entries[i]->data) + { free(string->entries[i]->data); string->entries[i]->data = NULL; } @@ -373,7 +411,8 @@ int i; char buf[3]; - if (hex == NULL || bin == NULL || len <= 0 || strlen(hex) != len * 2) { + if (hex == NULL || bin == NULL || len <= 0 || strlen(hex) != len * 2) + { printf("[ERROR] bin2hex input error\n"); return -1; } @@ -381,8 +420,10 @@ buf[2] = '\0'; p = (char *) hex; - for (i = 0; i < len; i++) { - if (p[0] == '\0' || p[1] == '\0' || !isxdigit(p[0]) || !isxdigit(p[1])) { + for (i = 0; i < len; i++) + { + if (p[0] == '\0' || p[1] == '\0' || !isxdigit(p[0]) || !isxdigit(p[1])) + { printf("[ERROR] bin2hex '%s' syntax error\n", hex); return -2; } @@ -400,15 +441,22 @@ int devprop_add_network_template(DevPropDevice *device, uint16_t vendor_id) { if(!device) + { return 0; + } + uint8_t builtin = 0x0; if((vendor_id != 0x168c) && (builtin_set == 0)) { builtin_set = 1; builtin = 0x01; } + if(!devprop_add_value(device, "built-in", (uint8_t*)&builtin, 1)) + { return 0; + } + devices_number++; return 1; } @@ -420,16 +468,19 @@ verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath); - if(!string) { + if(!string) + { string = devprop_create_string(); } device = devprop_add_device(string, devicepath); - if(device) { + if(device) + { verbose("Setting up lan keys\n"); devprop_add_network_template(device, eth_dev->vendor_id); stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length); - if(stringdata) { + if(stringdata) + { memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length); stringlength = string->length; } Index: trunk/i386/libsaio/ntfs.c =================================================================== --- trunk/i386/libsaio/ntfs.c (revision 2538) +++ trunk/i386/libsaio/ntfs.c (revision 2539) @@ -31,7 +31,7 @@ */ #include "exfat.h" -#define BYTE_ORDER_MARK 0xFEFF +#define BYTE_ORDER_MARK 0xFEFF #include "ntfs_private.h" @@ -41,14 +41,14 @@ #define MAX_BLOCK_SIZE 2048 #define MAX_CLUSTER_SIZE 32768 -#define LABEL_LENGTH 1024 -#define UNKNOWN_LABEL "Untitled NTFS" +#define LABEL_LENGTH 1024 +#define UNKNOWN_LABEL "Untitled NTFS" -#define FSUR_IO_FAIL -1 -#define FSUR_UNRECOGNIZED -1 -#define FSUR_RECOGNIZED 0 +#define FSUR_IO_FAIL -1 +#define FSUR_UNRECOGNIZED -1 +#define FSUR_RECOGNIZED 0 -#define ERROR -1 +#define ERROR -1 /* * Process per-sector "fixups" that NTFS uses to detect corruption of @@ -313,6 +313,7 @@ { return -1; } + bzero(buf,MAX_BLOCK_SIZE); /* * Read the boot sector, check signatures, and do some minimal @@ -329,12 +330,14 @@ if ( memcmp((void*)boot->bf_sysid, NTFS_BBID, NTFS_BBIDLEN) != 0 ) { // If not NTFS, maybe it is EXFAT + free(buf); return EXFATGetUUID(ih, uuidStr); } // Check for non-null volume serial number if( !boot->bf_volsn ) { + free(buf); return -1; } @@ -344,11 +347,11 @@ return 0; } -bool NTFSProbe(const void * buffer) +bool NTFSProbe(const void *buffer) { bool result = false; - const struct bootfile * part_bootfile = buffer; // NTFS boot sector structure + const struct bootfile *part_bootfile = buffer; // NTFS boot sector structure // Looking for NTFS signature. if (strncmp((const char *)part_bootfile->bf_sysid, NTFS_BBID, NTFS_BBIDLEN) == 0) Index: trunk/i386/libsaio/disk.c =================================================================== --- trunk/i386/libsaio/disk.c (revision 2538) +++ trunk/i386/libsaio/disk.c (revision 2539) @@ -154,27 +154,26 @@ static const struct NamedValue fdiskTypes[] = { - { FDISK_DOS12, "DOS_FAT_12" }, - { FDISK_DOS16S, "DOS_FAT_16_S" }, - { FDISK_DOS16B, "DOS_FAT_16" }, - { FDISK_NTFS, "Windows NTFS" }, - { FDISK_DOS16SLBA, "Windows FAT16" }, - - { FDISK_FAT32, "Windows FAT32" }, - { FDISK_SMALLFAT32, "Windows FAT32" }, - - { FDISK_LINUX, "Linux" }, - - - { FDISK_FREEBSD, "FreeBSD" }, - { FDISK_OPENBSD, "OpenBSD" }, + { FDISK_DOS12, "DOS_FAT_12" }, // 0x01 + { FDISK_DOS16S, "DOS_FAT_16_S" }, // 0x04 + { FDISK_DOS16B, "DOS_FAT_16" }, // 0x06 + { FDISK_NTFS, "Windows NTFS" }, // 0x07 + { FDISK_SMALLFAT32, "DOS_FAT_32" }, // 0x0B + { FDISK_FAT32, "Windows FAT_32" }, // 0x0C + { FDISK_DOS16SLBA, "Windows FAT_16" }, // 0x0E + { FDISK_WIN_LDM, "Windows_LDM" }, // 0x42 + { FDISK_LINUX_SWAP, "Linux_Swap" }, // 0x82 + { FDISK_LINUX, "Linux" }, // 0x83 + { FDISK_LINUX_LVM, "Linux_LVM" }, // 0x8E + { FDISK_FREEBSD, "FreeBSD" }, // 0xA5 + { FDISK_OPENBSD, "OpenBSD" }, // 0xA6 { FDISK_NEXTNAME, "Apple_Rhapsody_UFS" }, // 0xA7 - { FDISK_UFS, "Apple UFS" }, + { FDISK_UFS, "Apple UFS" }, // 0xA8 { FDISK_NETBSD, "NetBSD" }, // 0xA9 { FDISK_BOOTER, "Apple_Boot" }, // 0xAB { FDISK_ENCRYPTED, "Apple_Encrypted" }, // 0xAE { FDISK_HFS, "Apple HFS" }, // 0xAF - { 0xCD, "CD-ROM" }, + { 0xCD, "CD-ROM" }, // 0xCD { FDISK_BEFS, "Haiku" }, // 0xEB { FDISK_LINUX_RAID, "Linux_RAID" }, // 0xFD { 0x00, NULL } /* must be last */ @@ -593,17 +592,14 @@ { result = FDISK_FREEBSD; } - else if (OpenBSDProbe(probeBuffer)) { result = FDISK_OPENBSD; } - else if (BeFSProbe(probeBuffer)) { result = FDISK_BEFS; } - else if (NTFSProbe(probeBuffer)) { result = FDISK_NTFS; @@ -1529,7 +1525,8 @@ // NOTE: EFI_GUID's are in LE and we know we're on an x86. // The IOGUIDPartitionScheme.cpp code uses byte-based UUIDs, we don't. - if (isPartitionUsed(gptMap)) { + if (isPartitionUsed(gptMap)) + { char stringuuid[100]; efi_guid_unparse_upper((EFI_GUID*)gptMap->ent_type, stringuuid); verbose("Reading GPT partition %d, type %s\n", gptID, stringuuid); @@ -1537,7 +1534,8 @@ // Getting fdisk like partition type. fsType = probeFileSystem(biosdev, gptMap->ent_lba_start); - if ( (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) || (efi_guid_compare(&GPT_HFS_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ) { + if ( (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) || (efi_guid_compare(&GPT_HFS_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ) + { bvrFlags = (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ? kBVFlagBooter : 0; bvr = newGPTBVRef(biosdev, gptID, @@ -1645,7 +1643,8 @@ break; default: - if (biosdev == gBIOSDev) { + if (biosdev == gBIOSDev) + { gBIOSBootVolume = bvr; } break; @@ -1752,6 +1751,7 @@ { const char *val; int len; + if (getValueForKey(kProductVersion, &val, &len, &systemVersion)) { // getValueForKey uses const char for val @@ -1875,6 +1875,11 @@ void rescanBIOSDevice(int biosdev) { struct DiskBVMap *oldMap = diskResetBootVolumes(biosdev); + if (oldMap == NULL) + { + return; + } + CacheReset(); diskFreeMap(oldMap); oldMap = NULL; @@ -1907,7 +1912,8 @@ } else { - stop(""); + stop("diskResetBootVolumes error\n"); + return NULL; } } // Return the old map, either to be freed, or reinserted later @@ -1958,6 +1964,7 @@ { bvr = diskScanFDiskBootVolumes(biosdev, &count); } + if (bvr == NULL) { bvr = diskScanAPMBootVolumes(biosdev, &count); @@ -2046,6 +2053,8 @@ { continue; } + bzero(newBVR,sizeof(*newBVR)); + bcopy(bvr, newBVR, sizeof(*newBVR)); /* @@ -2108,6 +2117,10 @@ #if DEBUG //Azi: warning - too big for boot-log.. far too big.. i mean HUGE!! :P for (bvr = chain; bvr; bvr = bvr->next) { + if (!bvr) + { + break; + } printf(" bvr: %d, dev: %d, part: %d, flags: %d, vis: %d\n", bvr, bvr->biosdev, bvr->part_no, bvr->flags, bvr->visible); } printf("count: %d\n", bvCount); @@ -2130,6 +2143,11 @@ while (bvr) { + if (!bvr) + { + break; + } + nextBVR = bvr->next; if (bvr->filtered) Index: trunk/i386/libsaio/smbios.c =================================================================== --- trunk/i386/libsaio/smbios.c (revision 2538) +++ trunk/i386/libsaio/smbios.c (revision 2539) @@ -34,79 +34,79 @@ /* ======================= BIOS Information (Type 0) ========================= */ -#define kSMBBIOSInformationVendorKey "SMbiosvendor" // Apple Inc. -#define kSMBBIOSInformationVersionKey "SMbiosversion" // MP31.88Z.006C.B05.0802291410 -#define kSMBBIOSInformationReleaseDateKey "SMbiosdate" // 02/29/08 +#define kSMBBIOSInformationVendorKey "SMbiosvendor" // Apple Inc. +#define kSMBBIOSInformationVersionKey "SMbiosversion" // MP31.88Z.006C.B05.0802291410 +#define kSMBBIOSInformationReleaseDateKey "SMbiosdate" // 02/29/08 // Bungo -#define kSMBBIOSInformationReleaseKey "SMbiosrelease" // BIOS Revision +#define kSMBBIOSInformationReleaseKey "SMbiosrelease" // BIOS Revision // example: BIOS Revision: 1.23 --> 2 bytes: Major=0x01, Minor=0x17 --> after swap: 0x1701hex = 5889dec (SMBIOS_spec_DSP0134_2.7.1) /* ========================= System Information (Type 1) =========================== */ -#define kSMBSystemInformationManufacturerKey "SMmanufacturer" // Apple Inc. -#define kSMBSystemInformationProductNameKey "SMproductname" // MacPro3,1 -#define kSMBSystemInformationVersionKey "SMsystemversion" // 1.0 -#define kSMBSystemInformationSerialNumberKey "SMserial" // Serial number +#define kSMBSystemInformationManufacturerKey "SMmanufacturer" // Apple Inc. +#define kSMBSystemInformationProductNameKey "SMproductname" // MacPro3,1 +#define kSMBSystemInformationVersionKey "SMsystemversion" // 1.0 +#define kSMBSystemInformationSerialNumberKey "SMserial" // Serial number //Bungo -#define kSMBSystemInformationUUIDKey "SMsystemuuid" // ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }' -#define kSMBSystemInformationSKUNumberKey "SMskunumber" // System SKU# +#define kSMBSystemInformationUUIDKey "SMsystemuuid" // ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }' +#define kSMBSystemInformationSKUNumberKey "SMskunumber" // System SKU# -#define kSMBSystemInformationFamilyKey "SMfamily" // MacPro +#define kSMBSystemInformationFamilyKey "SMfamily" // MacPro /* ========================================= Base Board (or Module) Information (Type 2) =========================================== */ -#define kSMBBaseBoardManufacturerKey "SMboardmanufacturer" // Apple Inc. -#define kSMBBaseBoardProductKey "SMboardproduct" // Mac-F2268DC8 +#define kSMBBaseBoardManufacturerKey "SMboardmanufacturer" // Apple Inc. +#define kSMBBaseBoardProductKey "SMboardproduct" // Mac-F2268DC8 // Bungo -#define kSMBBaseBoardVersionKey "SMboardversion" // MacPro3,1 -#define kSMBBaseBoardSerialNumberKey "SMboardserial" // C02140302D5DMT31M -#define kSMBBaseBoardAssetTagKey "SMboardassettag" // Base Board Asset Tag# Bungo: renamed folowing convention -#define kSMBBaseBoardLocationInChassisKey "SMboardlocation" // Part Component +#define kSMBBaseBoardVersionKey "SMboardversion" // MacPro3,1 +#define kSMBBaseBoardSerialNumberKey "SMboardserial" // C02140302D5DMT31M +#define kSMBBaseBoardAssetTagKey "SMboardassettag" // Base Board Asset Tag# Bungo: renamed folowing convention +#define kSMBBaseBoardLocationInChassisKey "SMboardlocation" // Part Component // ErmaC BoardType 0x0a(10) or 0x0b(11) MacPro Family -#define kSMBBaseBoardTypeKey "SMboardtype" // 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro +#define kSMBBaseBoardTypeKey "SMboardtype" // 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro // Bungo /* ======================= System Enclosure (Type 3) ========================= */ -#define kSMBSystemEnclosureManufacturerKey "SMchassismanufacturer" // Apple Inc. -#define kSMBSystemEnclosureTypeKey "SMchassistype" // 7 Desktop -#define kSMBSystemEnclosureVersionKey "SMchassisversion" // Mac-F42C88C8 -#define kSMBSystemEnclosureSerialNumberKey "SMchassisserial" // Serial number -#define kSMBSystemEnclosureAssetTagKey "SMchassisassettag" // Pro-Enclosure Bungo: renamed folowing convention +#define kSMBSystemEnclosureManufacturerKey "SMchassismanufacturer" // Apple Inc. +#define kSMBSystemEnclosureTypeKey "SMchassistype" // 7 Desktop +#define kSMBSystemEnclosureVersionKey "SMchassisversion" // Mac-F42C88C8 +#define kSMBSystemEnclosureSerialNumberKey "SMchassisserial" // Serial number +#define kSMBSystemEnclosureAssetTagKey "SMchassisassettag" // Pro-Enclosure Bungo: renamed folowing convention /* ============================ Processor Information (Type 4) ============================== */ // Bungo -#define kSMBProcessorInformationSocketKey "SMcpusocket" -#define kSMBProcessorInformationManufacturerKey "SMcpumanufacturer" -#define kSMBProcessorInformationVersionKey "SMcpuversion" +#define kSMBProcessorInformationSocketKey "SMcpusocket" +#define kSMBProcessorInformationManufacturerKey "SMcpumanufacturer" +#define kSMBProcessorInformationVersionKey "SMcpuversion" // #define kSMBProcessorInformationExternalClockKey "SMexternalclock" #define kSMBProcessorInformationMaximumClockKey "SMmaximalclock" // Bungo -#define kSMBProcessorInformationCurrentClockKey "SMcurrentclock" -#define kSMBProcessorInformationUpgradeKey "SMcpuupgrade" -#define kSMBProcessorInformationSerialNumberKey "SMcpuserial" -#define kSMBProcessorInformationAssetTagKey "SMcpuassettag" // Bungo: renamed folowing convention -#define kSMBProcessorInformationPartNumberKey "SMcpupartnumber" +#define kSMBProcessorInformationCurrentClockKey "SMcurrentclock" +#define kSMBProcessorInformationUpgradeKey "SMcpuupgrade" +#define kSMBProcessorInformationSerialNumberKey "SMcpuserial" +#define kSMBProcessorInformationAssetTagKey "SMcpuassettag" // Bungo: renamed folowing convention +#define kSMBProcessorInformationPartNumberKey "SMcpupartnumber" /* ===================== Memory Device (Type 17) ======================= */ -#define kSMBMemoryDeviceDeviceLocatorKey "SMmemdevloc" // -#define kSMBMemoryDeviceBankLocatorKey "SMmembankloc" // -#define kSMBMemoryDeviceMemoryTypeKey "SMmemtype" // -#define kSMBMemoryDeviceMemorySpeedKey "SMmemspeed" // -#define kSMBMemoryDeviceManufacturerKey "SMmemmanufacturer" // -#define kSMBMemoryDeviceSerialNumberKey "SMmemserial" // -#define kSMBMemoryDevicePartNumberKey "SMmempart" // +#define kSMBMemoryDeviceDeviceLocatorKey "SMmemdevloc" // +#define kSMBMemoryDeviceBankLocatorKey "SMmembankloc" // +#define kSMBMemoryDeviceMemoryTypeKey "SMmemtype" // +#define kSMBMemoryDeviceMemorySpeedKey "SMmemspeed" // +#define kSMBMemoryDeviceManufacturerKey "SMmemmanufacturer" // +#define kSMBMemoryDeviceSerialNumberKey "SMmemserial" // +#define kSMBMemoryDevicePartNumberKey "SMmempart" // // Bungo: -#define kSMBMemoryDeviceAssetTagKey "SMmemassettag" // +#define kSMBMemoryDeviceAssetTagKey "SMmemassettag" // /* =========================================== Memory SPD Data (Apple Specific - Type 130) @@ -115,17 +115,17 @@ /* ============================================ OEM Processor Type (Apple Specific - Type 131) ============================================== */ -#define kSMBOemProcessorTypeKey "SMoemcputype" // Bungo: renamed from SMcputype +#define kSMBOemProcessorTypeKey "SMoemcputype" // Bungo: renamed from SMcputype /* ================================================= OEM Processor Bus Speed (Apple Specific - Type 132) =================================================== */ -#define kSMBOemProcessorBusSpeedKey "SMoemcpubusspeed" // Bungo: renamed from SMbusspeed +#define kSMBOemProcessorBusSpeedKey "SMoemcpubusspeed" // Bungo: renamed from SMbusspeed /* ============================================== OEM Platform Feature (Apple Specific - Type 133) ================================================ */ -//#define kSMBOemPlatformFeatureKey "SMoemplatformfeature" +//#define kSMBOemPlatformFeatureKey "SMoemplatformfeature" /* ==================================================*/ #define getFieldOffset(struct, field) ((uint8_t)(uint32_t)&(((struct *)0)->field)) @@ -208,75 +208,75 @@ BIOS Information (Type 0) ========================= */ { kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, vendor), - kSMBBIOSInformationVendorKey, NULL, &defaultBIOSInfo.vendor }, // SMbiosvendor - Apple Inc. + kSMBBIOSInformationVendorKey, NULL, &defaultBIOSInfo.vendor }, // SMbiosvendor - Apple Inc. { kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, version), - kSMBBIOSInformationVersionKey, NULL, &defaultBIOSInfo.version }, // SMbiosversion - MP31.88Z.006C.B05.0802291410 + kSMBBIOSInformationVersionKey, NULL, &defaultBIOSInfo.version }, // SMbiosversion - MP31.88Z.006C.B05.0802291410 { kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, releaseDate), - kSMBBIOSInformationReleaseDateKey, NULL, &defaultBIOSInfo.releaseDate }, // SMbiosdate - 02/29/08 + kSMBBIOSInformationReleaseDateKey, NULL, &defaultBIOSInfo.releaseDate }, // SMbiosdate - 02/29/08 // Bungo { kSMBTypeBIOSInformation, kSMBWord, getFieldOffset(SMBBIOSInformation, releaseMajor), - kSMBBIOSInformationReleaseKey, NULL, (char **)&defaultBIOSInfo.release }, // SMbiosrelease - 0.1 (256) + kSMBBIOSInformationReleaseKey, NULL, (char **)&defaultBIOSInfo.release }, // SMbiosrelease - 0.1 (256) /* ========================= System Information (Type 1) =========================== */ {kSMBTypeSystemInformation, kSMBString, getFieldOffset(SMBSystemInformation, manufacturer), - kSMBSystemInformationManufacturerKey, NULL, &defaultSystemInfo.manufacturer }, // SMmanufacturer - Apple Inc. + kSMBSystemInformationManufacturerKey, NULL, &defaultSystemInfo.manufacturer }, // SMmanufacturer - Apple Inc. {kSMBTypeSystemInformation, kSMBString, getFieldOffset(SMBSystemInformation, productName), - kSMBSystemInformationProductNameKey, NULL, &defaultSystemInfo.productName }, // SMproductname - MacPro3,1 + kSMBSystemInformationProductNameKey, NULL, &defaultSystemInfo.productName }, // SMproductname - MacPro3,1 {kSMBTypeSystemInformation, kSMBString, getFieldOffset(SMBSystemInformation, version), - kSMBSystemInformationVersionKey, NULL, &defaultSystemInfo.version }, // SMsystemversion - 1.0 + kSMBSystemInformationVersionKey, NULL, &defaultSystemInfo.version }, // SMsystemversion - 1.0 {kSMBTypeSystemInformation, kSMBString, getFieldOffset(SMBSystemInformation, serialNumber), - kSMBSystemInformationSerialNumberKey, NULL, &defaultSystemInfo.serialNumber }, // SMserial - Serial number + kSMBSystemInformationSerialNumberKey, NULL, &defaultSystemInfo.serialNumber }, // SMserial - Serial number /* Bungo: {kSMBTypeSystemInformation, kSMBByte, getFieldOffset(SMBSystemInformation, uuid), - kSMBSystemInformationUUIDKey, NULL, NULL}, // SMsystemuuid + kSMBSystemInformationUUIDKey, NULL, NULL}, // SMsystemuuid {kSMBTypeSystemInformation, kSMBByte, getFieldOffset(SMBSystemInformation, wakeupReason), - NULL, NULL, NULL}, // reason for system wakeup + NULL, NULL, NULL}, // reason for system wakeup */ // Bungo {kSMBTypeSystemInformation, kSMBString, getFieldOffset(SMBSystemInformation, skuNumber), - kSMBSystemInformationSKUNumberKey, NULL, &defaultSystemInfo.skuNumber}, // SMskunumber - System SKU# + kSMBSystemInformationSKUNumberKey, NULL, &defaultSystemInfo.skuNumber}, // SMskunumber - System SKU# {kSMBTypeSystemInformation, kSMBString, getFieldOffset(SMBSystemInformation, family), - kSMBSystemInformationFamilyKey, NULL, &defaultSystemInfo.family}, // SMfamily - MacPro + kSMBSystemInformationFamilyKey, NULL, &defaultSystemInfo.family}, // SMfamily - MacPro /* ========================================= Base Board (or Module) Information (Type 2) =========================================== */ {kSMBTypeBaseBoard, kSMBString, getFieldOffset(SMBBaseBoard, manufacturer), - kSMBBaseBoardManufacturerKey, NULL, &defaultBaseBoard.manufacturer }, // SMboardmanufacturer - Apple Inc. + kSMBBaseBoardManufacturerKey, NULL, &defaultBaseBoard.manufacturer }, // SMboardmanufacturer - Apple Inc. {kSMBTypeBaseBoard, kSMBString, getFieldOffset(SMBBaseBoard, product), - kSMBBaseBoardProductKey, NULL, &defaultBaseBoard.product }, // SMboardproduct - Mac-F2268DC8 + kSMBBaseBoardProductKey, NULL, &defaultBaseBoard.product }, // SMboardproduct - Mac-F2268DC8 // Bungo {kSMBTypeBaseBoard, kSMBString, getFieldOffset(SMBBaseBoard, version), - kSMBBaseBoardVersionKey, NULL, &defaultBaseBoard.version }, // SMboardversion - MacPro3,1 + kSMBBaseBoardVersionKey, NULL, &defaultBaseBoard.version }, // SMboardversion - MacPro3,1 {kSMBTypeBaseBoard, kSMBString, getFieldOffset(SMBBaseBoard, serialNumber), - kSMBBaseBoardSerialNumberKey, NULL, &defaultBaseBoard.serialNumber }, // SMboardserial - C02140302D5DMT31M + kSMBBaseBoardSerialNumberKey, NULL, &defaultBaseBoard.serialNumber }, // SMboardserial - C02140302D5DMT31M {kSMBTypeBaseBoard, kSMBString, getFieldOffset(SMBBaseBoard, assetTag), - kSMBBaseBoardAssetTagKey, NULL, &defaultBaseBoard.assetTag }, // SMboardassettag - Base Board Asset Tag# + kSMBBaseBoardAssetTagKey, NULL, &defaultBaseBoard.assetTag }, // SMboardassettag - Base Board Asset Tag# {kSMBTypeBaseBoard, kSMBString, getFieldOffset(SMBBaseBoard, locationInChassis), - kSMBBaseBoardLocationInChassisKey, NULL, &defaultBaseBoard.locationInChassis }, // SMboardlocation - Part Component + kSMBBaseBoardLocationInChassisKey, NULL, &defaultBaseBoard.locationInChassis }, // SMboardlocation - Part Component {kSMBTypeBaseBoard, kSMBByte, getFieldOffset(SMBBaseBoard, boardType), - kSMBBaseBoardTypeKey, NULL, (char **)&defaultBaseBoard.boardType }, // SMboardtype - 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro + kSMBBaseBoardTypeKey, NULL, (char **)&defaultBaseBoard.boardType }, // SMboardtype - 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro /* {kSMBTypeBaseBoard, kSMBByte, getFieldOffset(SMBBaseBoard, numberOfContainedHandles), - NULL , NULL, NULL }, // numberOfContainedHandles = 0 + NULL , NULL, NULL }, // numberOfContainedHandles = 0 */ // @@ -285,19 +285,19 @@ System Enclosure (Type 3) ========================= */ {kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, manufacturer), - kSMBSystemEnclosureManufacturerKey, NULL, &defaultChassis.manufacturer }, // SMchassismanufacturer - Apple Inc. + kSMBSystemEnclosureManufacturerKey, NULL, &defaultChassis.manufacturer }, // SMchassismanufacturer - Apple Inc. {kSMBTypeSystemEnclosure, kSMBByte, getFieldOffset(SMBSystemEnclosure, chassisType), - kSMBSystemEnclosureTypeKey, NULL, (char **)&defaultChassis.chassisType }, // SMchassistype - 7 + kSMBSystemEnclosureTypeKey, NULL, (char **)&defaultChassis.chassisType }, // SMchassistype - 7 {kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, version), - kSMBSystemEnclosureVersionKey, NULL, &defaultChassis.version }, // SMchassisversion - Mac-F42C88C8 + kSMBSystemEnclosureVersionKey, NULL, &defaultChassis.version }, // SMchassisversion - Mac-F42C88C8 {kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, serialNumber), - kSMBSystemEnclosureSerialNumberKey, NULL, &defaultChassis.serialNumber }, // SMchassisserial + kSMBSystemEnclosureSerialNumberKey, NULL, &defaultChassis.serialNumber }, // SMchassisserial {kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, assetTag), - kSMBSystemEnclosureAssetTagKey, NULL, &defaultChassis.assetTag }, // SMchassisassettag - Pro Enclosure + kSMBSystemEnclosureAssetTagKey, NULL, &defaultChassis.assetTag }, // SMchassisassettag - Pro Enclosure /* {kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, skuNumber), @@ -308,32 +308,32 @@ Processor Information (Type 4) ============================== */ {kSMBTypeProcessorInformation, kSMBString, getFieldOffset(SMBProcessorInformation, socketDesignation), - kSMBProcessorInformationSocketKey, NULL, NULL}, // SMcpusocket - + kSMBProcessorInformationSocketKey, NULL, NULL}, // SMcpusocket - {kSMBTypeProcessorInformation, kSMBString, getFieldOffset(SMBProcessorInformation, manufacturer), - kSMBProcessorInformationManufacturerKey, NULL, NULL}, // SMcpumanufacturer - Intel(R) Corporation + kSMBProcessorInformationManufacturerKey, NULL, NULL}, // SMcpumanufacturer - Intel(R) Corporation {kSMBTypeProcessorInformation, kSMBString, getFieldOffset(SMBProcessorInformation, processorVersion), - kSMBProcessorInformationVersionKey, NULL, NULL}, // SMcpuversion + kSMBProcessorInformationVersionKey, NULL, NULL}, // SMcpuversion {kSMBTypeProcessorInformation, kSMBWord, getFieldOffset(SMBProcessorInformation, externalClock), - kSMBProcessorInformationExternalClockKey, getProcessorInformationExternalClock, NULL}, // SMcpuexternalclock + kSMBProcessorInformationExternalClockKey, getProcessorInformationExternalClock, NULL}, // SMcpuexternalclock {kSMBTypeProcessorInformation, kSMBWord, getFieldOffset(SMBProcessorInformation, maximumClock), - kSMBProcessorInformationMaximumClockKey, getProcessorInformationMaximumClock, NULL}, // SMcpumaximumclock + kSMBProcessorInformationMaximumClockKey, getProcessorInformationMaximumClock, NULL}, // SMcpumaximumclock // Bungo {kSMBTypeProcessorInformation, kSMBWord, getFieldOffset(SMBProcessorInformation, currentClock), - kSMBProcessorInformationCurrentClockKey, NULL, NULL}, // SMcpucurrentclock + kSMBProcessorInformationCurrentClockKey, NULL, NULL}, // SMcpucurrentclock {kSMBTypeProcessorInformation, kSMBByte, getFieldOffset(SMBProcessorInformation, processorUpgrade), - kSMBProcessorInformationUpgradeKey, NULL, NULL}, // SMcpuupgrade + kSMBProcessorInformationUpgradeKey, NULL, NULL}, // SMcpuupgrade // {kSMBTypeProcessorInformation, kSMBString, getFieldOffset(SMBProcessorInformation, serialNumber), kSMBProcessorInformationSerialNumberKey, NULL, NULL}, // Bungo {kSMBTypeProcessorInformation, kSMBString, getFieldOffset(SMBProcessorInformation, assetTag), - kSMBProcessorInformationAssetTagKey, NULL, NULL}, // SMcpuassettag + kSMBProcessorInformationAssetTagKey, NULL, NULL}, // SMcpuassettag // {kSMBTypeProcessorInformation, kSMBString, getFieldOffset(SMBProcessorInformation, partNumber), kSMBProcessorInformationPartNumberKey, NULL, NULL}, @@ -372,25 +372,25 @@ // Apple Specific //------------------------------------------------------------------------------------------------------------------------- // OEM Processor Type (Apple Specific - Type 131) - {kSMBTypeOemProcessorType, kSMBWord, getFieldOffset(SMBOemProcessorType, ProcessorType), kSMBOemProcessorTypeKey, + {kSMBTypeOemProcessorType, kSMBWord, getFieldOffset(SMBOemProcessorType, ProcessorType), kSMBOemProcessorTypeKey, getSMBOemProcessorType, NULL}, // OEM Processor Bus Speed (Apple Specific - Type 132) {kSMBTypeOemProcessorBusSpeed, kSMBWord, getFieldOffset(SMBOemProcessorBusSpeed, ProcessorBusSpeed), kSMBOemProcessorBusSpeedKey, - getSMBOemProcessorBusSpeed, NULL} + getSMBOemProcessorBusSpeed, NULL} // OEM Platform Feature (Apple Specific - Type 133) /* {kSMBTypeOemPlatformFeature, kSMBWord, getFieldOffset(SMBOemPlatformFeature, PlatformFeature), kSMBOemPlatformFeatureKey, - getSMBOemPlatformFeature, NULL} + getSMBOemPlatformFeature, NULL} */ }; int numOfSetters = sizeof(SMBSetters) / sizeof(SMBValueSetter); -SMBEntryPoint *origeps = 0; -SMBEntryPoint *neweps = 0; +SMBEntryPoint *origeps = 0; +SMBEntryPoint *neweps = 0; static uint8_t stringIndex; // increament when a string is added and set the field value accordingly static uint8_t stringsSize; // add string size @@ -616,9 +616,9 @@ /* ============================================ */ -bool useSMBIOSdefaults = true; // Bungo +bool useSMBIOSdefaults = true; // Bungo -SMBByte PlatformType = 1; // Bungo: same as Platfom.Type in platform.h. Because can't get from ACPI FADT PM profile and platformCPUFeature(CPU_FEATURE_MOBILE)) doesn't work as expect, FIXING NEEDED. +SMBByte PlatformType = 1; // Bungo: same as Platfom.Type in platform.h. Because can't get from ACPI FADT PM profile and platformCPUFeature(CPU_FEATURE_MOBILE)) doesn't work as expect, FIXING NEEDED. /* Rewrite this function */ void setDefaultSMBData(void) // Bungo: setting data from real Macs @@ -707,8 +707,8 @@ defaultChassis.chassisType = kSMBchassisAllInOne; break; - case CPUID_MODEL_SANDYBRIDGE: // Intel Core i3, i5, i7 LGA1155 (32nm) - case CPUID_MODEL_IVYBRIDGE: // Intel Core i3, i5, i7 LGA1155 (22nm) + case CPUID_MODEL_SANDYBRIDGE: // Intel Core i3, i5, i7 LGA1155 (32nm) + case CPUID_MODEL_IVYBRIDGE: // Intel Core i3, i5, i7 LGA1155 (22nm) defaultBIOSInfo.version = kDefaultiMacSandyBIOSVersion; defaultBIOSInfo.releaseDate = kDefaultiMacSandyBIOSReleaseDate; defaultSystemInfo.productName = kDefaultiMacSandy; @@ -780,19 +780,25 @@ int len; char key[24]; - if (current != structHeader->handle) { + if (current != structHeader->handle) + { idx++; current = structHeader->handle; } sprintf(key, "%s%d", keyString, idx); - if (value) { - if (getIntForKey(key, (int *)&(value->dword), SMBPlist)) { + if (value) + { + if (getIntForKey(key, (int *)&(value->dword), SMBPlist)) + { return true; } - } else { - if (getValueForKey(key, string, &len, SMBPlist)) { + } + else + { + if (getValueForKey(key, string, &len, SMBPlist)) + { return true; } } @@ -801,12 +807,13 @@ char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field) { - uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length; - - if (!field) { + if (!field) + { return NULL; } + uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length; + for (field--; field != 0 && strlen((char *)stringPtr) > 0; field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1)); @@ -817,11 +824,13 @@ { int strSize; - if (!field) { + if (!field) + { return; } - if (!string) { + if (!string) + { *field = 0; return; } @@ -829,13 +838,16 @@ strSize = strlen(string); // remove any spaces found at the end but only in MemoryDevice avoiding errors - if (structHeader->type == kSMBTypeMemoryDevice) { - while ((strSize != 0) && (string[strSize - 1] == ' ')) { + if (structHeader->type == kSMBTypeMemoryDevice) + { + while ((strSize != 0) && (string[strSize - 1] == ' ')) + { strSize--; } } - if (strSize == 0) { + if (strSize == 0) + { *field = 0; return; } @@ -854,11 +866,13 @@ bool parsed; int val; - if (numOfSetters <= idx) { + if (numOfSetters <= idx) + { return false; } - switch (SMBSetters[idx].valueType) { + switch (SMBSetters[idx].valueType) + { case kSMBString: { if (SMBSetters[idx].keyString) @@ -866,7 +880,9 @@ if (getValueForKey(SMBSetters[idx].keyString, &string, &len, SMBPlist)) { break; - } else { + } + else + { if (structPtr->orig->type == kSMBTypeMemoryDevice) // MemoryDevice only { if (getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, &string, NULL)) @@ -877,33 +893,42 @@ } } - if (SMBSetters[idx].getSMBValue) { - if (SMBSetters[idx].getSMBValue((returnType *)&string)) { + if (SMBSetters[idx].getSMBValue) + { + if (SMBSetters[idx].getSMBValue((returnType *)&string)) + { break; } } // if ((SMBSetters[idx].defaultValue) && *(SMBSetters[idx].defaultValue)) Bungo - if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue)) { + if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue)) + { string = *(SMBSetters[idx].defaultValue); break; } string = getSMBStringForField(structPtr->orig, *(uint8_t *)value); break; } + case kSMBByte: case kSMBWord: case kSMBDWord: case kSMBQWord: - if (SMBSetters[idx].keyString) { + if (SMBSetters[idx].keyString) + { parsed = getIntForKey(SMBSetters[idx].keyString, &val, SMBPlist); if (!parsed) { - if (structPtr->orig->type == kSMBTypeMemoryDevice) { // MemoryDevice only + if (structPtr->orig->type == kSMBTypeMemoryDevice) // MemoryDevice only + { parsed = getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, NULL, (returnType *)&val); } } - if (parsed) { - switch (SMBSetters[idx].valueType) { + + if (parsed) + { + switch (SMBSetters[idx].valueType) + { case kSMBByte: value->byte = (uint8_t)val; break; @@ -922,14 +947,17 @@ } } - if (SMBSetters[idx].getSMBValue) { - if (SMBSetters[idx].getSMBValue(value)) { + if (SMBSetters[idx].getSMBValue) + { + if (SMBSetters[idx].getSMBValue(value)) + { return true; } } // #if 0 Bungo: enables code below // if (*(SMBSetters[idx].defaultValue)) Bungo - if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue)) { + if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue)) + { // value->dword = *(uint32_t *)(SMBSetters[idx].defaultValue); Bungo switch (SMBSetters[idx].valueType) { case kSMBByte: @@ -953,7 +981,8 @@ } // if (SMBSetters[idx].valueType == kSMBString && string) Bungo: use null string too -> "Not Specified" - if ((SMBSetters[idx].valueType == kSMBString) && string) { + if ((SMBSetters[idx].valueType == kSMBString) && string) + { setSMBStringForField(structPtr->new, string, &value->byte); } return true; @@ -1050,7 +1079,9 @@ /* ============================================== OEM Platform Feature (Apple Specific - Type 133) ================================================ */ - /*void addSMBOemPlatformFeature(SMBStructPtrs *structPtr) { +/* +void addSMBOemPlatformFeature(SMBStructPtrs *structPtr) +{ SMBOemPlatformFeature *p = (SMBOemPlatformFeature *)structPtr->new; p->header.type = kSMBTypeOemPlatformFeature; @@ -1062,7 +1093,8 @@ structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemPPlatformFeature) + 2); tableLength += sizeof(SMBOemPlatformFeature) + 2; structureCount++; - }*/ + } +*/ //------------------------------------------------------------------------------------------------------------------------- // EndOfTable @@ -1090,9 +1122,11 @@ // http://forge.voodooprojects.org/p/chameleon/issues/361/ bool forceFullMemInfo = false; - if (structPtr->orig->type == kSMBTypeMemoryDevice) { + if (structPtr->orig->type == kSMBTypeMemoryDevice) + { getBoolForKey(kMemFullInfo, &forceFullMemInfo, &bootInfo->chameleonConfig); - if (forceFullMemInfo) { + if (forceFullMemInfo) + { structPtr->orig->length = 27; } }*/ @@ -1100,11 +1134,13 @@ stringIndex = 1; stringsSize = 0; - if (handle < structPtr->orig->handle) { + if (handle < structPtr->orig->handle) + { handle = structPtr->orig->handle; } // Bungo: fix unsuported tables lengths from original smbios: extend shorter or truncate longer - we use SMBIOS rev. 2.4 like Apple uses - switch (structPtr->orig->type) { + switch (structPtr->orig->type) + { case kSMBTypeBIOSInformation: structSize = sizeof(SMBBIOSInformation); break; @@ -1129,38 +1165,48 @@ } // memcpy((void *)structPtr->new, structPtr->orig, structPtr->orig->length); - if (structPtr->orig->length <= structSize) { + if (structPtr->orig->length <= structSize) + { memcpy((void *)structPtr->new, structPtr->orig, structPtr->orig->length); - } else { + } + else + { memcpy((void *)structPtr->new, structPtr->orig, structSize); } structPtr->new->length = structSize; - for (i = 0; i < numOfSetters; i++) { + for (i = 0; i < numOfSetters; i++) + { // Bungo: //if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structPtr->orig->length)) { - if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structSize)) { + if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structSize)) + { setterFound = true; setSMBValue(structPtr, i, (returnType *)((uint8_t *)structPtr->new + SMBSetters[i].fieldOffset)); } } - if (setterFound) { + if (setterFound) + { // Bungo: // ptr = (uint8_t *)structPtr->new + structPtr->orig->length; ptr = (uint8_t *)structPtr->new + structPtr->new->length; for (; ((uint16_t *)ptr)[0] != 0; ptr++); - if (((uint16_t *)ptr)[0] == 0) { + if (((uint16_t *)ptr)[0] == 0) + { ptr += 2; } structSize = ptr - (uint8_t *)structPtr->new; - } else { + } + else + { ptr = (uint8_t *)structPtr->orig + structPtr->orig->length; for (; ((uint16_t *)ptr)[0] != 0; ptr++); - if (((uint16_t *)ptr)[0] == 0) { + if (((uint16_t *)ptr)[0] == 0) + { ptr += 2; } @@ -1172,7 +1218,8 @@ tableLength += structSize; - if (structSize > maxStructSize) { + if (structSize > maxStructSize) + { maxStructSize = structSize; } @@ -1206,7 +1253,8 @@ ptr = (uint8_t *)((uint32_t)structPtr->orig + structPtr->orig->length); for (; ((uint16_t *)ptr)[0] != 0; ptr++); - if (((uint16_t *)ptr)[0] == 0) { + if (((uint16_t *)ptr)[0] == 0) + { ptr += 2; } @@ -1236,7 +1284,8 @@ ptr = (uint8_t *)((uint32_t)structHeader + structHeader->length); for (; ((uint16_t *)ptr)[0] != 0; ptr++); - if (((uint16_t *)ptr)[0] == 0) { + if (((uint16_t *)ptr)[0] == 0) + { ptr += 2; } @@ -1245,18 +1294,21 @@ ptr = ((SMBSystemInformation *)structHeader)->uuid; - if (!sysId || !ret) { // no or bad custom uuid,... + if (!sysId || !ret) // no or bad custom uuid,... + { sysId = 0; ret = Platform.UUID; // ...use original (factory) system uuid } for (i = 0, isZero = 1, isOnes = 1; i < UUID_LEN; i++) // check if empty (zeroed) or setable (FFed), means: no uuid present { - if (ret[i] != 0x00) { + if (ret[i] != 0x00) + { isZero = 0; } - if (ret[i] != 0xff) { + if (ret[i] != 0xff) + { isOnes = 0; } } @@ -1277,19 +1329,22 @@ uint8_t *buffer; // bool setSMB = true; Bungo: now we use useSMBIOSdefaults - if (!origeps) { + if (!origeps) + { return; } neweps = origeps; structPtr = (SMBStructPtrs *)malloc(sizeof(SMBStructPtrs)); - if (!structPtr) { + if (!structPtr) + { return; } buffer = (uint8_t *)malloc(SMB_ALLOC_SIZE); - if (!buffer) { + if (!buffer) + { free(structPtr); return; } @@ -1305,7 +1360,8 @@ setupNewSMBIOSTable(origeps, structPtr); neweps = (SMBEntryPoint *)AllocateKernelMemory(sizeof(SMBEntryPoint)); - if (!neweps) { + if (!neweps) + { free(buffer); free(structPtr); return; @@ -1332,7 +1388,8 @@ neweps->dmi.structureCount = structureCount; neweps->dmi.bcdRevision = 0x24; // ... and 2.4 DMI rev. as real Macs - if (!neweps->dmi.tableAddress) { + if (!neweps->dmi.tableAddress) + { free(buffer); free(structPtr); return; @@ -1360,9 +1417,11 @@ void *getSmbios(int which) { - switch (which) { + switch (which) + { case SMBIOS_ORIGINAL: - if (!origeps) { + if (!origeps) + { origeps = getAddressOfSmbiosTable(); } return origeps; @@ -1393,7 +1452,8 @@ break; case kSMBTypeSystemEnclosure: // Bungo: determine platform type - switch (((SMBSystemEnclosure *)structHeader)->chassisType) { + switch (((SMBSystemEnclosure *)structHeader)->chassisType) + { case kSMBchassisDesktop: case kSMBchassisLPDesktop: case kSMBchassisAllInOne: @@ -1419,10 +1479,12 @@ case kSMBTypeMemoryDevice: Platform.DMI.CntMemorySlots++; - if (((SMBMemoryDevice *)structHeader)->memorySize != 0) { + if (((SMBMemoryDevice *)structHeader)->memorySize != 0) + { Platform.DMI.MemoryModules++; } - if (((SMBMemoryDevice *)structHeader)->memorySpeed > 0) { + if (((SMBMemoryDevice *)structHeader)->memorySpeed > 0) + { Platform.RAM.DIMM[dimmnbr].Frequency = ((SMBMemoryDevice *)structHeader)->memorySpeed; } dimmnbr++; @@ -1434,7 +1496,8 @@ structPtr = (uint8_t *)((uint32_t)structHeader + structHeader->length); for (; ((uint16_t *)structPtr)[0] != 0; structPtr++); - if (((uint16_t *)structPtr)[0] == 0) { + if (((uint16_t *)structPtr)[0] == 0) + { structPtr += 2; } Index: trunk/i386/libsaio/pci.c =================================================================== --- trunk/i386/libsaio/pci.c (revision 2538) +++ trunk/i386/libsaio/pci.c (revision 2539) @@ -75,17 +75,23 @@ uint8_t secondary_bus; uint8_t header_type; - for (dev = 0; dev < 32; dev++) { - for (func = 0; func < 8; func++) { + for (dev = 0; dev < 32; dev++) + { + for (func = 0; func < 8; func++) + { pci_addr = PCIADDR(bus, dev, func); id = pci_config_read32(pci_addr, PCI_VENDOR_ID); - if (!id || id == 0xfffffffful) { + if (!id || id == 0xfffffffful) + { continue; } + new = (pci_dt_t*)malloc(sizeof(pci_dt_t)); - if (!new) { + if (!new) + { continue; } + bzero(new, sizeof(pci_dt_t)); new->dev.addr = pci_addr; @@ -99,21 +105,25 @@ new->parent = start; header_type = pci_config_read8(pci_addr, PCI_HEADER_TYPE); - switch (header_type & 0x7f) { - case PCI_HEADER_TYPE_BRIDGE: - case PCI_HEADER_TYPE_CARDBUS: - secondary_bus = pci_config_read8(pci_addr, PCI_SECONDARY_BUS); - if (secondary_bus != 0) { - scan_pci_bus(new, secondary_bus); - } - break; - default: - break; + switch (header_type & 0x7f) + { + case PCI_HEADER_TYPE_BRIDGE: + case PCI_HEADER_TYPE_CARDBUS: + secondary_bus = pci_config_read8(pci_addr, PCI_SECONDARY_BUS); + if (secondary_bus != 0) + { + scan_pci_bus(new, secondary_bus); + } + break; + default: + break; } + *current = new; current = &new->next; - if ((func == 0) && ((header_type & 0x80) == 0)) { + if ((func == 0) && ((header_type & 0x80) == 0)) + { break; } } @@ -131,6 +141,7 @@ { return; } + rcba = pci_config_read32(PCIADDR(0, 0x1f, 0), 0xf0) & ~1; //this is LPC host fd = (uint32_t *)(rcba + 0x3418); /* set SMBus Disable (SD) to 0 */ @@ -144,7 +155,8 @@ { root_pci_dev = malloc(sizeof(pci_dt_t)); - if (!root_pci_dev) { + if (!root_pci_dev) + { return; } @@ -164,7 +176,7 @@ { pci_dt_t *current; pci_dt_t *end; - int dev_path_len = 0; + int dev_path_len = 0; dev_path[0] = 0; end = root_pci_dev; @@ -176,11 +188,14 @@ while (current->parent != end) current = current->parent; end = current; - if (current->parent == root_pci_dev) { + if (current->parent == root_pci_dev) + { dev_path_len += snprintf(dev_path + dev_path_len, sizeof(dev_path) - dev_path_len, "PciRoot(0x%x)/Pci(0x%x,0x%x)", uid, current->dev.bits.dev, current->dev.bits.func); - } else { + } + else + { dev_path_len += snprintf(dev_path + dev_path_len, sizeof(dev_path) - dev_path_len, "/Pci(0x%x,0x%x)", current->dev.bits.dev, current->dev.bits.func); Index: trunk/i386/libsaio/msdos.c =================================================================== --- trunk/i386/libsaio/msdos.c (revision 2538) +++ trunk/i386/libsaio/msdos.c (revision 2539) @@ -52,12 +52,12 @@ #include "msdos.h" #define LABEL_LENGTH 11 -#define MSDOS_CACHE_BLOCKSIZE BPS +#define MSDOS_CACHE_BLOCKSIZE BPS -#define CLUST_FIRST 2/* reserved cluster range */ -#define CLUST_RSRVD32 0x0ffffff8 /* reserved cluster range */ -#define CLUST_RSRVD16 0xfff8 /* reserved cluster range */ -#define CLUST_RSRVD12 0xff8 /* reserved cluster range */ +#define CLUST_FIRST 2 /* reserved cluster range */ +#define CLUST_RSRVD32 0x0ffffff8 /* reserved cluster range */ +#define CLUST_RSRVD16 0xfff8 /* reserved cluster range */ +#define CLUST_RSRVD12 0xff8 /* reserved cluster range */ #define tolower(c) (((c)>='A' && c<='Z')?((c) | 0x20):(c)) @@ -149,8 +149,7 @@ } -long -MSDOSInitPartition (CICell ih) +long MSDOSInitPartition (CICell ih) { union bootsector *bsp; struct bpb33 *b33; @@ -252,8 +251,7 @@ return 0; } -static int -readSector(CICell ih, off_t readOffset, char *buf, int size) +static int readSector(CICell ih, off_t readOffset, char *buf, int size) { // Caching only FAT entries (4 bytes) by utlizing the cache with sector aligned read requests. if (size < BPS) @@ -280,8 +278,7 @@ return 0; } -static int -msdosreadcluster (CICell ih, uint8_t *buf, int size, off_t *cluster) +static int msdosreadcluster (CICell ih, uint8_t *buf, int size, off_t *cluster) { off_t readOffset; char tmpbuf[8]; @@ -346,8 +343,7 @@ } } -static struct direntry * -getnextdirent (CICell ih, uint16_t *longname, struct msdosdirstate *st) +static struct direntry *getnextdirent (CICell ih, uint16_t *longname, struct msdosdirstate *st) { struct direntry *dirp; while (1) @@ -391,7 +387,9 @@ bcopy (&(wdirp->wePart1),longname+WIN_CHARS*(num-1),sizeof (wdirp->wePart1)); bcopy (&(wdirp->wePart2),longname+WIN_CHARS*(num-1)+5,sizeof (wdirp->wePart2)); bcopy (&(wdirp->wePart3),longname+WIN_CHARS*(num-1)+11,sizeof (wdirp->wePart3)); - } else { + } + else + { uint8_t labelchecksum; int i; longname[st->vfatnumber*WIN_CHARS]=0; @@ -417,16 +415,20 @@ } } -static void -initRoot (struct msdosdirstate *st) +static void initRoot (struct msdosdirstate *st) { - if (msdosrootDirSectors) { /* FAT12 or FAT16 */ + if (msdosrootDirSectors) + { + /* FAT12 or FAT16 */ st->root16 = 1; st->vfatchecksum = 0; st->nument = 0; st->cluster = 0; st->vfatnumber = 0; - } else { /* FAT32 */ + } + else + { + /* FAT32 */ st->root16 = 0; st->vfatchecksum = 0; st->nument = 0; @@ -568,8 +570,7 @@ {0x00A0,0x00A0} }; -static int -checkname (uint16_t *ucsname, int ucslen, struct direntry *dirp, uint16_t *vfatname) +static int checkname (uint16_t *ucsname, int ucslen, struct direntry *dirp, uint16_t *vfatname) { uint16_t tmp[15]; if (vfatname[0]) @@ -605,8 +606,7 @@ } -static struct direntry * -getdirpfrompath (CICell ih, char *dirspec, uint8_t *buf) +static struct direntry *getdirpfrompath (CICell ih, char *dirspec, uint8_t *buf) { struct msdosdirstate st; struct direntry *dirp; @@ -633,10 +633,16 @@ { for (;*ptr && *ptr!='/';ptr++); if (!*ptr) + { return dirp; + } + ptr++; if (!*ptr) + { return dirp; + } + for (slash=ptr;*slash && *slash!='/';slash++); c=*slash; *slash=0; @@ -645,7 +651,10 @@ ucsname[ucslenhost]=0; *slash=c; if (!(dirp->deAttributes & ATTR_DIRECTORY)) + { return 0; + } + st.root16 = 0; st.vfatchecksum = 0; st.nument = 0; @@ -662,8 +671,8 @@ char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid) { - struct msdosdirstate *st; - struct direntry *dirp; + struct msdosdirstate *st; + struct direntry *dirp; uint16_t vfatname[WIN_MAXLEN+2*WIN_CHARS]; if (MSDOSInitPartition (ih)<0) { @@ -683,6 +692,7 @@ { return -1; } + bzero(st,sizeof (struct msdosdirstate) ); if (dirPath[0]) { uint8_t *buf=malloc(msdosclustersize); @@ -691,6 +701,8 @@ free (st); return -1; } + bzero(buf,msdosclustersize ); + dirp = getdirpfrompath (ih, dirPath, buf); if (!dirp || !(dirp->deAttributes & ATTR_DIRECTORY)) { @@ -711,7 +723,10 @@ } else + { initRoot (st); + } + *dirIndex = (long long) (long) st; } while((dirp = getnextdirent (ih, vfatname, st))&& (dirp->deAttributes & ATTR_VOLUME)); @@ -745,21 +760,26 @@ free (st); return -1; } + for (i=7;i>=0;i--) + { if (dirp->deName[i]!=' ') { break; } + } j=i+1; tmp[i+1]=0; for(;i>=0;i--) tmp[i]=(dirp->deName[i]>=128)?cp850[dirp->deName[i]-128][0]:tolower(dirp->deName[i]); for (i=2;i>=0;i--) + { if (dirp->deName[8+i]!=' ') { break; } + } if (i>=0) { @@ -767,7 +787,10 @@ tmp[j+i+1]=0; k=j+i+1; for(;i>=0;i--) + { tmp[j+i]=(dirp->deName[i]>=128)?cp850[dirp->deName[i+8]-128][0]:tolower(dirp->deName[i+8]); + } + j=k; } @@ -794,8 +817,7 @@ return 0; } -long -MSDOSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length) +long MSDOSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length) { uint8_t *buf; off_t cluster; @@ -816,11 +838,15 @@ { filePath++; } + buf = malloc(msdosclustersize); + if (!buf) { return -1; } + + bzero(buf,msdosclustersize); dirp = getdirpfrompath (ih, filePath, buf); if (!dirp || (dirp->deAttributes & ATTR_DIRECTORY)) @@ -828,23 +854,32 @@ free (buf); return -1; } + cluster = OSReadLittleInt16 ((dirp->deStartCluster),0); + if (msdosfatbits == 32) { cluster |= ((uint32_t)OSReadLittleInt16 ((dirp->deHighClust),0)) <<16; } size = (uint32_t)OSReadLittleInt32 ((dirp->deFileSize),0); + if (size<=offset) { free (buf); return -1; } + nskip=offset/msdosclustersize; - for (i=0;isize-offset) { toread=size-offset; @@ -878,42 +913,67 @@ uint8_t *buf; off_t cluster; struct direntry *dirp; + if (MSDOSInitPartition (ih)<0) + { return -1; + } + if (filePath[0] == '/') + { filePath++; + } + buf = malloc(msdosclustersize); + if (!buf) { return -1; } + bzero(buf,msdosclustersize); + dirp = getdirpfrompath (ih, filePath, buf); + if (!dirp || (dirp->deAttributes & ATTR_DIRECTORY)) { free (buf); return -1; } + cluster = OSReadLittleInt16 ((dirp->deStartCluster),0); + if (msdosfatbits == 32) + { cluster |= ((uint32_t)OSReadLittleInt16 ((dirp->deHighClust),0)) <<16; - + } + off_t clusn; - switch (msdosfatbits) { + switch (msdosfatbits) + { case 32: if (cluster < CLUST_FIRST ||cluster >= CLUST_RSRVD32) + { return -1; + } + clusn = cluster - CLUST_FIRST; break; case 16: if (cluster < CLUST_FIRST ||cluster >= CLUST_RSRVD16) + { return 0; + } + clusn = cluster - CLUST_FIRST; break; case 12: if (cluster < CLUST_FIRST ||cluster >= CLUST_RSRVD12) + { return 0; + } + clusn = cluster - CLUST_FIRST; break; default: @@ -944,45 +1004,58 @@ label[0] = 0xE5; /* Remove any trailing spaces */ - for (i=LABEL_LENGTH-1; i>=0; --i) { - if (label[i] == ' ') - label[i] = 0; - else - break; + for (i=LABEL_LENGTH-1; i>=0; --i) + { + if (label[i] == ' ') + { + label[i] = 0; + } + else + { + break; + } } + labelucs[i++]=0; len=i; for (;i>=0;--i) + { labelucs[i]=label[i]>=128?cp850[label[i]-128][1]:(label[i]); - + } + utf_encodestr(labelucs, len, (uint8_t *)str, strMaxLen, OSHostByteOrder() ); } - void MSDOSGetDescription(CICell ih, char *str, long strMaxLen) { - struct direntry *dirp; - uint8_t label[LABEL_LENGTH+1]; - uint16_t vfatlabel[WIN_MAXLEN+2*WIN_CHARS]; - struct msdosdirstate st; - int labelfound = 0; + struct direntry *dirp; + uint8_t label[LABEL_LENGTH+1]; + uint16_t vfatlabel[WIN_MAXLEN+2*WIN_CHARS]; + struct msdosdirstate st; + int labelfound = 0; - if (MSDOSInitPartition (ih)<0) + if (MSDOSInitPartition(ih) < 0) { str[0]=0; return; } + bzero(label,sizeof(label)); + bzero(vfatlabel,sizeof(vfatlabel)); + label[0] = '\0'; - initRoot (&st); + initRoot(&st); st.buf = malloc(msdosclustersize); if (!st.buf) { return; } + bzero(st.buf,msdosclustersize); + while ((dirp = getnextdirent (ih, vfatlabel, &st))) - if (dirp->deAttributes & ATTR_VOLUME) { + if (dirp->deAttributes & ATTR_VOLUME) + { strncpy((char *)label, (char *)dirp->deName, LABEL_LENGTH); labelfound = 1; break; @@ -997,8 +1070,10 @@ utf_encodestr(vfatlabel, i, (u_int8_t *)str, strMaxLen, OSLittleEndian ); } else if (labelfound) + { fixLabel(label, str, strMaxLen); - + } + /* else look in the boot blocks */ if (!labelfound || str[0] == '\0') { @@ -1026,8 +1101,7 @@ return; } -long -MSDOSGetUUID(CICell ih, char *uuidStr) +long MSDOSGetUUID(CICell ih, char *uuidStr) { char *buf = malloc (512); if (!buf) @@ -1047,10 +1121,10 @@ if (msdosfatbits == 32) { /* It's FAT32 */ memcpy(uuidStr+12, (char *)((struct extboot *)bsp->bs710.bsExt)->exVolumeID, 4); } - else if (msdosfatbits == 16) { + else if (msdosfatbits == 16) + { memcpy(uuidStr+12, (char *)((struct extboot *)bsp->bs50.bsExt)->exVolumeID, 4); } free (buf); - return 0; - + return 0; } Index: trunk/i386/libsaio/state_generator.c =================================================================== --- trunk/i386/libsaio/state_generator.c (revision 2538) +++ trunk/i386/libsaio/state_generator.c (revision 2539) @@ -72,7 +72,7 @@ struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt *dsdt) { - if (Platform.CPU.Vendor != 0x756E6547) + if (Platform.CPU.Vendor != CPUID_VENDOR_INTEL) // 0x756E6547 { DBG("Not an Intel platform: P-States will not be generated !!!\n"); return NULL; @@ -358,7 +358,7 @@ struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt *fadt) { - if (Platform.CPU.Vendor != 0x756E6547) + if (Platform.CPU.Vendor != CPUID_VENDOR_INTEL) // 0x756E6547 { DBG("Not an Intel platform: C-States will not be generated !!!\n"); return NULL; Index: trunk/i386/boot2/boot.h =================================================================== --- trunk/i386/boot2/boot.h (revision 2538) +++ trunk/i386/boot2/boot.h (revision 2539) @@ -61,146 +61,146 @@ /* * Keys used in system Boot.plist */ -#define kGraphicsModeKey "Graphics Mode" -#define kTextModeKey "Text Mode" -#define kQuietBootKey "Quiet Boot" -#define kKernelFlagsKey "Kernel Flags" -#define kKernelArchKey "Kernel Architecture" -#define kMKextCacheKey "MKext Cache" -#define kKernelNameKey "Kernel" -#define kKernelCacheKey "Kernel Cache" -#define kUseKernelCache "UseKernelCache" /* boot.c */ -#define kBootDeviceKey "Boot Device" -#define kTimeoutKey "Timeout" -#define kRootDeviceKey "rd" -#define kBootUUIDKey "boot-uuid" -#define kHelperRootUUIDKey "Root UUID" -#define kPlatformKey "platform" -#define kACPIKey "acpi" -#define kCDROMPromptKey "CD-ROM Prompt" -#define kCDROMOptionKey "CD-ROM Option Key" -#define kRescanPromptKey "Rescan Prompt" -#define kRescanKey "Rescan" -#define kScanSingleDriveKey "Scan Single Drive" -#define kInstantMenuKey "Instant Menu" -#define kDefaultKernel "mach_kernel" -#define kOSXKernel "kernel" // Yosemite -#define kGUIKey "GUI" -#define kBootBannerKey "Boot Banner" -#define kShowInfoKey "ShowInfo" // gui.c -#define kWaitForKeypressKey "Wait" +#define kGraphicsModeKey "Graphics Mode" +#define kTextModeKey "Text Mode" +#define kQuietBootKey "Quiet Boot" +#define kKernelFlagsKey "Kernel Flags" +#define kKernelArchKey "Kernel Architecture" +#define kMKextCacheKey "MKext Cache" +#define kKernelNameKey "Kernel" +#define kKernelCacheKey "Kernel Cache" +#define kUseKernelCache "UseKernelCache" /* boot.c */ +#define kBootDeviceKey "Boot Device" +#define kTimeoutKey "Timeout" +#define kRootDeviceKey "rd" +#define kBootUUIDKey "boot-uuid" +#define kHelperRootUUIDKey "Root UUID" +#define kPlatformKey "platform" +#define kACPIKey "acpi" +#define kCDROMPromptKey "CD-ROM Prompt" +#define kCDROMOptionKey "CD-ROM Option Key" +#define kRescanPromptKey "Rescan Prompt" +#define kRescanKey "Rescan" +#define kScanSingleDriveKey "Scan Single Drive" +#define kInstantMenuKey "Instant Menu" +#define kDefaultKernel "mach_kernel" +#define kOSXKernel "kernel" // Yosemite +#define kGUIKey "GUI" +#define kBootBannerKey "Boot Banner" +#define kShowInfoKey "ShowInfo" // gui.c +#define kWaitForKeypressKey "Wait" /* AsereBLN: added these keys */ -#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" /* acpi_patcher.c */ -#define kDropSSDT "DropSSDT" /* acpi_patcher.c */ -#define kDeviceProperties "device-properties" /* device_inject.c */ -#define kHidePartition "Hide Partition" /* disk.c */ -#define kRenamePartition "Rename Partition" /* disk.c */ -#define kSMBIOSKey "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 && ati.c */ -#define kPCIRootUID "PCIRootUID" /* pci_root.c */ -#define kEthernetBuiltIn "EthernetBuiltIn" /* pci_setup.c */ -#define kGraphicsEnabler "GraphicsEnabler" /* pci_setup.c */ -#define kForceHPET "ForceHPET" /* pci_setup.c */ -#define kUseMemDetect "UseMemDetect" /* platform.c */ -#define kSMBIOSdefaults "SMBIOSdefaults" /* smbios_patcher.c */ -#define kUSBBusFix "USBBusFix" /* usb.c */ -#define kEHCIacquire "EHCIacquire" /* usb.c */ -#define kUHCIreset "UHCIreset" /* usb.c */ -#define kEHCIhard "EHCIhard" /* usb.c */ -#define kDefaultPartition "Default Partition" /* sys.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" /* acpi_patcher.c */ +#define kDropSSDT "DropSSDT" /* acpi_patcher.c */ +#define kDeviceProperties "device-properties" /* device_inject.c */ +#define kHidePartition "Hide Partition" /* disk.c */ +#define kRenamePartition "Rename Partition" /* disk.c */ +#define kSMBIOSKey "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 && ati.c */ +#define kPCIRootUID "PCIRootUID" /* pci_root.c */ +#define kEthernetBuiltIn "EthernetBuiltIn" /* pci_setup.c */ +#define kGraphicsEnabler "GraphicsEnabler" /* pci_setup.c */ +#define kForceHPET "ForceHPET" /* pci_setup.c */ +#define kUseMemDetect "UseMemDetect" /* platform.c */ +#define kSMBIOSdefaults "SMBIOSdefaults" /* smbios_patcher.c */ +#define kUSBBusFix "USBBusFix" /* usb.c */ +#define kEHCIacquire "EHCIacquire" /* usb.c */ +#define kUHCIreset "UHCIreset" /* usb.c */ +#define kEHCIhard "EHCIhard" /* usb.c */ +#define kDefaultPartition "Default Partition" /* sys.c */ /* Zenith432: added this */ -#define kXHCILegacyOff "XHCILegacyOff" /* usb.c */ +#define kXHCILegacyOff "XHCILegacyOff" /* usb.c */ /* Duvel300: added this */ -#define kRestartFix "RestartFix" /* acpi_patcher.c */ +#define kRestartFix "RestartFix" /* acpi_patcher.c */ /* Slice: added this */ -#define kPS2RestartFix "PS2RestartFix" /* acpi_patcher.c */ -#define kUseIntelHDMI "UseIntelHDMI" /* ati.c && nvidia.c && gma.c */ +#define kPS2RestartFix "PS2RestartFix" /* acpi_patcher.c */ +#define kUseIntelHDMI "UseIntelHDMI" /* ati.c && nvidia.c && gma.c */ /* Signal64: added this key */ -#define kLegacyOff "USBLegacyOff" /* usb.c */ +#define kLegacyOff "USBLegacyOff" /* usb.c */ /* Lebidou: added this key */ /* Meklort: added this key */ -#define kMD0Image "md0" /* ramdisk.h */ +#define kMD0Image "md0" /* ramdisk.h */ /* Andyvand: added these keys */ /* Mojodojo: added these keys */ -#define kGeneratePStates "GeneratePStates" /* acpi_patcher.c */ -#define kGenerateCStates "GenerateCStates" /* acpi_patcher.c */ -#define kCSTUsingSystemIO "CSTUsingSystemIO" /* acpi_patcher.c */ -#define kEnableC2State "EnableC2State" /* acpi_patcher.c */ -#define kEnableC3State "EnableC3State" /* acpi_patcher.c */ -#define kEnableC4State "EnableC4State" /* acpi_patcher.c */ -#define kEnableC6State "EnableC6State" /* acpi_patcher.c */ -#define kEnableC7State "EnableC7State" /* acpi_patcher.c */ +#define kGeneratePStates "GeneratePStates" /* acpi_patcher.c */ +#define kGenerateCStates "GenerateCStates" /* acpi_patcher.c */ +#define kCSTUsingSystemIO "CSTUsingSystemIO" /* acpi_patcher.c */ +#define kEnableC2State "EnableC2State" /* acpi_patcher.c */ +#define kEnableC3State "EnableC3State" /* acpi_patcher.c */ +#define kEnableC4State "EnableC4State" /* acpi_patcher.c */ +#define kEnableC6State "EnableC6State" /* acpi_patcher.c */ +#define kEnableC7State "EnableC7State" /* acpi_patcher.c */ /* valv: added these keys */ -#define kbusratio "busratio" /* cpu.c */ -#define kDcfg0 "display_0" /* nvidia.c */ -#define kDcfg1 "display_1" /* nvidia.c */ +#define kbusratio "busratio" /* cpu.c */ +#define kDcfg0 "display_0" /* nvidia.c */ +#define kDcfg1 "display_1" /* nvidia.c */ /* Marchrius: added these keys */ -#define kEnableBacklight "EnableBacklight" /* nvidia.c */ +#define kEnableBacklight "EnableBacklight" /* nvidia.c */ /* Kabyl: added these keys */ -#define kAtiConfig "AtiConfig" /* ati.c */ -#define kAtiPorts "AtiPorts" /* ati.c */ -#define kATYbinimage "ATYbinimage" /* ati.c */ +#define kAtiConfig "AtiConfig" /* ati.c */ +#define kAtiPorts "AtiPorts" /* ati.c */ +#define kATYbinimage "ATYbinimage" /* ati.c */ /* cosmo1: added these keys */ -#define kEnableHDMIAudio "EnableHDMIAudio" /* ati.c && nvidia.c */ +#define kEnableHDMIAudio "EnableHDMIAudio" /* ati.c && nvidia.c */ /* cparm: added these keys */ /* ErmaC: added these keys */ -#define kEnableDualLink "EnableDualLink" /* nvidia.c && gma.c*/ -#define kNvidiaGeneric "NvidiaGeneric" /* nvidia.c */ -#define kSkipIntelGfx "SkipIntelGfx" /* pci_setup.c */ -#define kSkipNvidiaGfx "SkipNvidiaGfx" /* pci_setup.c */ -#define kSkipAtiGfx "SkipAtiGfx" /* pci_setup.c */ -#define kIntelCapriFB "IntelCapriFB" /* gma.c was HD4K-ig */ -#define kIntelAzulFB "IntelAzulFB" /* gma.c was HD5K-ig */ -#define kAAPLCustomIG "InjectIntel-ig" /* gma.c */ -#define kHDAEnabler "HDAEnabler" /* pci_setup.c */ -#define kHDEFLayoutID "HDEFLayoutID" /* hda.c */ -#define kHDAULayoutID "HDAULayoutID" /* hda.c */ +#define kEnableDualLink "EnableDualLink" /* nvidia.c && gma.c*/ +#define kNvidiaGeneric "NvidiaGeneric" /* nvidia.c */ +#define kSkipIntelGfx "SkipIntelGfx" /* pci_setup.c */ +#define kSkipNvidiaGfx "SkipNvidiaGfx" /* pci_setup.c */ +#define kSkipAtiGfx "SkipAtiGfx" /* pci_setup.c */ +#define kIntelCapriFB "IntelCapriFB" /* gma.c was HD4K-ig */ +#define kIntelAzulFB "IntelAzulFB" /* gma.c was HD5K-ig */ +#define kAAPLCustomIG "InjectIntel-ig" /* gma.c */ +#define kHDAEnabler "HDAEnabler" /* pci_setup.c */ +#define kHDEFLayoutID "HDEFLayoutID" /* hda.c */ +#define kHDAULayoutID "HDAULayoutID" /* hda.c */ /* Karas: added these keys */ -#define kMemFullInfo "ForceFullMemInfo" /* smbios.c */ +#define kMemFullInfo "ForceFullMemInfo" /* smbios.c */ /* Bungo: added these keys */ -#define kPrivateData "PrivateData" /* smbios_decode.c */ +#define kPrivateData "PrivateData" /* smbios_decode.c */ /* * Flags to the booter or kernel */ -#define kVerboseModeFlag "-v" -#define kSafeModeFlag "-x" -#define kIgnoreCachesFlag "-f" -#define kIgnoreBootFileFlag "-F" -#define kSingleUserModeFlag "-s" +#define kVerboseModeFlag "-v" +#define kSafeModeFlag "-x" +#define kIgnoreCachesFlag "-f" +#define kIgnoreBootFileFlag "-F" +#define kSingleUserModeFlag "-s" /* * Booter behavior control */ -#define kBootTimeout -1 -#define kCDBootTimeout 8 +#define kBootTimeout -1 +#define kCDBootTimeout 8 /* * A global set by boot() to record the device that the booter was loaded from. @@ -277,8 +277,9 @@ extern long LoadDrivers(char * dirSpec); extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize); typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin); - // Bungo +// Bungo extern char *gDarwinBuildVerStr; + /*! Hookable function pointer called during the driver loading phase that allows other code to cause additional drivers to be loaded. Index: trunk/i386/boot2/bmdecompress.c =================================================================== --- trunk/i386/boot2/bmdecompress.c (revision 2538) +++ trunk/i386/boot2/bmdecompress.c (revision 2539) @@ -41,6 +41,12 @@ uint16_t * sc1 = malloc((width+2) * sizeof(uint16_t)); uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t)); uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t)); + + if (!sc0 || !sc1 || !sc2 || !sc3) + { + return; + } + uint32_t sr0, sr1, sr2, sr3; bzero(sc0, (width+2) * sizeof(uint16_t)); @@ -153,6 +159,12 @@ uint16_t * sc1 = malloc((width+2) * sizeof(uint16_t)); uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t)); uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t)); + + if (!sc0 || !sc1 || !sc2 || !sc3) + { + return; + } + uint32_t sr0, sr1, sr2, sr3; bzero(sc0, (width+2) * sizeof(uint16_t)); Index: trunk/i386/boot2/options.c =================================================================== --- trunk/i386/boot2/options.c (revision 2538) +++ trunk/i386/boot2/options.c (revision 2539) @@ -38,8 +38,8 @@ #define DBG(x...) msglog(x) #endif -bool showBootBanner = true; //Azi:showinfo -static bool shouldboot = false; +bool showBootBanner = true; //Azi:showinfo +static bool shouldboot = false; extern int multiboot_timeout; extern int multiboot_timeout_set;