Skip to content

Commit b41a8d2

Browse files
Sysman: add firmware flash API (#1368)
* Sysman: add firmware flash API Signed-off-by: Vilvaraj, T J Vivek <[email protected]> * Sysman: fixed windows implementation of firmware flash API. Signed-off-by: Vilvaraj, T J Vivek <[email protected]> * add unit tests to test flashing. Signed-off-by: Vilvaraj, T J Vivek <[email protected]> * sysman: add firmware flashing support to zello sysman Signed-off-by: T J Vivek Vilvaraj <[email protected]> * sysman: added progress update function to firmware flash API Signed-off-by: T J Vivek Vilvaraj <[email protected]>
1 parent 8c2cb54 commit b41a8d2

File tree

15 files changed

+106
-19
lines changed

15 files changed

+106
-19
lines changed

level_zero/api/sysman/zes_sysman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ zesFirmwareFlash(
388388
zes_firmware_handle_t hFirmware,
389389
void *pImage,
390390
uint32_t size) {
391-
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
391+
return L0::Firmware::fromHandle(hFirmware)->firmwareFlash(pImage, size);
392392
}
393393

394394
ZE_APIEXPORT ze_result_t ZE_APICALL

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -22,6 +22,7 @@ class Firmware : _zes_firmware_handle_t {
2222
public:
2323
virtual ~Firmware() {}
2424
virtual ze_result_t firmwareGetProperties(zes_firmware_properties_t *pProperties) = 0;
25+
virtual ze_result_t firmwareFlash(void *pImage, uint32_t size) = 0;
2526

2627
inline zes_firmware_handle_t toHandle() { return this; }
2728

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -20,6 +20,10 @@ ze_result_t FirmwareImp::firmwareGetProperties(zes_firmware_properties_t *pPrope
2020
return ZE_RESULT_SUCCESS;
2121
}
2222

23+
ze_result_t FirmwareImp::firmwareFlash(void *pImage, uint32_t size) {
24+
return pOsFirmware->osFirmwareFlash(pImage, size);
25+
}
26+
2327
void FirmwareImp::init() {
2428
this->isFirmwareEnabled = pOsFirmware->isFirmwareSupported();
2529
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -19,6 +19,7 @@ class OsFirmware;
1919
class FirmwareImp : public Firmware, NEO::NonCopyableOrMovableClass {
2020
public:
2121
ze_result_t firmwareGetProperties(zes_firmware_properties_t *pProperties) override;
22+
ze_result_t firmwareFlash(void *pImage, uint32_t size) override;
2223
FirmwareImp() = default;
2324
FirmwareImp(OsSysman *pOsSysman);
2425
~FirmwareImp() override;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ void LinuxFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties)
2727
strncpy_s(pProperties->version, ZES_STRING_PROPERTY_SIZE, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
2828
}
2929
}
30+
31+
ze_result_t LinuxFirmwareImp::osFirmwareFlash(void *pImage, uint32_t size) {
32+
return pFwInterface->fwFlashGSC(pImage, size);
33+
}
34+
3035
void LinuxFirmwareImp::getFirmwareVersion(char *firmwareVersion) {
3136
std::string fwVersion;
3237
pFwInterface->fwGetVersion(fwVersion);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -18,6 +18,7 @@ class LinuxFirmwareImp : public OsFirmware, NEO::NonCopyableOrMovableClass {
1818
public:
1919
bool isFirmwareSupported(void) override;
2020
void osGetFwProperties(zes_firmware_properties_t *pProperties) override;
21+
ze_result_t osFirmwareFlash(void *pImage, uint32_t size) override;
2122
LinuxFirmwareImp() = default;
2223
LinuxFirmwareImp(OsSysman *pOsSysman);
2324
~LinuxFirmwareImp() override = default;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -16,7 +16,7 @@ class OsFirmware {
1616
public:
1717
virtual bool isFirmwareSupported(void) = 0;
1818
virtual void osGetFwProperties(zes_firmware_properties_t *pProperties) = 0;
19-
19+
virtual ze_result_t osFirmwareFlash(void *pImage, uint32_t size) = 0;
2020
static OsFirmware *create(OsSysman *pOsSysman);
2121
virtual ~OsFirmware() {}
2222
};

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -14,6 +14,9 @@ bool WddmFirmwareImp::isFirmwareSupported(void) {
1414
}
1515

1616
void WddmFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties){};
17+
ze_result_t WddmFirmwareImp::osFirmwareFlash(void *pImage, uint32_t size) {
18+
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
19+
};
1720

1821
OsFirmware *OsFirmware::create(OsSysman *pOsSysman) {
1922
WddmFirmwareImp *pWddmFirmwareImp = new WddmFirmwareImp();

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -16,6 +16,7 @@ class WddmFirmwareImp : public OsFirmware {
1616
public:
1717
bool isFirmwareSupported(void) override;
1818
void osGetFwProperties(zes_firmware_properties_t *pProperties) override;
19+
ze_result_t osFirmwareFlash(void *pImage, uint32_t size) override;
1920
};
2021

2122
} // namespace L0

level_zero/tools/source/sysman/linux/firmware_util/firmware_util.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -27,6 +27,7 @@ class FirmwareUtil {
2727
virtual ze_result_t fwDeviceInit() = 0;
2828
virtual ze_result_t getFirstDevice(igsc_device_info *) = 0;
2929
virtual ze_result_t fwGetVersion(std::string &fwVersion) = 0;
30+
virtual ze_result_t fwFlashGSC(void *pImage, uint32_t size) = 0;
3031
virtual ~FirmwareUtil() = default;
3132
};
3233
} // namespace L0

0 commit comments

Comments
 (0)