Skip to content

Commit

Permalink
firmware: Read new firmware version from sysfs
Browse files Browse the repository at this point in the history
- Read the newly added firmware version from sysfs node


Related-To: LOCI-2557
Signed-off-by: Pichika Uday Kiran <[email protected]>
  • Loading branch information
Pichika Uday Kiran authored and Compute-Runtime-Automation committed Nov 3, 2021
1 parent ca4af1d commit 99cbd1b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
3 changes: 2 additions & 1 deletion level_zero/tools/source/sysman/firmware/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2020 Intel Corporation
# Copyright (C) 2020-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
Expand All @@ -8,6 +8,7 @@ set(L0_SRCS_TOOLS_SYSMAN_FIRMWARE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/os_firmware_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_firmware_imp.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}os_firmware_imp_helper.cpp
)

if(UNIX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ bool LinuxFirmwareImp::isFirmwareSupported(void) {
}

void LinuxFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties) {
std::string fwVersion;
if (ZE_RESULT_SUCCESS == pFwInterface->getFwVersion(osFwType, fwVersion)) {
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, fwVersion.c_str(), ZES_STRING_PROPERTY_SIZE);
} else {
if (ZE_RESULT_SUCCESS != getFirmwareVersion(osFwType, pProperties)) {
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
}
pProperties->canControl = true; //Assuming that user has permission to flash the firmware
Expand All @@ -63,6 +60,7 @@ ze_result_t LinuxFirmwareImp::osFirmwareFlash(void *pImage, uint32_t size) {

LinuxFirmwareImp::LinuxFirmwareImp(OsSysman *pOsSysman, const std::string &fwType) : osFwType(fwType) {
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ class LinuxFirmwareImp : public OsFirmware, NEO::NonCopyableOrMovableClass {
bool isFirmwareSupported(void) override;
void osGetFwProperties(zes_firmware_properties_t *pProperties) override;
ze_result_t osFirmwareFlash(void *pImage, uint32_t size) override;
ze_result_t getFirmwareVersion(std::string fwType, zes_firmware_properties_t *pProperties);
LinuxFirmwareImp() = default;
LinuxFirmwareImp(OsSysman *pOsSysman, const std::string &fwType);
~LinuxFirmwareImp() override = default;

protected:
FirmwareUtil *pFwInterface = nullptr;
SysfsAccess *pSysfsAccess = nullptr;
bool isFWInitalized = false;
std::string osFwType;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#include "level_zero/tools/source/sysman/firmware/linux/os_firmware_imp.h"

namespace L0 {

ze_result_t LinuxFirmwareImp::getFirmwareVersion(std::string fwType, zes_firmware_properties_t *pProperties) {
std::string fwVersion;
ze_result_t result = pFwInterface->getFwVersion(fwType, fwVersion);
if (ZE_RESULT_SUCCESS == result) {
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, fwVersion.c_str(), ZES_STRING_PROPERTY_SIZE);
}
return result;
}

} // namespace L0

0 comments on commit 99cbd1b

Please sign in to comment.