moel@196
|
1 |
/*
|
moel@196
|
2 |
|
moel@344
|
3 |
This Source Code Form is subject to the terms of the Mozilla Public
|
moel@344
|
4 |
License, v. 2.0. If a copy of the MPL was not distributed with this
|
moel@344
|
5 |
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
moel@196
|
6 |
|
moel@344
|
7 |
Copyright (C) 2009-2010 Michael Möller <mmoeller@openhardwaremonitor.org>
|
moel@344
|
8 |
|
moel@196
|
9 |
*/
|
moel@196
|
10 |
|
moel@196
|
11 |
namespace OpenHardwareMonitor.Hardware.CPU {
|
moel@196
|
12 |
|
moel@196
|
13 |
internal abstract class AMDCPU : GenericCPU {
|
moel@196
|
14 |
|
moel@196
|
15 |
private const byte PCI_BUS = 0;
|
moel@271
|
16 |
private const byte PCI_BASE_DEVICE = 0x18;
|
moel@196
|
17 |
private const byte DEVICE_VENDOR_ID_REGISTER = 0;
|
moel@196
|
18 |
private const ushort AMD_VENDOR_ID = 0x1022;
|
moel@196
|
19 |
|
moel@196
|
20 |
public AMDCPU(int processorIndex, CPUID[][] cpuid, ISettings settings)
|
moel@196
|
21 |
: base(processorIndex, cpuid, settings) { }
|
moel@196
|
22 |
|
moel@196
|
23 |
protected uint GetPciAddress(byte function, ushort deviceId) {
|
moel@197
|
24 |
|
moel@197
|
25 |
// assemble the pci address
|
moel@236
|
26 |
uint address = Ring0.GetPciAddress(PCI_BUS,
|
moel@196
|
27 |
(byte)(PCI_BASE_DEVICE + processorIndex), function);
|
moel@196
|
28 |
|
moel@197
|
29 |
// verify that we have the correct bus, device and function
|
moel@196
|
30 |
uint deviceVendor;
|
moel@236
|
31 |
if (!Ring0.ReadPciConfig(
|
moel@196
|
32 |
address, DEVICE_VENDOR_ID_REGISTER, out deviceVendor))
|
moel@236
|
33 |
return Ring0.InvalidPciAddress;
|
moel@197
|
34 |
|
moel@196
|
35 |
if (deviceVendor != (deviceId << 16 | AMD_VENDOR_ID))
|
moel@236
|
36 |
return Ring0.InvalidPciAddress;
|
moel@196
|
37 |
|
moel@196
|
38 |
return address;
|
moel@196
|
39 |
}
|
moel@196
|
40 |
|
moel@196
|
41 |
}
|
moel@196
|
42 |
}
|