xref: /kvm-unit-tests/lib/arm/asm/thread_info.h (revision f6d10793f9b42e852a1c3081afe567bd03004528)
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 
11 #define THREAD_SIZE		16384
12 #define THREAD_START_SP		(THREAD_SIZE - 16)
13 
14 #define TIF_USER_MODE		(1U << 0)
15 
16 struct thread_info {
17 	int cpu;
18 	unsigned int flags;
19 	char ext[0];		/* allow unit tests to add extended info */
20 };
21 
22 static inline struct thread_info *thread_info_sp(unsigned long sp)
23 {
24 	return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
25 }
26 
27 register unsigned long current_stack_pointer asm("sp");
28 
29 static inline struct thread_info *current_thread_info(void)
30 {
31 	return thread_info_sp(current_stack_pointer);
32 }
33 
34 extern void thread_info_init(struct thread_info *ti, unsigned int flags);
35 
36 #endif /* _ASMARM_THREAD_INFO_H_ */
37