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.

299 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. amdk6.h
  5. Author:
  6. Todd Carpenter (7/20/00) - create file
  7. Environment:
  8. Kernel mode
  9. Notes:
  10. Revision History:
  11. --*/
  12. #ifndef _AMDK6_H
  13. #define _AMDK6_H
  14. #include "..\lib\processor.h"
  15. #include "..\eventmsg.h"
  16. #include <pshpack1.h>
  17. #define AMDK6_GEMINI_CPUID_EPM 0x80000007
  18. #define AMDK6_GEMINI_EPMR_MSR 0xC0000086
  19. #define AMDK6_GEMINI_PSOR_MSR 0xC0000087
  20. //
  21. // The follow definitions are taken from information the
  22. // Gemini SMI API Specification, version 0.80
  23. //
  24. #define PLATFORM_AMDK6 0x6
  25. #define PLATFORM_AMDK7 0x7
  26. //
  27. // Function 0, Gemini State Change
  28. //
  29. #define IS_GEMINI_SUPPORTED 0x0000 // Function 0, Sub-function 0
  30. #define GET_GEMINI_STATES 0x0001 // Function 0, Sub-function 1
  31. #define GET_MAX_GEMINI_STATE 0x0002 // Function 0, Sub-function 2
  32. #define SET_MAX_GEMINI_STATE 0x0003 // Function 0, Sub-function 3
  33. #define GET_MIN_GEMINI_STATE 0x0004 // Function 0, Sub-function 4
  34. #define SET_MIN_GEMINI_STATE 0x0005 // Function 0, Sub-function 5
  35. #define GET_CURRENT_GEMINI_STATE 0x0006 // Function 0, Sub-function 6
  36. #define SET_CURRENT_GEMINI_STATE 0x0007 // Function 0, Sub-function 7
  37. //
  38. // Function 1, Gemini Thermal Control
  39. //
  40. #define GET_CURRENT_TALERT_MODES 0x0100 // Function 1, Sub-function 0
  41. #define GET_CURRENT_TALERT_SETTINGS 0x0101 // Function 1, Sub-function 1
  42. #define SET_TALERT_CONTROLS 0x0102 // Function 1, Sub-function 2
  43. #define GET_CURRENT_TPANIC_SETTINGS 0x0103 // Function 1, Sub-function 3
  44. #define SET_TPANIC_SETTINGS 0x0104 // Function 1, Sub-function 4
  45. #define GET_CURRENT_TEMPERATURE 0x0105 // Function 1, Sub-function 5
  46. //
  47. // Function 2, Gemini Connect/Disconnect
  48. //
  49. #define GEMINI_CONNECT 0x0200 // Function 2, Sub-function 0
  50. #define GEMINI_DISCONNECT 0x0201 // Function 2, Sub-function 1
  51. #define GBDT_SIGNATURE 0x54444247 // "GBDT"
  52. #define GBDT_SEARCH_RANGE_BEGIN 0xC0000
  53. #define GBDT_SEARCH_RANGE_END 0xFFFFF
  54. #define GBDT_SEARCH_RANGE_LENGTH (GBDT_SEARCH_RANGE_END-GBDT_SEARCH_RANGE_BEGIN+1)
  55. #define GBDT_SEARCH_INTERVAL 16 // search on 16 byte boundaries
  56. #define CONVERT_PERF_STATE_INDEX(_x_) ((LegacyInterface.GBDT->MaxStateSupported) - _x_)
  57. //
  58. // Gemini Processor Voltage and Frequency information
  59. //
  60. typedef struct _GEMINI_PROCESSOR_STATE {
  61. USHORT CpuVoltage; // format A.BCD
  62. USHORT CpuFrequency; // mhz
  63. UCHAR Vid; // VID[4:0]
  64. UCHAR Bf; // BF[2:0]
  65. } GEMINI_PROCESSOR_STATE, *PGEMINI_PROCESSOR_STATE;
  66. typedef struct _AVAILABLE_STATE_INFO {
  67. UCHAR Vid;
  68. UCHAR Bf;
  69. UCHAR State;
  70. UCHAR Reserved; // should be zero
  71. } AVAILABLE_STATE_INFO, *PAVAILABLE_STATE_INFO;
  72. //
  73. // Gemini BIOS Descriptor Table
  74. //
  75. typedef struct _GBDT {
  76. ULONG Signature; // "GBDT"
  77. UCHAR Length;
  78. UCHAR Revsion;
  79. UCHAR Checksum;
  80. UCHAR Capabilities;
  81. USHORT BusSpeed;
  82. USHORT MaxCpuSpeed;
  83. UCHAR MaxStateSupported; // Min state always = 0, Max state < 16
  84. UCHAR SmiCommandPortType; // defines type, IO or MEM, and access size
  85. ULONG SmiCommandPortAddress; // IO or MEM address
  86. ULONG GeminiSmiCode; // loaded in ESI before SMI call.
  87. GEMINI_PROCESSOR_STATE State[0]; // Processor performance states
  88. } GBDT, *PGBDT, **PPGBDT;
  89. //
  90. // Auto Performance Table
  91. //
  92. typedef struct _GEMINI_AUTO_PERF_TABLE {
  93. UCHAR CpuUtilizationThreshold;
  94. UCHAR GeminiThresholdTargeState;
  95. } GEMINI_AUTO_PERF_TABLE, *PGEMINI_AUTO_PERF_TABLE;
  96. //
  97. // Gemini Processor Voltage and Frequency information
  98. //
  99. typedef struct _LEGACY_GEMINI_SMI {
  100. ULONG SmiAccessType;
  101. ULONG SmiAccessSize;
  102. ULONG SmiAddress;
  103. ULONG GeminiCode;
  104. ULONG CurrentState;
  105. ULONG MaxSupportedStates;
  106. ULONG CurrentlyAvailableStates;
  107. ULONG EpmIoAddress;
  108. PGBDT GBDT;
  109. } LEGACY_GEMINI_SMI, *PLEGACY_GEMINI_SMI;
  110. typedef struct _LEGACY_GEMINI_PERF_STATE {
  111. ULONG Frequency; // in megahertz
  112. USHORT Power; // in milliwatts
  113. UCHAR PercentFrequency; // for quick lookup
  114. ULONG GeminiState;
  115. ULONG GeminiVID;
  116. ULONG GeminiBF;
  117. } LEGACY_GEMINI_PERF_STATE, *PLEGACY_GEMINI_PERF_STATE;
  118. typedef struct _LEGACY_GEMINI_PERF_STATES {
  119. PSET_PROCESSOR_THROTTLE TransitionFunction;
  120. ULONG TransitionLatency; // in milliseconds
  121. UCHAR Current;
  122. UCHAR Count;
  123. LEGACY_GEMINI_PERF_STATE State[1]; // sorted from fastest to slowest
  124. } LEGACY_GEMINI_PERF_STATES, *PLEGACY_GEMINI_PERF_STATES;
  125. //
  126. // bios.c
  127. //
  128. NTSTATUS
  129. FindGBDT (
  130. OUT PPGBDT GeminiInfo
  131. );
  132. NTSTATUS
  133. InitializeLegacyInterface (
  134. VOID
  135. );
  136. NTSTATUS
  137. IsGeminiSupported (
  138. PULONG Results
  139. );
  140. NTSTATUS
  141. GetAvailableStatesSmm (
  142. PULONG Results
  143. );
  144. NTSTATUS
  145. GetMaxStateSmm (
  146. PULONG Results
  147. );
  148. NTSTATUS
  149. SetMaxStateSmm (
  150. VOID
  151. );
  152. NTSTATUS
  153. GetMinStateSmm (
  154. PULONG Results
  155. );
  156. NTSTATUS
  157. SetMinStateSmm (
  158. VOID
  159. );
  160. NTSTATUS
  161. GetCurrentStateSmm (
  162. PULONG Results
  163. );
  164. NTSTATUS
  165. SetCurrentStateSmm (
  166. ULONG State
  167. );
  168. NTSTATUS
  169. ConnectDisconnectGeminiInterface (
  170. BOOLEAN Connect
  171. );
  172. NTSTATUS
  173. GetCpuFrequency (
  174. IN ULONG State,
  175. OUT PULONG CpuSpeed
  176. );
  177. NTSTATUS
  178. GetCpuVoltage (
  179. IN ULONG State,
  180. OUT PULONG Voltage
  181. );
  182. NTSTATUS
  183. GetLegacyMaxProcFrequency (
  184. OUT PULONG CpuSpeed
  185. );
  186. NTSTATUS
  187. ConvertVidBfValueToGeminiState (
  188. IN UCHAR VidBfValue,
  189. OUT PULONG State
  190. );
  191. //
  192. // amdk6msr.c
  193. //
  194. NTSTATUS
  195. GetCurrentCpuSpeedMSR (
  196. OUT PULONG CpuSpeed
  197. );
  198. NTSTATUS
  199. SetCurrentStateMSR (
  200. ULONG State
  201. );
  202. NTSTATUS
  203. ReadEpmInfo (
  204. OUT PULONG EpmInfo
  205. );
  206. NTSTATUS
  207. EnableGeminiTransitionsMSR (
  208. PULONG BaseAddress
  209. );
  210. VOID
  211. DisplayEPM (
  212. IN ULONG Epm
  213. );
  214. VOID
  215. DisplayEPMR (
  216. IN ULONG Epmr
  217. );
  218. VOID
  219. DisplayPSOR (
  220. IN ULONG Psor
  221. );
  222. #endif