Skip to content

Commit

Permalink
sdfw_services: Support for SUIT manifest-controlled variables
Browse files Browse the repository at this point in the history
Added definition and implementation of SUIT SSF services
for manifest-controlled variables

Ref: NCSDK-30530

Signed-off-by: Sylwester Konczyk <[email protected]>
  • Loading branch information
SylwesterKonczyk authored and tomchy committed Dec 4, 2024
1 parent a5e4efe commit b4851ab
Show file tree
Hide file tree
Showing 8 changed files with 2,430 additions and 1,867 deletions.
2 changes: 2 additions & 0 deletions subsys/sdfw_services/services/suit_service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ zephyr_library_sources(suit_update.c)
zephyr_library_sources(suit_mci.c)
zephyr_library_sources(suit_invoke.c)
zephyr_library_sources_ifdef(CONFIG_SUIT_PROCESSOR suit_auth.c)
zephyr_library_sources_ifdef(CONFIG_SUIT_MANIFEST_VARIABLES suit_mfst_var.c)

zephyr_library_link_libraries(suit_utils)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_MANIFEST_VARIABLES suit_manifest_variables)

if(CONFIG_SUIT_STREAM_SOURCE_IPC)
zephyr_library_link_libraries(suit_stream_sources_interface)
Expand Down
81 changes: 81 additions & 0 deletions subsys/sdfw_services/services/suit_service/suit_mfst_var.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <suit_manifest_variables.h>
#include <sdfw/sdfw_services/ssf_client.h>
#include "suit_service_decode.h"
#include "suit_service_encode.h"
#include "suit_service_types.h"
#include "suit_service_utils.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(suit_mfst_var, CONFIG_SSF_SUIT_SERVICE_LOG_LEVEL);

extern const struct ssf_client_srvc suit_srvc;

suit_plat_err_t suit_mfst_var_get(uint32_t id, uint32_t *val)
{
int err;
struct suit_req req = {0};
struct suit_rsp rsp = {0};
struct suit_get_manifest_var_req *req_data = NULL;
struct suit_get_manifest_var_rsp *rsp_data = NULL;
const uint8_t *rsp_pkt = NULL;

if (val == NULL) {
return SUIT_PLAT_ERR_INVAL;
}

req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(get_manifest_var);
req_data = &req.SSF_SUIT_REQ(get_manifest_var);

req_data->SSF_SUIT_REQ_ARG(get_manifest_var, id) = id;

err = ssf_client_send_request(&suit_srvc, &req, &rsp, &rsp_pkt);
if (err != 0) {
LOG_ERR("ssf_client_send_request failed");
return SUIT_PLAT_ERR_IPC;
}

rsp_data = &rsp.SSF_SUIT_RSP(get_manifest_var);
err = rsp_data->SSF_SUIT_RSP_ARG(get_manifest_var, ret);
if (err != SUIT_PLAT_SUCCESS) {
ssf_client_decode_done(rsp_pkt);
LOG_ERR("ssf_client response return code: %d", err);
return err;
}

*val = rsp_data->SSF_SUIT_RSP_ARG(get_manifest_var, value);
ssf_client_decode_done(rsp_pkt);

LOG_INF("suit_mfst_var_get, id: %d, value: %d", id, *val);

return SUIT_PLAT_SUCCESS;
}

suit_plat_err_t suit_mfst_var_set(uint32_t id, uint32_t val)
{
int err;
struct suit_req req = {0};
struct suit_rsp rsp = {0};
struct suit_set_manifest_var_req *req_data = NULL;

LOG_INF("suit_mfst_var_set, id: %d, value: %d", id, val);

req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(set_manifest_var);
req_data = &req.SSF_SUIT_REQ(set_manifest_var);

req_data->SSF_SUIT_REQ_ARG(set_manifest_var, id) = id;
req_data->SSF_SUIT_REQ_ARG(set_manifest_var, value) = val;

err = ssf_client_send_request(&suit_srvc, &req, &rsp, NULL);
if (err != 0) {
LOG_ERR("ssf_client_send_request failed");
return SUIT_PLAT_ERR_IPC;
}

return rsp.SSF_SUIT_RSP(set_manifest_var).SSF_SUIT_RSP_ARG(set_manifest_var, ret);
}
32 changes: 32 additions & 0 deletions subsys/sdfw_services/services/suit_service/suit_service.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,32 @@ suit_check_component_compatibility_rsp = (
ret: int,
)

; Get manifest variable request
suit_get_manifest_var_req = (
14,
id: uint,
)

; Get manifest variable response
suit_get_manifest_var_rsp = (
14,
ret: int,
value: uint,
)

; Set manifest variable request
suit_set_manifest_var_req = (
15,
id: uint,
value: uint,
)

; Set manifest variable response
suit_set_manifest_var_rsp = (
15,
ret: int,
)

; Get supported manifest roles request
suit_get_supported_manifest_roles_req = (
18,
Expand Down Expand Up @@ -371,6 +397,9 @@ suit_req = [
suit_get_supported_manifest_info_req /
suit_authorize_process_dependency_req /

suit_get_manifest_var_req /
suit_set_manifest_var_req /

suit_evt_sub_req /
suit_chunk_enqueue_req /
suit_chunk_status_req /
Expand Down Expand Up @@ -399,6 +428,9 @@ suit_rsp = [
suit_get_supported_manifest_info_rsp /
suit_authorize_process_dependency_rsp /

suit_get_manifest_var_rsp /
suit_set_manifest_var_rsp /

suit_evt_sub_rsp /
suit_chunk_enqueue_rsp /
suit_chunk_status_rsp /
Expand Down
Loading

0 comments on commit b4851ab

Please sign in to comment.