xref: /kvm-unit-tests/lib/arm/asm/processor.h (revision 39ac3f8494beb048a121f44bf626275b18c66da5)
1 #ifndef _ASMARM_PROCESSOR_H_
2 #define _ASMARM_PROCESSOR_H_
3 /*
4  * Copyright (C) 2014, Red Hat Inc, Andrew Jones <drjones@redhat.com>
5  *
6  * This work is licensed under the terms of the GNU LGPL, version 2.
7  */
8 #include <asm/ptrace.h>
9 
10 enum vector {
11 	EXCPTN_RST,
12 	EXCPTN_UND,
13 	EXCPTN_SVC,
14 	EXCPTN_PABT,
15 	EXCPTN_DABT,
16 	EXCPTN_ADDREXCPTN,
17 	EXCPTN_IRQ,
18 	EXCPTN_FIQ,
19 	EXCPTN_MAX,
20 };
21 
22 typedef void (*exception_fn)(struct pt_regs *);
23 extern void install_exception_handler(enum vector v, exception_fn fn);
24 
25 extern void show_regs(struct pt_regs *regs);
26 extern void *get_sp(void);
27 
28 static inline unsigned long current_cpsr(void)
29 {
30 	unsigned long cpsr;
31 	asm volatile("mrs %0, cpsr" : "=r" (cpsr));
32 	return cpsr;
33 }
34 
35 #define current_mode() (current_cpsr() & MODE_MASK)
36 
37 extern void start_usr(void (*func)(void *arg), void *arg, unsigned long sp_usr);
38 
39 #endif /* _ASMARM_PROCESSOR_H_ */
40