Split BasicCpuInfo_arm.
This commit is contained in:
parent
650d794fb1
commit
34b4448a81
6 changed files with 138 additions and 56 deletions
|
@ -49,8 +49,15 @@ endif()
|
||||||
if (XMRIG_ARM)
|
if (XMRIG_ARM)
|
||||||
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo_arm.cpp)
|
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo_arm.cpp)
|
||||||
|
|
||||||
if (XMRIG_OS_UNIX)
|
if (XMRIG_OS_WIN)
|
||||||
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/lscpu_arm.cpp)
|
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo_arm_win.cpp)
|
||||||
|
elseif(XMRIG_OS_APPLE)
|
||||||
|
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo_arm_mac.cpp)
|
||||||
|
else()
|
||||||
|
list(APPEND SOURCES_BACKEND_CPU
|
||||||
|
src/backend/cpu/platform/lscpu_arm.cpp
|
||||||
|
src/backend/cpu/platform/BasicCpuInfo_arm_unix.cpp
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo.cpp)
|
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo.cpp)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright (c) 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright (c) 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright (c) 2016-2023 XMRig <support@xmrig.com>
|
* Copyright (c) 2016-2025 XMRig <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -85,6 +85,8 @@ private:
|
||||||
uint32_t m_family = 0;
|
uint32_t m_family = 0;
|
||||||
uint32_t m_model = 0;
|
uint32_t m_model = 0;
|
||||||
uint32_t m_stepping = 0;
|
uint32_t m_stepping = 0;
|
||||||
|
# else
|
||||||
|
void init_arm();
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
Assembly m_assembly = Assembly::NONE;
|
Assembly m_assembly = Assembly::NONE;
|
||||||
|
|
|
@ -16,44 +16,16 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "base/tools/String.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
|
||||||
#if __ARM_FEATURE_CRYPTO && !defined(__APPLE__) && !defined(XMRIG_OS_WIN)
|
|
||||||
# include <sys/auxv.h>
|
|
||||||
# if !defined(XMRIG_OS_FREEBSD)
|
|
||||||
# include <asm/hwcap.h>
|
|
||||||
# else
|
|
||||||
# include <stdint.h>
|
|
||||||
# include <machine/armreg.h>
|
|
||||||
# ifndef ID_AA64ISAR0_AES_VAL
|
|
||||||
# define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include "backend/cpu/platform/BasicCpuInfo.h"
|
#include "backend/cpu/platform/BasicCpuInfo.h"
|
||||||
#include "3rdparty/rapidjson/document.h"
|
#include "3rdparty/rapidjson/document.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(XMRIG_OS_UNIX)
|
|
||||||
namespace xmrig {
|
|
||||||
|
|
||||||
extern String cpu_name_arm();
|
|
||||||
|
|
||||||
} // namespace xmrig
|
|
||||||
#elif defined(XMRIG_OS_MACOS)
|
|
||||||
# include <sys/sysctl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
xmrig::BasicCpuInfo::BasicCpuInfo() :
|
xmrig::BasicCpuInfo::BasicCpuInfo() :
|
||||||
m_threads(std::thread::hardware_concurrency())
|
m_threads(std::thread::hardware_concurrency())
|
||||||
{
|
{
|
||||||
|
@ -68,30 +40,7 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
||||||
memcpy(m_brand, "ARMv7", 5);
|
memcpy(m_brand, "ARMv7", 5);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if __ARM_FEATURE_CRYPTO
|
init_arm();
|
||||||
# if defined(__APPLE__)
|
|
||||||
m_flags.set(FLAG_AES, true);
|
|
||||||
# elif defined(XMRIG_OS_FREEBSD)
|
|
||||||
uint64_t isar0 = READ_SPECIALREG(id_aa64isar0_el1);
|
|
||||||
m_flags.set(FLAG_AES, ID_AA64ISAR0_AES_VAL(isar0) >= ID_AA64ISAR0_AES_BASE);
|
|
||||||
# elif (defined(XMRIG_OS_WIN))
|
|
||||||
m_flags.set(FLAG_AES, true); // FIXME
|
|
||||||
# else
|
|
||||||
m_flags.set(FLAG_AES, getauxval(AT_HWCAP) & HWCAP_AES);
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if defined(XMRIG_OS_UNIX)
|
|
||||||
auto name = cpu_name_arm();
|
|
||||||
if (!name.isNull()) {
|
|
||||||
strncpy(m_brand, name, sizeof(m_brand) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_flags.set(FLAG_PDPE1GB, std::ifstream("/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages").good());
|
|
||||||
# elif defined(XMRIG_OS_MACOS)
|
|
||||||
size_t buflen = sizeof(m_brand);
|
|
||||||
sysctlbyname("machdep.cpu.brand_string", &m_brand, &buflen, nullptr, 0);
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
32
src/backend/cpu/platform/BasicCpuInfo_arm_mac.cpp
Normal file
32
src/backend/cpu/platform/BasicCpuInfo_arm_mac.cpp
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright (c) 2016-2025 XMRig <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "backend/cpu/platform/BasicCpuInfo.h"
|
||||||
|
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::BasicCpuInfo::init_arm()
|
||||||
|
{
|
||||||
|
# if __ARM_FEATURE_CRYPTO
|
||||||
|
m_flags.set(FLAG_AES, true); // FIXME
|
||||||
|
# endif
|
||||||
|
|
||||||
|
size_t buflen = sizeof(m_brand);
|
||||||
|
sysctlbyname("machdep.cpu.brand_string", &m_brand, &buflen, nullptr, 0);
|
||||||
|
}
|
65
src/backend/cpu/platform/BasicCpuInfo_arm_unix.cpp
Normal file
65
src/backend/cpu/platform/BasicCpuInfo_arm_unix.cpp
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright (c) 2016-2025 XMRig <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "backend/cpu/platform/BasicCpuInfo.h"
|
||||||
|
#include "base/tools/String.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if __ARM_FEATURE_CRYPTO
|
||||||
|
# include <sys/auxv.h>
|
||||||
|
# if !defined(XMRIG_OS_FREEBSD)
|
||||||
|
# include <asm/hwcap.h>
|
||||||
|
# else
|
||||||
|
# include <stdint.h>
|
||||||
|
# include <machine/armreg.h>
|
||||||
|
# ifndef ID_AA64ISAR0_AES_VAL
|
||||||
|
# define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
extern String cpu_name_arm();
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::BasicCpuInfo::init_arm()
|
||||||
|
{
|
||||||
|
# if __ARM_FEATURE_CRYPTO
|
||||||
|
# if defined(XMRIG_OS_FREEBSD)
|
||||||
|
uint64_t isar0 = READ_SPECIALREG(id_aa64isar0_el1);
|
||||||
|
m_flags.set(FLAG_AES, ID_AA64ISAR0_AES_VAL(isar0) >= ID_AA64ISAR0_AES_BASE);
|
||||||
|
# else
|
||||||
|
m_flags.set(FLAG_AES, getauxval(AT_HWCAP) & HWCAP_AES);
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(XMRIG_OS_UNIX)
|
||||||
|
auto name = cpu_name_arm();
|
||||||
|
if (!name.isNull()) {
|
||||||
|
strncpy(m_brand, name, sizeof(m_brand) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_flags.set(FLAG_PDPE1GB, std::ifstream("/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages").good());
|
||||||
|
# endif
|
||||||
|
}
|
27
src/backend/cpu/platform/BasicCpuInfo_arm_win.cpp
Normal file
27
src/backend/cpu/platform/BasicCpuInfo_arm_win.cpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright (c) 2016-2025 XMRig <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "backend/cpu/platform/BasicCpuInfo.h"
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::BasicCpuInfo::init_arm()
|
||||||
|
{
|
||||||
|
# if __ARM_FEATURE_CRYPTO
|
||||||
|
m_flags.set(FLAG_AES, true); // FIXME
|
||||||
|
# endif
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue