mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-27 07:44:16 +08:00
Update the Linux os class not allow copying by usage of NEO::NonCopyableClass. Change-Id: Icc0d40eaa83d7a46ec0d48a5fc9deb5c57c0e3f8 Signed-off-by: macabral <matias.a.cabral@intel.com>
77 lines
2.0 KiB
C++
77 lines
2.0 KiB
C++
/*
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
|
|
|
#include "level_zero/tools/source/sysman/linux/fs_access.h"
|
|
|
|
namespace L0 {
|
|
|
|
ze_result_t LinuxSysmanImp::init() {
|
|
pFsAccess = FsAccess::create();
|
|
UNRECOVERABLE_IF(nullptr == pFsAccess);
|
|
|
|
pProcfsAccess = ProcfsAccess::create();
|
|
UNRECOVERABLE_IF(nullptr == pProcfsAccess);
|
|
|
|
Device *pDevice = Device::fromHandle(pParentSysmanImp->hCoreDevice);
|
|
NEO::OSInterface &OsInterface = pDevice->getOsInterface();
|
|
NEO::Drm *pDrm = OsInterface.get()->getDrm();
|
|
int myDeviceFd = pDrm->getFileDescriptor();
|
|
std::string myDeviceName;
|
|
ze_result_t result = pProcfsAccess->getFileName(pProcfsAccess->myProcessId(), myDeviceFd, myDeviceName);
|
|
if (ZE_RESULT_SUCCESS != result) {
|
|
return result;
|
|
}
|
|
|
|
pSysfsAccess = SysfsAccess::create(myDeviceName);
|
|
UNRECOVERABLE_IF(nullptr == pSysfsAccess);
|
|
|
|
return ZE_RESULT_SUCCESS;
|
|
}
|
|
|
|
FsAccess &LinuxSysmanImp::getFsAccess() {
|
|
UNRECOVERABLE_IF(nullptr == pFsAccess);
|
|
return *pFsAccess;
|
|
}
|
|
|
|
ProcfsAccess &LinuxSysmanImp::getProcfsAccess() {
|
|
UNRECOVERABLE_IF(nullptr == pProcfsAccess);
|
|
return *pProcfsAccess;
|
|
}
|
|
|
|
SysfsAccess &LinuxSysmanImp::getSysfsAccess() {
|
|
UNRECOVERABLE_IF(nullptr == pSysfsAccess);
|
|
return *pSysfsAccess;
|
|
}
|
|
|
|
LinuxSysmanImp::LinuxSysmanImp(SysmanImp *pParentSysmanImp) {
|
|
this->pParentSysmanImp = pParentSysmanImp;
|
|
}
|
|
|
|
LinuxSysmanImp::~LinuxSysmanImp() {
|
|
if (nullptr != pSysfsAccess) {
|
|
delete pSysfsAccess;
|
|
pSysfsAccess = nullptr;
|
|
}
|
|
if (nullptr != pProcfsAccess) {
|
|
delete pProcfsAccess;
|
|
pProcfsAccess = nullptr;
|
|
}
|
|
if (nullptr != pFsAccess) {
|
|
delete pFsAccess;
|
|
pFsAccess = nullptr;
|
|
}
|
|
}
|
|
|
|
OsSysman *OsSysman::create(SysmanImp *pParentSysmanImp) {
|
|
LinuxSysmanImp *pLinuxSysmanImp = new LinuxSysmanImp(pParentSysmanImp);
|
|
return static_cast<OsSysman *>(pLinuxSysmanImp);
|
|
}
|
|
|
|
} // namespace L0
|