Added a mainboard specific configuration for the ECS A890GXM-A.
3 Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 The contents of this file are subject to the Mozilla Public License Version
6 1.1 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 for the specific language governing rights and limitations under the License.
15 The Original Code is the Open Hardware Monitor code.
17 The Initial Developer of the Original Code is
18 Michael Möller <m.moeller@gmx.ch>.
19 Portions created by the Initial Developer are Copyright (C) 2009-2010
20 the Initial Developer. All Rights Reserved.
24 Alternatively, the contents of this file may be used under the terms of
25 either the GNU General Public License Version 2 or later (the "GPL"), or
26 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 in which case the provisions of the GPL or the LGPL are applicable instead
28 of those above. If you wish to allow use of your version of this file only
29 under the terms of either the GPL or the LGPL, and not to allow others to
30 use your version of this file under the terms of the MPL, indicate your
31 decision by deleting the provisions above and replace them with the notice
32 and other provisions required by the GPL or the LGPL. If you do not delete
33 the provisions above, a recipient may use your version of this file under
34 the terms of any one of the MPL, the GPL or the LGPL.
39 using System.Collections.Generic;
41 using System.Management;
44 namespace OpenHardwareMonitor.Hardware.Mainboard {
46 internal class SMBIOS {
49 private Structure[] table;
51 private BIOSInformation biosInformation = null;
52 private BaseBoardInformation baseBoardInformation = null;
54 private static string ReadSysFS(string path) {
56 if (File.Exists(path)) {
57 using (StreamReader reader = new StreamReader(path))
58 return reader.ReadLine();
68 int p = (int)System.Environment.OSVersion.Platform;
69 if ((p == 4) || (p == 128)) {
73 string boardVendor = ReadSysFS("/sys/class/dmi/id/board_vendor");
74 string boardName = ReadSysFS("/sys/class/dmi/id/board_name");
75 string boardVersion = ReadSysFS("/sys/class/dmi/id/board_version");
76 this.baseBoardInformation = new BaseBoardInformation(
77 boardVendor, boardName, boardVersion, null);
79 string biosVendor = ReadSysFS("/sys/class/dmi/id/bios_vendor");
80 string biosVersion = ReadSysFS("/sys/class/dmi/id/bios_version");
81 this.biosInformation = new BIOSInformation(biosVendor, biosVersion);
84 List<Structure> structureList = new List<Structure>();
88 ManagementObjectCollection collection;
89 using (ManagementObjectSearcher searcher =
90 new ManagementObjectSearcher("root\\WMI",
91 "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables")) {
92 collection = searcher.Get();
95 foreach (ManagementObject mo in collection) {
96 raw = (byte[])mo["SMBiosData"];
101 if (raw != null && raw.Length > 0) {
103 byte type = raw[offset];
104 while (offset + 4 < raw.Length && type != 127) {
107 int length = raw[offset + 1];
108 ushort handle = (ushort)((raw[offset + 2] << 8) | raw[offset + 3]);
110 if (offset + length > raw.Length)
112 byte[] data = new byte[length];
113 Array.Copy(raw, offset, data, 0, length);
116 List<string> stringsList = new List<string>();
117 if (offset < raw.Length && raw[offset] == 0)
120 while (offset < raw.Length && raw[offset] != 0) {
121 StringBuilder sb = new StringBuilder();
122 while (offset < raw.Length && raw[offset] != 0) {
123 sb.Append((char)raw[offset]); offset++;
126 stringsList.Add(sb.ToString());
131 this.biosInformation = new BIOSInformation(
132 type, handle, data, stringsList.ToArray());
133 structureList.Add(this.biosInformation); break;
134 case 0x02: this.baseBoardInformation = new BaseBoardInformation(
135 type, handle, data, stringsList.ToArray());
136 structureList.Add(this.baseBoardInformation); break;
137 default: structureList.Add(new Structure(
138 type, handle, data, stringsList.ToArray())); break;
143 table = structureList.ToArray();
147 public string GetReport() {
148 StringBuilder r = new StringBuilder();
151 r.Append("BIOS Vendor: "); r.AppendLine(BIOS.Vendor);
152 r.Append("BIOS Version: "); r.AppendLine(BIOS.Version);
157 r.Append("Mainboard Manufacturer: ");
158 r.AppendLine(Board.ManufacturerName);
159 r.Append("Mainboard Name: ");
160 r.AppendLine(Board.ProductName);
161 r.Append("Mainboard Version: ");
162 r.AppendLine(Board.Version);
167 string base64 = Convert.ToBase64String(raw);
168 r.AppendLine("SMBIOS Table");
171 for (int i = 0; i < Math.Ceiling(base64.Length / 64.0); i++) {
173 for (int j = 0; j < 0x40; j++) {
174 int index = (i << 6) | j;
175 if (index < base64.Length) {
176 r.Append(base64[index]);
187 public BIOSInformation BIOS {
188 get { return biosInformation; }
191 public BaseBoardInformation Board {
192 get { return baseBoardInformation; }
195 public class Structure {
197 private ushort handle;
200 private string[] strings;
202 protected string GetString(int offset) {
203 if (offset < data.Length && data[offset] > 0 &&
204 data[offset] <= strings.Length)
205 return strings[data[offset] - 1];
210 public Structure(byte type, ushort handle, byte[] data, string[] strings)
213 this.handle = handle;
215 this.strings = strings;
218 public byte Type { get { return type; } }
220 public ushort Handle { get { return handle; } }
223 public class BIOSInformation : Structure {
225 private string vendor;
226 private string version;
228 public BIOSInformation(string vendor, string version)
229 : base (0x00, 0, null, null)
231 this.vendor = vendor;
232 this.version = version;
235 public BIOSInformation(byte type, ushort handle, byte[] data,
237 : base(type, handle, data, strings)
239 this.vendor = GetString(0x04);
240 this.version = GetString(0x05);
243 public string Vendor { get { return vendor; } }
245 public string Version { get { return version; } }
248 public class BaseBoardInformation : Structure {
250 private string manufacturerName;
251 private string productName;
252 private string version;
253 private string serialNumber;
254 private Manufacturer manufacturer;
257 private void SetManufacturerName(string name) {
258 this.manufacturerName = name;
262 manufacturer = Manufacturer.ASRock; break;
263 case "ASUSTeK Computer INC.":
264 manufacturer = Manufacturer.ASUS; break;
266 manufacturer = Manufacturer.Dell; break;
269 manufacturer = Manufacturer.DFI; break;
271 manufacturer = Manufacturer.ECS; break;
272 case "EPoX COMPUTER CO., LTD":
273 manufacturer = Manufacturer.EPoX; break;
275 manufacturer = Manufacturer.EVGA; break;
276 case "First International Computer, Inc.":
277 manufacturer = Manufacturer.FIC; break;
278 case "Gigabyte Technology Co., Ltd.":
279 manufacturer = Manufacturer.Gigabyte; break;
280 case "Hewlett-Packard":
281 manufacturer = Manufacturer.HP; break;
283 manufacturer = Manufacturer.IBM; break;
284 case "MICRO-STAR INTERNATIONAL CO., LTD":
285 case "MICRO-STAR INTERNATIONAL CO.,LTD":
286 manufacturer = Manufacturer.MSI; break;
288 manufacturer = Manufacturer.XFX; break;
289 case "To be filled by O.E.M.":
290 manufacturer = Manufacturer.Unknown; break;
292 manufacturer = Manufacturer.Unknown; break;
296 private void SetProductName(string name) {
297 this.productName = name;
301 model = Model._880GMH_USB3; break;
302 case "Crosshair III Formula":
303 model = Model.Crosshair_III_Formula; break;
304 case "M2N-SLI DELUXE":
305 model = Model.M2N_SLI_DELUXE; break;
307 model = Model.M4A79XTD_EVO; break;
308 case "P5W DH Deluxe":
309 model = Model.P5W_DH_Deluxe; break;
311 model = Model.P6X58D_E; break;
312 case "Rampage Extreme":
313 model = Model.Rampage_Extreme; break;
314 case "Rampage II GENE":
315 model = Model.Rampage_II_GENE; break;
316 case "LP BI P45-T2RS Elite":
317 model = Model.LP_BI_P45_T2RS_Elite; break;
318 case "LP DK P55-T3eH9":
319 model = Model.LP_DK_P55_T3eH9; break;
321 model = Model.A890GXM_A; break;
322 case "X58 SLI Classified":
323 model = Model.X58_SLI_Classified; break;
325 model = Model._965P_S3; break;
327 model = Model.EP45_DS3R; break;
329 model = Model.EP45_UD3R; break;
331 model = Model.EX58_EXTREME; break;
332 case "GA-MA770T-UD3":
333 model = Model.GA_MA770T_UD3; break;
334 case "GA-MA785GMT-UD2H":
335 model = Model.GA_MA785GMT_UD2H; break;
337 model = Model.P35_DS3; break;
339 model = Model.P35_DS3L; break;
341 model = Model.P55_UD4; break;
343 model = Model.P55M_UD4; break;
345 model = Model.X38_DS5; break;
347 model = Model.X58A_UD3R; break;
348 case "To be filled by O.E.M.":
349 model = Model.Unknown; break;
351 model = Model.Unknown; break;
355 public BaseBoardInformation(string manufacturerName, string productName,
356 string version, string serialNumber)
357 : base(0x02, 0, null, null)
359 SetManufacturerName(manufacturerName);
360 SetProductName(productName);
361 this.version = version;
362 this.serialNumber = serialNumber;
365 public BaseBoardInformation(byte type, ushort handle, byte[] data,
367 : base(type, handle, data, strings) {
369 SetManufacturerName(GetString(0x04).Trim());
370 SetProductName(GetString(0x05).Trim());
371 this.version = GetString(0x06).Trim();
372 this.serialNumber = GetString(0x07).Trim();
375 public string ManufacturerName { get { return manufacturerName; } }
377 public string ProductName { get { return productName; } }
379 public string Version { get { return version; } }
381 public string SerialNumber { get { return serialNumber; } }
383 public Manufacturer Manufacturer { get { return manufacturer; } }
385 public Model Model { get { return model; } }