2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
2022-11-17 07:46:07 +00:00
|
|
|
File: AuCpuInfo.cpp
|
2021-06-27 21:25:29 +00:00
|
|
|
Date: 2021-6-12
|
|
|
|
Author: Reece
|
|
|
|
***/
|
2021-09-30 14:57:41 +00:00
|
|
|
#include <Source/RuntimeInternal.hpp>
|
2022-11-17 07:46:07 +00:00
|
|
|
#include "AuHWInfo.hpp"
|
|
|
|
#include "AuCpuInfo.hpp"
|
|
|
|
#include "AuCpuId.hpp"
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-09-17 19:26:05 +00:00
|
|
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/sysinfo.h>
|
|
|
|
#endif
|
|
|
|
|
2022-01-26 04:22:12 +00:00
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
2022-11-17 07:46:07 +00:00
|
|
|
#include "AuCpuInfo.NT.hpp"
|
2021-10-02 16:07:33 +00:00
|
|
|
#endif
|
|
|
|
|
2022-01-26 04:22:12 +00:00
|
|
|
#if defined(AURORA_IS_BSD_DERIVED)
|
2022-11-17 07:46:07 +00:00
|
|
|
#include "AuCpuInfo.BSD.hpp"
|
2022-01-24 18:37:06 +00:00
|
|
|
#endif
|
|
|
|
|
2022-01-26 04:22:12 +00:00
|
|
|
#if defined(AURORA_IS_LINUX_DERIVED)
|
2022-11-17 07:46:07 +00:00
|
|
|
#include "AuCpuInfo.Linux.hpp"
|
2022-01-26 04:22:12 +00:00
|
|
|
#endif
|
2022-01-26 00:01:06 +00:00
|
|
|
|
2021-09-13 20:11:12 +00:00
|
|
|
namespace Aurora::HWInfo
|
|
|
|
{
|
2022-01-24 18:37:06 +00:00
|
|
|
static void SetCpuTopology()
|
|
|
|
{
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
|
|
SetCpuTopologyNT();
|
2021-09-13 20:11:12 +00:00
|
|
|
#elif defined(AURORA_IS_BSD_DERIVED)
|
2022-01-26 04:22:12 +00:00
|
|
|
SetCpuTopologyBSD();
|
2021-09-17 19:26:05 +00:00
|
|
|
#elif defined(AURORA_IS_LINUX_DERIVED)
|
2022-01-26 04:22:12 +00:00
|
|
|
SetCpuTopologyLinux();
|
2021-09-13 20:11:12 +00:00
|
|
|
#elif defined(AURORA_IS_POSIX_DERIVED)
|
2021-09-14 13:13:58 +00:00
|
|
|
|
2022-02-18 10:46:51 +00:00
|
|
|
gCpuInfo.uSocket = 1;
|
|
|
|
gCpuInfo.uCores = 1;
|
|
|
|
gCpuInfo.uThreads = sysconf(_SC_NPROCESSORS_ONLN);
|
2021-09-14 13:13:58 +00:00
|
|
|
|
2021-09-13 20:11:12 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-01-24 18:37:06 +00:00
|
|
|
static void SetFakeTopologyIfMissing()
|
|
|
|
{
|
2022-03-20 12:50:36 +00:00
|
|
|
// This stunk
|
2022-01-24 18:37:06 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 20:11:12 +00:00
|
|
|
void InitCpuInfo()
|
|
|
|
{
|
2022-02-18 10:46:51 +00:00
|
|
|
gCpuInfo.bMaskMTContig = false;
|
|
|
|
gCpuInfo.bMaskMTHalf = false;
|
2021-09-13 20:11:12 +00:00
|
|
|
gCpuInfo.cpuArch = Aurora::Build::kCurrentArchitecture;
|
|
|
|
SetCpuId();
|
|
|
|
SetCpuTopology();
|
2022-01-24 18:37:06 +00:00
|
|
|
SetFakeTopologyIfMissing();
|
2021-09-13 20:11:12 +00:00
|
|
|
}
|
2021-10-02 16:07:33 +00:00
|
|
|
}
|