2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-02-23 05:21:06 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2019-02-27 18:39:32 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/utilities/cpu_info.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <intrin.h>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-08-01 09:43:05 +08:00
|
|
|
void cpuid_windows_wrapper(int cpuInfo[4], int functionId) {
|
|
|
|
__cpuid(cpuInfo, functionId);
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
void cpuidex_windows_wrapper(int *cpuInfo, int functionId, int subfunctionId) {
|
|
|
|
__cpuidex(cpuInfo, functionId, subfunctionId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void (*CpuInfo::cpuidexFunc)(int *, int, int) = cpuidex_windows_wrapper;
|
2019-08-01 09:43:05 +08:00
|
|
|
void (*CpuInfo::cpuidFunc)(int[4], int) = cpuid_windows_wrapper;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
const CpuInfo CpuInfo::instance;
|
|
|
|
|
|
|
|
void CpuInfo::cpuid(
|
|
|
|
uint32_t cpuInfo[4],
|
|
|
|
uint32_t functionId) const {
|
2019-08-01 09:43:05 +08:00
|
|
|
cpuidFunc(reinterpret_cast<int *>(cpuInfo), functionId);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CpuInfo::cpuidex(
|
|
|
|
uint32_t cpuInfo[4],
|
|
|
|
uint32_t functionId,
|
|
|
|
uint32_t subfunctionId) const {
|
|
|
|
cpuidexFunc(reinterpret_cast<int *>(cpuInfo), functionId, subfunctionId);
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|