2021-09-13 20:11:12 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: HWInfo.hpp
|
|
|
|
Date: 2021-6-19
|
|
|
|
Author: Reece
|
|
|
|
***/
|
2021-09-30 14:57:41 +00:00
|
|
|
#include <Source/RuntimeInternal.hpp>
|
2021-09-13 20:11:12 +00:00
|
|
|
#include "HWInfo.hpp"
|
|
|
|
#include "CpuInfo.hpp"
|
|
|
|
#include "RamInfo.hpp"
|
|
|
|
|
|
|
|
#if defined(AURORA_IS_BSD_DERIVED)
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace Aurora::HWInfo
|
|
|
|
{
|
2021-11-08 23:59:19 +00:00
|
|
|
template<typename T>
|
|
|
|
AuOptional<T> QueryBsdHwStat(int id)
|
2021-09-13 20:11:12 +00:00
|
|
|
{
|
|
|
|
#if defined(AURORA_IS_BSD_DERIVED)
|
|
|
|
int mib[4];
|
2021-11-08 23:59:19 +00:00
|
|
|
T stat;
|
2021-09-13 20:11:12 +00:00
|
|
|
size_t len = sizeof(stat);
|
|
|
|
|
|
|
|
mib[0] = CTL_HW;
|
|
|
|
mib[1] = id;
|
|
|
|
|
|
|
|
auto ret = sysctl(mib, 2, &stat, &len, NULL, 0);
|
|
|
|
return ret == 0 ? stat : {};
|
|
|
|
#else
|
|
|
|
return {};
|
|
|
|
#endif
|
|
|
|
}
|
2021-11-08 23:59:19 +00:00
|
|
|
|
|
|
|
template<>
|
|
|
|
AuOptional<AuUInt> QueryBsdHwStat(int id);
|
|
|
|
|
|
|
|
template<>
|
|
|
|
AuOptional<unsigned int> QueryBsdHwStat(int id);
|
|
|
|
|
|
|
|
template<>
|
|
|
|
AuOptional<uint64_t> QueryBsdHwStat(int id);
|
2021-09-13 20:11:12 +00:00
|
|
|
|
|
|
|
void Init()
|
|
|
|
{
|
|
|
|
InitCpuInfo();
|
|
|
|
InitRamInfo();
|
|
|
|
}
|
|
|
|
}
|