1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/*
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/sysman/source/api/firmware/linux/sysman_os_firmware_imp.h"
#include "shared/source/helpers/string.h"
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/sysman_const.h"
namespace L0 {
namespace Sysman {
void OsFirmware::getSupportedFwTypes(std::vector<std::string> &supportedFwTypes, OsSysman *pOsSysman) {
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
supportedFwTypes.clear();
if (pFwInterface != nullptr) {
if (pLinuxSysmanImp->isDeviceInSurvivabilityMode()) {
pFwInterface->getDeviceSupportedFwTypes(supportedFwTypes);
} else {
auto pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper();
pSysmanProductHelper->getDeviceSupportedFwTypes(pFwInterface, supportedFwTypes);
// get supported late binding fw handles
auto pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
pSysmanKmdInterface->getLateBindingSupportedFwTypes(supportedFwTypes);
}
}
}
void LinuxFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties) {
if (ZE_RESULT_SUCCESS != getFirmwareVersion(osFwType, pProperties)) {
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.data(), ZES_STRING_PROPERTY_SIZE - 1);
}
pProperties->canControl = true; // Assuming that user has permission to flash the firmware
}
ze_result_t LinuxFirmwareImp::osFirmwareFlash(void *pImage, uint32_t size) {
return pFwInterface->flashFirmware(osFwType, pImage, size);
}
ze_result_t LinuxFirmwareImp::osGetSecurityVersion(char *pVersion) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFirmwareImp::osSetSecurityVersion() {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFirmwareImp::osGetConsoleLogs(size_t *pSize, char *pFirmwareLog) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFirmwareImp::osGetFirmwareFlashProgress(uint32_t *pCompletionPercent) {
return pFwInterface->getFlashFirmwareProgress(pCompletionPercent);
}
LinuxFirmwareImp::LinuxFirmwareImp(OsSysman *pOsSysman, const std::string &fwType) : osFwType(fwType) {
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
if (!pLinuxSysmanImp->isDeviceInSurvivabilityMode()) {
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
}
pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
}
std::unique_ptr<OsFirmware> OsFirmware::create(OsSysman *pOsSysman, const std::string &fwType) {
std::unique_ptr<LinuxFirmwareImp> pLinuxFirmwareImp = std::make_unique<LinuxFirmwareImp>(pOsSysman, fwType);
return pLinuxFirmwareImp;
}
} // namespace Sysman
} // namespace L0
|