mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
Merge pull request #15595 from amerhifi/feature/platform
BUGZ-296: Linux platform implementation
This commit is contained in:
commit
009068222f
2 changed files with 42 additions and 6 deletions
|
@ -9,15 +9,51 @@
|
||||||
#include "LinuxPlatform.h"
|
#include "LinuxPlatform.h"
|
||||||
#include "platformJsonKeys.h"
|
#include "platformJsonKeys.h"
|
||||||
#include <GPUIdent.h>
|
#include <GPUIdent.h>
|
||||||
|
#include <thread>
|
||||||
using namespace platform;
|
using namespace platform;
|
||||||
|
|
||||||
|
static void getLCpuId( uint32_t* p, uint32_t ax )
|
||||||
|
{
|
||||||
|
|
||||||
|
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||||
|
__asm __volatile
|
||||||
|
( "movl %%ebx, %%esi\n\t"
|
||||||
|
"cpuid\n\t"
|
||||||
|
"xchgl %%ebx, %%esi"
|
||||||
|
: "=a" (p[0]), "=S" (p[1]),
|
||||||
|
"=c" (p[2]), "=d" (p[3])
|
||||||
|
: "0" (ax)
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void LinuxInstance::enumerateCpu() {
|
void LinuxInstance::enumerateCpu() {
|
||||||
json cpu = {};
|
json cpu = {};
|
||||||
|
|
||||||
|
uint32_t cpuInfo[4]={0,0,0,0};
|
||||||
|
char CPUBrandString[16];
|
||||||
|
char CPUModelString[16];
|
||||||
|
char CPUClockString[16];
|
||||||
|
uint32_t nExIds;
|
||||||
|
getLCpuId(cpuInfo, 0x80000000);
|
||||||
|
nExIds = cpuInfo[0];
|
||||||
|
|
||||||
|
for (uint32_t i = 0x80000000; i <= nExIds; ++i) {
|
||||||
|
getLCpuId(cpuInfo, i);
|
||||||
|
// Interpret CPU brand string
|
||||||
|
if (i == 0x80000002) {
|
||||||
|
memcpy(CPUBrandString, cpuInfo, sizeof(cpuInfo));
|
||||||
|
} else if (i == 0x80000003) {
|
||||||
|
memcpy(CPUModelString, cpuInfo, sizeof(cpuInfo));
|
||||||
|
} else if (i == 0x80000004) {
|
||||||
|
memcpy(CPUClockString, cpuInfo, sizeof(cpuInfo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cpu["cpuBrand"] = "";
|
cpu["cpuBrand"] = CPUBrandString;
|
||||||
cpu["cpuModel"] = "";
|
cpu["cpuModel"] = CPUModelString;
|
||||||
cpu["cpuClockSpeed"] = "";
|
cpu["cpuClockSpeed"] = CPUClockString;
|
||||||
cpu["cpuNumCores"] = "";
|
cpu["cpuNumCores"] = std::thread::hardware_concurrency();
|
||||||
|
|
||||||
_cpu.push_back(cpu);
|
_cpu.push_back(cpu);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
|
||||||
|
|
||||||
|
#include <QtCore/QtGlobal>
|
||||||
#include "SharedLogging.h"
|
#include "SharedLogging.h"
|
||||||
|
|
||||||
GPUIdent GPUIdent::_instance {};
|
GPUIdent GPUIdent::_instance {};
|
||||||
|
|
Loading…
Reference in a new issue