|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Nordic Semiconductor ASA |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +#ifndef ZEPHYR_SOC_NORDIC_IRONSIDE_INCLUDE_NRF_IRONSIDE_BOOTMODE_H_ |
| 7 | +#define ZEPHYR_SOC_NORDIC_IRONSIDE_INCLUDE_NRF_IRONSIDE_BOOTMODE_H_ |
| 8 | + |
| 9 | +#include <stdbool.h> |
| 10 | +#include <stdint.h> |
| 11 | +#include <stddef.h> |
| 12 | + |
| 13 | +/** |
| 14 | + * @name Boot mode service error codes. |
| 15 | + * @{ |
| 16 | + */ |
| 17 | + |
| 18 | +/** Invalid/unsupported boot mode transition. */ |
| 19 | +#define IRONSIDE_BOOTMODE_ERROR_UNSUPPORTED_MODE (1) |
| 20 | +/** Failed to reboot into the boot mode due to other activity preventing a reset. */ |
| 21 | +#define IRONSIDE_BOOTMODE_ERROR_BUSY (2) |
| 22 | +/** The boot message is too large to fit in the buffer. */ |
| 23 | +#define IRONSIDE_BOOTMODE_ERROR_MESSAGE_TOO_LARGE (3) |
| 24 | + |
| 25 | +/** |
| 26 | + * @} |
| 27 | + */ |
| 28 | + |
| 29 | +/* IronSide call identifiers with implicit versions. */ |
| 30 | +#define IRONSIDE_CALL_ID_BOOTMODE_SERVICE_V1 5 |
| 31 | + |
| 32 | +enum { |
| 33 | + IRONSIDE_BOOTMODE_SERVICE_MODE_IDX, |
| 34 | + IRONSIDE_BOOTMODE_SERVICE_MSG_0_IDX, |
| 35 | + IRONSIDE_BOOTMODE_SERVICE_MSG_1_IDX, |
| 36 | + IRONSIDE_BOOTMODE_SERVICE_MSG_2_IDX, |
| 37 | + IRONSIDE_BOOTMODE_SERVICE_MSG_3_IDX, |
| 38 | + /* The last enum value is reserved for the number of arguments */ |
| 39 | + IRONSIDE_BOOTMODE_SERVICE_NUM_ARGS, |
| 40 | +}; |
| 41 | + |
| 42 | +/* Maximum size of the message parameter. */ |
| 43 | +#define IRONSIDE_BOOTMODE_SERVICE_MSG_MAX_SIZE (4 * sizeof(uint32_t)) |
| 44 | + |
| 45 | +/* Index of the return code within the service buffer. */ |
| 46 | +#define IRONSIDE_BOOTMODE_SERVICE_RETCODE_IDX (0) |
| 47 | + |
| 48 | +/** |
| 49 | + * @brief Request a reboot into the secondary firmware boot mode. |
| 50 | + * |
| 51 | + * This invokes the IronSide SE boot mode service to restart the system into the secondary boot |
| 52 | + * mode. In this mode, the secondary configuration defined in UICR is applied instead of the |
| 53 | + * primary one. The system immediately reboots without a reply if the request succeeds. |
| 54 | + * |
| 55 | + * The given message data is passed to the boot report of the CPU booted in the secondary boot mode. |
| 56 | + * |
| 57 | + * @note This function does not return if the request is successful. |
| 58 | + * @note The device will boot into the secondary firmware instead of primary firmware. |
| 59 | + * @note The request does not fail if the secondary firmware is not defined. |
| 60 | + * |
| 61 | + * @param msg A message that can be placed in the cpu's boot report. |
| 62 | + * @param msg_size Size of the message in bytes. |
| 63 | + * |
| 64 | + * @retval 0 on success. |
| 65 | + * @retval -IRONSIDE_BOOTMODE_ERROR_UNSUPPORTED_MODE if the secondary boot mode is unsupported. |
| 66 | + * @retval -IRONSIDE_BOOTMODE_ERROR_BUSY if the reboot was blocked. |
| 67 | + * @retval -IRONSIDE_BOOTMODE_ERROR_MESSAGE_TOO_LARGE if msg_size is greater than |
| 68 | + * IRONSIDE_BOOTMODE_SERVICE_MSG_MAX_SIZE. |
| 69 | + * @retval Positive error status if reported by IronSide call (see error codes in @ref call.h). |
| 70 | + */ |
| 71 | +int ironside_bootmode_secondary_reboot(const uint8_t *msg, size_t msg_size); |
| 72 | + |
| 73 | +#endif /* ZEPHYR_SOC_NORDIC_IRONSIDE_INCLUDE_NRF_IRONSIDE_BOOTMODE_H_ */ |
0 commit comments