Skip to content

Commit bddc63e

Browse files
add firmware flashing utility interface
Signed-off-by: Vilvaraj, T J Vivek <[email protected]>
1 parent ff3d479 commit bddc63e

File tree

20 files changed

+440
-16
lines changed

20 files changed

+440
-16
lines changed

level_zero/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ if(BUILD_WITH_L0)
8080
endif()
8181
endif()
8282

83+
if(UNIX)
84+
# Firmware Update Library
85+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/source/sysman/linux/firmware_util")
86+
find_package(libigsc)
87+
if(libigsc_LIBRARIES)
88+
set(libigsc_FOUND TRUE)
89+
add_definitions(-DIGSC_PRESENT=$(libigsc_FOUND))
90+
message(STATUS "libigsc Library headers directory: ${libigsc_INCLUDE_DIR}")
91+
else()
92+
message(STATUS "libigsc Library headers not available. Building without")
93+
endif()
94+
endif()
95+
8396
if(UNIX)
8497
# Load GNUInstallDirs to determine install targets for Linux packages
8598
include(GNUInstallDirs)

level_zero/tools/source/sysman/firmware/firmware_imp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
namespace L0 {
1717

1818
ze_result_t FirmwareImp::firmwareGetProperties(zes_firmware_properties_t *pProperties) {
19-
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
19+
pOsFirmware->osGetFwProperties(pProperties);
20+
return ZE_RESULT_SUCCESS;
2021
}
2122

2223
void FirmwareImp::init() {

level_zero/tools/source/sysman/firmware/linux/os_firmware_imp.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,30 @@
1010
namespace L0 {
1111

1212
bool LinuxFirmwareImp::isFirmwareSupported(void) {
13-
return false;
13+
if (pFwInterface != nullptr) {
14+
isFWInitalized = ((ZE_RESULT_SUCCESS == pFwInterface->fwDeviceInit()) ? true : false);
15+
}
16+
return isFWInitalized;
17+
}
18+
19+
void LinuxFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties) {
20+
if (isFWInitalized) {
21+
getFirmwareVersion(pProperties->name);
22+
getFirmwareVersion(pProperties->version);
23+
} else {
24+
std::strncpy(pProperties->name, unknown.c_str(), (ZES_STRING_PROPERTY_SIZE - 1));
25+
std::strncpy(pProperties->version, unknown.c_str(), (ZES_STRING_PROPERTY_SIZE - 1));
26+
}
27+
}
28+
void LinuxFirmwareImp::getFirmwareVersion(char *firmwareVersion) {
29+
std::string fwVersion;
30+
pFwInterface->fwGetVersion(fwVersion);
31+
std::strncpy(firmwareVersion, fwVersion.c_str(), (ZES_STRING_PROPERTY_SIZE - 1));
1432
}
1533

1634
LinuxFirmwareImp::LinuxFirmwareImp(OsSysman *pOsSysman) {
35+
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
36+
pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
1737
}
1838

1939
OsFirmware *OsFirmware::create(OsSysman *pOsSysman) {

level_zero/tools/source/sysman/firmware/linux/os_firmware_imp.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ namespace L0 {
1717
class LinuxFirmwareImp : public OsFirmware, NEO::NonCopyableOrMovableClass {
1818
public:
1919
bool isFirmwareSupported(void) override;
20-
20+
void osGetFwProperties(zes_firmware_properties_t *pProperties) override;
2121
LinuxFirmwareImp() = default;
2222
LinuxFirmwareImp(OsSysman *pOsSysman);
2323
~LinuxFirmwareImp() override = default;
24+
25+
protected:
26+
FirmwareUtil *pFwInterface = nullptr;
27+
bool isFWInitalized = false;
28+
29+
private:
30+
void getFirmwareVersion(char *);
2431
};
2532

2633
} // namespace L0

level_zero/tools/source/sysman/firmware/os_firmware.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace L0 {
1515
class OsFirmware {
1616
public:
1717
virtual bool isFirmwareSupported(void) = 0;
18+
virtual void osGetFwProperties(zes_firmware_properties_t *pProperties) = 0;
1819

1920
static OsFirmware *create(OsSysman *pOsSysman);
2021
virtual ~OsFirmware() {}

level_zero/tools/source/sysman/firmware/windows/os_firmware_imp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ bool WddmFirmwareImp::isFirmwareSupported(void) {
1313
return false;
1414
}
1515

16+
void WddmFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties){};
17+
1618
OsFirmware *OsFirmware::create(OsSysman *pOsSysman) {
1719
WddmFirmwareImp *pWddmFirmwareImp = new WddmFirmwareImp();
1820
return static_cast<OsFirmware *>(pWddmFirmwareImp);

level_zero/tools/source/sysman/firmware/windows/os_firmware_imp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace L0 {
1515
class WddmFirmwareImp : public OsFirmware {
1616
public:
1717
bool isFirmwareSupported(void) override;
18+
void osGetFwProperties(zes_firmware_properties_t *pProperties) override;
1819
};
1920

2021
} // namespace L0
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Copyright (C) 2020 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(libigsc_FOUND)
8+
set(L0_SRCS_TOOLS_SYSMAN_LINUX_FIRMWARE_UTIL
9+
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_imp.cpp
10+
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_imp.h
11+
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util.h
12+
)
13+
14+
else()
15+
set(L0_SRCS_TOOLS_SYSMAN_LINUX_FIRMWARE_UTIL
16+
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util_imp_stub.cpp
17+
${CMAKE_CURRENT_SOURCE_DIR}/firmware_util.h
18+
)
19+
endif()
20+
21+
if(UNIX)
22+
target_sources(${L0_STATIC_LIB_NAME}
23+
PRIVATE
24+
${L0_SRCS_TOOLS_SYSMAN_LINUX_FIRMWARE_UTIL}
25+
)
26+
endif()
27+
28+
# Make our source files visible to parent
29+
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_FIRMWARE_UTIL_LINUX ${L0_SRCS_TOOLS_SYSMAN_FIRMWARE_UTIL_LINUX})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# Copyright (C) 2020 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
find_path(libigsc_INCLUDE_DIR NAMES igsc_lib.h PATHS /usr/local/include /usr/include)
8+
find_library(libigsc_LIBRARIES NAMES igsc libigsc PATHS /usr/local/lib /usr/lib)
9+
10+
include(FindPackageHandleStandardArgs)
11+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libigsc DEFAULT_MSG libigsc_LIBRARIES libigsc_INCLUDE_DIR)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (C) 2020 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include "shared/source/helpers/non_copyable_or_moveable.h"
11+
12+
#include "level_zero/core/source/device/device.h"
13+
14+
#ifdef IGSC_PRESENT
15+
#include "igsc_lib.h"
16+
#else
17+
typedef struct igsc_device_info {
18+
} igsc_device_info_t;
19+
#endif
20+
#include <string>
21+
#include <vector>
22+
23+
namespace L0 {
24+
class FirmwareUtil {
25+
public:
26+
static FirmwareUtil *create();
27+
virtual ze_result_t fwDeviceInit() = 0;
28+
virtual ze_result_t getFirstDevice(igsc_device_info *) = 0;
29+
virtual ze_result_t fwGetVersion(std::string &fwVersion) = 0;
30+
virtual ~FirmwareUtil() = default;
31+
};
32+
} // namespace L0

0 commit comments

Comments
 (0)