Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

263 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. crusoe.h
  5. Author:
  6. Todd Carpenter (10/31/00) - create file
  7. Environment:
  8. Kernel mode
  9. Notes:
  10. Revision History:
  11. --*/
  12. #ifndef _CRUSOE_H
  13. #define _CRUSOE_H
  14. #include "..\lib\processor.h"
  15. #include "..\eventmsg.h"
  16. #include <pshpack1.h>
  17. //
  18. // CPUID
  19. //
  20. #define LONGRUN_CPUID_MAXFUNCTION 0x80860000 // Max supported CPUID function, (ie 0x80860007)
  21. #define LONGRUN_CPUID_PROCESSOR_INFO 0x80860001
  22. #define LONGRUN_CPUID_GETSTATE 0x80860007 // Current Speed, Voltage, and State
  23. //
  24. // read: upper:lower bound of current performance percentage window
  25. // write: set the upper:lower bound of desired performance percentage window
  26. // Correct:
  27. // if EDX == EAX == 100d, then full performance (ie LongRun disabled)
  28. // if EDX == EAX, then fixed performance
  29. // if EDX > EAX, the performance within upper:lower window
  30. //
  31. // Incorrect: (results in #GP(0))
  32. // if (EDX > 100d) or (EAX > 100d)
  33. // if (EDX < EAX)
  34. //
  35. //
  36. // CMS4.1 MSR
  37. //
  38. #define LONGRUN_CONTROL_STATUS_MSR 0x80868010
  39. //
  40. // CMS4.2 Longrun Table Interface MSR's
  41. //
  42. #define LONGRUN_FLAGS_REGISTER_MSR 0x80868011
  43. #define LONGRUN_TI_READOUT_MSR 0x80868018
  44. #define LONGRUN_TI_PERFORMANCE_INDEX_MSR 0x80868019
  45. #define LONGRUN_TI_VOLTAGE_FREQUENCY_MSR 0x8086801A
  46. #define LONGRUN_TI_MEMORY_DIVISORS_MSR 0x8086801B
  47. #define LONGRUN_TI_IO_DIVISORS_MSR 0x8086801C
  48. #define LONGRUN_TI_GATE_DELAY_MSR 0x8086801D
  49. //
  50. // Processor Feature Flags
  51. //
  52. #define FEATURE_LONGRUN_ENALBED 0x2
  53. #define FEATURE_LRTI_ENABLED 0x8
  54. #define INVALID_LONGRUN_STATE (ULONG)-1
  55. #define MAX_LONGRUN_VALUE 100
  56. #define MAX_LONGRUN_STATES 4
  57. #define CRUSOE_TRANSITION_LATENCY 20 // microseconds
  58. typedef struct _STATE_INFO {
  59. ULONG CpuSpeed;
  60. ULONG Voltage;
  61. ULONG LongRunValue;
  62. } STATE_INFO, *PSTATE_INFO;
  63. typedef struct _LEGACY_INTERFACE_INFO {
  64. ULONG CurrentState;
  65. ULONG MaxSupportedStates;
  66. ULONG CurrentlyAvailableStates;
  67. } LEGACY_INTERFACE_INFO, *PLEGACY_INTERFACE_INFO;
  68. typedef struct _LONGRUN_STATES {
  69. ULONG MaxState;
  70. STATE_INFO States[MAX_LONGRUN_STATES];
  71. } LONGRUN_STATES, *PLONGRUN_STATES;
  72. //
  73. // Acpi 2.0 stuff
  74. //
  75. typedef struct {
  76. union {
  77. struct {
  78. ULONG Min:16; // 15:0 LongRun Lower Bound
  79. ULONG Max:16; // 31:16 LongRun Upper Bound
  80. };
  81. ULONG AsDWord;
  82. };
  83. } CRUSOE_PSS_VALUE;
  84. //
  85. // crusoe.c
  86. //
  87. NTSTATUS
  88. AdjustLegacyProcessorPerformanceStates(
  89. IN OUT PPROCESSOR_PERFORMANCE_STATES PerfStates
  90. );
  91. //
  92. // longrun.c
  93. //
  94. NTSTATUS
  95. InitializeLegacyInterface(
  96. IN PFDO_DATA DeviceExtension
  97. );
  98. NTSTATUS
  99. SetCurrentStateMSR(
  100. IN ULONG State,
  101. IN BOOLEAN InitPhase
  102. );
  103. ULONG
  104. ConvertLongRunValueToPerfState(
  105. IN PLONGRUN_STATES PerfStates,
  106. IN ULONG LongRunValue
  107. );
  108. NTSTATUS
  109. GetCurrentCpuSpeed(
  110. OUT PULONG CpuSpeed
  111. );
  112. NTSTATUS
  113. GetMaxCpuSpeed(
  114. OUT PULONG CpuSpeed
  115. );
  116. VOID
  117. GetProcessorFeatureFlags(
  118. OUT PULONG Flags
  119. );
  120. NTSTATUS
  121. GetCurrentStateInfo(
  122. OUT PSTATE_INFO StateInfo
  123. );
  124. ULONGLONG
  125. GetCurrentPerformanceRange(
  126. VOID
  127. );
  128. VOID
  129. SetCurrentPerformanceRange(
  130. IN ULONG Min,
  131. IN ULONG Max
  132. );
  133. NTSTATUS
  134. CalculateLongRunPerfStates(
  135. IN PLONGRUN_STATES PerfStates
  136. );
  137. NTSTATUS
  138. BuildAcpi2PerformanceStates(
  139. IN PACPI_PSS_PACKAGE PerfStates
  140. );
  141. NTSTATUS
  142. BuildLongRunPerfStatesCMS41(
  143. OUT PACPI_PSS_PACKAGE *PssPackage
  144. );
  145. NTSTATUS
  146. BuildLongRunPerfStatesCMS42(
  147. OUT PACPI_PSS_PACKAGE *PssPackage
  148. );
  149. ULONG
  150. LRTI_GetMaxSupportedLevel(
  151. VOID
  152. );
  153. VOID
  154. LRTI_SetCurrentLevel (
  155. ULONG LongRunLevel
  156. );
  157. ULONG
  158. LRTI_GetPerformanceIndex (
  159. VOID
  160. );
  161. ULONG
  162. LRTI_GetVoltage (
  163. VOID
  164. );
  165. ULONG
  166. LRTI_GetFrequency (
  167. VOID
  168. );
  169. ULONG
  170. GetLongRunFlagsRegister (
  171. VOID
  172. );
  173. VOID
  174. SetLongRunEconomyMode (
  175. VOID
  176. );
  177. VOID
  178. SetLongRunPerformanceMode (
  179. VOID
  180. );
  181. #if DBG
  182. VOID
  183. DisplayStateInfo(
  184. IN PSTATE_INFO State
  185. );
  186. VOID
  187. DisplayLongRunStates(
  188. IN PLONGRUN_STATES States
  189. );
  190. #else
  191. #define DisplayStateInfo(_x_)
  192. #define DisplayLongRunStates(_x_)
  193. #endif
  194. #endif