Hardware/Mainboard/SuperIOHardware.cs
author moel.mich
Mon, 02 Jul 2012 12:50:03 +0000
changeset 356 e471b1c2b1a6
parent 354 e71b968c04f9
child 357 fb8dc26f65a4
permissions -rw-r--r--
Corrected the temperature reading on NCT6779D super I/O chips. Added a default mainboard specific configuration for NCT6779D super I/O chips.
     1 /*
     2  
     3   This Source Code Form is subject to the terms of the Mozilla Public
     4   License, v. 2.0. If a copy of the MPL was not distributed with this
     5   file, You can obtain one at http://mozilla.org/MPL/2.0/.
     6  
     7   Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
     8 	
     9 */
    10 
    11 using System;
    12 using System.Collections.Generic;
    13 using System.Globalization;
    14 using System.Threading;
    15 using OpenHardwareMonitor.Hardware.LPC;
    16 
    17 namespace OpenHardwareMonitor.Hardware.Mainboard {
    18   internal class SuperIOHardware : Hardware {
    19 
    20     private readonly Mainboard mainboard;
    21     private readonly ISuperIO superIO;
    22 
    23     private readonly List<Sensor> voltages = new List<Sensor>();
    24     private readonly List<Sensor> temperatures = new List<Sensor>();
    25     private readonly List<Sensor> fans = new List<Sensor>();
    26     private readonly List<Sensor> controls = new List<Sensor>();
    27 
    28     private delegate float? ReadValueDelegate(int index);
    29     private delegate void UpdateDelegate();
    30 
    31     // delegates for mainboard specific sensor reading code
    32     private readonly ReadValueDelegate readVoltage;
    33     private readonly ReadValueDelegate readTemperature;
    34     private readonly ReadValueDelegate readFan;
    35     private readonly ReadValueDelegate readControl;
    36 
    37     // delegate for post update mainboard specific code
    38     private readonly UpdateDelegate postUpdate;
    39 
    40     // mainboard specific mutex
    41     private readonly Mutex mutex;
    42 
    43     public SuperIOHardware(Mainboard mainboard, ISuperIO superIO, 
    44       Manufacturer manufacturer, Model model, ISettings settings) 
    45       : base(ChipName.GetName(superIO.Chip), new Identifier("lpc", 
    46         superIO.Chip.ToString().ToLower(CultureInfo.InvariantCulture)), 
    47         settings)
    48     {
    49       this.mainboard = mainboard;
    50       this.superIO = superIO;
    51 
    52       this.readVoltage = (index) => superIO.Voltages[index];
    53       this.readTemperature = (index) => superIO.Temperatures[index];
    54       this.readFan = (index) => superIO.Fans[index];
    55       this.readControl = (index) => superIO.Controls[index];
    56 
    57       this.postUpdate = () => { };
    58 
    59       List<Voltage> v = new List<Voltage>();
    60       List<Temperature> t = new List<Temperature>();
    61       List<Fan> f = new List<Fan>();
    62       List<Ctrl> c = new List<Ctrl>();
    63 
    64       switch (superIO.Chip) {
    65         case Chip.IT8705F:
    66         case Chip.IT8712F:
    67         case Chip.IT8716F:
    68         case Chip.IT8718F:
    69         case Chip.IT8720F: 
    70         case Chip.IT8726F:        
    71           switch (manufacturer) {
    72             case Manufacturer.ASUS:
    73               switch (model) {
    74                 case Model.Crosshair_III_Formula: // IT8720F
    75                   v.Add(new Voltage("VBat", 8));
    76                   t.Add(new Temperature("CPU", 0));
    77                   for (int i = 0; i < superIO.Fans.Length; i++)
    78                     f.Add(new Fan("Fan #" + (i + 1), i));
    79                   break;
    80                 case Model.M2N_SLI_DELUXE:                
    81                   v.Add(new Voltage("CPU VCore", 0));
    82                   v.Add(new Voltage("+3.3V", 1));
    83                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
    84                   v.Add(new Voltage("+12V", 4, 30, 10));
    85                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
    86                   v.Add(new Voltage("VBat", 8));
    87                   t.Add(new Temperature("CPU", 0));
    88                   t.Add(new Temperature("Motherboard", 1));
    89                   f.Add(new Fan("CPU Fan", 0));
    90                   f.Add(new Fan("Chassis Fan #1", 1));
    91                   f.Add(new Fan("Power Fan", 2));
    92                   break;
    93                 case Model.M4A79XTD_EVO: // IT8720F           
    94                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
    95                   v.Add(new Voltage("VBat", 8));
    96                   t.Add(new Temperature("CPU", 0));
    97                   t.Add(new Temperature("Motherboard", 1));
    98                   f.Add(new Fan("CPU Fan", 0));
    99                   f.Add(new Fan("Chassis Fan #1", 1));
   100                   f.Add(new Fan("Chassis Fan #2", 2));
   101                   break;
   102                 default:
   103                   v.Add(new Voltage("CPU VCore", 0));
   104                   v.Add(new Voltage("Voltage #2", 1, true));
   105                   v.Add(new Voltage("Voltage #3", 2, true));
   106                   v.Add(new Voltage("Voltage #4", 3, true));
   107                   v.Add(new Voltage("Voltage #5", 4, true));
   108                   v.Add(new Voltage("Voltage #6", 5, true));
   109                   v.Add(new Voltage("Voltage #7", 6, true));
   110                   v.Add(new Voltage("Voltage #8", 7, true));
   111                   v.Add(new Voltage("VBat", 8));
   112                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   113                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   114                   for (int i = 0; i < superIO.Fans.Length; i++)
   115                     f.Add(new Fan("Fan #" + (i + 1), i));
   116                   break;
   117               }
   118               break;
   119 
   120             case Manufacturer.ASRock:
   121               switch (model) {
   122                 case Model.P55_Deluxe: // IT8720F
   123                   
   124                   v.Add(new Voltage("CPU VCore", 0));
   125                   v.Add(new Voltage("+3.3V", 2));
   126                   v.Add(new Voltage("+12V", 4, 30, 10));
   127                   v.Add(new Voltage("+5V", 5, 6.8f, 10));
   128                   v.Add(new Voltage("VBat", 8));                  
   129                   t.Add(new Temperature("CPU", 0));
   130                   t.Add(new Temperature("Motherboard", 1));
   131                   f.Add(new Fan("CPU Fan", 0));
   132                   f.Add(new Fan("Chassis Fan #1", 1));
   133 
   134                   // this mutex is also used by the official ASRock tool
   135                   mutex = new Mutex(false, "ASRockOCMark");
   136                   
   137                   bool exclusiveAccess = false;
   138                   try {
   139                     exclusiveAccess = mutex.WaitOne(10, false);
   140                   } catch (AbandonedMutexException) { } 
   141                     catch (InvalidOperationException) { }  
   142 
   143                   // only read additional fans if we get exclusive access
   144                   if (exclusiveAccess) {
   145 
   146                     f.Add(new Fan("Chassis Fan #2", 2));
   147                     f.Add(new Fan("Chassis Fan #3", 3));
   148                     f.Add(new Fan("Power Fan", 4));
   149 
   150                     readFan = (index) => {
   151                       if (index < 2) {
   152                         return superIO.Fans[index];
   153                       } else {
   154                         // get GPIO 80-87
   155                         byte? gpio = superIO.ReadGPIO(7);
   156                         if (!gpio.HasValue)
   157                           return null;
   158 
   159                         // read the last 3 fans based on GPIO 83-85
   160                         int[] masks = { 0x05, 0x03, 0x06 };
   161                         return (((gpio.Value >> 3) & 0x07) ==
   162                           masks[index - 2]) ? superIO.Fans[2] : null;
   163                       }
   164                     };
   165 
   166                     int fanIndex = 0;
   167                     postUpdate = () => {
   168                       // get GPIO 80-87
   169                       byte? gpio = superIO.ReadGPIO(7);
   170                       if (!gpio.HasValue)
   171                         return;
   172 
   173                       // prepare the GPIO 83-85 for the next update
   174                       int[] masks = { 0x05, 0x03, 0x06 };
   175                       superIO.WriteGPIO(7,
   176                         (byte)((gpio.Value & 0xC7) | (masks[fanIndex] << 3)));
   177                       fanIndex = (fanIndex + 1) % 3;
   178                     };
   179                   }
   180 
   181                   break;
   182                 default:
   183                   v.Add(new Voltage("CPU VCore", 0));
   184                   v.Add(new Voltage("Voltage #2", 1, true));
   185                   v.Add(new Voltage("Voltage #3", 2, true));
   186                   v.Add(new Voltage("Voltage #4", 3, true));
   187                   v.Add(new Voltage("Voltage #5", 4, true));
   188                   v.Add(new Voltage("Voltage #6", 5, true));
   189                   v.Add(new Voltage("Voltage #7", 6, true));
   190                   v.Add(new Voltage("Voltage #8", 7, true));
   191                   v.Add(new Voltage("VBat", 8));
   192                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   193                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   194                   for (int i = 0; i < superIO.Fans.Length; i++)
   195                     f.Add(new Fan("Fan #" + (i + 1), i));
   196                   break;
   197               };
   198               break;
   199 
   200             case Manufacturer.DFI:
   201               switch (model) {
   202                 case Model.LP_BI_P45_T2RS_Elite: // IT8718F
   203                   v.Add(new Voltage("CPU VCore", 0));
   204                   v.Add(new Voltage("FSB VTT", 1));
   205                   v.Add(new Voltage("+3.3V", 2));
   206                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   207                   v.Add(new Voltage("+12V", 4, 30, 10));
   208                   v.Add(new Voltage("NB Core", 5));
   209                   v.Add(new Voltage("VDIMM", 6));
   210                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
   211                   v.Add(new Voltage("VBat", 8));
   212                   t.Add(new Temperature("CPU", 0));
   213                   t.Add(new Temperature("System", 1));
   214                   t.Add(new Temperature("Chipset", 2));
   215                   f.Add(new Fan("Fan #1", 0));
   216                   f.Add(new Fan("Fan #2", 1));
   217                   f.Add(new Fan("Fan #3", 2));
   218                   break;
   219                 case Model.LP_DK_P55_T3eH9: // IT8720F
   220                   v.Add(new Voltage("CPU VCore", 0));
   221                   v.Add(new Voltage("VTT", 1));
   222                   v.Add(new Voltage("+3.3V", 2));
   223                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   224                   v.Add(new Voltage("+12V", 4, 30, 10));
   225                   v.Add(new Voltage("CPU PLL", 5));
   226                   v.Add(new Voltage("DRAM", 6));
   227                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
   228                   v.Add(new Voltage("VBat", 8));
   229                   t.Add(new Temperature("Chipset", 0));
   230                   t.Add(new Temperature("CPU PWM", 1));
   231                   t.Add(new Temperature("CPU", 2));
   232                   f.Add(new Fan("Fan #1", 0));
   233                   f.Add(new Fan("Fan #2", 1));
   234                   f.Add(new Fan("Fan #3", 2));
   235                   break;
   236                 default:
   237                   v.Add(new Voltage("CPU VCore", 0));
   238                   v.Add(new Voltage("VTT", 1, true));
   239                   v.Add(new Voltage("+3.3V", 2, true));
   240                   v.Add(new Voltage("+5V", 3, 6.8f, 10, 0, true));
   241                   v.Add(new Voltage("+12V", 4, 30, 10, 0, true));
   242                   v.Add(new Voltage("Voltage #6", 5, true));
   243                   v.Add(new Voltage("DRAM", 6, true));
   244                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0, true));
   245                   v.Add(new Voltage("VBat", 8));
   246                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   247                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   248                   for (int i = 0; i < superIO.Fans.Length; i++)
   249                     f.Add(new Fan("Fan #" + (i + 1), i));
   250                   break;
   251               }
   252               break;
   253 
   254             case Manufacturer.Gigabyte:
   255               switch (model) {
   256                 case Model._965P_S3: // IT8718F
   257                   v.Add(new Voltage("CPU VCore", 0));
   258                   v.Add(new Voltage("DRAM", 1));
   259                   v.Add(new Voltage("+3.3V", 2));
   260                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   261                   v.Add(new Voltage("+12V", 7, 27, 9.1f));
   262                   v.Add(new Voltage("VBat", 8));
   263                   t.Add(new Temperature("System", 0));
   264                   t.Add(new Temperature("CPU", 1));
   265                   f.Add(new Fan("CPU Fan", 0));
   266                   f.Add(new Fan("System Fan", 1));
   267                   break;
   268                 case Model.EP45_DS3R: // IT8718F
   269                 case Model.EP45_UD3R: 
   270                 case Model.X38_DS5:    
   271                   v.Add(new Voltage("CPU VCore", 0));
   272                   v.Add(new Voltage("DRAM", 1));
   273                   v.Add(new Voltage("+3.3V", 2));
   274                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   275                   v.Add(new Voltage("+12V", 7, 27, 9.1f));
   276                   v.Add(new Voltage("VBat", 8));
   277                   t.Add(new Temperature("System", 0));
   278                   t.Add(new Temperature("CPU", 1));
   279                   f.Add(new Fan("CPU Fan", 0));
   280                   f.Add(new Fan("System Fan #2", 1));
   281                   f.Add(new Fan("Power Fan", 2));
   282                   f.Add(new Fan("System Fan #1", 3));
   283                   break;
   284                 case Model.EX58_EXTREME: // IT8720F 
   285                   v.Add(new Voltage("CPU VCore", 0));
   286                   v.Add(new Voltage("DRAM", 1));
   287                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   288                   v.Add(new Voltage("VBat", 8));
   289                   t.Add(new Temperature("System", 0));
   290                   t.Add(new Temperature("CPU", 1));
   291                   t.Add(new Temperature("Northbridge", 2));
   292                   f.Add(new Fan("CPU Fan", 0));
   293                   f.Add(new Fan("System Fan #2", 1));
   294                   f.Add(new Fan("Power Fan", 2));
   295                   f.Add(new Fan("System Fan #1", 3));
   296                   break;
   297                 case Model.P35_DS3: // IT8718F 
   298                 case Model.P35_DS3L: // IT8718F
   299                   v.Add(new Voltage("CPU VCore", 0));
   300                   v.Add(new Voltage("DRAM", 1));
   301                   v.Add(new Voltage("+3.3V", 2));
   302                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   303                   v.Add(new Voltage("+12V", 7, 27, 9.1f));
   304                   v.Add(new Voltage("VBat", 8));
   305                   t.Add(new Temperature("System", 0));
   306                   t.Add(new Temperature("CPU", 1));
   307                   f.Add(new Fan("CPU Fan", 0));
   308                   f.Add(new Fan("System Fan #1", 1));
   309                   f.Add(new Fan("System Fan #2", 2));
   310                   f.Add(new Fan("Power Fan", 3));
   311                   break;
   312                 case Model.P55_UD4: // IT8720F
   313                 case Model.P55M_UD4: // IT8720F
   314                   v.Add(new Voltage("CPU VCore", 0));
   315                   v.Add(new Voltage("DRAM", 1));
   316                   v.Add(new Voltage("+3.3V", 2));
   317                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   318                   v.Add(new Voltage("+12V", 5, 27, 9.1f));
   319                   v.Add(new Voltage("VBat", 8));
   320                   t.Add(new Temperature("System", 0));
   321                   t.Add(new Temperature("CPU", 2));
   322                   f.Add(new Fan("CPU Fan", 0));
   323                   f.Add(new Fan("System Fan #2", 1));
   324                   f.Add(new Fan("Power Fan", 2));
   325                   f.Add(new Fan("System Fan #1", 3));
   326                   break;
   327                 case Model.GA_MA770T_UD3: // IT8720F
   328                   v.Add(new Voltage("CPU VCore", 0));
   329                   v.Add(new Voltage("DRAM", 1));
   330                   v.Add(new Voltage("+3.3V", 2));
   331                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   332                   v.Add(new Voltage("+12V", 4, 27, 9.1f));
   333                   v.Add(new Voltage("VBat", 8));
   334                   t.Add(new Temperature("System", 0));
   335                   t.Add(new Temperature("CPU", 1));
   336                   f.Add(new Fan("CPU Fan", 0));
   337                   f.Add(new Fan("System Fan #1", 1));
   338                   f.Add(new Fan("System Fan #2", 2));
   339                   f.Add(new Fan("Power Fan", 3));
   340                   break;
   341                 case Model.GA_MA785GMT_UD2H: // IT8718F
   342                   v.Add(new Voltage("CPU VCore", 0));
   343                   v.Add(new Voltage("DRAM", 1));
   344                   v.Add(new Voltage("+3.3V", 2));
   345                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   346                   v.Add(new Voltage("+12V", 4, 27, 9.1f));
   347                   v.Add(new Voltage("VBat", 8));
   348                   t.Add(new Temperature("System", 0));
   349                   t.Add(new Temperature("CPU", 1));
   350                   f.Add(new Fan("CPU Fan", 0));
   351                   f.Add(new Fan("System Fan", 1));
   352                   f.Add(new Fan("NB Fan", 2));
   353                   break;
   354                 case Model.X58A_UD3R: // IT8720F 
   355                   v.Add(new Voltage("CPU VCore", 0));
   356                   v.Add(new Voltage("DRAM", 1));
   357                   v.Add(new Voltage("+3.3V", 2));
   358                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   359                   v.Add(new Voltage("+12V", 5, 27, 9.1f));
   360                   v.Add(new Voltage("VBat", 8));
   361                   t.Add(new Temperature("System", 0));
   362                   t.Add(new Temperature("CPU", 1));
   363                   t.Add(new Temperature("Northbridge", 2));
   364                   f.Add(new Fan("CPU Fan", 0));
   365                   f.Add(new Fan("System Fan #2", 1));
   366                   f.Add(new Fan("Power Fan", 2));
   367                   f.Add(new Fan("System Fan #1", 3));
   368                   break;
   369                 default:
   370                   v.Add(new Voltage("CPU VCore", 0));
   371                   v.Add(new Voltage("DRAM", 1, true));
   372                   v.Add(new Voltage("+3.3V", 2, true));
   373                   v.Add(new Voltage("+5V", 3, 6.8f, 10, 0, true));
   374                   v.Add(new Voltage("Voltage #5", 4, true));
   375                   v.Add(new Voltage("Voltage #6", 5, true));
   376                   v.Add(new Voltage("Voltage #7", 6, true));
   377                   v.Add(new Voltage("Voltage #8", 7, true));
   378                   v.Add(new Voltage("VBat", 8));
   379                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   380                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   381                   for (int i = 0; i < superIO.Fans.Length; i++)
   382                     f.Add(new Fan("Fan #" + (i + 1), i));
   383                   break;
   384               }
   385               break;
   386 
   387             default:
   388               v.Add(new Voltage("CPU VCore", 0));
   389               v.Add(new Voltage("Voltage #2", 1, true));
   390               v.Add(new Voltage("Voltage #3", 2, true));
   391               v.Add(new Voltage("Voltage #4", 3, true));
   392               v.Add(new Voltage("Voltage #5", 4, true));
   393               v.Add(new Voltage("Voltage #6", 5, true));
   394               v.Add(new Voltage("Voltage #7", 6, true));
   395               v.Add(new Voltage("Voltage #8", 7, true));
   396               v.Add(new Voltage("VBat", 8));
   397               for (int i = 0; i < superIO.Temperatures.Length; i++)
   398                 t.Add(new Temperature("Temperature #" + (i + 1), i));
   399               for (int i = 0; i < superIO.Fans.Length; i++)
   400                 f.Add(new Fan("Fan #" + (i + 1), i));
   401               break;
   402           }
   403           break;
   404 
   405         case Chip.IT8721F:
   406         case Chip.IT8728F:
   407         case Chip.IT8771E:
   408         case Chip.IT8772E:
   409           switch (manufacturer) {
   410             case Manufacturer.ECS:
   411               switch (model) {
   412                 case Model.A890GXM_A: // IT8721F
   413                   v.Add(new Voltage("CPU VCore", 0));
   414                   v.Add(new Voltage("VDIMM", 1));
   415                   v.Add(new Voltage("NB Voltage", 2));
   416                   v.Add(new Voltage("Analog +3.3V", 3, 10, 10));
   417                   // v.Add(new Voltage("VDIMM", 6, true));
   418                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
   419                   v.Add(new Voltage("VBat", 8, 10, 10));
   420                   t.Add(new Temperature("CPU", 0));
   421                   t.Add(new Temperature("System", 1));
   422                   t.Add(new Temperature("Northbridge", 2));
   423                   f.Add(new Fan("CPU Fan", 0));
   424                   f.Add(new Fan("System Fan", 1));
   425                   f.Add(new Fan("Power Fan", 2));
   426                   break;
   427                 default:
   428                   v.Add(new Voltage("Voltage #1", 0, true));
   429                   v.Add(new Voltage("Voltage #2", 1, true));
   430                   v.Add(new Voltage("Voltage #3", 2, true));
   431                   v.Add(new Voltage("Analog +3.3V", 3, 10, 10, 0, true));
   432                   v.Add(new Voltage("Voltage #5", 4, true));
   433                   v.Add(new Voltage("Voltage #6", 5, true));
   434                   v.Add(new Voltage("Voltage #7", 6, true));
   435                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
   436                   v.Add(new Voltage("VBat", 8, 10, 10));
   437                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   438                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   439                   for (int i = 0; i < superIO.Fans.Length; i++)
   440                     f.Add(new Fan("Fan #" + (i + 1), i));
   441                   break;
   442               }
   443               break;
   444             case Manufacturer.Gigabyte:
   445               switch (model) {
   446                 case Model.P67A_UD4_B3: // IT8728F
   447                   v.Add(new Voltage("+12V", 0, 100, 10));
   448                   v.Add(new Voltage("+5V", 1, 15, 10));
   449                   v.Add(new Voltage("Voltage #3", 2, true));
   450                   v.Add(new Voltage("Voltage #4", 3, true));
   451                   v.Add(new Voltage("Voltage #5", 4, true));
   452                   v.Add(new Voltage("CPU VCore", 5));
   453                   v.Add(new Voltage("DRAM", 6));
   454                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
   455                   v.Add(new Voltage("VBat", 8, 10, 10));
   456                   t.Add(new Temperature("System", 0));
   457                   t.Add(new Temperature("CPU", 2));
   458                   f.Add(new Fan("CPU Fan", 0));
   459                   f.Add(new Fan("System Fan #2", 1));
   460                   f.Add(new Fan("Power Fan", 2));
   461                   f.Add(new Fan("System Fan #1", 3));
   462                   break;
   463                 case Model.H67A_UD3H_B3: // IT8728F
   464                   v.Add(new Voltage("VTT", 0));
   465                   v.Add(new Voltage("+5V", 1, 15, 10));
   466                   v.Add(new Voltage("+12V", 2, 68, 22));
   467                   v.Add(new Voltage("Voltage #4", 3, true));
   468                   v.Add(new Voltage("Voltage #5", 4, true));
   469                   v.Add(new Voltage("CPU VCore", 5));
   470                   v.Add(new Voltage("DRAM", 6));
   471                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
   472                   v.Add(new Voltage("VBat", 8, 10, 10));
   473                   t.Add(new Temperature("System", 0));
   474                   t.Add(new Temperature("CPU", 2));
   475                   f.Add(new Fan("CPU Fan", 0));
   476                   f.Add(new Fan("System Fan #1", 1));
   477                   f.Add(new Fan("Power Fan", 2));
   478                   f.Add(new Fan("System Fan #2", 3));
   479                   break;
   480                 case Model.Z68X_UD7_B3: // IT8728F
   481                   v.Add(new Voltage("VTT", 0));
   482                   v.Add(new Voltage("+3.3V", 1, 13.3f, 20.5f));
   483                   v.Add(new Voltage("+12V", 2, 68, 22));
   484                   v.Add(new Voltage("+5V", 3, 14.3f, 20));
   485                   v.Add(new Voltage("CPU VCore", 5));
   486                   v.Add(new Voltage("DRAM", 6));
   487                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
   488                   v.Add(new Voltage("VBat", 8, 10, 10));
   489                   t.Add(new Temperature("System", 0));
   490                   t.Add(new Temperature("CPU", 1));
   491                   t.Add(new Temperature("System 3", 2));
   492                   f.Add(new Fan("CPU Fan", 0));
   493                   f.Add(new Fan("Power Fan", 1));
   494                   f.Add(new Fan("System Fan #1", 2));
   495                   f.Add(new Fan("System Fan #2", 3));
   496                   f.Add(new Fan("System Fan #3", 4));
   497                   break;
   498                 default:
   499                   v.Add(new Voltage("Voltage #1", 0, true));
   500                   v.Add(new Voltage("Voltage #2", 1, true));
   501                   v.Add(new Voltage("Voltage #3", 2, true));
   502                   v.Add(new Voltage("Voltage #4", 3, true));
   503                   v.Add(new Voltage("Voltage #5", 4, true));
   504                   v.Add(new Voltage("Voltage #6", 5, true));
   505                   v.Add(new Voltage("Voltage #7", 6, true));
   506                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
   507                   v.Add(new Voltage("VBat", 8, 10, 10));
   508                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   509                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   510                   for (int i = 0; i < superIO.Fans.Length; i++)
   511                     f.Add(new Fan("Fan #" + (i + 1), i));
   512                   break;
   513               }
   514               break;
   515             case Manufacturer.Shuttle:
   516               switch (model) {
   517                 case Model.FH67: // IT8772E 
   518                   v.Add(new Voltage("CPU VCore", 0));
   519                   v.Add(new Voltage("DRAM", 1));
   520                   v.Add(new Voltage("PCH VCCIO", 2));
   521                   v.Add(new Voltage("CPU VCCIO", 3));
   522                   v.Add(new Voltage("Graphic Voltage", 4));
   523                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
   524                   v.Add(new Voltage("VBat", 8, 10, 10));
   525                   t.Add(new Temperature("System", 0));
   526                   t.Add(new Temperature("CPU", 1));                  
   527                   f.Add(new Fan("Fan #1", 0));
   528                   f.Add(new Fan("CPU Fan", 1));
   529                   break;
   530                 default:
   531                   v.Add(new Voltage("Voltage #1", 0, true));
   532                   v.Add(new Voltage("Voltage #2", 1, true));
   533                   v.Add(new Voltage("Voltage #3", 2, true));
   534                   v.Add(new Voltage("Voltage #4", 3, true));
   535                   v.Add(new Voltage("Voltage #5", 4, true));
   536                   v.Add(new Voltage("Voltage #6", 5, true));
   537                   v.Add(new Voltage("Voltage #7", 6, true));
   538                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
   539                   v.Add(new Voltage("VBat", 8, 10, 10));
   540                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   541                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   542                   for (int i = 0; i < superIO.Fans.Length; i++)
   543                     f.Add(new Fan("Fan #" + (i + 1), i));
   544                   break;
   545               }
   546               break;
   547             default:
   548               v.Add(new Voltage("Voltage #1", 0, true));
   549               v.Add(new Voltage("Voltage #2", 1, true));
   550               v.Add(new Voltage("Voltage #3", 2, true));
   551               v.Add(new Voltage("Voltage #4", 3, true));
   552               v.Add(new Voltage("Voltage #5", 4, true));
   553               v.Add(new Voltage("Voltage #6", 5, true));
   554               v.Add(new Voltage("Voltage #7", 6, true));
   555               v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
   556               v.Add(new Voltage("VBat", 8, 10, 10));
   557               for (int i = 0; i < superIO.Temperatures.Length; i++)
   558                 t.Add(new Temperature("Temperature #" + (i + 1), i));
   559               for (int i = 0; i < superIO.Fans.Length; i++)
   560                 f.Add(new Fan("Fan #" + (i + 1), i));
   561               break;
   562           }
   563           break;
   564           
   565         case Chip.F71858:
   566           v.Add(new Voltage("VCC3V", 0, 150, 150));
   567           v.Add(new Voltage("VSB3V", 1, 150, 150));
   568           v.Add(new Voltage("Battery", 2, 150, 150));
   569           for (int i = 0; i < superIO.Temperatures.Length; i++)
   570             t.Add(new Temperature("Temperature #" + (i + 1), i));
   571           for (int i = 0; i < superIO.Fans.Length; i++)
   572             f.Add(new Fan("Fan #" + (i + 1), i));
   573           break;
   574         case Chip.F71862: 
   575         case Chip.F71869: 
   576         case Chip.F71882:
   577         case Chip.F71889AD: 
   578         case Chip.F71889ED: 
   579         case Chip.F71889F:
   580         case Chip.F71808E:
   581           switch (manufacturer) {
   582             case Manufacturer.EVGA:
   583               switch (model) {
   584                 case Model.X58_SLI_Classified: // F71882 
   585                   v.Add(new Voltage("VCC3V", 0, 150, 150));
   586                   v.Add(new Voltage("CPU VCore", 1, 47, 100));
   587                   v.Add(new Voltage("DIMM", 2, 47, 100));
   588                   v.Add(new Voltage("CPU VTT", 3, 24, 100));
   589                   v.Add(new Voltage("IOH Vcore", 4, 24, 100));
   590                   v.Add(new Voltage("+5V", 5, 51, 12));
   591                   v.Add(new Voltage("+12V", 6, 56, 6.8f));
   592                   v.Add(new Voltage("3VSB", 7, 150, 150));
   593                   v.Add(new Voltage("VBat", 8, 150, 150));
   594                   t.Add(new Temperature("CPU", 0));
   595                   t.Add(new Temperature("VREG", 1));
   596                   t.Add(new Temperature("System", 2));
   597                   f.Add(new Fan("CPU Fan", 0));
   598                   f.Add(new Fan("Power Fan", 1));
   599                   f.Add(new Fan("Chassis Fan", 2));
   600                   break;
   601                 default:
   602                   v.Add(new Voltage("VCC3V", 0, 150, 150));
   603                   v.Add(new Voltage("CPU VCore", 1));
   604                   v.Add(new Voltage("Voltage #3", 2, true));
   605                   v.Add(new Voltage("Voltage #4", 3, true));
   606                   v.Add(new Voltage("Voltage #5", 4, true));
   607                   v.Add(new Voltage("Voltage #6", 5, true));
   608                   v.Add(new Voltage("Voltage #7", 6, true));
   609                   v.Add(new Voltage("VSB3V", 7, 150, 150));
   610                   v.Add(new Voltage("VBat", 8, 150, 150));
   611                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   612                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   613                   for (int i = 0; i < superIO.Fans.Length; i++)
   614                     f.Add(new Fan("Fan #" + (i + 1), i));
   615                   break;
   616               }
   617               break;
   618             default:
   619               v.Add(new Voltage("VCC3V", 0, 150, 150));
   620               v.Add(new Voltage("CPU VCore", 1));
   621               v.Add(new Voltage("Voltage #3", 2, true));
   622               v.Add(new Voltage("Voltage #4", 3, true));
   623               v.Add(new Voltage("Voltage #5", 4, true));
   624               v.Add(new Voltage("Voltage #6", 5, true));
   625               if (superIO.Chip != Chip.F71808E) 
   626                   v.Add(new Voltage("Voltage #7", 6, true)); 
   627               v.Add(new Voltage("VSB3V", 7, 150, 150));
   628               v.Add(new Voltage("VBat", 8, 150, 150));
   629               for (int i = 0; i < superIO.Temperatures.Length; i++)
   630                 t.Add(new Temperature("Temperature #" + (i + 1), i));
   631               for (int i = 0; i < superIO.Fans.Length; i++)
   632                 f.Add(new Fan("Fan #" + (i + 1), i));
   633               break;
   634           }
   635           break;
   636 
   637         case Chip.W83627EHF:
   638           switch (manufacturer) {
   639             case Manufacturer.ASRock:
   640               switch (model) {
   641                 case Model.AOD790GX_128M: // W83627EHF
   642                   v.Add(new Voltage("CPU VCore", 0));
   643                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   644                   v.Add(new Voltage("+3.3V", 4, 10, 10));
   645                   v.Add(new Voltage("+5V", 5, 20, 10));
   646                   v.Add(new Voltage("+12V", 6, 28, 5));
   647                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   648                   v.Add(new Voltage("VBAT", 8, 34, 34));
   649                   t.Add(new Temperature("CPU", 0));
   650                   t.Add(new Temperature("Motherboard", 2));
   651                   f.Add(new Fan("CPU Fan", 0));
   652                   f.Add(new Fan("Chassis Fan", 1));                 
   653                   break;
   654                 default:
   655                   v.Add(new Voltage("CPU VCore", 0));
   656                   v.Add(new Voltage("Voltage #2", 1, true));
   657                   v.Add(new Voltage("AVCC", 2, 34, 34));
   658                   v.Add(new Voltage("3VCC", 3, 34, 34));
   659                   v.Add(new Voltage("Voltage #5", 4, true));
   660                   v.Add(new Voltage("Voltage #6", 5, true));
   661                   v.Add(new Voltage("Voltage #7", 6, true));
   662                   v.Add(new Voltage("3VSB", 7, 34, 34));
   663                   v.Add(new Voltage("VBAT", 8, 34, 34));
   664                   v.Add(new Voltage("Voltage #10", 9, true));
   665                   t.Add(new Temperature("CPU", 0));
   666                   t.Add(new Temperature("Auxiliary", 1));
   667                   t.Add(new Temperature("System", 2));
   668                   f.Add(new Fan("System Fan", 0));
   669                   f.Add(new Fan("CPU Fan", 1));
   670                   f.Add(new Fan("Auxiliary Fan", 2));
   671                   f.Add(new Fan("CPU Fan #2", 3));
   672                   f.Add(new Fan("Auxiliary Fan #2", 4));
   673                   break;
   674               } break;
   675             default:
   676               v.Add(new Voltage("CPU VCore", 0));
   677               v.Add(new Voltage("Voltage #2", 1, true));
   678               v.Add(new Voltage("AVCC", 2, 34, 34));
   679               v.Add(new Voltage("3VCC", 3, 34, 34));
   680               v.Add(new Voltage("Voltage #5", 4, true));
   681               v.Add(new Voltage("Voltage #6", 5, true));
   682               v.Add(new Voltage("Voltage #7", 6, true));
   683               v.Add(new Voltage("3VSB", 7, 34, 34));
   684               v.Add(new Voltage("VBAT", 8, 34, 34));
   685               v.Add(new Voltage("Voltage #10", 9, true));
   686               t.Add(new Temperature("CPU", 0));
   687               t.Add(new Temperature("Auxiliary", 1));
   688               t.Add(new Temperature("System", 2));
   689               f.Add(new Fan("System Fan", 0));
   690               f.Add(new Fan("CPU Fan", 1));
   691               f.Add(new Fan("Auxiliary Fan", 2));
   692               f.Add(new Fan("CPU Fan #2", 3));
   693               f.Add(new Fan("Auxiliary Fan #2", 4));
   694               break;
   695           }
   696           break;
   697         case Chip.W83627DHG: 
   698         case Chip.W83627DHGP:                      
   699         case Chip.W83667HG:
   700         case Chip.W83667HGB:
   701           switch (manufacturer) {
   702             case Manufacturer.ASRock:
   703               switch (model) {
   704                 case Model._880GMH_USB3: // W83627DHG-P
   705                   v.Add(new Voltage("CPU VCore", 0));
   706                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   707                   v.Add(new Voltage("+5V", 5, 15, 7.5f));
   708                   v.Add(new Voltage("+12V", 6, 56, 10));
   709                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   710                   v.Add(new Voltage("VBAT", 8, 34, 34));
   711                   t.Add(new Temperature("CPU", 0));
   712                   t.Add(new Temperature("Motherboard", 2));
   713                   f.Add(new Fan("Chassis Fan", 0));
   714                   f.Add(new Fan("CPU Fan", 1));
   715                   f.Add(new Fan("Power Fan", 2));
   716                   break;
   717                 default:
   718                   v.Add(new Voltage("CPU VCore", 0));
   719                   v.Add(new Voltage("Voltage #2", 1, true));
   720                   v.Add(new Voltage("AVCC", 2, 34, 34));
   721                   v.Add(new Voltage("3VCC", 3, 34, 34));
   722                   v.Add(new Voltage("Voltage #5", 4, true));
   723                   v.Add(new Voltage("Voltage #6", 5, true));
   724                   v.Add(new Voltage("Voltage #7", 6, true));
   725                   v.Add(new Voltage("3VSB", 7, 34, 34));
   726                   v.Add(new Voltage("VBAT", 8, 34, 34));
   727                   t.Add(new Temperature("CPU", 0));
   728                   t.Add(new Temperature("Auxiliary", 1));
   729                   t.Add(new Temperature("System", 2));
   730                   f.Add(new Fan("System Fan", 0));
   731                   f.Add(new Fan("CPU Fan", 1));
   732                   f.Add(new Fan("Auxiliary Fan", 2));
   733                   f.Add(new Fan("CPU Fan #2", 3));
   734                   f.Add(new Fan("Auxiliary Fan #2", 4));
   735                   break;
   736               }
   737               break;
   738             case Manufacturer.ASUS:
   739               switch (model) {
   740                 case Model.P6T: // W83667HG
   741                 case Model.P6X58D_E: // W83667HG                 
   742                 case Model.Rampage_II_GENE: // W83667HG 
   743                   v.Add(new Voltage("CPU VCore", 0));
   744                   v.Add(new Voltage("+12V", 1, 11.5f, 1.91f));
   745                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   746                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   747                   v.Add(new Voltage("+5V", 4, 15, 7.5f));
   748                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   749                   v.Add(new Voltage("VBAT", 8, 34, 34));
   750                   t.Add(new Temperature("CPU", 0));
   751                   t.Add(new Temperature("Motherboard", 2));
   752                   f.Add(new Fan("Chassis Fan #1", 0));
   753                   f.Add(new Fan("CPU Fan", 1));
   754                   f.Add(new Fan("Power Fan", 2));
   755                   f.Add(new Fan("Chassis Fan #2", 3));
   756                   f.Add(new Fan("Chassis Fan #3", 4));
   757                   break;
   758                 case Model.Rampage_Extreme: // W83667HG 
   759                   v.Add(new Voltage("CPU VCore", 0));
   760                   v.Add(new Voltage("+12V", 1, 12, 2));
   761                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   762                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   763                   v.Add(new Voltage("+5V", 4, 15, 7.5f));
   764                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   765                   v.Add(new Voltage("VBAT", 8, 34, 34));
   766                   t.Add(new Temperature("CPU", 0));
   767                   t.Add(new Temperature("Motherboard", 2));
   768                   f.Add(new Fan("Chassis Fan #1", 0));
   769                   f.Add(new Fan("CPU Fan", 1));
   770                   f.Add(new Fan("Power Fan", 2));
   771                   f.Add(new Fan("Chassis Fan #2", 3));
   772                   f.Add(new Fan("Chassis Fan #3", 4));
   773                   break;
   774                 default:
   775                   v.Add(new Voltage("CPU VCore", 0));
   776                   v.Add(new Voltage("Voltage #2", 1, true));
   777                   v.Add(new Voltage("AVCC", 2, 34, 34));
   778                   v.Add(new Voltage("3VCC", 3, 34, 34));
   779                   v.Add(new Voltage("Voltage #5", 4, true));
   780                   v.Add(new Voltage("Voltage #6", 5, true));
   781                   v.Add(new Voltage("Voltage #7", 6, true));
   782                   v.Add(new Voltage("3VSB", 7, 34, 34));
   783                   v.Add(new Voltage("VBAT", 8, 34, 34));
   784                   t.Add(new Temperature("CPU", 0));
   785                   t.Add(new Temperature("Auxiliary", 1));
   786                   t.Add(new Temperature("System", 2));
   787                   f.Add(new Fan("System Fan", 0));
   788                   f.Add(new Fan("CPU Fan", 1));
   789                   f.Add(new Fan("Auxiliary Fan", 2));
   790                   f.Add(new Fan("CPU Fan #2", 3));
   791                   f.Add(new Fan("Auxiliary Fan #2", 4));
   792                   break;
   793               }
   794               break;
   795             default:
   796               v.Add(new Voltage("CPU VCore", 0));
   797               v.Add(new Voltage("Voltage #2", 1, true));
   798               v.Add(new Voltage("AVCC", 2, 34, 34));
   799               v.Add(new Voltage("3VCC", 3, 34, 34));
   800               v.Add(new Voltage("Voltage #5", 4, true));
   801               v.Add(new Voltage("Voltage #6", 5, true));
   802               v.Add(new Voltage("Voltage #7", 6, true));
   803               v.Add(new Voltage("3VSB", 7, 34, 34));
   804               v.Add(new Voltage("VBAT", 8, 34, 34));
   805               t.Add(new Temperature("CPU", 0));
   806               t.Add(new Temperature("Auxiliary", 1));
   807               t.Add(new Temperature("System", 2));
   808               f.Add(new Fan("System Fan", 0));
   809               f.Add(new Fan("CPU Fan", 1));
   810               f.Add(new Fan("Auxiliary Fan", 2));
   811               f.Add(new Fan("CPU Fan #2", 3));
   812               f.Add(new Fan("Auxiliary Fan #2", 4));
   813               break;
   814           } 
   815           break;
   816         case Chip.W83627HF: 
   817         case Chip.W83627THF: 
   818         case Chip.W83687THF:
   819           v.Add(new Voltage("CPU VCore", 0));
   820           v.Add(new Voltage("Voltage #2", 1, true));
   821           v.Add(new Voltage("Voltage #3", 2, true));
   822           v.Add(new Voltage("AVCC", 3, 34, 51));
   823           v.Add(new Voltage("Voltage #5", 4, true));
   824           v.Add(new Voltage("5VSB", 5, 34, 51));
   825           v.Add(new Voltage("VBAT", 6));
   826           t.Add(new Temperature("CPU", 0));
   827           t.Add(new Temperature("Auxiliary", 1));
   828           t.Add(new Temperature("System", 2));
   829           f.Add(new Fan("System Fan", 0));
   830           f.Add(new Fan("CPU Fan", 1));
   831           f.Add(new Fan("Auxiliary Fan", 2));
   832           break;
   833         case Chip.NCT6771F:
   834         case Chip.NCT6776F:
   835           switch (manufacturer) {
   836             case Manufacturer.ASUS:
   837               switch (model) {
   838                 case Model.P8P67: // NCT6776F
   839                 case Model.P8P67_EVO: // NCT6776F
   840                 case Model.P8P67_PRO: // NCT6776F
   841                   v.Add(new Voltage("CPU VCore", 0));
   842                   v.Add(new Voltage("+12V", 1, 11, 1));
   843                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   844                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   845                   v.Add(new Voltage("+5V", 4, 12, 3));
   846                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   847                   v.Add(new Voltage("VBAT", 8, 34, 34));
   848                   t.Add(new Temperature("CPU", 0));
   849                   t.Add(new Temperature("Auxiliary", 2));
   850                   t.Add(new Temperature("Motherboard", 3));
   851                   f.Add(new Fan("Chassis Fan #1", 0));
   852                   f.Add(new Fan("CPU Fan", 1));
   853                   f.Add(new Fan("Power Fan", 2));
   854                   f.Add(new Fan("Chassis Fan #2", 3));
   855                   c.Add(new Ctrl("Chassis Fan #2", 0));
   856                   c.Add(new Ctrl("CPU Fan", 1));
   857                   c.Add(new Ctrl("Chassis Fan #1", 2));
   858                   break;
   859                 case Model.P8P67_M_PRO: // NCT6776F
   860                   v.Add(new Voltage("CPU VCore", 0));
   861                   v.Add(new Voltage("+12V", 1, 11, 1));
   862                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   863                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   864                   v.Add(new Voltage("+5V", 4, 12, 3));
   865                   v.Add(new Voltage("Voltage #6", 5, true));
   866                   v.Add(new Voltage("Voltage #7", 6, true));
   867                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   868                   v.Add(new Voltage("VBAT", 8, 34, 34));
   869                   t.Add(new Temperature("CPU", 0));
   870                   t.Add(new Temperature("Motherboard", 3));
   871                   f.Add(new Fan("Chassis Fan #1", 0));
   872                   f.Add(new Fan("CPU Fan", 1));
   873                   f.Add(new Fan("Chassis Fan #2", 2));
   874                   f.Add(new Fan("Power Fan", 3));
   875                   f.Add(new Fan("Auxiliary Fan", 4));
   876                   break;
   877                 case Model.P8Z68_V_PRO: // NCT6776F
   878                   v.Add(new Voltage("CPU VCore", 0));
   879                   v.Add(new Voltage("+12V", 1, 11, 1));
   880                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   881                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   882                   v.Add(new Voltage("+5V", 4, 12, 3));
   883                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   884                   v.Add(new Voltage("VBAT", 8, 34, 34));
   885                   t.Add(new Temperature("CPU", 0));
   886                   t.Add(new Temperature("Auxiliary", 2));
   887                   t.Add(new Temperature("Motherboard", 3));
   888                   for (int i = 0; i < superIO.Fans.Length; i++)
   889                     f.Add(new Fan("Fan #" + (i + 1), i));
   890                   for (int i = 0; i < superIO.Controls.Length; i++)
   891                     c.Add(new Ctrl("Fan #" + (i + 1), i));
   892                   break;
   893                 case Model.P9X79: // NCT6776F
   894                   v.Add(new Voltage("CPU VCore", 0));
   895                   v.Add(new Voltage("+12V", 1, 11, 1));
   896                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   897                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   898                   v.Add(new Voltage("+5V", 4, 12, 3));
   899                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   900                   v.Add(new Voltage("VBAT", 8, 34, 34));
   901                   t.Add(new Temperature("CPU", 0));
   902                   t.Add(new Temperature("Motherboard", 3));
   903                   for (int i = 0; i < superIO.Fans.Length; i++)
   904                     f.Add(new Fan("Fan #" + (i + 1), i));
   905                   break;
   906                 default:
   907                   v.Add(new Voltage("CPU VCore", 0));
   908                   v.Add(new Voltage("Voltage #2", 1, true));
   909                   v.Add(new Voltage("AVCC", 2, 34, 34));
   910                   v.Add(new Voltage("3VCC", 3, 34, 34));
   911                   v.Add(new Voltage("Voltage #5", 4, true));
   912                   v.Add(new Voltage("Voltage #6", 5, true));
   913                   v.Add(new Voltage("Voltage #7", 6, true));
   914                   v.Add(new Voltage("3VSB", 7, 34, 34));
   915                   v.Add(new Voltage("VBAT", 8, 34, 34));
   916                   t.Add(new Temperature("CPU Core", 0));                  
   917                   t.Add(new Temperature("Temperature #1", 1));
   918                   t.Add(new Temperature("Temperature #2", 2));
   919                   t.Add(new Temperature("Temperature #3", 3));
   920                   for (int i = 0; i < superIO.Fans.Length; i++)
   921                     f.Add(new Fan("Fan #" + (i + 1), i));
   922                   break;
   923               }
   924               break;
   925             default:
   926               v.Add(new Voltage("CPU VCore", 0));
   927               v.Add(new Voltage("Voltage #2", 1, true));
   928               v.Add(new Voltage("AVCC", 2, 34, 34));
   929               v.Add(new Voltage("3VCC", 3, 34, 34));
   930               v.Add(new Voltage("Voltage #5", 4, true));
   931               v.Add(new Voltage("Voltage #6", 5, true));
   932               v.Add(new Voltage("Voltage #7", 6, true));
   933               v.Add(new Voltage("3VSB", 7, 34, 34));
   934               v.Add(new Voltage("VBAT", 8, 34, 34));
   935               t.Add(new Temperature("CPU Core", 0));
   936               t.Add(new Temperature("Temperature #1", 1));
   937               t.Add(new Temperature("Temperature #2", 2));
   938               t.Add(new Temperature("Temperature #3", 3));
   939               for (int i = 0; i < superIO.Fans.Length; i++)
   940                 f.Add(new Fan("Fan #" + (i + 1), i));
   941               break;
   942           }
   943           break;
   944         case Chip.NCT6779D:
   945           v.Add(new Voltage("CPU VCore", 0));
   946           v.Add(new Voltage("Voltage #2", 1, true));
   947           v.Add(new Voltage("AVCC", 2, 34, 34));
   948           v.Add(new Voltage("3VCC", 3, 34, 34));
   949           v.Add(new Voltage("Voltage #5", 4, true));
   950           v.Add(new Voltage("Voltage #6", 5, true));
   951           v.Add(new Voltage("Voltage #7", 6, true));
   952           v.Add(new Voltage("3VSB", 7, 34, 34));
   953           v.Add(new Voltage("VBAT", 8, 34, 34));
   954           v.Add(new Voltage("VTT", 9));
   955           v.Add(new Voltage("Voltage #11", 10, true));
   956           v.Add(new Voltage("Voltage #12", 11, true));
   957           v.Add(new Voltage("Voltage #13", 12, true));
   958           v.Add(new Voltage("Voltage #14", 13, true));
   959           v.Add(new Voltage("Voltage #15", 14, true));
   960           t.Add(new Temperature("CPU Core", 0));
   961           t.Add(new Temperature("Temperature #1", 1));
   962           t.Add(new Temperature("Temperature #2", 2));
   963           t.Add(new Temperature("Temperature #3", 3));
   964           t.Add(new Temperature("Temperature #4", 4));
   965           t.Add(new Temperature("Temperature #5", 5));
   966           t.Add(new Temperature("Temperature #6", 6));
   967           for (int i = 0; i < superIO.Fans.Length; i++)
   968             f.Add(new Fan("Fan #" + (i + 1), i));
   969           for (int i = 0; i < superIO.Controls.Length; i++)
   970             c.Add(new Ctrl("Fan Control #" + (i + 1), i));
   971           break;
   972         default:
   973           for (int i = 0; i < superIO.Voltages.Length; i++)
   974             v.Add(new Voltage("Voltage #" + (i + 1), i, true));
   975           for (int i = 0; i < superIO.Temperatures.Length; i++)
   976             t.Add(new Temperature("Temperature #" + (i + 1), i));
   977           for (int i = 0; i < superIO.Fans.Length; i++)
   978             f.Add(new Fan("Fan #" + (i + 1), i));
   979           for (int i = 0; i < superIO.Controls.Length; i++)
   980             c.Add(new Ctrl("Fan Control #" + (i + 1), i));
   981           break;
   982       }
   983 
   984       const string formula = "Voltage = value + (value - Vf) * Ri / Rf.";
   985       foreach (Voltage voltage in v) 
   986         if (voltage.Index < superIO.Voltages.Length) {
   987           Sensor sensor = new Sensor(voltage.Name, voltage.Index, 
   988             voltage.Hidden, SensorType.Voltage, this, new [] {
   989             new ParameterDescription("Ri [kΩ]", "Input resistance.\n" + 
   990               formula, voltage.Ri),
   991             new ParameterDescription("Rf [kΩ]", "Reference resistance.\n" + 
   992               formula, voltage.Rf),
   993             new ParameterDescription("Vf [V]", "Reference voltage.\n" + 
   994               formula, voltage.Vf)
   995             }, settings);
   996           voltages.Add(sensor);
   997       }
   998 
   999       foreach (Temperature temperature in t) 
  1000         if (temperature.Index < superIO.Temperatures.Length) {
  1001         Sensor sensor = new Sensor(temperature.Name, temperature.Index,
  1002           SensorType.Temperature, this, new [] {
  1003           new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
  1004         }, settings);
  1005         temperatures.Add(sensor);
  1006       }
  1007 
  1008       foreach (Fan fan in f)
  1009         if (fan.Index < superIO.Fans.Length) {
  1010           Sensor sensor = new Sensor(fan.Name, fan.Index, SensorType.Fan,
  1011             this, settings);
  1012           fans.Add(sensor);
  1013         }
  1014 
  1015       foreach (Ctrl ctrl in c) {
  1016         int index = ctrl.Index;
  1017         if (index < superIO.Controls.Length) {
  1018           Sensor sensor = new Sensor(ctrl.Name, index, SensorType.Control,
  1019             this, settings);
  1020           Control control = new Control(sensor, settings, 0, 100);
  1021           control.ControlModeChanged += (cc) => {
  1022             if (cc.ControlMode == ControlMode.Default) {
  1023               superIO.SetControl(index, null);
  1024             } else {
  1025               superIO.SetControl(index, (byte)(cc.SoftwareValue * 2.55));
  1026             }
  1027           };
  1028           control.SoftwareControlValueChanged += (cc) => {
  1029             if (cc.ControlMode == ControlMode.Software) 
  1030               superIO.SetControl(index, (byte)(cc.SoftwareValue * 2.55));
  1031           };
  1032           if (control.ControlMode == ControlMode.Software) 
  1033             superIO.SetControl(index, (byte)(control.SoftwareValue * 2.55));
  1034           sensor.Control = control;
  1035           controls.Add(sensor);
  1036         }
  1037       }
  1038     }
  1039 
  1040     public override HardwareType HardwareType {
  1041       get { return HardwareType.SuperIO; }
  1042     }
  1043 
  1044     public override IHardware Parent {
  1045       get { return mainboard; }
  1046     }
  1047 
  1048 
  1049     public override string GetReport() {
  1050       return superIO.GetReport();
  1051     }
  1052 
  1053     public override void Update() {
  1054       superIO.Update();
  1055 
  1056       foreach (Sensor sensor in voltages) {
  1057         float? value = readVoltage(sensor.Index);
  1058         if (value.HasValue) {
  1059           sensor.Value = value + (value - sensor.Parameters[2].Value) *
  1060             sensor.Parameters[0].Value / sensor.Parameters[1].Value;
  1061           ActivateSensor(sensor);
  1062         }
  1063       }
  1064 
  1065       foreach (Sensor sensor in temperatures) {
  1066         float? value = readTemperature(sensor.Index);
  1067         if (value.HasValue) {
  1068           sensor.Value = value + sensor.Parameters[0].Value;
  1069           ActivateSensor(sensor);
  1070         }
  1071       }
  1072 
  1073       foreach (Sensor sensor in fans) {
  1074         float? value = readFan(sensor.Index);
  1075         if (value.HasValue) {
  1076           sensor.Value = value;
  1077           if (value.Value > 0)
  1078             ActivateSensor(sensor);
  1079         }
  1080       }
  1081 
  1082       foreach (Sensor sensor in controls) {
  1083         float? value = readControl(sensor.Index);
  1084         if (value.HasValue) {
  1085           sensor.Value = value;
  1086           ActivateSensor(sensor);
  1087         }
  1088       }
  1089 
  1090       postUpdate();
  1091     }
  1092 
  1093     public override void Close() {
  1094       foreach (Sensor sensor in controls) {
  1095         // restore all controls back to default
  1096         superIO.SetControl(sensor.Index, null);
  1097       }
  1098       base.Close();
  1099     }
  1100 
  1101     private class Voltage {
  1102       public readonly string Name;
  1103       public readonly int Index;
  1104       public readonly float Ri;
  1105       public readonly float Rf;
  1106       public readonly float Vf;
  1107       public readonly bool Hidden;
  1108 
  1109       public Voltage(string name, int index) :
  1110         this(name, index, false) { }
  1111       
  1112       public Voltage(string name, int index, bool hidden) :
  1113         this(name, index, 0, 1, 0, hidden) { }
  1114       
  1115       public Voltage(string name, int index, float ri, float rf) :
  1116         this(name, index, ri, rf, 0, false) { }
  1117       
  1118       // float ri = 0, float rf = 1, float vf = 0, bool hidden = false) 
  1119       
  1120       public Voltage(string name, int index, 
  1121         float ri, float rf, float vf, bool hidden) 
  1122       {
  1123         this.Name = name;
  1124         this.Index = index;
  1125         this.Ri = ri;
  1126         this.Rf = rf;
  1127         this.Vf = vf;
  1128         this.Hidden = hidden;
  1129       }
  1130     }
  1131 
  1132     private class Temperature {
  1133       public readonly string Name;
  1134       public readonly int Index;
  1135 
  1136       public Temperature(string name, int index) {
  1137         this.Name = name;
  1138         this.Index = index;
  1139       }
  1140     }
  1141 
  1142     private class Fan {
  1143       public readonly string Name;
  1144       public readonly int Index;
  1145 
  1146       public Fan(string name, int index) {
  1147         this.Name = name;
  1148         this.Index = index;
  1149       }
  1150     }
  1151 
  1152     private class Ctrl {
  1153       public readonly string Name;
  1154       public readonly int Index;
  1155 
  1156       public Ctrl(string name, int index) {
  1157         this.Name = name;
  1158         this.Index = index;
  1159       }
  1160     }
  1161   }
  1162 }