moel@196: /* moel@196: moel@344: This Source Code Form is subject to the terms of the Mozilla Public moel@344: License, v. 2.0. If a copy of the MPL was not distributed with this moel@344: file, You can obtain one at http://mozilla.org/MPL/2.0/. moel@196: moel@344: Copyright (C) 2009-2010 Michael Möller moel@344: moel@196: */ moel@196: moel@196: namespace OpenHardwareMonitor.Hardware.CPU { moel@196: moel@196: internal abstract class AMDCPU : GenericCPU { moel@196: moel@196: private const byte PCI_BUS = 0; moel@271: private const byte PCI_BASE_DEVICE = 0x18; moel@196: private const byte DEVICE_VENDOR_ID_REGISTER = 0; moel@196: private const ushort AMD_VENDOR_ID = 0x1022; moel@196: moel@196: public AMDCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) moel@196: : base(processorIndex, cpuid, settings) { } moel@196: moel@196: protected uint GetPciAddress(byte function, ushort deviceId) { moel@197: moel@197: // assemble the pci address moel@236: uint address = Ring0.GetPciAddress(PCI_BUS, moel@196: (byte)(PCI_BASE_DEVICE + processorIndex), function); moel@196: moel@197: // verify that we have the correct bus, device and function moel@196: uint deviceVendor; moel@236: if (!Ring0.ReadPciConfig( moel@196: address, DEVICE_VENDOR_ID_REGISTER, out deviceVendor)) moel@236: return Ring0.InvalidPciAddress; moel@197: moel@196: if (deviceVendor != (deviceId << 16 | AMD_VENDOR_ID)) moel@236: return Ring0.InvalidPciAddress; moel@196: moel@196: return address; moel@196: } moel@196: moel@196: } moel@196: }