1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 #ifndef _ASMRISCV_PROCESSOR_H_ 3 #define _ASMRISCV_PROCESSOR_H_ 4 #include <asm/csr.h> 5 #include <asm/ptrace.h> 6 7 #define EXCEPTION_CAUSE_MAX 24 8 #define INTERRUPT_CAUSE_MAX 16 9 10 typedef void (*exception_fn)(struct pt_regs *); 11 12 struct thread_info { 13 int cpu; 14 unsigned long hartid; 15 unsigned long isa[1]; 16 exception_fn exception_handlers[EXCEPTION_CAUSE_MAX]; 17 exception_fn interrupt_handlers[INTERRUPT_CAUSE_MAX]; 18 }; 19 20 static inline struct thread_info *current_thread_info(void) 21 { 22 return (struct thread_info *)csr_read(CSR_SSCRATCH); 23 } 24 25 static inline void local_irq_enable(void) 26 { 27 csr_set(CSR_SSTATUS, SR_SIE); 28 } 29 30 static inline void local_irq_disable(void) 31 { 32 csr_clear(CSR_SSTATUS, SR_SIE); 33 } 34 35 void install_exception_handler(unsigned long cause, void (*handler)(struct pt_regs *)); 36 void install_irq_handler(unsigned long cause, void (*handler)(struct pt_regs *)); 37 void do_handle_exception(struct pt_regs *regs); 38 void thread_info_init(void); 39 void local_hart_init(void); 40 41 void show_regs(struct pt_regs *regs); 42 43 #endif /* _ASMRISCV_PROCESSOR_H_ */ 44