intel_gsic.c 2.2 KB

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