Hardware/SMBIOS.cs
changeset 378 64d3ddf8d73b
parent 373 3b8443edb0e6
     1.1 --- a/Hardware/SMBIOS.cs	Thu Jul 26 06:51:19 2012 +0000
     1.2 +++ b/Hardware/SMBIOS.cs	Sat Aug 11 21:32:59 2012 +0000
     1.3 @@ -25,6 +25,7 @@
     1.4      private readonly BIOSInformation biosInformation;
     1.5      private readonly SystemInformation systemInformation;
     1.6      private readonly BaseBoardInformation baseBoardInformation;
     1.7 +    private readonly ProcessorInformation processorInformation;
     1.8      private readonly MemoryDevice[] memoryDevices;
     1.9  
    1.10      private static string ReadSysFS(string path) {
    1.11 @@ -84,7 +85,7 @@
    1.12              minorVersion = (byte)mo["SmbiosMinorVersion"];            
    1.13              break;
    1.14            }
    1.15 -        } catch { }
    1.16 +        } catch { }      
    1.17  
    1.18          if (majorVersion > 0 || minorVersion > 0)
    1.19            version = new Version(majorVersion, minorVersion);
    1.20 @@ -129,6 +130,9 @@
    1.21                case 0x02: this.baseBoardInformation = new BaseBoardInformation(
    1.22                    type, handle, data, stringsList.ToArray());
    1.23                  structureList.Add(this.baseBoardInformation); break;
    1.24 +              case 0x04: this.processorInformation = new ProcessorInformation(
    1.25 +                  type, handle, data, stringsList.ToArray());
    1.26 +                structureList.Add(this.processorInformation); break;
    1.27                case 0x11: MemoryDevice m = new MemoryDevice(
    1.28                    type, handle, data, stringsList.ToArray());
    1.29                  memoryDeviceList.Add(m);
    1.30 @@ -178,6 +182,23 @@
    1.31          r.AppendLine();
    1.32        }
    1.33  
    1.34 +      if (Processor != null) {
    1.35 +        r.Append("Processor Manufacturer: ");
    1.36 +        r.AppendLine(Processor.ManufacturerName);
    1.37 +        r.Append("Processor Version: ");
    1.38 +        r.AppendLine(Processor.Version);
    1.39 +        r.Append("Processor Core Count: ");
    1.40 +        r.AppendLine(Processor.CoreCount.ToString());
    1.41 +        r.Append("Processor Core Enabled: ");
    1.42 +        r.AppendLine(Processor.CoreEnabled.ToString());
    1.43 +        r.Append("Processor Thread Count: ");
    1.44 +        r.AppendLine(Processor.ThreadCount.ToString());
    1.45 +        r.Append("Processor External Clock: ");
    1.46 +        r.Append(Processor.ExternalClock);
    1.47 +        r.AppendLine(" Mhz");
    1.48 +        r.AppendLine();
    1.49 +      }
    1.50 +
    1.51        for (int i = 0; i < MemoryDevices.Length; i++) {        
    1.52          r.Append("Memory Device [" + i + "] Manufacturer: ");
    1.53          r.AppendLine(MemoryDevices[i].ManufacturerName);
    1.54 @@ -187,6 +208,9 @@
    1.55          r.AppendLine(MemoryDevices[i].DeviceLocator);
    1.56          r.Append("Memory Device [" + i + "] Bank Locator: ");
    1.57          r.AppendLine(MemoryDevices[i].BankLocator);
    1.58 +        r.Append("Memory Device [" + i + "] Speed: ");
    1.59 +        r.Append(MemoryDevices[i].Speed);
    1.60 +        r.AppendLine(" MHz");
    1.61          r.AppendLine();
    1.62        }
    1.63  
    1.64 @@ -223,6 +247,11 @@
    1.65        get { return baseBoardInformation; }
    1.66      }
    1.67  
    1.68 +
    1.69 +    public ProcessorInformation Processor {
    1.70 +      get { return processorInformation; }
    1.71 +    }
    1.72 +
    1.73      public MemoryDevice[] MemoryDevices {
    1.74        get { return memoryDevices; }
    1.75      }
    1.76 @@ -234,6 +263,20 @@
    1.77        private readonly byte[] data;
    1.78        private readonly string[] strings;
    1.79  
    1.80 +      protected int GetByte(int offset) {
    1.81 +        if (offset < data.Length && offset >= 0)
    1.82 +          return data[offset];
    1.83 +        else
    1.84 +          return 0;
    1.85 +      }
    1.86 +
    1.87 +      protected int GetWord(int offset) {
    1.88 +        if (offset + 1 < data.Length && offset >= 0)
    1.89 +          return (data[offset + 1] << 8) | data[offset];
    1.90 +        else
    1.91 +          return 0;
    1.92 +      }
    1.93 +
    1.94        protected string GetString(int offset) {
    1.95          if (offset < data.Length && data[offset] > 0 &&
    1.96           data[offset] <= strings.Length)
    1.97 @@ -359,13 +402,41 @@
    1.98  
    1.99      }
   1.100  
   1.101 +    public class ProcessorInformation : Structure {
   1.102 +
   1.103 +      public ProcessorInformation(byte type, ushort handle, byte[] data,
   1.104 +        string[] strings)
   1.105 +        : base(type, handle, data, strings) 
   1.106 +      {
   1.107 +        this.ManufacturerName = GetString(0x07).Trim();
   1.108 +        this.Version = GetString(0x10).Trim();
   1.109 +        this.CoreCount = GetByte(0x23);
   1.110 +        this.CoreEnabled = GetByte(0x24);
   1.111 +        this.ThreadCount = GetByte(0x25);
   1.112 +        this.ExternalClock = GetWord(0x12);
   1.113 +      }
   1.114 +
   1.115 +      public string ManufacturerName { get; private set; }
   1.116 +
   1.117 +      public string Version { get; private set; }
   1.118 +
   1.119 +      public int CoreCount { get; private set; }
   1.120 +
   1.121 +      public int CoreEnabled { get; private set; }
   1.122 +
   1.123 +      public int ThreadCount { get; private set; }
   1.124 +     
   1.125 +      public int ExternalClock { get; private set; }
   1.126 +    }
   1.127 +
   1.128      public class MemoryDevice : Structure {
   1.129  
   1.130        private readonly string deviceLocator;
   1.131        private readonly string bankLocator;
   1.132        private readonly string manufacturerName;
   1.133        private readonly string serialNumber;
   1.134 -      private readonly string partNumber;      
   1.135 +      private readonly string partNumber;
   1.136 +      private readonly int speed;
   1.137  
   1.138        public MemoryDevice(byte type, ushort handle, byte[] data,
   1.139          string[] strings)
   1.140 @@ -376,6 +447,7 @@
   1.141          this.manufacturerName = GetString(0x17).Trim();
   1.142          this.serialNumber = GetString(0x18).Trim();
   1.143          this.partNumber = GetString(0x1A).Trim();
   1.144 +        this.speed = GetWord(0x15);
   1.145        }
   1.146  
   1.147        public string DeviceLocator { get { return deviceLocator; } }
   1.148 @@ -388,7 +460,7 @@
   1.149  
   1.150        public string PartNumber { get { return partNumber; } }
   1.151  
   1.152 -       
   1.153 +      public int Speed { get { return speed; } }
   1.154  
   1.155      }
   1.156    }