1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
/** @file
Header file for Cpu Platform Lib implementation.
@copyright
Copyright (c) 2012 Intel Corporation. All rights reserved
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.
This file contains a 'Sample Driver' and is licensed as such
under the terms of your license agreement with Intel or your
vendor. This file may be modified by the user, subject to
the additional terms of the license agreement
**/
#ifndef _OVERCLOCKING_LIBRARY_H_
#define _OVERCLOCKING_LIBRARY_H_
#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
#include "EdkIIGlueBase.h"
#endif
//
// OC Mailbox MSR
//
#define MSR_OC_MAILBOX 0x00000150
#define OC_LIB_WAIT_TIMEOUT 5000 ///< 5 milliseconds
//
// OC Mailbox commands
//
#define OC_LIB_CMD_GET_OC_CAPABILITIES 0x01
#define OC_LIB_CMD_GET_PER_CORE_RATIO_LIMIT 0x02
#define OC_LIB_CMD_GET_VOLTAGE_FREQUENCY 0x10
#define OC_LIB_CMD_SET_VOLTAGE_FREQUENCY 0x11
#define OC_LIB_CMD_GET_SVID_CONFIG 0x12
#define OC_LIB_CMD_SET_SVID_CONFIG 0x13
#define OC_LIB_CMD_GET_GLOBAL_CONFIG 0x14
#define OC_LIB_CMD_SET_GLOBAL_CONFIG 0x15
//
// OC Mailbox completion codes
//
#define OC_LIB_COMPLETION_CODE_SUCCESS 0x00
#define OC_LIB_COMPLETION_CODE_OC_LOCKED 0x01
#define OC_LIB_COMPLETION_CODE_INVALID_DOMAIN 0x02
#define OC_LIB_COMPLETION_CODE_MAX_RATIO_EXCEEDED 0x03
#define OC_LIB_COMPLETION_CODE_MAX_VOLTAGE_EXCEEDED 0x04
#define OC_LIB_COMPLETION_CODE_OC_NOT_SUPPORTED 0x05
#define OC_LIB_COMPLETION_CODE_WRITE_FAILED 0x06
#define OC_LIB_COMPLETION_CODE_READ_FAILED 0x07
//
// Domain ID definitions
//
#define OC_LIB_DOMAIN_ID_IA_CORE 0x00
#define OC_LIB_DOMAIN_ID_GT 0x01
#define OC_LIB_DOMAIN_ID_CLR 0x02
#define OC_LIB_DOMAIN_ID_UNCORE 0x03
#define OC_LIB_DOMAIN_ID_IOA 0x04
#define OC_LIB_DOMAIN_ID_IOD 0x05
//
// Bit 10 is the S11.0.10V sign bit
//
#define FIXED_POINT_SIGN_BIT_MASK 0x0400
#define INT16_SIGN_BIT_MASK 0x8000
//
// Voltage Conversion defines
//
#define MILLIVOLTS_PER_VOLT 1000
#define MAX_TARGET_MV 4095
#define MAX_OFFSET_MV 500
#define CONVERT_TO_FIXED_POINT_VOLTS 0
#define CONVERT_TO_BINARY_MILLIVOLT 1
//
// Masks and offsets
//
#define BIT0_MASK 0x1
#define MAX_RATIO_MASK 0x000000FF
#define VOLTAGE_TARGET_MASK 0x000FFF00
#define VOLTAGE_TARGET_OFFSET 8
#define VOLTAGE_MODE_MASK 0x00100000
#define VOLTAGE_MODE_OFFSET 20
#define VOLTAGE_OFFSET_MASK 0xFFE00000
#define VOLTAGE_OFFSET_OFFSET 21
#define SVID_DISABLE_MASK 0x80000000
#define SVID_DISABLE_OFFSET 31
#define SVID_VOLTAGE_MASK 0x00000FFF
#define FIVR_FAULTS_MASK 0x00000001
#define FIVR_EFFICIENCY_MASK 0x00000002
#define FIVR_EFFICIENCY_OFFSET 1
#define OC_CAPS_MAX_RATIO_MASK 0x000000FF
#define OC_CAPS_RATIO_SUPPORT_MASK 0x00000100
#define OC_CAPS_RATIO_SUPPORT_OFFSET 8
#define OC_CAPS_OVERRIDE_SUPPORT_MASK 0x00000200
#define OC_CAPS_OVERRIDE_SUPPORT_OFFSET 9
#define OC_CAPS_OFFSET_SUPPORT_MASK 0x00000400
#define OC_CAPS_OFFSET_SUPPORT_OFFSET 10
//
// Voltage offset definitions
//
#define OC_LIB_OFFSET_ADAPTIVE 0
#define OC_LIB_OFFSET_OVERRIDE 1
#define OC_LIB_VOLTAGE_DO_NOT_UPDATE 0xFFFF
///
/// OC Library structures
///
typedef struct {
UINT32 CommandData;
UINT8 CommandCompletion : 8;
UINT8 Param1 : 8;
UINT8 Param2 : 8;
UINT8 Reserved : 7;
UINT8 RunBusy : 1;
} OC_LIBRARY_COMMAND;
typedef union _OC_MAILBOX_COMMAND {
UINT32 InterfaceData;
struct {
UINT8 CommandCompletion : 8;
UINT8 Param1 : 8;
UINT8 Param2 : 8;
UINT8 Reserved : 7;
UINT8 RunBusy : 1;
} Fields;
} OC_MAILBOX_COMMAND;
typedef struct _OC_MAILBOX_ITEM {
UINT32 Data;
OC_MAILBOX_COMMAND Interface;
} OC_MAILBOX_ITEM;
typedef struct {
UINT8 MaxOcRatio;
UINT8 VoltageTargetMode;
UINT16 VoltageTarget;
INT16 VoltageOffset;
} VOLTAGE_FREQUENCY_SETTINGS;
typedef struct {
VOLTAGE_FREQUENCY_SETTINGS VfSettings;
UINT8 DomainId;
} VOLTAGE_FREQUENCY_ITEM;
typedef enum {
IaCore,
Gt,
Clr,
Uncore
} CPU_DOMAIN_ID;
typedef struct {
UINT16 VoltageTarget;
BOOLEAN SvidDisable;
} SVID_CONFIG_ITEM;
typedef struct {
UINT8 MaxOcRatioLimit;
BOOLEAN RatioOcSupported;
BOOLEAN VoltageOverridesSupported;
BOOLEAN VoltageOffsetSupported;
UINT8 DomainId;
} OC_CAPABILITIES_ITEM;
typedef struct {
UINT8 MaxOcRatioLimit1C;
UINT8 MaxOcRatioLimit2C;
UINT8 MaxOcRatioLimit3C;
UINT8 MaxOcRatioLimit4C;
UINT8 Index;
} CORE_RATIO_LIMITS_ITEM;
typedef struct {
UINT8 DisableFivrFaults;
UINT8 DisableFivrEfficiency;
} GLOBAL_CONFIG_ITEM;
typedef struct {
UINT32 MaxOcRatio : 8;
UINT32 VoltageTargetU12 : 12;
UINT32 TargetMode : 1;
UINT32 VoltageOffsetS11 : 11;
} VF_MAILBOX_COMMAND_DATA;
///
/// OC Library Function Prototypes
///
EFI_STATUS
EFIAPI GetVoltageFrequencyItem (
OUT VOLTAGE_FREQUENCY_ITEM *VfSettings,
OUT UINT32 *LibStatus
)
/**
Gets the Voltage and Frequency information for a given CPU domain
@param[OUT] *VfSettings
@param[OUT] *LibStatus
@retval EFI_STATUS
**/
;
EFI_STATUS
EFIAPI SetVoltageFrequencyItem (
IN VOLTAGE_FREQUENCY_ITEM VfSettings,
OUT UINT32 *LibStatus
)
/**
Sets the Voltage and Frequency information for a given CPU domain
@param[IN] *VfSettings
@param[OUT] *LibStatus
@retval EFI_STATUS
**/
;
EFI_STATUS
EFIAPI GetFivrConfig (
OUT GLOBAL_CONFIG_ITEM *FivrConfig,
OUT UINT32 *LibStatus
)
/**
Get the global FIVR Configuration information
@param[OUT] *FivrConfig
@param[OUT] *LibStatus
@retval EFI_STATUS
**/
;
EFI_STATUS
EFIAPI SetFivrConfig (
IN GLOBAL_CONFIG_ITEM FivrConfig,
OUT UINT32 *LibStatus
)
/**
Set the Global FIVR Configuration information
@param[IN] FivrConfig
@param[OUT] *LibStatus
@retval EFI_STATUS
**/
;
EFI_STATUS
EFIAPI GetSvidConfig (
OUT SVID_CONFIG_ITEM *SvidConfig,
OUT UINT32 *LibStatus
)
/**
Get the SVID Configuration information
@param[OUT] *SvidConfig
@param[OUT] *LibStatus
@retval EFI_STATUS
**/
;
EFI_STATUS
EFIAPI SetSvidConfig (
IN SVID_CONFIG_ITEM SvidConfig,
OUT UINT32 *LibStatus
)
/**
Set the SVID Configuration information
@param[IN] SvidConfig
@param[OUT] *LibStatus
@retval EFI_STATUS
**/
;
EFI_STATUS
EFIAPI GetOcCapabilities (
OUT OC_CAPABILITIES_ITEM *OcCapabilities,
OUT UINT32 *LibStatus
)
/**
Get the overclocking capabilities for a given CPU Domain
@param[OUT] *OcCapabilities
@param[OUT] *LibStatus
@retval EFI_STATUS
**/
;
VOID
ConvertVoltageTarget (
IN UINT16 InputVoltageTarget,
OUT UINT16 *OutputVoltageTarget,
IN UINT8 ConversionType
)
/**
Converts the input voltage target to the fixed point U12.2.10 Volt format or
the Binary millivolts representation based on the ConversionType
@param[IN] InputVoltageTarget
@param[OUT] *OutputVoltageTarget
@param[IN] ConversionType - 0:fixed point, 1:Binary millivolts
**/
;
VOID
ConvertVoltageOffset (
IN INT16 InputVoltageOffset,
OUT INT16 *OutputVoltageOffset,
IN UINT8 ConversionType
)
/**
Converts the input votlage Offset to the fixed point S11.0.10 Volt format or
to Binary illivolts representation based on the ConversionType.
@param[IN] InputVoltageTarget
@param[OUT] *OutputVoltageTarget
@param[IN] ConversionType - 0:fixed point, 1:Signed Binary millivolts
**/
;
VOID
ConvertToMailboxFormat (
IN VOID *InputData,
OUT OC_MAILBOX_ITEM *MailboxData,
IN UINT32 CommandId
)
/**
Converts the input data to valid mailbox command format based on CommandID
@param[IN] InputData
@param[OUT] *MailboxData
@param[IN] CommandId
**/
;
#endif
|