Skip to content

Commit b4851ab

Browse files
SylwesterKonczyktomchy
authored andcommitted
sdfw_services: Support for SUIT manifest-controlled variables
Added definition and implementation of SUIT SSF services for manifest-controlled variables Ref: NCSDK-30530 Signed-off-by: Sylwester Konczyk <[email protected]>
1 parent a5e4efe commit b4851ab

File tree

8 files changed

+2430
-1867
lines changed

8 files changed

+2430
-1867
lines changed

subsys/sdfw_services/services/suit_service/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ zephyr_library_sources(suit_update.c)
1111
zephyr_library_sources(suit_mci.c)
1212
zephyr_library_sources(suit_invoke.c)
1313
zephyr_library_sources_ifdef(CONFIG_SUIT_PROCESSOR suit_auth.c)
14+
zephyr_library_sources_ifdef(CONFIG_SUIT_MANIFEST_VARIABLES suit_mfst_var.c)
1415

1516
zephyr_library_link_libraries(suit_utils)
17+
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_MANIFEST_VARIABLES suit_manifest_variables)
1618

1719
if(CONFIG_SUIT_STREAM_SOURCE_IPC)
1820
zephyr_library_link_libraries(suit_stream_sources_interface)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <suit_manifest_variables.h>
8+
#include <sdfw/sdfw_services/ssf_client.h>
9+
#include "suit_service_decode.h"
10+
#include "suit_service_encode.h"
11+
#include "suit_service_types.h"
12+
#include "suit_service_utils.h"
13+
14+
#include <zephyr/logging/log.h>
15+
LOG_MODULE_REGISTER(suit_mfst_var, CONFIG_SSF_SUIT_SERVICE_LOG_LEVEL);
16+
17+
extern const struct ssf_client_srvc suit_srvc;
18+
19+
suit_plat_err_t suit_mfst_var_get(uint32_t id, uint32_t *val)
20+
{
21+
int err;
22+
struct suit_req req = {0};
23+
struct suit_rsp rsp = {0};
24+
struct suit_get_manifest_var_req *req_data = NULL;
25+
struct suit_get_manifest_var_rsp *rsp_data = NULL;
26+
const uint8_t *rsp_pkt = NULL;
27+
28+
if (val == NULL) {
29+
return SUIT_PLAT_ERR_INVAL;
30+
}
31+
32+
req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(get_manifest_var);
33+
req_data = &req.SSF_SUIT_REQ(get_manifest_var);
34+
35+
req_data->SSF_SUIT_REQ_ARG(get_manifest_var, id) = id;
36+
37+
err = ssf_client_send_request(&suit_srvc, &req, &rsp, &rsp_pkt);
38+
if (err != 0) {
39+
LOG_ERR("ssf_client_send_request failed");
40+
return SUIT_PLAT_ERR_IPC;
41+
}
42+
43+
rsp_data = &rsp.SSF_SUIT_RSP(get_manifest_var);
44+
err = rsp_data->SSF_SUIT_RSP_ARG(get_manifest_var, ret);
45+
if (err != SUIT_PLAT_SUCCESS) {
46+
ssf_client_decode_done(rsp_pkt);
47+
LOG_ERR("ssf_client response return code: %d", err);
48+
return err;
49+
}
50+
51+
*val = rsp_data->SSF_SUIT_RSP_ARG(get_manifest_var, value);
52+
ssf_client_decode_done(rsp_pkt);
53+
54+
LOG_INF("suit_mfst_var_get, id: %d, value: %d", id, *val);
55+
56+
return SUIT_PLAT_SUCCESS;
57+
}
58+
59+
suit_plat_err_t suit_mfst_var_set(uint32_t id, uint32_t val)
60+
{
61+
int err;
62+
struct suit_req req = {0};
63+
struct suit_rsp rsp = {0};
64+
struct suit_set_manifest_var_req *req_data = NULL;
65+
66+
LOG_INF("suit_mfst_var_set, id: %d, value: %d", id, val);
67+
68+
req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(set_manifest_var);
69+
req_data = &req.SSF_SUIT_REQ(set_manifest_var);
70+
71+
req_data->SSF_SUIT_REQ_ARG(set_manifest_var, id) = id;
72+
req_data->SSF_SUIT_REQ_ARG(set_manifest_var, value) = val;
73+
74+
err = ssf_client_send_request(&suit_srvc, &req, &rsp, NULL);
75+
if (err != 0) {
76+
LOG_ERR("ssf_client_send_request failed");
77+
return SUIT_PLAT_ERR_IPC;
78+
}
79+
80+
return rsp.SSF_SUIT_RSP(set_manifest_var).SSF_SUIT_RSP_ARG(set_manifest_var, ret);
81+
}

subsys/sdfw_services/services/suit_service/suit_service.cddl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,32 @@ suit_check_component_compatibility_rsp = (
179179
ret: int,
180180
)
181181

182+
; Get manifest variable request
183+
suit_get_manifest_var_req = (
184+
14,
185+
id: uint,
186+
)
187+
188+
; Get manifest variable response
189+
suit_get_manifest_var_rsp = (
190+
14,
191+
ret: int,
192+
value: uint,
193+
)
194+
195+
; Set manifest variable request
196+
suit_set_manifest_var_req = (
197+
15,
198+
id: uint,
199+
value: uint,
200+
)
201+
202+
; Set manifest variable response
203+
suit_set_manifest_var_rsp = (
204+
15,
205+
ret: int,
206+
)
207+
182208
; Get supported manifest roles request
183209
suit_get_supported_manifest_roles_req = (
184210
18,
@@ -371,6 +397,9 @@ suit_req = [
371397
suit_get_supported_manifest_info_req /
372398
suit_authorize_process_dependency_req /
373399

400+
suit_get_manifest_var_req /
401+
suit_set_manifest_var_req /
402+
374403
suit_evt_sub_req /
375404
suit_chunk_enqueue_req /
376405
suit_chunk_status_req /
@@ -399,6 +428,9 @@ suit_rsp = [
399428
suit_get_supported_manifest_info_rsp /
400429
suit_authorize_process_dependency_rsp /
401430

431+
suit_get_manifest_var_rsp /
432+
suit_set_manifest_var_rsp /
433+
402434
suit_evt_sub_rsp /
403435
suit_chunk_enqueue_rsp /
404436
suit_chunk_status_rsp /

0 commit comments

Comments
 (0)