-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sdfw_services: Add SUIT invoke services handlers
Add implementation of SUIT SSF invoke services. Ref: NCSDK-29996 Signed-off-by: Tomasz Chyrowicz <[email protected]>
- Loading branch information
Showing
5 changed files
with
163 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
subsys/sdfw_services/services/suit_service/suit_invoke.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <sdfw/sdfw_services/ssf_client.h> | ||
#include "suit_service_types.h" | ||
#include <sdfw/sdfw_services/suit_service.h> | ||
#include "suit_service_utils.h" | ||
|
||
#include <zephyr/logging/log.h> | ||
LOG_MODULE_REGISTER(suit_srvc_invoke, CONFIG_SSF_SUIT_SERVICE_LOG_LEVEL); | ||
|
||
extern const struct ssf_client_srvc suit_srvc; | ||
|
||
suit_ssf_err_t suit_execution_mode_read(suit_execution_mode_t *mode) | ||
{ | ||
int ret; | ||
struct suit_req req; | ||
struct suit_rsp rsp; | ||
struct suit_execution_mode_read_rsp *rsp_data; | ||
const uint8_t *rsp_pkt; | ||
|
||
if (mode == NULL) { | ||
return SUIT_PLAT_ERR_INVAL; | ||
} | ||
|
||
memset(&req, 0, sizeof(struct suit_req)); | ||
req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(execution_mode_read); | ||
|
||
ret = ssf_client_send_request(&suit_srvc, &req, &rsp, &rsp_pkt); | ||
if (ret != 0) { | ||
ssf_client_decode_done(rsp_pkt); | ||
return SUIT_PLAT_ERR_IPC; | ||
} | ||
|
||
rsp_data = &rsp.SSF_SUIT_RSP(execution_mode_read); | ||
ret = rsp_data->SSF_SUIT_RSP_ARG(execution_mode_read, ret); | ||
if (ret != SUIT_PLAT_SUCCESS) { | ||
ssf_client_decode_done(rsp_pkt); | ||
return ret; | ||
} | ||
|
||
*mode = (suit_execution_mode_t)rsp_data->SSF_SUIT_RSP_ARG(execution_mode_read, | ||
execution_mode); | ||
|
||
ssf_client_decode_done(rsp_pkt); | ||
|
||
return ret; | ||
} | ||
|
||
suit_ssf_err_t suit_invoke_confirm(int ret); | ||
{ | ||
int ret; | ||
struct suit_req req; | ||
struct suit_rsp rsp; | ||
struct suit_invoke_confirm_req *req_data; | ||
|
||
memset(&req, 0, sizeof(struct suit_req)); | ||
req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(invoke_confirm); | ||
req_data = &req.SSF_SUIT_REQ(invoke_confirm); | ||
req_data->SSF_SUIT_REQ_ARG(invoke_confirm, ret) = ret; | ||
|
||
ret = ssf_client_send_request(&suit_srvc, &req, &rsp, NULL); | ||
if (ret != 0) { | ||
return SUIT_PLAT_ERR_IPC; | ||
} | ||
|
||
return rsp.SSF_SUIT_RSP(invoke_confirm).SSF_SUIT_RSP_ARG(invoke_confirm, ret); | ||
} | ||
|
||
suit_ssf_err_t suit_boot_flags_reset(void) | ||
{ | ||
int ret; | ||
struct suit_req req; | ||
struct suit_rsp rsp; | ||
|
||
memset(&req, 0, sizeof(struct suit_req)); | ||
req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(boot_flags_reset); | ||
|
||
ret = ssf_client_send_request(&suit_srvc, &req, &rsp, NULL); | ||
if (ret != 0) { | ||
return SUIT_PLAT_ERR_IPC; | ||
} | ||
|
||
return rsp.SSF_SUIT_RSP(boot_flags_reset).SSF_SUIT_RSP_ARG(boot_flags_reset, ret); | ||
} | ||
|
||
suit_ssf_err_t suit_foreground_dfu_required(void) | ||
{ | ||
int ret; | ||
struct suit_req req; | ||
struct suit_rsp rsp; | ||
|
||
memset(&req, 0, sizeof(struct suit_req)); | ||
req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(foreground_dfu_required); | ||
|
||
ret = ssf_client_send_request(&suit_srvc, &req, &rsp, NULL); | ||
if (ret != 0) { | ||
return SUIT_PLAT_ERR_IPC; | ||
} | ||
|
||
return rsp.SSF_SUIT_RSP(foreground_dfu_required) | ||
.SSF_SUIT_RSP_ARG(foreground_dfu_required, ret); | ||
} |