|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Nordic Semiconductor ASA |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +#ifndef ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_CPUCONF_H_ |
| 7 | +#define ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_CPUCONF_H_ |
| 8 | + |
| 9 | +#include <zephyr/drivers/firmware/nrf_ironside/call.h> |
| 10 | + |
| 11 | +#include <nrfx.h> |
| 12 | + |
| 13 | +/** |
| 14 | + * @name CPUCONF service error codes. |
| 15 | + * @{ |
| 16 | + */ |
| 17 | + |
| 18 | +#define IRONSIDE_CPUCONF_ERROR_STARTING_CPU_FAILED 0x5eb0 |
| 19 | +#define IRONSIDE_CPUCONF_ERROR_WRONG_CPU 0x5eb2 |
| 20 | +#define IRONSIDE_CPUCONF_ERROR_MEM_ACCESS_NOT_PERMITTED 0x5eb1 |
| 21 | +#define IRONSIDE_CPUCONF_ERROR_IRONSIDE_CALL_FAILED 0x5eb3 |
| 22 | + |
| 23 | +/** |
| 24 | + * @} |
| 25 | + */ |
| 26 | + |
| 27 | +#define IRONSIDE_CALL_ID_CPUCONF_V0 2 |
| 28 | + |
| 29 | +enum { |
| 30 | + IRONSIDE_CPUCONF_SERVICE_CPU_IDX, |
| 31 | + IRONSIDE_CPUCONF_SERVICE_VECTOR_TABLE_IDX, |
| 32 | + IRONSIDE_CPUCONF_SERVICE_CPU_WAIT_IDX, |
| 33 | + IRONSIDE_CPUCONF_SERVICE_MSG_IDX, |
| 34 | + IRONSIDE_CPUCONF_SERVICE_MSG_SIZE_IDX, |
| 35 | + /* The last enum value is reserved for the number of arguments */ |
| 36 | + IRONSIDE_SE_CPUCONF_NUM_ARGS |
| 37 | +}; |
| 38 | + |
| 39 | +/* IDX 0 is re-used by the error return code and the 'cpu' parameter. */ |
| 40 | +#define IRONSIDE_CPUCONF_SERVICE_RETCODE_IDX 0 |
| 41 | + |
| 42 | +BUILD_ASSERT(IRONSIDE_SE_CPUCONF_NUM_ARGS <= NRF_IRONSIDE_CALL_NUM_ARGS); |
| 43 | + |
| 44 | +/** |
| 45 | + * @brief Boot a local domain CPU |
| 46 | + * |
| 47 | + * @param cpu The CPU to be booted |
| 48 | + * @param vector_table Pointer to the vector table used to boot the CPU. |
| 49 | + * @param cpu_wait When this is true, the CPU will WAIT even if the CPU has clock. |
| 50 | + * @param msg A message that can be placed in radiocore's boot report. |
| 51 | + * @param msg_size Size of the message in bytes. |
| 52 | + * |
| 53 | + * @note cpu_wait is only intended to be enabled for debug purposes |
| 54 | + * and it is only supported that a debugger resumes the CPU. |
| 55 | + * |
| 56 | + * @retval 0 on success or if the CPU has already booted. |
| 57 | + * @retval -IRONSIDE_CPUCONF_ERROR_WRONG_CPU if cpu is unrecognized |
| 58 | + * @retval -IRONSIDE_CPUCONF_ERROR_STARTING_CPU_FAILED if starting the CPU failed |
| 59 | + * @retval -IRONSIDE_CPUCONF_ERROR_MEM_ACCESS_NOT_PERMITTED |
| 60 | + * if the CPU does not have read access configured for the vector_table address |
| 61 | + * @retval -IRONSIDE_CPUCONF_ERROR_IRONSIDE_CALL_FAILED The IRONside call failed. |
| 62 | + */ |
| 63 | +int ironside_cpuconf(NRF_PROCESSORID_Type cpu, void *vector_table, bool cpu_wait, uint8_t *msg, |
| 64 | + size_t msg_size); |
| 65 | + |
| 66 | +#endif /* ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_CPUCONF_H_ */ |
0 commit comments