Index: branches/mozodojo/i386/libsaio/acpi_patcher.c =================================================================== --- branches/mozodojo/i386/libsaio/acpi_patcher.c (revision 195) +++ branches/mozodojo/i386/libsaio/acpi_patcher.c (revision 196) @@ -195,28 +195,32 @@ for (i=0; i> 6) + 1, j; + bool add_name = TRUE; + for (j=0; j<4; j++) { - if (aml_isvalidchar(dsdt[i+2+j])) + char c = dsdt[offset+j]; + + if (!aml_isvalidchar(c)) { - acpi_cpu_name[acpi_cpu_count][j] = dsdt[i+2+j]; + add_name = FALSE; + verbose("Invalid characters found in ProcessorOP!\n"); + break; } - else - { - verbose("Invalid characters found in ProcessorOP!"); - free(acpi_cpu_name[acpi_cpu_count]); - continue; - } } - verbose("Found %c%c%c%c (from DSDT)\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]); - - acpi_cpu_count++; + if (add_name && dsdt[offset+5] < 32 ) + { + acpi_cpu_name[acpi_cpu_count] = malloc(5); + memcpy(acpi_cpu_name[acpi_cpu_count], dsdt+offset, 4); + + verbose("Found %c%c%c%c (from DSDT)\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]); + + if (++acpi_cpu_count == 32) return; + } } } } @@ -775,8 +779,9 @@ // Mozodojo: Load additional SSDTs struct acpi_2_ssdt *new_ssdt[32]; // 30 + 2 additional tables for pss & cst - struct acpi_2_fadt *fadt; // will be used in CST generator int ssdt_count=0; + + // SSDT Options bool drop_ssdt=false, generate_pstates=false, generate_cstates=false; getBoolForKey(kDropSSDT, &drop_ssdt, &bootInfo->bootConfig); @@ -841,7 +846,8 @@ int rsdt_entries_num; int dropoffset=0, i; - rsdt_mod=(struct acpi_2_rsdt *)AllocateKernelMemory(rsdt->Length); + // mozo: using malloc cos I didn't found how to free already allocated kernel memory + rsdt_mod=(struct acpi_2_rsdt *)malloc(rsdt->Length); memcpy (rsdt_mod, rsdt, rsdt->Length); rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod; rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4; @@ -872,7 +878,7 @@ } if (tableSign(table, "FACP")) { - struct acpi_2_fadt *fadt_mod; + struct acpi_2_fadt *fadt, *fadt_mod; fadt=(struct acpi_2_fadt *)rsdt_entries[i]; DBG("FADT found @%x, Length %d\n",fadt, fadt->Length); @@ -899,44 +905,25 @@ } DBG("\n"); + // Allocate rsdt in Kernel memory area + rsdt_mod->Length += rsdt_mod->Length + 4*ssdt_count - 4*dropoffset; + struct acpi_2_rsdt *rsdt_copy = (struct acpi_2_rsdt *)AllocateKernelMemory(rsdt_mod->Length); + memcpy (rsdt_copy, rsdt_mod, rsdt_mod->Length); + free(rsdt_mod); rsdt_mod = rsdt_copy; + rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod; + rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4; + rsdt_entries=(uint32_t *)(rsdt_mod+1); + // Mozodojo: Insert additional SSDTs into RSDT if(ssdt_count>0) { - uint32_t j = rsdt_mod->Length; - bool add_new_ssdt = TRUE; + int j; - rsdt_mod->Length+=4*ssdt_count-4*dropoffset; - - if (rsdt_mod->Length > j) - { - struct acpi_2_rsdt *rsdt_copy = (struct acpi_2_rsdt *)AllocateKernelMemory(rsdt_mod->Length); - if (rsdt_copy) - { - memcpy (rsdt_copy, rsdt_mod, rsdt_mod->Length); - free(rsdt_mod); rsdt_mod = rsdt_copy; - rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod; - rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4; - rsdt_entries=(uint32_t *)(rsdt_mod+1); - } - else - { - verbose("RSDT: Couldn't allocate memory for additional SSDT tables!\n"); - add_new_ssdt = FALSE; - } - } - - if (add_new_ssdt) - { - for (j=0; jLength-=4*dropoffset; - } // Correct the checksum of RSDT DBG("RSDT: Original checksum %d, ", rsdt_mod->Checksum); @@ -967,7 +954,8 @@ int xsdt_entries_num, i; int dropoffset=0; - xsdt_mod=(struct acpi_2_xsdt*)AllocateKernelMemory(xsdt->Length); + // mozo: using malloc cos I didn't found how to free already allocated kernel memory + xsdt_mod=(struct acpi_2_xsdt*)malloc(xsdt->Length); memcpy(xsdt_mod, xsdt, xsdt->Length); rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod; xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8; @@ -998,7 +986,7 @@ } if (tableSign(table, "FACP")) { - struct acpi_2_fadt *fadt_mod; + struct acpi_2_fadt *fadt, *fadt_mod; fadt=(struct acpi_2_fadt *)(uint32_t)xsdt_entries[i]; DBG("FADT found @%x,%x, Length %d\n",(uint32_t)(xsdt_entries[i]>>32),fadt, @@ -1030,45 +1018,25 @@ } + // Allocate xsdt in Kernel memory area + xsdt_mod->Length += 8*ssdt_count - 8*dropoffset; + struct acpi_2_xsdt *xsdt_copy = (struct acpi_2_xsdt *)AllocateKernelMemory(xsdt_mod->Length); + memcpy(xsdt_copy, xsdt_mod, xsdt_mod->Length); + free(xsdt_mod); xsdt_mod = xsdt_copy; + rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod; + xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8; + xsdt_entries=(uint64_t *)(xsdt_mod+1); + // Mozodojo: Insert additional SSDTs into XSDT if(ssdt_count>0) { - int j = xsdt_mod->Length; - bool add_new_ssdt = TRUE; + int j; - xsdt_mod->Length+=8*ssdt_count-8*dropoffset; - - if (xsdt_mod->Length > j) - { - struct acpi_2_xsdt *xsdt_copy = (struct acpi_2_xsdt *)AllocateKernelMemory(xsdt_mod->Length); + for (j=0; jLength); - free(xsdt_mod); xsdt_mod = xsdt_copy; - rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod; - xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8; - xsdt_entries=(uint64_t *)(xsdt_mod+1); - } - else - { - verbose("RSDT: Couldn't allocate memory for additional SSDT tables!\n"); - add_new_ssdt = FALSE; - } - } - - if (add_new_ssdt) - { - for (j=0; jLength-=8*dropoffset; - } // Correct the checksum of XSDT xsdt_mod->Checksum=0; Index: branches/mozodojo/i386/libsaio/spd.c =================================================================== --- branches/mozodojo/i386/libsaio/spd.c (revision 195) +++ branches/mozodojo/i386/libsaio/spd.c (revision 196) @@ -175,7 +175,7 @@ } if (!ret) sprintf(asciiSerial, "10000000%d", serialnum++); - else sprintf(asciiSerial, "%d", ret); + else sprintf(asciiSerial, "%X", ret); return strdup(asciiSerial); } @@ -197,15 +197,16 @@ if (sPart) { // Check that the spd part name is zero terminated and that it is ascii: bzero(asciiPartNo, 32); for (i=0; i<32; i++) { - if (isalpha(sPart[i]) || isdigit(sPart[i])) // It seems that System Profiler likes only letters and digits... - asciiPartNo[index++] = sPart[i]; - else if (!isascii(sPart[i])) + char c = sPart[i]; + if (isalpha(c) || isdigit(c) || ispunct(c)) // It seems that System Profiler likes only letters and digits... + asciiPartNo[index++] = c; + else if (!isascii(c)) break; } return strdup(asciiPartNo); } - return "N/A"; + return NULL; } int mapping []= {0,2,1,3,4,6,5,7,8,10,9,11}; Index: branches/mozodojo/i386/libsaio/smbios_patcher.c =================================================================== --- branches/mozodojo/i386/libsaio/smbios_patcher.c (revision 195) +++ branches/mozodojo/i386/libsaio/smbios_patcher.c (revision 196) @@ -142,88 +142,46 @@ 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.Vendor == 0x756E6547) { - int cores = Platform.CPU.NoCores; - int intelPM = Platform.CPU.Model; //+ (Platform.CPU.ExtModel<< 4);//verify this + if (Platform.CPU.Vendor == 0x756E6547) // Intel + { + verbose("CPU is Intel, model 0x%x, ext.model 0x%x\n", Platform.CPU.Model, Platform.CPU.ExtModel); - switch (intelPM) { - case 13: // Pentium M model D - return 0x0101; - break; - case 14: // Core Solo/Duo, "Yonah", 65nm - return 0x0201; - break; - case 15: // Pentium 4, Core 2, Xeon, "Merom", "Conroe", 65nm - switch (cores) { - case 1: // Core Solo - return 0x0201; - break; - case 2: // Core 2, 65nm - return 0x0301; - break; - case 4: // Quad Core, Xeon - return 0x0501; - break; - default: - return 0x0301; - break; - } - /* if (cores == 1) - return 0x0201; // Core Solo - else if (cores == 2) - return 0x0301; // Core 2, 65nm - else if (cores == 4) - return 0x0501; // Quad-Core Xeon - else - return 0x0301;*/ - break; - case 21: // EP80579 integrated processor - return 0x0301; // ??? - break; - case 22: // Core 2 Solo, "Merom-L", "Conroe-L", 45nm - return 0x0201; // ??? - break; - case 23: // Core 2 Extreme, Xeon, "Penryn", "Wolfdale", 45nm - return 0x0301; - break; - case 26: // Nehalem, Xeon 5500, "Bloomfield", 45nm + 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; - break; - case 29: // Six-Core Xeon 7400, "Dunnington", 45nm - return 0x0401; - break; - case 30: // Nehalem, Xeon, "Lynnfield", "Clarksfield", "Jasper", 45nm - return 0x0701; - break; - case 31: // Core i5, Xeon MP, "Havendale", "Auburndale", 45nm + case 0x1E: // Intel Core i5, i7 LGA1156 (45nm) + case 0x1F: // Intel Core i5, i7 LGA1156 (45nm) ??? return 0x0601; - break; - case 37: // Nehalem, "Clarkdale", 32nm - return 0x0301; // ??? - break; - case 44: // Nehalem, "Gulftown", 32nm + 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; - break; - case 46: // "Nehalem-ex", "Beckton", 45nm - return 0x0301; // ??? - break; - default: - goto core_ident; } - } else { - core_ident: - if (Platform.CPU.NoCores == 1) { - return 0x0201; // Core Solo - } else if (Platform.CPU.NoCores == 2) { - return 0x0301; // Core 2 Duo - } else if (Platform.CPU.NoCores >= 4) { - return 0x0501; // Quad-Core Xeon - } else { - return 0x0301; // Core 2 Duo - } } + + return sm_get_simplecputype(); } static int sm_get_memtype (const char *name, int table_num) Index: branches/mozodojo/i386/libsaio/aml_generator.c =================================================================== --- branches/mozodojo/i386/libsaio/aml_generator.c (revision 195) +++ branches/mozodojo/i386/libsaio/aml_generator.c (revision 196) @@ -15,7 +15,7 @@ return 2; else if (length > 0x3FFF) return 3; - + return 1; } @@ -163,31 +163,11 @@ return 4; } -int aml_get_names_count(const char* name) -{ - int i, len = strlen(name), count = 0; - - for (i = 0; i < len; i++) - { - if (name[i] == '.') - { - count++; - } - else if (!aml_isvalidchar(name[i])) - { - len = i; - break; - } - } - - if (count == 0 && len > 0) - count++; - - return count; -} - int aml_fill_name(struct aml_chunk* node, const char* name) { + if (!node) + return -1; + int i, len = strlen(name), count = 0; for (i = 0; i < len; i++) @@ -230,11 +210,13 @@ node->Buffer[offset++] = 0x2f; // Multi name node->Buffer[offset++] = count; // Names count } - + int j = 0; for (i = 0; i < count; i++) { + offset += aml_fill_simple_name(node->Buffer + offset, name + j); + while (name[j] != '.') { if (j < len) @@ -247,8 +229,6 @@ return -1; } } - - offset += aml_fill_simple_name(node->Buffer + offset, name + j); } return offset; @@ -261,9 +241,9 @@ if (node) { node->Type = AML_CHUNK_NAME; - + aml_fill_name(node, name); - + return node->Length; } Index: branches/mozodojo/i386/libsa/libsa.h =================================================================== --- branches/mozodojo/i386/libsa/libsa.h (revision 195) +++ branches/mozodojo/i386/libsa/libsa.h (revision 196) @@ -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