18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * (C) 2003 Bruno Ducrot 48c2ecf20Sopenharmony_ci * (C) 2004 Dominik Brodowski <linux@dominikbrodowski.de> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Based on code found in 78c2ecf20Sopenharmony_ci * linux/include/asm-i386/ist.h and linux/arch/i386/kernel/setup.c 88c2ecf20Sopenharmony_ci * and originally developed by Andy Grover <andrew.grover@intel.com> 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <stdio.h> 128c2ecf20Sopenharmony_ci#include <string.h> 138c2ecf20Sopenharmony_ci#include <lrmi.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciint main (void) 168c2ecf20Sopenharmony_ci{ 178c2ecf20Sopenharmony_ci struct LRMI_regs r; 188c2ecf20Sopenharmony_ci int retval; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci if (!LRMI_init()) 218c2ecf20Sopenharmony_ci return 0; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci memset(&r, 0, sizeof(r)); 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci r.eax = 0x0000E980; 268c2ecf20Sopenharmony_ci r.edx = 0x47534943; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci retval = LRMI_int(0x15, &r); 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci if (!retval) { 318c2ecf20Sopenharmony_ci printf("Failed!\n"); 328c2ecf20Sopenharmony_ci return 0; 338c2ecf20Sopenharmony_ci } 348c2ecf20Sopenharmony_ci if (r.eax == 0x47534943) { 358c2ecf20Sopenharmony_ci printf("BIOS supports GSIC call:\n"); 368c2ecf20Sopenharmony_ci printf("\tsignature: %c%c%c%c\n", 378c2ecf20Sopenharmony_ci (r.eax >> 24) & 0xff, 388c2ecf20Sopenharmony_ci (r.eax >> 16) & 0xff, 398c2ecf20Sopenharmony_ci (r.eax >> 8) & 0xff, 408c2ecf20Sopenharmony_ci (r.eax) & 0xff); 418c2ecf20Sopenharmony_ci printf("\tcommand port = 0x%.4x\n", 428c2ecf20Sopenharmony_ci r.ebx & 0xffff); 438c2ecf20Sopenharmony_ci printf("\tcommand = 0x%.4x\n", 448c2ecf20Sopenharmony_ci (r.ebx >> 16) & 0xffff); 458c2ecf20Sopenharmony_ci printf("\tevent port = 0x%.8x\n", r.ecx); 468c2ecf20Sopenharmony_ci printf("\tflags = 0x%.8x\n", r.edx); 478c2ecf20Sopenharmony_ci if (((r.ebx >> 16) & 0xffff) != 0x82) { 488c2ecf20Sopenharmony_ci printf("non-default command value. If speedstep-smi " 498c2ecf20Sopenharmony_ci "doesn't work out of the box,\nyou may want to " 508c2ecf20Sopenharmony_ci "try out the default value by passing " 518c2ecf20Sopenharmony_ci "smi_cmd=0x82 to the module\n ON YOUR OWN " 528c2ecf20Sopenharmony_ci "RISK.\n"); 538c2ecf20Sopenharmony_ci } 548c2ecf20Sopenharmony_ci if ((r.ebx & 0xffff) != 0xb2) { 558c2ecf20Sopenharmony_ci printf("non-default command port. If speedstep-smi " 568c2ecf20Sopenharmony_ci "doesn't work out of the box,\nyou may want to " 578c2ecf20Sopenharmony_ci "try out the default value by passing " 588c2ecf20Sopenharmony_ci "smi_port=0x82 to the module\n ON YOUR OWN " 598c2ecf20Sopenharmony_ci "RISK.\n"); 608c2ecf20Sopenharmony_ci } 618c2ecf20Sopenharmony_ci } else { 628c2ecf20Sopenharmony_ci printf("BIOS DOES NOT support GSIC call. Dumping registers anyway:\n"); 638c2ecf20Sopenharmony_ci printf("eax = 0x%.8x\n", r.eax); 648c2ecf20Sopenharmony_ci printf("ebx = 0x%.8x\n", r.ebx); 658c2ecf20Sopenharmony_ci printf("ecx = 0x%.8x\n", r.ecx); 668c2ecf20Sopenharmony_ci printf("edx = 0x%.8x\n", r.edx); 678c2ecf20Sopenharmony_ci printf("Note also that some BIOS do not support the initial " 688c2ecf20Sopenharmony_ci "GSIC call, but the newer\nspeedstep-smi driver may " 698c2ecf20Sopenharmony_ci "work.\nFor this, you need to pass some arguments to " 708c2ecf20Sopenharmony_ci "the speedstep-smi driver:\n"); 718c2ecf20Sopenharmony_ci printf("\tsmi_cmd=0x?? smi_port=0x?? smi_sig=1\n"); 728c2ecf20Sopenharmony_ci printf("\nUnfortunately, you have to know what exactly are " 738c2ecf20Sopenharmony_ci "smi_cmd and smi_port, and this\nis system " 748c2ecf20Sopenharmony_ci "dependent.\n"); 758c2ecf20Sopenharmony_ci } 768c2ecf20Sopenharmony_ci return 1; 778c2ecf20Sopenharmony_ci} 78