1 /* 2 * Copyright (c) 2018, Synopsys, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #include <rtthread.h> 7 8 #include "inc/arc/arc_exception.h" 9 10 /* enable interrupt and set interrupt priority mask */ 11 #define ARC_INIT_STATUS (AUX_STATUS_MASK_IE | ((-1 - INT_PRI_MIN) << 1)) 12 13 14 extern void start_r(void); 15 16 17 rt_uint32_t context_switch_reqflg; 18 rt_uint32_t rt_interrupt_from_thread; 19 rt_uint32_t rt_interrupt_to_thread; 20 21 struct init_stack_frame { 22 rt_uint32_t pc; 23 rt_uint32_t blink; 24 rt_uint32_t task; 25 rt_uint32_t status32; 26 rt_uint32_t r0; 27 }; 28 29 /** 30 * shutdown CPU 31 */ 32 void rt_hw_cpu_shutdown(void) 33 { 34 35 } 36 37 rt_uint8_t *rt_hw_stack_init(void *tentry, 38 void *parameter, 39 rt_uint8_t *stack_addr, 40 void *texit) 41 { 42 struct init_stack_frame *stack_frame; 43 rt_uint8_t *stk; 44 45 stk = stack_addr + sizeof(rt_uint32_t); 46 stk = (rt_uint8_t *)RT_ALIGN_DOWN((rt_uint32_t)stk, 8); 47 stk -= sizeof(struct init_stack_frame); 48 49 stack_frame = (struct init_stack_frame *)stk; 50 51 stack_frame->pc = (rt_uint32_t)start_r; 52 stack_frame->blink = (rt_uint32_t)texit; 53 stack_frame->task = (rt_uint32_t)tentry; 54 stack_frame->status32 = ARC_INIT_STATUS; 55 stack_frame->r0 = (rt_uint32_t)parameter; 56 57 return stk; 58 } 59 60 61 /** 62 * This function set the hook, which is invoked on fault exception handling. 63 * 64 * @param exception_handle the exception handling hook function. 65 */ 66 void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context)) 67 { 68 exception_handle = exception_handle; 69 }