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