+++ /dev/null
-use crate::{intel_arc, winring0};
-
-const OLS_TYPE: u32 = 40000;
-
-const F17H_M01H_THM_TCON_CUR_TMP: u32 = 0x00059800;
-const F17H_TEMP_OFFSET_FLAG: u32 = 0x80000;
-const FAMILY_17H_PCI_CONTROL_REGISTER: u32 = 0x60;
-
-pub struct Sensors {
- gpu_devices: intel_arc::Devices,
-}
-
-impl Sensors {
- pub fn new() -> Self {
- unsafe {
- Sensors {
- gpu_devices: intel_arc::GetDevices(),
- }
- }
- }
-
- pub fn read_cpu_temp(&self) -> f32 {
- unsafe {
- winring0::WritePciConfigDwordEx(
- 0x00,
- FAMILY_17H_PCI_CONTROL_REGISTER,
- F17H_M01H_THM_TCON_CUR_TMP,
- );
-
- let output: &mut u32 = &mut 0;
- let ok =
- winring0::ReadPciConfigDwordEx(0x00, FAMILY_17H_PCI_CONTROL_REGISTER + 4, output);
- let offset_flag = *output & F17H_TEMP_OFFSET_FLAG != 0;
- let mut temperature = ((*output >> 21) * 125) as f32 * 0.001;
- if offset_flag {
- temperature -= 49.;
- }
-
- // dbg!(ok);
- // dbg!(temperature);
-
- temperature
- }
- }
-
- pub fn read_gpu_temp(&self) -> f32 {
- unsafe { intel_arc::GetTemperature(self.gpu_devices, 0) as f32 }
- }
-}
-
-impl Drop for Sensors {
- fn drop(&mut self) {
- unsafe {
- intel_arc::FreeDevices(self.gpu_devices);
- }
- }
-}