xref: /kvm-unit-tests/lib/arm/asm/thread_info.h (revision ad14f089be824ef2baebb5960649271119c46d66)
1 #ifndef _ASMARM_THREAD_INFO_H_
2 #define _ASMARM_THREAD_INFO_H_
3 /*
4  * Adapted from arch/arm64/include/asm/thread_info.h
5  *
6  * Copyright (C) 2015, Red Hat Inc, Andrew Jones <drjones@redhat.com>
7  *
8  * This work is licensed under the terms of the GNU LGPL, version 2.
9  */
10 #include <asm/processor.h>
11 #include <asm/page.h>
12 
13 #define __MIN_THREAD_SIZE	16384
14 #if PAGE_SIZE > __MIN_THREAD_SIZE
15 #define THREAD_SIZE		PAGE_SIZE
16 #else
17 #define THREAD_SIZE		__MIN_THREAD_SIZE
18 #endif
19 #define THREAD_START_SP		(THREAD_SIZE - 16)
20 
21 #define TIF_USER_MODE		(1U << 0)
22 
23 struct thread_info {
24 	int cpu;
25 	unsigned int flags;
26 #ifdef __arm__
27 	exception_fn exception_handlers[EXCPTN_MAX];
28 #else
29 	vector_fn vector_handlers[VECTOR_MAX];
30 	exception_fn exception_handlers[VECTOR_MAX][EC_MAX];
31 #endif
32 	char ext[0];		/* allow unit tests to add extended info */
33 };
34 
35 static inline struct thread_info *thread_info_sp(unsigned long sp)
36 {
37 	return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
38 }
39 
40 register unsigned long current_stack_pointer asm("sp");
41 
42 static inline struct thread_info *current_thread_info(void)
43 {
44 	return thread_info_sp(current_stack_pointer);
45 }
46 
47 extern void thread_info_init(struct thread_info *ti, unsigned int flags);
48 
49 #endif /* _ASMARM_THREAD_INFO_H_ */
50