xref: /kvm-unit-tests/lib/arm/asm/processor.h (revision 92fca209bc2c7979f421060d6b6360ef6a562985)
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 #include <asm/sysreg.h>
10 
11 enum vector {
12 	EXCPTN_RST,
13 	EXCPTN_UND,
14 	EXCPTN_SVC,
15 	EXCPTN_PABT,
16 	EXCPTN_DABT,
17 	EXCPTN_ADDREXCPTN,
18 	EXCPTN_IRQ,
19 	EXCPTN_FIQ,
20 	EXCPTN_MAX,
21 };
22 
23 typedef void (*exception_fn)(struct pt_regs *);
24 extern void install_exception_handler(enum vector v, exception_fn fn);
25 
26 extern void show_regs(struct pt_regs *regs);
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 #define MPIDR __ACCESS_CP15(c0, 0, c0, 5)
38 static inline unsigned int get_mpidr(void)
39 {
40 	return read_sysreg(MPIDR);
41 }
42 
43 /* Only support Aff0 for now, up to 4 cpus */
44 #define mpidr_to_cpu(mpidr) ((int)((mpidr) & 0xff))
45 
46 extern void start_usr(void (*func)(void *arg), void *arg, unsigned long sp_usr);
47 extern bool is_user(void);
48 
49 #endif /* _ASMARM_PROCESSOR_H_ */
50