1/* 2 * Copyright (c) 2021 Telink Semiconductor 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7#include <zephyr/offsets.h> 8#include <zephyr/toolchain.h> 9 10#include <soc.h> 11 12#define NDS_MXSTATUS 0x7C4 13 14/* Exports */ 15#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE 16GTEXT(__soc_save_context) 17GTEXT(__soc_restore_context) 18#endif 19 20#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE 21 22SECTION_FUNC(exception.other, __soc_save_context) 23 24#ifdef CONFIG_TELINK_B91_PFT_ARCH 25 csrr t0, NDS_MXSTATUS 26#endif 27#ifdef __riscv_dsp 28 csrr t1, ucode 29#endif 30 31#ifdef CONFIG_TELINK_B91_PFT_ARCH 32 sw t0, __soc_esf_t_mxstatus_OFFSET(a0) 33#endif 34#ifdef __riscv_dsp 35 sw t1, __soc_esf_t_ucode_OFFSET(a0) 36#endif 37 ret 38 39SECTION_FUNC(exception.other, __soc_restore_context) 40 41#ifdef CONFIG_TELINK_B91_PFT_ARCH 42 lw t0, __soc_esf_t_mxstatus_OFFSET(a0) 43#endif 44#ifdef __riscv_dsp 45 lw t1, __soc_esf_t_ucode_OFFSET(a0) 46#endif 47 48#ifdef CONFIG_TELINK_B91_PFT_ARCH 49 csrw NDS_MXSTATUS, t0 50#endif 51#ifdef __riscv_dsp 52 csrw ucode, t1 53#endif 54 ret 55 56#endif /* CONFIG_RISCV_SOC_CONTEXT_SAVE */ 57