2020-03-06 11:09:57 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-03-22 08:52:57 +01:00
|
|
|
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2020-03-22 08:52:57 +01:00
|
|
|
#include "level_zero/tools/source/sysman/linux/sysfs_access.h"
|
2020-03-06 11:09:57 +01:00
|
|
|
|
|
|
|
|
namespace L0 {
|
|
|
|
|
|
|
|
|
|
ze_result_t LinuxSysmanImp::init() {
|
|
|
|
|
Device *pDevice = Device::fromHandle(pParentSysmanImp->hCoreDevice);
|
|
|
|
|
NEO::OSInterface &OsInterface = pDevice->getOsInterface();
|
|
|
|
|
NEO::Drm *pDrm = OsInterface.get()->getDrm();
|
|
|
|
|
int fd = pDrm->getFileDescriptor();
|
|
|
|
|
|
|
|
|
|
pSysfsAccess = SysfsAccess::create(fd);
|
|
|
|
|
UNRECOVERABLE_IF(nullptr == pSysfsAccess);
|
|
|
|
|
return ZE_RESULT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysfsAccess &LinuxSysmanImp::getSysfsAccess() {
|
|
|
|
|
UNRECOVERABLE_IF(nullptr == pSysfsAccess);
|
|
|
|
|
return *pSysfsAccess;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LinuxSysmanImp::~LinuxSysmanImp() {
|
|
|
|
|
if (nullptr != pSysfsAccess) {
|
|
|
|
|
delete pSysfsAccess;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OsSysman *OsSysman::create(SysmanImp *pParentSysmanImp) {
|
|
|
|
|
LinuxSysmanImp *pLinuxSysmanImp = new LinuxSysmanImp(pParentSysmanImp);
|
|
|
|
|
return static_cast<OsSysman *>(pLinuxSysmanImp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace L0
|