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