mgmt: updatehub: Add userspace syscalls
The current updatehub version forces user application to run in kernel mode. This add necessary api syscalls to isolate userspace from kernel. Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
This commit is contained in:
parent
000257dad0
commit
647c48c574
5 changed files with 69 additions and 12 deletions
|
@ -14,6 +14,10 @@
|
|||
#ifndef ZEPHYR_INCLUDE_MGMT_UPDATEHUB_H_
|
||||
#define ZEPHYR_INCLUDE_MGMT_UPDATEHUB_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Responses messages from UpdateHub.
|
||||
*
|
||||
|
@ -41,7 +45,7 @@ enum updatehub_response {
|
|||
* @details The updatehub_autohandler handles the whole process
|
||||
* in pre-determined time intervals.
|
||||
*/
|
||||
void updatehub_autohandler(void);
|
||||
__syscall void updatehub_autohandler(void);
|
||||
|
||||
/**
|
||||
* @brief The UpdateHub probe verify if there is some update to be performed.
|
||||
|
@ -52,7 +56,7 @@ void updatehub_autohandler(void);
|
|||
* @return UPDATEHUB_INCOMPATIBLE_HARDWARE if Incompatible hardware.
|
||||
* @return UPDATEHUB_METADATA_ERROR fail to parse or to encode the metadata.
|
||||
*/
|
||||
enum updatehub_response updatehub_probe(void);
|
||||
__syscall enum updatehub_response updatehub_probe(void);
|
||||
|
||||
/**
|
||||
* @brief Apply the update package.
|
||||
|
@ -67,7 +71,7 @@ enum updatehub_response updatehub_probe(void);
|
|||
* @return UPDATEHUB_INSTALL_ERROR fail while installing the update package.
|
||||
* @return UPDATEHUB_FLASH_INIT_ERROR fail to initialize the flash.
|
||||
*/
|
||||
enum updatehub_response updatehub_update(void);
|
||||
__syscall enum updatehub_response updatehub_update(void);
|
||||
|
||||
/**
|
||||
* @brief Confirm that image is running as expected.
|
||||
|
@ -77,17 +81,22 @@ enum updatehub_response updatehub_update(void);
|
|||
*
|
||||
* @return Return 0 if success otherwise a negative 'errno' value.
|
||||
*/
|
||||
int updatehub_confirm(void);
|
||||
__syscall int updatehub_confirm(void);
|
||||
|
||||
/**
|
||||
* @brief Request system to reboot.
|
||||
*
|
||||
* @return Return 0 if success otherwise a negative 'errno' value.
|
||||
*/
|
||||
int updatehub_reboot(void);
|
||||
__syscall int updatehub_reboot(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <syscalls/updatehub.h>
|
||||
#endif /* ZEPHYR_INCLUDE_MGMT_UPDATEHUB_H_ */
|
||||
|
|
|
@ -15,11 +15,18 @@ tests:
|
|||
- CONFIG_UPDATEHUB_PRODUCT_UID="e4d37cfe6ec48a2d069cc0bbb8b078677e9a0d8df3a027c4d8ea131130c4265f"
|
||||
- CONFIG_UPDATEHUB_POLL_INTERVAL=1
|
||||
- CONFIG_UPDATEHUB_CE=y
|
||||
- CONFIG_UPDATEHUB_SERVER="10.5.3.67"
|
||||
- CONFIG_UPDATEHUB_SERVER="updatehub.io"
|
||||
sample.net.updatehub.userspace:
|
||||
extra_configs:
|
||||
- CONFIG_UPDATEHUB_PRODUCT_UID="e4d37cfe6ec48a2d069cc0bbb8b078677e9a0d8df3a027c4d8ea131130c4265f"
|
||||
- CONFIG_UPDATEHUB_POLL_INTERVAL=1
|
||||
- CONFIG_UPDATEHUB_CE=y
|
||||
- CONFIG_UPDATEHUB_SERVER="updatehub.io"
|
||||
- CONFIG_USERSPACE=y
|
||||
sample.net.updatehub.dtls:
|
||||
extra_args: OVERLAY_CONFIG="overlay-dtls.conf"
|
||||
extra_configs:
|
||||
- CONFIG_UPDATEHUB_PRODUCT_UID="e4d37cfe6ec48a2d069cc0bbb8b078677e9a0d8df3a027c4d8ea131130c4265f"
|
||||
- CONFIG_UPDATEHUB_POLL_INTERVAL=1
|
||||
- CONFIG_UPDATEHUB_CE=y
|
||||
- CONFIG_UPDATEHUB_SERVER="10.5.3.67"
|
||||
- CONFIG_UPDATEHUB_SERVER="updatehub.io"
|
||||
|
|
|
@ -14,6 +14,8 @@ zephyr_library_sources_ifdef(CONFIG_UPDATEHUB updatehub_integrity.c)
|
|||
zephyr_library_sources_ifdef(CONFIG_UPDATEHUB updatehub_storage.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_UPDATEHUB_SHELL shell.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_USERSPACE updatehub_handlers.c)
|
||||
|
||||
zephyr_include_directories(
|
||||
${ZEPHYR_BASE}/subsys/mgmt/updatehub/include
|
||||
)
|
||||
|
|
|
@ -743,19 +743,19 @@ static void probe_cb(char *metadata, size_t metadata_size)
|
|||
LOG_INF("Probe metadata received");
|
||||
}
|
||||
|
||||
int updatehub_confirm(void)
|
||||
int z_impl_updatehub_confirm(void)
|
||||
{
|
||||
return updatehub_storage_mark_partition_as_confirmed(UPDATEHUB_SLOT_PARTITION_0);
|
||||
}
|
||||
|
||||
int updatehub_reboot(void)
|
||||
int z_impl_updatehub_reboot(void)
|
||||
{
|
||||
sys_reboot(SYS_REBOOT_WARM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum updatehub_response updatehub_probe(void)
|
||||
enum updatehub_response z_impl_updatehub_probe(void)
|
||||
{
|
||||
struct probe request;
|
||||
struct resp_probe_some_boards metadata_some_boards = { 0 };
|
||||
|
@ -919,7 +919,7 @@ error:
|
|||
return ctx.code_status;
|
||||
}
|
||||
|
||||
enum updatehub_response updatehub_update(void)
|
||||
enum updatehub_response z_impl_updatehub_update(void)
|
||||
{
|
||||
if (report(UPDATEHUB_STATE_DOWNLOADING) < 0) {
|
||||
LOG_ERR("Could not reporting downloading state");
|
||||
|
@ -1005,7 +1005,7 @@ static void autohandler(struct k_work *work)
|
|||
k_work_reschedule(&updatehub_work_handle, UPDATEHUB_POLL_INTERVAL);
|
||||
}
|
||||
|
||||
void updatehub_autohandler(void)
|
||||
void z_impl_updatehub_autohandler(void)
|
||||
{
|
||||
#if defined(CONFIG_UPDATEHUB_DOWNLOAD_SHA256_VERIFICATION)
|
||||
LOG_INF("SHA-256 verification on download only");
|
||||
|
|
39
subsys/mgmt/updatehub/updatehub_handlers.c
Normal file
39
subsys/mgmt/updatehub/updatehub_handlers.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2023 O.S.Systems
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/syscall_handler.h>
|
||||
#include <zephyr/mgmt/updatehub.h>
|
||||
|
||||
|
||||
static inline void z_vrfy_updatehub_autohandler(void)
|
||||
{
|
||||
z_impl_updatehub_autohandler();
|
||||
}
|
||||
#include <syscalls/updatehub_autohandler_mrsh.c>
|
||||
|
||||
static inline enum updatehub_response z_vrfy_updatehub_probe(void)
|
||||
{
|
||||
return z_impl_updatehub_probe();
|
||||
}
|
||||
#include <syscalls/updatehub_probe_mrsh.c>
|
||||
|
||||
static inline enum updatehub_response z_vrfy_updatehub_update(void)
|
||||
{
|
||||
return z_impl_updatehub_update();
|
||||
}
|
||||
#include <syscalls/updatehub_update_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_updatehub_confirm(void)
|
||||
{
|
||||
return z_impl_updatehub_confirm();
|
||||
}
|
||||
#include <syscalls/updatehub_confirm_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_updatehub_reboot(void)
|
||||
{
|
||||
return z_impl_updatehub_reboot();
|
||||
}
|
||||
#include <syscalls/updatehub_reboot_mrsh.c>
|
Loading…
Add table
Add a link
Reference in a new issue