xref: /kvm-unit-tests/lib/riscv/asm/processor.h (revision 386561f8cd050f58e9dc2ec7562014c8f1680de3)
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	16
8 
9 typedef void (*exception_fn)(struct pt_regs *);
10 
11 struct thread_info {
12 	int cpu;
13 	unsigned long hartid;
14 	exception_fn exception_handlers[EXCEPTION_CAUSE_MAX];
15 };
16 
17 static inline struct thread_info *current_thread_info(void)
18 {
19 	return (struct thread_info *)csr_read(CSR_SSCRATCH);
20 }
21 
22 void install_exception_handler(unsigned long cause, void (*handler)(struct pt_regs *));
23 void do_handle_exception(struct pt_regs *regs);
24 void thread_info_init(void);
25 
26 void show_regs(struct pt_regs *regs);
27 
28 #endif /* _ASMRISCV_PROCESSOR_H_ */
29