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.

275 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. p3.h
  5. Abstract:
  6. This is included by every file in p3.sys
  7. Author:
  8. Jake Oshins (3/21/00) - create file
  9. Environment:
  10. Kernel mode
  11. Notes:
  12. Revision History:
  13. --*/
  14. #ifndef _P3_H_
  15. #define _P3_H_
  16. #include "..\lib\processor.h"
  17. #include "..\eventmsg.h"
  18. //
  19. // Time defined in 100ns intervals
  20. //
  21. #define MICROSECOND 10
  22. #define MILLISECOND (MICROSECOND * 1000)
  23. #define SECOND (MILLISECOND * 1000)
  24. #define MINUTE (SECOND * 60)
  25. #define STATUS_PERF_TRANSITIONS_UNAVAILABLE MAXULONG
  26. #define MAX_RETRY_TIMEOUT 1800 // 30 minutes
  27. #define MIN_RETRY_TIMEOUT 1 // 1 second
  28. #define DEFAULT_RETRY_TIMEOUT 60 // 1 minute
  29. //
  30. // Registry location for p3.sys's parameters regkey
  31. //
  32. #define P3_PARAMETERS_KEY L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\P3\\Parameters"
  33. #define ENABLE_LEGACY_SPEEDSTEP_INTERFACE 0x1
  34. #define INTEL_APPLET_REMOVED_ON_UPGRADE 0x2
  35. #define ENABLE_HIGH_SPEED_ON_BATTERY 0x4
  36. //
  37. // Geyserville defintions
  38. //
  39. #define MAX_GEYSERVILLE_STATES 2
  40. #define BIT0 0x1
  41. #define BIT1 0x2
  42. #define BIT2 0x4
  43. #define BIT3 0x8
  44. #define BIT4 0x10
  45. #define MSR_17 0x17
  46. #define MSR_17_HIGH_MOBILE_PROCESSOR 0x40000 // bit 18
  47. #define MSR_17_PLATFORM_ID_OFFSET 19
  48. #define MSR_17_IST_FIELD_OFFSET 24
  49. #define MSR_20 0x20
  50. #define MSR_20_STRIDE_BIT_OFFSET 15
  51. #define MSR_20_STRIDE_BIT (1 << MSR_20_STRIDE_BIT_OFFSET)
  52. #define MSR_2A 0x2A
  53. #define MSR_2A_BUS_SPEED_OFFSET 18
  54. #define MSR_2A_BUS_RATIO_OFFSET 22
  55. #define MSR_2A_BUS_RATIO_MSB_BIT 0x8000000 // bit 27
  56. #define MSR_119 0x119
  57. extern LEGACY_GEYSERVILLE_INT15 LegacyInterface;
  58. //
  59. // Array index is the Bus Ratio
  60. //
  61. #define PROC_STATE_INFO_SIZE 32
  62. //
  63. // State Flags
  64. //
  65. #define COPPERMINE_PROCESSOR 0x1
  66. #define TUALATINE_PROCESSOR 0x2
  67. #define BUS_133MHZ 0x4
  68. #define EXTENDED_BUS_RATIO 0x8
  69. //
  70. // From the Geyserville BIOS Writer's guide, Chapter 2.
  71. // The input is MSR2A[25:22] and MSR2A[27] in a Mobile PentiumIII.
  72. // The output is the core frequency for a 100MHz front-side bus.
  73. //
  74. #define HIGHEST_KNOWN_COPPERMINE_CPUID 0x68A
  75. #define HIGHEST_KNOWN_TUALATIN_CPUID 0x6B1
  76. #define FAMILYMODEL_MASK 0x0FF0 // Mask for family/model codes.
  77. #define FAMILYMODEL_COPPERMINE 0x0680 // Coppermine family/mode code.
  78. #define FAMILYMODEL_TUALATIN 0x06B0 // Tualatin family/mode code.
  79. #define EXTENDED_INFO_TYPE 0x0686 // CPUID of extended bus ratio support
  80. #define EXTENDED_BIN_TYPE 0x068A // CPUID of extended bin support
  81. //
  82. // This is put in ebx before a call.
  83. //
  84. typedef enum {
  85. GeyservilleControl,
  86. GetGeyservilleStatus,
  87. SetGeyservilleState,
  88. SetGeyservilleSetup
  89. } LEGACY_GEYSERVILLE_CONTROL_CODES;
  90. typedef enum {
  91. GeyservilleControlEnableApp,
  92. GeyservilleControlReserved,
  93. GeyservilleControlDisableApp
  94. } LEGACY_GEYSERVILLE_CONTROL_SUBCODES;
  95. typedef enum {
  96. GeyservilleControlSuccessful,
  97. GeyservilleDisabledInSetup,
  98. GeyservilleSystemNotCapable,
  99. GeyservilleDisabledByOS,
  100. GeyservilleInvalidSignature,
  101. GeyservilleUnknownError
  102. } LEGACY_GEYSERVILLE_CONTROL_RETURN_CODES;
  103. typedef enum {
  104. GeyservilleSetSuccessful,
  105. GeyservilleStateUnavailable,
  106. GeyservilleUnsuccessfulTransition,
  107. GeyservilleAbortCritical,
  108. GeyservilleSetUnknownError,
  109. GeyservilleTransitionUnavailable
  110. } LEGACY_GEYSERVILLE_SET_RETURN_CODES;
  111. typedef struct _LEGACY_GEYSERVILLE_INTERFACE_INFO {
  112. ULONG CurrentState;
  113. UCHAR InterfaceMajorRev;
  114. USHORT InterfaceMinorRev;
  115. UCHAR InterfaceReserved;
  116. UCHAR MaxSupportedStates;
  117. UCHAR CurrentlyAvailableStates;
  118. USHORT CurrentBiosSettings;
  119. } LEGACY_GEYSERVILLE_INTERFACE_INFO, *PLEGACY_GEYSERVILLE_INTERFACE_INFO;
  120. typedef struct _P3_GLOBALS {
  121. ULONG HackFlags;
  122. BOOLEAN KnownCPUID;
  123. LEGACY_GEYSERVILLE_INTERFACE_INFO LegacyInterfaceInfo;
  124. ULONG MaxLevelAc;
  125. ULONG MaxLevelDc;
  126. ULONG IstField;
  127. BOOLEAN TransitionsUnavailable;
  128. KDPC Dpc;
  129. KTIMER Timer;
  130. LARGE_INTEGER TimeOut;
  131. } P3_GLOBALS;
  132. typedef struct _PROCESSOR_STATE_INFO {
  133. ULONG BinValue;
  134. ULONG Frequency;
  135. ULONG Power;
  136. } PROCESSOR_STATE_INFO, *PPROCESSOR_STATE_INFO;
  137. //
  138. // bios.c
  139. //
  140. NTSTATUS
  141. InitializeLegacyInterface (
  142. PLEGACY_GEYSERVILLE_INTERFACE_INFO Info,
  143. PFDO_DATA DeviceExtension
  144. );
  145. NTSTATUS
  146. FindLegacyGeyservilleInterface(
  147. VOID
  148. );
  149. NTSTATUS
  150. GetCurrentStateSmm(
  151. PLEGACY_GEYSERVILLE_INTERFACE_INFO Info
  152. );
  153. NTSTATUS
  154. SetCurrentStateSmm(
  155. ULONG NewState
  156. );
  157. NTSTATUS
  158. SetCurrentSetupSmm(
  159. ULONG NewState
  160. );
  161. NTSTATUS
  162. InitializeSmmInterface(
  163. VOID
  164. );
  165. NTSTATUS
  166. GetCurrentProcFrequency (
  167. IN ULONG State,
  168. OUT PULONG CpuSpeed
  169. );
  170. NTSTATUS
  171. CollectProcessorInfomation (
  172. VOID
  173. );
  174. ULONG
  175. FindCpuSpeedByBinValue (
  176. ULONG BinValue,
  177. PPROCESSOR_STATE_INFO Table
  178. );
  179. NTSTATUS
  180. AdjustLegacyProcessorPerformanceStates(
  181. IN OUT PACPI_PSS_PACKAGE PssPackage
  182. );
  183. NTSTATUS
  184. ProcessSleepStateNotification (
  185. IN POWER_STATE_HANDLER_TYPE State,
  186. IN PVOID Context,
  187. IN BOOLEAN Entering
  188. );
  189. VOID
  190. DumpStateFlags (
  191. ULONG StateFlags
  192. );
  193. VOID
  194. P3TimerDpcHandler (
  195. IN PKDPC Dpc,
  196. IN PVOID DeferredContext,
  197. IN PVOID SystemArgument1,
  198. IN PVOID SystemArgument2
  199. );
  200. #endif