2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-02-27 18:39:32 +08:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2018-09-18 15:11:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
#include "runtime/device/driver_info.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2019-08-29 18:15:33 +08:00
|
|
|
#include "core/os_interface/windows/debug_registry_reader.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/os_interface/windows/driver_info.h"
|
|
|
|
#include "runtime/os_interface/windows/os_interface.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/os_interface/windows/wddm/wddm.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
DriverInfo *DriverInfo::create(OSInterface *osInterface) {
|
|
|
|
if (osInterface) {
|
|
|
|
auto wddm = osInterface->get()->getWddm();
|
|
|
|
DEBUG_BREAK_IF(wddm == nullptr);
|
|
|
|
|
2018-03-03 04:43:37 +08:00
|
|
|
std::string path(wddm->getDeviceRegistryPath());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
auto result = new DriverInfoWindows();
|
|
|
|
path = result->trimRegistryKey(path);
|
|
|
|
|
2019-09-02 18:04:22 +08:00
|
|
|
result->setRegistryReader(new RegistryReader(false, path));
|
2017-12-21 07:45:38 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
void DriverInfoWindows::setRegistryReader(SettingsReader *reader) {
|
|
|
|
registryReader.reset(reader);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string DriverInfoWindows::trimRegistryKey(std::string path) {
|
|
|
|
std::string prefix("\\REGISTRY\\MACHINE\\");
|
|
|
|
auto pos = prefix.find(prefix);
|
|
|
|
if (pos != std::string::npos)
|
|
|
|
path.erase(pos, prefix.length());
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string DriverInfoWindows::getDeviceName(std::string defaultName) {
|
|
|
|
return registryReader.get()->getSetting("HardwareInformation.AdapterString", defaultName);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string DriverInfoWindows::getVersion(std::string defaultVersion) {
|
|
|
|
return registryReader.get()->getSetting("DriverVersion", defaultVersion);
|
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|