[PATCH 2/5] ntdll: Return as many PROCESSOR_POWER_INFORMATIONs as there are CPUs

James Eder jimportal at gmail.com
Fri Sep 7 15:29:27 CDT 2012


---
 dlls/ntdll/nt.c | 159 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 83 insertions(+), 76 deletions(-)

diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 44bdc5f..d38fedb 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -2264,86 +2264,93 @@ NTSTATUS WINAPI NtInitiatePowerAction(
 	
 
 /******************************************************************************
- *  NtPowerInformation				[NTDLL.@]
+ *  NtPowerInformation                          [NTDLL.@]
  *
  */
 NTSTATUS WINAPI NtPowerInformation(
-	IN POWER_INFORMATION_LEVEL InformationLevel,
-	IN PVOID lpInputBuffer,
-	IN ULONG nInputBufferSize,
-	IN PVOID lpOutputBuffer,
-	IN ULONG nOutputBufferSize)
+    IN POWER_INFORMATION_LEVEL InformationLevel,
+    IN PVOID lpInputBuffer,
+    IN ULONG nInputBufferSize,
+    IN PVOID lpOutputBuffer,
+    IN ULONG nOutputBufferSize)
 {
-	TRACE("(%d,%p,%d,%p,%d)\n",
-		InformationLevel,lpInputBuffer,nInputBufferSize,lpOutputBuffer,nOutputBufferSize);
-	switch(InformationLevel) {
-		case SystemPowerCapabilities: {
-			PSYSTEM_POWER_CAPABILITIES PowerCaps = lpOutputBuffer;
-			FIXME("semi-stub: SystemPowerCapabilities\n");
-			if (nOutputBufferSize < sizeof(SYSTEM_POWER_CAPABILITIES))
-				return STATUS_BUFFER_TOO_SMALL;
-			/* FIXME: These values are based off a native XP desktop, should probably use APM/ACPI to get the 'real' values */
-			PowerCaps->PowerButtonPresent = TRUE;
-			PowerCaps->SleepButtonPresent = FALSE;
-			PowerCaps->LidPresent = FALSE;
-			PowerCaps->SystemS1 = TRUE;
-			PowerCaps->SystemS2 = FALSE;
-			PowerCaps->SystemS3 = FALSE;
-			PowerCaps->SystemS4 = TRUE;
-			PowerCaps->SystemS5 = TRUE;
-			PowerCaps->HiberFilePresent = TRUE;
-			PowerCaps->FullWake = TRUE;
-			PowerCaps->VideoDimPresent = FALSE;
-			PowerCaps->ApmPresent = FALSE;
-			PowerCaps->UpsPresent = FALSE;
-			PowerCaps->ThermalControl = FALSE;
-			PowerCaps->ProcessorThrottle = FALSE;
-			PowerCaps->ProcessorMinThrottle = 100;
-			PowerCaps->ProcessorMaxThrottle = 100;
-			PowerCaps->DiskSpinDown = TRUE;
-			PowerCaps->SystemBatteriesPresent = FALSE;
-			PowerCaps->BatteriesAreShortTerm = FALSE;
-			PowerCaps->BatteryScale[0].Granularity = 0;
-			PowerCaps->BatteryScale[0].Capacity = 0;
-			PowerCaps->BatteryScale[1].Granularity = 0;
-			PowerCaps->BatteryScale[1].Capacity = 0;
-			PowerCaps->BatteryScale[2].Granularity = 0;
-			PowerCaps->BatteryScale[2].Capacity = 0;
-			PowerCaps->AcOnLineWake = PowerSystemUnspecified;
-			PowerCaps->SoftLidWake = PowerSystemUnspecified;
-			PowerCaps->RtcWake = PowerSystemSleeping1;
-			PowerCaps->MinDeviceWakeState = PowerSystemUnspecified;
-			PowerCaps->DefaultLowLatencyWake = PowerSystemUnspecified;
-			return STATUS_SUCCESS;
-		}
-		case SystemExecutionState: {
-			PULONG ExecutionState = lpOutputBuffer;
-			WARN("semi-stub: SystemExecutionState\n"); /* Needed for .NET Framework, but using a FIXME is really noisy. */
-			if (lpInputBuffer != NULL)
-				return STATUS_INVALID_PARAMETER;
-			/* FIXME: The actual state should be the value set by SetThreadExecutionState which is not currently implemented. */
-			*ExecutionState = ES_USER_PRESENT;
-			return STATUS_SUCCESS;
-		}
-                case ProcessorInformation: {
-			PPROCESSOR_POWER_INFORMATION cpu_power = lpOutputBuffer;
-
-			WARN("semi-stub: ProcessorInformation\n");
-			if (nOutputBufferSize < sizeof(PROCESSOR_POWER_INFORMATION))
-				return STATUS_BUFFER_TOO_SMALL;
-                        cpu_power->Number = NtCurrentTeb()->Peb->NumberOfProcessors;
-                        cpu_power->MaxMhz = cpuHz / 1000000;
-                        cpu_power->CurrentMhz = cpuHz / 1000000;
-                        cpu_power->MhzLimit = cpuHz / 1000000;
-                        cpu_power->MaxIdleState = 0; /* FIXME */
-                        cpu_power->CurrentIdleState = 0; /* FIXME */
-                        return STATUS_SUCCESS;
-                }
-		default:
-			/* FIXME: Needed by .NET Framework */
-			WARN("Unimplemented NtPowerInformation action: %d\n", InformationLevel);
-			return STATUS_NOT_IMPLEMENTED;
-	}
+    TRACE("(%d,%p,%d,%p,%d)\n",
+          InformationLevel,lpInputBuffer,nInputBufferSize,lpOutputBuffer,nOutputBufferSize);
+    switch(InformationLevel) {
+        case SystemPowerCapabilities: {
+            PSYSTEM_POWER_CAPABILITIES PowerCaps = lpOutputBuffer;
+            FIXME("semi-stub: SystemPowerCapabilities\n");
+            if (nOutputBufferSize < sizeof(SYSTEM_POWER_CAPABILITIES))
+                return STATUS_BUFFER_TOO_SMALL;
+            /* FIXME: These values are based off a native XP desktop, should probably use APM/ACPI to get the 'real' values */
+            PowerCaps->PowerButtonPresent = TRUE;
+            PowerCaps->SleepButtonPresent = FALSE;
+            PowerCaps->LidPresent = FALSE;
+            PowerCaps->SystemS1 = TRUE;
+            PowerCaps->SystemS2 = FALSE;
+            PowerCaps->SystemS3 = FALSE;
+            PowerCaps->SystemS4 = TRUE;
+            PowerCaps->SystemS5 = TRUE;
+            PowerCaps->HiberFilePresent = TRUE;
+            PowerCaps->FullWake = TRUE;
+            PowerCaps->VideoDimPresent = FALSE;
+            PowerCaps->ApmPresent = FALSE;
+            PowerCaps->UpsPresent = FALSE;
+            PowerCaps->ThermalControl = FALSE;
+            PowerCaps->ProcessorThrottle = FALSE;
+            PowerCaps->ProcessorMinThrottle = 100;
+            PowerCaps->ProcessorMaxThrottle = 100;
+            PowerCaps->DiskSpinDown = TRUE;
+            PowerCaps->SystemBatteriesPresent = FALSE;
+            PowerCaps->BatteriesAreShortTerm = FALSE;
+            PowerCaps->BatteryScale[0].Granularity = 0;
+            PowerCaps->BatteryScale[0].Capacity = 0;
+            PowerCaps->BatteryScale[1].Granularity = 0;
+            PowerCaps->BatteryScale[1].Capacity = 0;
+            PowerCaps->BatteryScale[2].Granularity = 0;
+            PowerCaps->BatteryScale[2].Capacity = 0;
+            PowerCaps->AcOnLineWake = PowerSystemUnspecified;
+            PowerCaps->SoftLidWake = PowerSystemUnspecified;
+            PowerCaps->RtcWake = PowerSystemSleeping1;
+            PowerCaps->MinDeviceWakeState = PowerSystemUnspecified;
+            PowerCaps->DefaultLowLatencyWake = PowerSystemUnspecified;
+            return STATUS_SUCCESS;
+        }
+        case SystemExecutionState: {
+            PULONG ExecutionState = lpOutputBuffer;
+            WARN("semi-stub: SystemExecutionState\n"); /* Needed for .NET Framework, but using a FIXME is really noisy. */
+            if (lpInputBuffer != NULL)
+                return STATUS_INVALID_PARAMETER;
+            /* FIXME: The actual state should be the value set by SetThreadExecutionState which is not currently implemented. */
+            *ExecutionState = ES_USER_PRESENT;
+            return STATUS_SUCCESS;
+        }
+        case ProcessorInformation: {
+            PROCESSOR_POWER_INFORMATION* cpu_power = lpOutputBuffer;
+            int i;
+
+            WARN("semi-stub: ProcessorInformation\n");
+
+            if ((lpOutputBuffer == NULL) || (nOutputBufferSize == 0))
+                return STATUS_INVALID_PARAMETER;
+            if ((nOutputBufferSize / sizeof(PROCESSOR_POWER_INFORMATION)) < NtCurrentTeb()->Peb->NumberOfProcessors)
+                return STATUS_BUFFER_TOO_SMALL;
+
+            for(i = 0; i < NtCurrentTeb()->Peb->NumberOfProcessors; i++) {
+                cpu_power[i].Number = i;
+                cpu_power[i].MaxMhz = cpuHz / 1000000;
+                cpu_power[i].CurrentMhz = cpuHz / 1000000;
+                cpu_power[i].MhzLimit = cpuHz / 1000000;
+                cpu_power[i].MaxIdleState = 0; /* FIXME */
+                cpu_power[i].CurrentIdleState = 0; /* FIXME */
+            }
+            return STATUS_SUCCESS;
+        }
+        default:
+            /* FIXME: Needed by .NET Framework */
+            WARN("Unimplemented NtPowerInformation action: %d\n", InformationLevel);
+            return STATUS_NOT_IMPLEMENTED;
+    }
 }
 
 /******************************************************************************
-- 
1.7.12




More information about the wine-patches mailing list