Added initial support for W83627HF. Some refactoring for IHardware classes.
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;
43 namespace OpenHardwareMonitor.Hardware.LPC {
44 public abstract class Winbond : LPCHardware {
46 private ushort address;
47 private byte revision;
49 private bool available;
52 private const ushort WINBOND_VENDOR_ID = 0x5CA3;
53 private const byte HIGH_BYTE = 0x80;
56 private const byte ADDRESS_REGISTER_OFFSET = 0x05;
57 private const byte DATA_REGISTER_OFFSET = 0x06;
59 // Hardware Monitor Registers
60 private const byte BANK_SELECT_REGISTER = 0x04E;
61 private const byte VENDOR_ID_REGISTER = 0x4F;
63 protected byte ReadByte(byte bank, byte register) {
64 WinRing0.WriteIoPortByte(
65 (ushort)(address + ADDRESS_REGISTER_OFFSET), BANK_SELECT_REGISTER);
66 WinRing0.WriteIoPortByte(
67 (ushort)(address + DATA_REGISTER_OFFSET), bank);
68 WinRing0.WriteIoPortByte(
69 (ushort)(address + ADDRESS_REGISTER_OFFSET), register);
70 return WinRing0.ReadIoPortByte(
71 (ushort)(address + DATA_REGISTER_OFFSET));
74 private bool IsWinbondVendor() {
76 (ushort)((ReadByte(HIGH_BYTE, VENDOR_ID_REGISTER) << 8) |
77 ReadByte(0, VENDOR_ID_REGISTER));
78 return vendorId == WINBOND_VENDOR_ID;
81 public Winbond(Chip chip, byte revision, ushort address)
84 this.address = address;
85 this.revision = revision;
87 available = IsWinbondVendor();
90 public bool IsAvailable {
91 get { return available; }
94 public string GetReport() {
95 StringBuilder r = new StringBuilder();
97 r.AppendLine("LPC " + this.GetType().Name);
99 r.Append("Chip ID: 0x"); r.AppendLine(chip.ToString("X"));
100 r.Append("Chip revision: 0x"); r.AppendLine(revision.ToString("X"));
101 r.Append("Base Adress: 0x"); r.AppendLine(address.ToString("X4"));
103 r.AppendLine("Hardware Monitor Registers");
105 r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
107 for (int i = 0; i < 0x7; i++) {
108 r.Append(" "); r.Append((i << 4).ToString("X2")); r.Append(" ");
109 for (int j = 0; j <= 0xF; j++) {
111 r.Append(ReadByte(0, (byte)((i << 4) | j)).ToString("X2"));
115 for (int k = 1; k <= 5; k++) {
116 r.AppendLine("Bank " + k);
117 for (int i = 0x5; i < 0x6; i++) {
118 r.Append(" "); r.Append((i << 4).ToString("X2")); r.Append(" ");
119 for (int j = 0; j <= 0xF; j++) {
121 r.Append(ReadByte((byte)(k),
122 (byte)((i << 4) | j)).ToString("X2"));