Index: branches/meklort/i386/modules/ACPIPatcher/acpi_patcher.c =================================================================== --- branches/meklort/i386/modules/ACPIPatcher/acpi_patcher.c (revision 655) +++ branches/meklort/i386/modules/ACPIPatcher/acpi_patcher.c (revision 656) @@ -25,12 +25,10 @@ #define DBG(x...) #endif -uint64_t acpi10_p; -uint64_t acpi20_p; - extern char* gSMBIOSBoardModel; + // Slice: New signature compare function boolean_t tableSign(char *table, const char *sgn) { @@ -106,13 +104,12 @@ sprintf(dirSpec,"%s.%s", gSMBIOSBoardModel, filename); fd = open(dirSpec, 0); } - if (fd < 0) { sprintf(dirSpec, "%s", filename); fd = open(dirSpec, 0); if (fd < 0) - { + { if(gSMBIOSBoardModel) { sprintf(dirSpec, "/Extra/%s.%s", gSMBIOSBoardModel, filename); @@ -130,12 +127,11 @@ fd = open(dirSpec, 0); } if (fd < 0) - { + { sprintf(dirSpec, "bt(0,0)/Extra/%s", filename); fd = open(dirSpec, 0); } } - } } } @@ -146,7 +142,7 @@ verbose("ACPI table not found: %s\n", filename); *dirSpec = '\0'; } - + if (outDirspec) *outDirspec = dirSpec; return fd; } @@ -266,12 +262,17 @@ if (acpi_cpu_count > 0) { - bool c2_enabled = fadt->C2_Latency < 100; - bool c3_enabled = fadt->C3_Latency < 1000; + bool c2_enabled = false; + bool c3_enabled = false; bool c4_enabled = false; + getBoolForKey(kEnableC2States, &c2_enabled, &bootInfo->bootConfig); + getBoolForKey(kEnableC3States, &c3_enabled, &bootInfo->bootConfig); getBoolForKey(kEnableC4States, &c4_enabled, &bootInfo->bootConfig); + c2_enabled = c2_enabled | (fadt->C2_Latency < 100); + c3_enabled = c3_enabled | (fadt->C3_Latency < 1000); + unsigned char cstates_count = 1 + (c2_enabled ? 1 : 0) + (c3_enabled ? 1 : 0); struct aml_chunk* root = aml_create_node(NULL); @@ -462,7 +463,7 @@ if (maximum.CID < minimum.CID) { DBG("Insane FID values!"); - p_states_count = 1; + p_states_count = 0; } else { @@ -512,7 +513,9 @@ p_states_count -= invalid; } - } break; + + break; + } case CPU_MODEL_FIELDS: case CPU_MODEL_DALES: case CPU_MODEL_DALES_32NM: @@ -520,6 +523,34 @@ case CPU_MODEL_NEHALEM_EX: case CPU_MODEL_WESTMERE: case CPU_MODEL_WESTMERE_EX: + { + maximum.Control = rdmsr64(MSR_IA32_PERF_STATUS) & 0xff; // Seems it always contains maximum multiplier value (with turbo, that's we need)... + minimum.Control = (rdmsr64(MSR_PLATFORM_INFO) >> 40) & 0xff; + + verbose("P-States: min 0x%x, max 0x%x\n", minimum.Control, maximum.Control); + + // Sanity check + if (maximum.Control < minimum.Control) + { + DBG("Insane control values!"); + p_states_count = 0; + } + else + { + uint8_t i; + p_states_count = 0; + + for (i = maximum.Control; i >= minimum.Control; i--) + { + p_states[p_states_count].Control = i; + p_states[p_states_count].CID = p_states[p_states_count].Control << 1; + p_states[p_states_count].Frequency = (Platform->CPU.FSBFrequency / 1000000) * i; + p_states_count++; + } + } + + break; + } default: verbose ("Unsupported CPU: P-States not generated !!!\n"); break; @@ -669,7 +700,6 @@ { DBG("DSDT: Old @%x,%x, ",fadt_mod->DSDT,fadt_mod->X_DSDT); - // Insert old dsdt into the IORegistery Node* node = DT__FindNode("/dsdt", false); if(node == NULL) @@ -744,6 +774,7 @@ sprintf(dirSpec, "DSDT.%s.aml", gSMBIOSBoardModel); new_dsdt = loadACPITable(dirSpec); } + // Mozodojo: going to patch FACP and load SSDT's even if DSDT.aml is not present /*if (!new_dsdt) { Index: branches/meklort/i386/modules/ACPIPatcher/aml_generator.h =================================================================== --- branches/meklort/i386/modules/ACPIPatcher/aml_generator.h (revision 655) +++ branches/meklort/i386/modules/ACPIPatcher/aml_generator.h (revision 656) @@ -11,7 +11,9 @@ #define __LIBSAIO_AML_GENERATOR_H #include "libsaio.h" +#include "ACPIPatcher.h" + #define AML_CHUNK_NONE 0xff #define AML_CHUNK_ZERO 0x00 #define AML_CHUNK_ONE 0x01 Index: branches/meklort/i386/modules/ACPIPatcher/acpi_patcher.h =================================================================== --- branches/meklort/i386/modules/ACPIPatcher/acpi_patcher.h (revision 655) +++ branches/meklort/i386/modules/ACPIPatcher/acpi_patcher.h (revision 656) @@ -7,6 +7,7 @@ #include "libsaio.h" #include "efi.h" +#include "ACPIPatcher.h" #define ACPI_2_0 2 #define ACPI_1_0 1 Index: branches/meklort/i386/modules/ACPIPatcher/ACPIPatcher.h =================================================================== --- branches/meklort/i386/modules/ACPIPatcher/ACPIPatcher.h (revision 0) +++ branches/meklort/i386/modules/ACPIPatcher/ACPIPatcher.h (revision 656) @@ -0,0 +1,3 @@ +#define kEnableC2States "EnableC2State" /* acpi_patcher.c */ +#define kEnableC3States "EnableC3State" /* acpi_patcher.c */ +#define kEnableC4States "EnableC4State" /* acpi_patcher.c */ \ No newline at end of file Index: branches/meklort/i386/modules/MakeInc.dir =================================================================== --- branches/meklort/i386/modules/MakeInc.dir (revision 655) +++ branches/meklort/i386/modules/MakeInc.dir (revision 656) @@ -16,7 +16,7 @@ HAVE_MODULES := $(wildcard $(SYMROOT)/*.dylib) ifneq ($(strip $(HAVE_MODULES)),) dylib: ${MODULE_OBJS} - @echo "\tLD $(MODULE_NAME).dylib" + @echo "\t[LD] $(MODULE_NAME).dylib" @ld -arch i386 \ -undefined dynamic_lookup \ -alias $(MODULE_START) start \