From dea5be0a57029074bde06db1faabbcd82be64bb8 Mon Sep 17 00:00:00 2001 From: XMRig Date: Wed, 20 Jan 2021 00:43:01 +0700 Subject: [PATCH] Added basic system reader. --- src/Summary.cpp | 8 ++++++-- src/hw/dmi/DmiBoard.cpp | 1 - src/hw/dmi/DmiReader.cpp | 4 ++++ src/hw/dmi/DmiReader.h | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Summary.cpp b/src/Summary.cpp index 8118f99d7..0cbbbbcad 100644 --- a/src/Summary.cpp +++ b/src/Summary.cpp @@ -142,6 +142,8 @@ static void print_memory() return; } + const bool vm = Cpu::info()->isVM(); + for (const auto &memory : reader.memory()) { if (!memory.isValid()) { continue; @@ -151,12 +153,14 @@ static void print_memory() Log::print(WHITE_BOLD(" %-13s") "%s: " CYAN_BOLD("%" PRIu64) CYAN(" GB ") WHITE_BOLD("%s @ %" PRIu64 " MHz ") BLACK_BOLD("%s"), "", memory.slot().data(), memory.size() / oneGiB, memory.type(), memory.speed() / 1000000ULL, memory.product().data()); } - else if (!Cpu::info()->isVM()) { + else if (!vm) { Log::print(WHITE_BOLD(" %-13s") "%s: " BLACK_BOLD(""), "", memory.slot().data()); } } - if (reader.board().isValid()) { + const auto &board = vm ? reader.system() : reader.board(); + + if (board.isValid()) { Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") " - " WHITE_BOLD("%s"), "MOTHERBOARD", reader.board().vendor().data(), reader.board().product().data()); } # endif diff --git a/src/hw/dmi/DmiBoard.cpp b/src/hw/dmi/DmiBoard.cpp index 381865f4e..5ebfd9aa3 100644 --- a/src/hw/dmi/DmiBoard.cpp +++ b/src/hw/dmi/DmiBoard.cpp @@ -23,7 +23,6 @@ #include "hw/dmi/DmiTools.h" - void xmrig::DmiBoard::decode(dmi_header *h) { if (h->length < 0x08) { diff --git a/src/hw/dmi/DmiReader.cpp b/src/hw/dmi/DmiReader.cpp index 5c6a9607f..9854ff1b4 100644 --- a/src/hw/dmi/DmiReader.cpp +++ b/src/hw/dmi/DmiReader.cpp @@ -82,6 +82,10 @@ bool xmrig::DmiReader::decode(uint8_t *buf) } switch (h.type) { + case 1: + m_system.decode(&h); + break; + case 2: m_board.decode(&h); break; diff --git a/src/hw/dmi/DmiReader.h b/src/hw/dmi/DmiReader.h index f140f8676..ccf2311ae 100644 --- a/src/hw/dmi/DmiReader.h +++ b/src/hw/dmi/DmiReader.h @@ -38,6 +38,7 @@ public: DmiReader() = default; inline const DmiBoard &board() const { return m_board; } + inline const DmiBoard &system() const { return m_system; } inline const std::vector &memory() const { return m_memory; } inline uint32_t size() const { return m_size; } inline uint32_t version() const { return m_version; } @@ -51,9 +52,10 @@ private: bool decode(uint8_t *buf); DmiBoard m_board; + DmiBoard m_system; + std::vector m_memory; uint32_t m_size = 0; uint32_t m_version = 0; - std::vector m_memory; };