Beispiel #1
0
        public bool ProbeForDevice()
        {
            int[] sioports = { 0x2e, 0x4e };
            var   sio      = new SuperIO();

            foreach (var port in sioports)
            {
                sio.BaseAddress = port;
                var devid = sio.GetDeviceId() & 0xFFF0;

                if (Enum.IsDefined(typeof(DeviceType), devid))
                {
                    device = (DeviceType)devid;

                    if (device != DeviceType.NotPresent || device != DeviceType.Unknown)
                    {
                        // read baseaddress
                        BaseAddress = sio.GetBaseAddress();
                        sioport     = port;

                        // reset values
                        Select(0);
                        Write(0x40, Read(0x40) | (1 << 7));
                    }

                    return(true);
                }
            }
            return(false);
        }
Beispiel #2
0
        internal void DumpSIOByteData(TextWriter writer)
        {
            var sio = new SuperIO {
                BaseAddress = sioport
            };

            //var css = sio.Read(sio.BankSelect);

            writer.WriteLine(DateTime.Now);
            writer.Write("     ");

            for (int i = 0; i < 16; i++)
            {
                writer.Write("{0:X2} ", i);
            }

            writer.WriteLine();

            for (int i = 7; i < 16; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    writer.Write("{0:X3}  ", i * 256 + j);

                    for (int k = 0; k < 16; k++)
                    {
                        int reg = j * 16 + k;

                        sio.Enter();
                        sio.Select(i);
                        var r = sio.Read(reg);
                        sio.Exit();

                        writer.Write("{0:X2} ", r);
                    }
                    writer.WriteLine();
                }
                writer.WriteLine();
            }

            writer.WriteLine();

            //sio.Select(css);
            //sio.Exit();
        }
Beispiel #3
0
        public IEnumerable<Sample> GetData()
        {
            if (device == DeviceType.Unknown || device == DeviceType.NotPresent)
              {
            yield break;
              }

              double
            cpufanout0rpm = 0,
            sysfanoutrpm = 0,
            auxfanout0rpm = 0,
            cpufanout1rpm = 0,
            motherboardtemp = 0,
            cputin = 0xFF,
            systin = 0xFF,
            auxtin = 0xFF;

              var cs = Read(BankSelect);

              while (cputin >= 99 || cputin <= -55)
              {
            Select(1);
            cputin = (sbyte)Read(0x50) + (Read(0x51) >> 7) * 0.5;
              }

              while (auxtin >= 99 || auxtin <= -55)
              {
            Select(2);
            auxtin = (sbyte)Read(0x50) + (Read(0x51) >> 7) * 0.5;
              }

              while (systin >= 99 || systin <= -55)
              {
            Select(0);
            systin = (sbyte)Read(0x27);
              }

              if (manufacturer == "ASUSTeK Computer INC." && product.StartsWith("P7P55D"))
              {
            // only on ASUS P7P55D
            var sio = new SuperIO { BaseAddress = sioport };

            sio.Enter();
            var css = sio.Read(sio.BankSelect);
            sio.Select(0xc);
            var cr20 = sio.Read(0x20);
            sio.Select(css);
            sio.Exit();

            if (cr20 == 0xb3)
            {
              Select(0);
              Write(0x7d, 0); // seems to be some other values in 1,2,3,4
              motherboardtemp = Read(0x7e);
            }
            else
            {
              motherboardtemp = systin;
            }
              }

              var cputinavg = double.IsNaN(lastcputin) ? cputin : (cputin + lastcputin) / 2;
              lastcputin = cputin;

              var cpufanspeed0 = CalculateFanSpeed(motherboardtemp, cputinavg, fansettings["CPUFAN0"]);
              var sysfanspeed = CalculateFanSpeed(motherboardtemp, cputinavg, fansettings["SYSFAN"]);

              Select(0);
              Write(0x4, 0);
              Write(1, sysfanspeed);
              Write(3, cpufanspeed0);

              var cpufanout0 = Read(0x29);

              int failcount = 0;

              while ((cpufanout0 == 0xff || cpufanout0 == 0) && failcount < 5)
              {
            Thread.Sleep(failcount);
            cpufanout0 = Read(0x29);
            failcount++;
              }

              if (failcount < 5 && cpufanout0 > 0 && cpufanout0 < 255)
              {
            var cpufanout0div = ((Read(0x47) >> 6) & 3) | (((Read(0x5d) >> 6) & 1) << 2);
            cpufanout0rpm = GetRPM(cpufanout0, cpufanout0div);
              }

              failcount = 0;

              var sysfanout = Read(0x28);

              while ((sysfanout == 0xff || sysfanout == 0) && failcount < 5)
              {
            Thread.Sleep(failcount);
            sysfanout = Read(0x28);
            failcount++;
              }

              if (failcount < 5 && sysfanout > 0 && sysfanout < 255)
              {
            var sysfanoutdiv = ((Read(0x47) >> 4) & 3) | (((Read(0x5d) >> 5) & 1) << 2);
            sysfanoutrpm = GetRPM(sysfanout, sysfanoutdiv);
              }

              failcount = 0;

              var auxfanout0 = Read(0x2a);

              while ((auxfanout0 == 0xff || auxfanout0 == 0) && failcount < 5)
              {
            Thread.Sleep(failcount);
            auxfanout0 = Read(0x2a);
            failcount++;
              }

              if (failcount < 5 && auxfanout0 > 0 && auxfanout0 < 255)
              {
            var auxfanout0div = ((Read(0x4b) >> 6) & 3) | (((Read(0x5d) >> 7) & 1) << 2);
            auxfanout0rpm = GetRPM(auxfanout0, auxfanout0div);
              }

              failcount = 0;

              var cpufanout1 = Read(0x3f);

              while ((cpufanout1 == 0xff || cpufanout1 == 0) && failcount < 5)
              {
            Thread.Sleep(failcount);
            cpufanout1 = Read(0x3f);
            failcount++;
              }

              if (failcount < 5 && cpufanout1 > 0 && cpufanout1 < 255)
              {
            var cpufanout1div = ((Read(0x59) >> 0) & 3) | (((Read(0x4c) >> 7) & 1) << 2);
            cpufanout1rpm = GetRPM(cpufanout1, cpufanout1div);

            Debug.Assert(cpufanout1rpm < 100000);
              }

              failcount = 0;

              var vcore = Read(0x20) * 0.008;
              var vin0_12v = Read(0x21) * 0.008 * 7; //guess
              //var avcc = Read(0x22) * 0.008;
              var vcc_3_3v = Read(0x23) * 0.008 * 2; //guess
              var vin1_5v = Read(0x24) * 0.008 * 3; //guess
              //var vin2_2_5v = Read(0x25) * 0.008;
              //var vin3 = Read(0x26) * 0.008;

              Select(cs);

              yield return Sample.Temperature("CPUTIN", cputin, true);
              yield return Sample.Temperature("SYSTIN", systin, false);
              yield return Sample.Temperature("AUXTIN", auxtin, true);

              if (motherboardtemp > 0)
              {
            yield return Sample.Temperature("Motherboard", motherboardtemp, true);
              }

              yield return Sample.FanSpeed("CPUFAN0", cpufanout0rpm, true);
              yield return Sample.FanSpeed("CPUFAN1", cpufanout1rpm, true);
              yield return Sample.FanSpeed("SYSFAN", sysfanoutrpm, true);
              yield return Sample.FanSpeed("AUXFAN", auxfanout0rpm, true);

              yield return Sample.Voltage("VCORE", vcore, true);
              yield return Sample.Voltage("12V", vin0_12v, false);
              yield return Sample.Voltage("5V", vin1_5v, false);
              yield return Sample.Voltage("3.3V", vcc_3_3v, false);
        }
Beispiel #4
0
        internal void DumpSIOByteData(TextWriter writer)
        {
            var sio = new SuperIO { BaseAddress = sioport };

              //var css = sio.Read(sio.BankSelect);

              writer.WriteLine(DateTime.Now);
              writer.Write("     ");

              for (int i = 0; i < 16; i++)
              {
            writer.Write("{0:X2} ", i);
              }

              writer.WriteLine();

              for (int i = 7; i < 16; i++)
              {
            for (int j = 0; j < 16; j++)
            {
              writer.Write("{0:X3}  ", i * 256 + j);

              for (int k = 0; k < 16; k++)
              {
            int reg = j * 16 + k;

            sio.Enter();
            sio.Select(i);
            var r = sio.Read(reg);
            sio.Exit();

            writer.Write("{0:X2} ", r);
              }
              writer.WriteLine();
            }
            writer.WriteLine();
              }

              writer.WriteLine();

              //sio.Select(css);
              //sio.Exit();
        }
Beispiel #5
0
        public bool ProbeForDevice()
        {
            int[] sioports = { 0x2e, 0x4e };
              var sio = new SuperIO();

              foreach (var port in sioports)
              {
            sio.BaseAddress = port;
            var devid = sio.GetDeviceId() & 0xFFF0;

            if (Enum.IsDefined(typeof(DeviceType), devid))
            {
              device = (DeviceType)devid;

              if (device != DeviceType.NotPresent || device != DeviceType.Unknown)
              {
            // read baseaddress
            BaseAddress = sio.GetBaseAddress();
            sioport = port;

            // reset values
            Select(0);
            Write(0x40, Read(0x40) | (1 << 7));
              }

              return true;
            }
              }
              return false;
        }
Beispiel #6
0
        public IEnumerable <Sample> GetData()
        {
            if (device == DeviceType.Unknown || device == DeviceType.NotPresent)
            {
                yield break;
            }

            double
                cpufanout0rpm   = 0,
                sysfanoutrpm    = 0,
                auxfanout0rpm   = 0,
                cpufanout1rpm   = 0,
                motherboardtemp = 0,
                cputin          = 0xFF,
                systin          = 0xFF,
                auxtin          = 0xFF;

            var cs = Read(BankSelect);

            while (cputin >= 99 || cputin <= -55)
            {
                Select(1);
                cputin = (sbyte)Read(0x50) + (Read(0x51) >> 7) * 0.5;
            }

            while (auxtin >= 99 || auxtin <= -55)
            {
                Select(2);
                auxtin = (sbyte)Read(0x50) + (Read(0x51) >> 7) * 0.5;
            }

            while (systin >= 99 || systin <= -55)
            {
                Select(0);
                systin = (sbyte)Read(0x27);
            }

            if (manufacturer == "ASUSTeK Computer INC." && product.StartsWith("P7P55D"))
            {
                // only on ASUS P7P55D
                var sio = new SuperIO {
                    BaseAddress = sioport
                };

                sio.Enter();
                var css = sio.Read(sio.BankSelect);
                sio.Select(0xc);
                var cr20 = sio.Read(0x20);
                sio.Select(css);
                sio.Exit();

                if (cr20 == 0xb3)
                {
                    Select(0);
                    Write(0x7d, 0); // seems to be some other values in 1,2,3,4
                    motherboardtemp = Read(0x7e);
                }
                else
                {
                    motherboardtemp = systin;
                }
            }

            var cputinavg = double.IsNaN(lastcputin) ? cputin : (cputin + lastcputin) / 2;

            lastcputin = cputin;

            var cpufanspeed0 = CalculateFanSpeed(motherboardtemp, cputinavg, fansettings["CPUFAN0"]);
            var sysfanspeed  = CalculateFanSpeed(motherboardtemp, cputinavg, fansettings["SYSFAN"]);

            Select(0);
            Write(0x4, 0);
            Write(1, sysfanspeed);
            Write(3, cpufanspeed0);

            var cpufanout0 = Read(0x29);

            int failcount = 0;

            while ((cpufanout0 == 0xff || cpufanout0 == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                cpufanout0 = Read(0x29);
                failcount++;
            }

            if (failcount < 5 && cpufanout0 > 0 && cpufanout0 < 255)
            {
                var cpufanout0div = ((Read(0x47) >> 6) & 3) | (((Read(0x5d) >> 6) & 1) << 2);
                cpufanout0rpm = GetRPM(cpufanout0, cpufanout0div);
            }

            failcount = 0;

            var sysfanout = Read(0x28);

            while ((sysfanout == 0xff || sysfanout == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                sysfanout = Read(0x28);
                failcount++;
            }

            if (failcount < 5 && sysfanout > 0 && sysfanout < 255)
            {
                var sysfanoutdiv = ((Read(0x47) >> 4) & 3) | (((Read(0x5d) >> 5) & 1) << 2);
                sysfanoutrpm = GetRPM(sysfanout, sysfanoutdiv);
            }

            failcount = 0;

            var auxfanout0 = Read(0x2a);

            while ((auxfanout0 == 0xff || auxfanout0 == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                auxfanout0 = Read(0x2a);
                failcount++;
            }

            if (failcount < 5 && auxfanout0 > 0 && auxfanout0 < 255)
            {
                var auxfanout0div = ((Read(0x4b) >> 6) & 3) | (((Read(0x5d) >> 7) & 1) << 2);
                auxfanout0rpm = GetRPM(auxfanout0, auxfanout0div);
            }

            failcount = 0;

            var cpufanout1 = Read(0x3f);

            while ((cpufanout1 == 0xff || cpufanout1 == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                cpufanout1 = Read(0x3f);
                failcount++;
            }

            if (failcount < 5 && cpufanout1 > 0 && cpufanout1 < 255)
            {
                var cpufanout1div = ((Read(0x59) >> 0) & 3) | (((Read(0x4c) >> 7) & 1) << 2);
                cpufanout1rpm = GetRPM(cpufanout1, cpufanout1div);

                Debug.Assert(cpufanout1rpm < 100000);
            }

            failcount = 0;

            var vcore    = Read(0x20) * 0.008;
            var vin0_12v = Read(0x21) * 0.008 * 7; //guess
            //var avcc = Read(0x22) * 0.008;
            var vcc_3_3v = Read(0x23) * 0.008 * 2; //guess
            var vin1_5v  = Read(0x24) * 0.008 * 3; //guess

            //var vin2_2_5v = Read(0x25) * 0.008;
            //var vin3 = Read(0x26) * 0.008;

            Select(cs);

            yield return(Sample.Temperature("CPUTIN", cputin, true));

            yield return(Sample.Temperature("SYSTIN", systin, false));

            yield return(Sample.Temperature("AUXTIN", auxtin, true));

            if (motherboardtemp > 0)
            {
                yield return(Sample.Temperature("Motherboard", motherboardtemp, true));
            }

            yield return(Sample.FanSpeed("CPUFAN0", cpufanout0rpm, true));

            yield return(Sample.FanSpeed("CPUFAN1", cpufanout1rpm, true));

            yield return(Sample.FanSpeed("SYSFAN", sysfanoutrpm, true));

            yield return(Sample.FanSpeed("AUXFAN", auxfanout0rpm, true));

            yield return(Sample.Voltage("VCORE", vcore, true));

            yield return(Sample.Voltage("12V", vin0_12v, false));

            yield return(Sample.Voltage("5V", vin1_5v, false));

            yield return(Sample.Voltage("3.3V", vcc_3_3v, false));
        }