Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/tools/power/cpupower/debug/i386/intel_gsic.c
26296 views
1
// SPDX-License-Identifier: GPL-2.0-only
2
/*
3
* (C) 2003 Bruno Ducrot
4
* (C) 2004 Dominik Brodowski <[email protected]>
5
*
6
* Based on code found in
7
* linux/include/asm-i386/ist.h and linux/arch/i386/kernel/setup.c
8
* and originally developed by Andy Grover <[email protected]>
9
*/
10
11
#include <stdio.h>
12
#include <string.h>
13
#include <lrmi.h>
14
15
int main (void)
16
{
17
struct LRMI_regs r;
18
int retval;
19
20
if (!LRMI_init())
21
return 0;
22
23
memset(&r, 0, sizeof(r));
24
25
r.eax = 0x0000E980;
26
r.edx = 0x47534943;
27
28
retval = LRMI_int(0x15, &r);
29
30
if (!retval) {
31
printf("Failed!\n");
32
return 0;
33
}
34
if (r.eax == 0x47534943) {
35
printf("BIOS supports GSIC call:\n");
36
printf("\tsignature: %c%c%c%c\n",
37
(r.eax >> 24) & 0xff,
38
(r.eax >> 16) & 0xff,
39
(r.eax >> 8) & 0xff,
40
(r.eax) & 0xff);
41
printf("\tcommand port = 0x%.4x\n",
42
r.ebx & 0xffff);
43
printf("\tcommand = 0x%.4x\n",
44
(r.ebx >> 16) & 0xffff);
45
printf("\tevent port = 0x%.8x\n", r.ecx);
46
printf("\tflags = 0x%.8x\n", r.edx);
47
if (((r.ebx >> 16) & 0xffff) != 0x82) {
48
printf("non-default command value. If speedstep-smi "
49
"doesn't work out of the box,\nyou may want to "
50
"try out the default value by passing "
51
"smi_cmd=0x82 to the module\n ON YOUR OWN "
52
"RISK.\n");
53
}
54
if ((r.ebx & 0xffff) != 0xb2) {
55
printf("non-default command port. If speedstep-smi "
56
"doesn't work out of the box,\nyou may want to "
57
"try out the default value by passing "
58
"smi_port=0x82 to the module\n ON YOUR OWN "
59
"RISK.\n");
60
}
61
} else {
62
printf("BIOS DOES NOT support GSIC call. Dumping registers anyway:\n");
63
printf("eax = 0x%.8x\n", r.eax);
64
printf("ebx = 0x%.8x\n", r.ebx);
65
printf("ecx = 0x%.8x\n", r.ecx);
66
printf("edx = 0x%.8x\n", r.edx);
67
printf("Note also that some BIOS do not support the initial "
68
"GSIC call, but the newer\nspeedstep-smi driver may "
69
"work.\nFor this, you need to pass some arguments to "
70
"the speedstep-smi driver:\n");
71
printf("\tsmi_cmd=0x?? smi_port=0x?? smi_sig=1\n");
72
printf("\nUnfortunately, you have to know what exactly are "
73
"smi_cmd and smi_port, and this\nis system "
74
"dependent.\n");
75
}
76
return 1;
77
}
78
79