home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / tx97mon.zip / tempclass.hpp < prev    next >
Text File  |  1997-09-12  |  3KB  |  105 lines

  1. #define INCL_DOSFILEMGR
  2. #define INCL_DOSDEVIOCTL
  3. #define INCL_ERRORS
  4. #include <os2.h>
  5. #include "cio.h"
  6.  
  7. class TempData{
  8.    double vCore;
  9.    double vIO;
  10.    double v5;
  11.    double v12;
  12.    double vneg12;
  13.    double vneg5;
  14.    int RPM1;
  15.    int RPM2;
  16.    int RPM3;
  17.    int mbTemp;
  18.    double cpuTemp;
  19.  
  20.    unsigned short LM78;
  21.    unsigned short LM75;
  22. public:
  23.    TempData();
  24.    ~TempData() {}
  25.    int read();
  26.    double Vcore() { return vCore;}
  27.    double Vio() { return vIO; }
  28.    double V5() { return v5; }
  29.    double V12() { return v12; }
  30.    double Vneg12() { return vneg12; }
  31.    double Vneg5() { return vneg5; }
  32.    int Rpm1() { return RPM1; }
  33.    int Rpm2() { return RPM2; }
  34.    int Rpm3() { return RPM3; }
  35.    int Mbt() { return mbTemp; }
  36.    double Cput() { return cpuTemp; }
  37. };
  38.  
  39.  
  40. TempData::TempData()
  41. {
  42.    unsigned int temp;
  43.    LM78 = 0x290;
  44.    io_init();
  45.    LM75 = c_inl((unsigned short)0x0CF8);
  46.    temp &= 0x7F000003;  //Make sure we keep all reserved bits as they were
  47.    temp |= 0x80000800;  //Enable CONE on the MTXC
  48.    temp |= (1<<11);     //Select Device number on the MTXC (PIIX4 = PCI Device 1)
  49.    temp |= (3<<8);      //Select Function number on the MTXC
  50.    temp |= (0x90);      //Select Address offset  on the MTXC
  51.    c_outl( (unsigned short) 0x0CF8, temp );
  52.    LM75 = (unsigned short)c_inw(0x0CFC)-1;
  53.  
  54.    c_outb(LM78+5, 0x47);
  55.    temp = c_inb(LM78+6);
  56. //   printf("Fan Div:\t%02X\n", (unsigned char)temp );
  57.  
  58. }
  59.  
  60. int TempData::read()
  61. {
  62.    c_outb(LM78+5, 0x61);
  63.    vCore = (unsigned int)c_inb(LM78+6) * 0.016f;
  64.    vIO = (unsigned int)c_inb(LM78+6) * 0.016f;
  65.    v5 = (unsigned int)c_inb(LM78+6) * 0.016f * 1.69;
  66.    v12 = (unsigned int)c_inb(LM78+6) * 0.016f * 3.81;
  67.    vneg12 = (unsigned int)c_inb(LM78+6) * 0.016f * -3.47;
  68.    vneg5 = (unsigned int)c_inb(LM78+6) * 0.016f * -1.49;
  69.    mbTemp = c_inb(LM78+6);
  70.    RPM1 = (unsigned char) c_inb(LM78+6);
  71.    RPM2 = (unsigned char) c_inb(LM78+6);
  72.    RPM3 = (unsigned char) c_inb(LM78+6);
  73.    RPM1 = (RPM1==0xff?0:1.35e6/RPM1/4);
  74.    RPM2 = (RPM2==0xff?0:(1.35e6/RPM2/4));
  75.    RPM3 = (RPM3==0xff?0:1.35e6/RPM3/2);
  76.  
  77.    unsigned char tmp;
  78.    tmp = c_inb(LM75);
  79.    if( (tmp & 0x1e) != 0 ){
  80. //      printf("Clearing inter.\n");
  81.       c_outb( LM75, tmp );
  82. //      printf("LM75:\t%08x\n", (unsigned int)c_inb(LM75) );
  83.    }
  84.    c_outb( LM75+3, 0x00 );
  85. //   printf("SmbCMD:\t%02X\n", c_inb(LM75+3) );
  86.    c_outb( LM75+4, 0x93 );
  87. //   printf("SmbAdd:\t%02X\n", c_inb(LM75+4) );
  88.  
  89.    tmp = c_inb( LM75+2 );
  90.    tmp = ( tmp & 0xe0 ) | 0x0c;
  91.    c_outb( LM75+2, tmp );
  92. //   printf("SmbCNT:\t%02X\n", c_inb(LM75+2) );
  93.  
  94.    c_outb( LM75+2, (tmp | 0x40) );
  95.    while( c_inb(LM75) & 0x1 ){
  96. //      printf("waiting\n");
  97.    }
  98. //   printf( "SmbTSTS:\t%02X\n", c_inb(LM75) );
  99.  
  100.    cpuTemp = c_inb(LM75+5);
  101.    cpuTemp += 0.5f *(c_inb(LM75+6)>>7);
  102. //   printf( "cpu temp %lf\n", cpuTemp);
  103.    return 0;
  104. }
  105.