xref: /openbmc/linux/arch/csky/include/asm/processor.h (revision d9679d00)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef __ASM_CSKY_PROCESSOR_H
4 #define __ASM_CSKY_PROCESSOR_H
5 
6 #include <linux/bitops.h>
7 #include <asm/segment.h>
8 #include <asm/ptrace.h>
9 #include <asm/current.h>
10 #include <asm/cache.h>
11 #include <abi/reg_ops.h>
12 #include <abi/regdef.h>
13 #include <abi/switch_context.h>
14 #ifdef CONFIG_CPU_HAS_FPU
15 #include <abi/fpu.h>
16 #endif
17 
18 struct cpuinfo_csky {
19 	unsigned long asid_cache;
20 } __aligned(SMP_CACHE_BYTES);
21 
22 extern struct cpuinfo_csky cpu_data[];
23 
24 /*
25  * User space process size: 2GB. This is hardcoded into a few places,
26  * so don't change it unless you know what you are doing.  TASK_SIZE
27  * for a 64 bit kernel expandable to 8192EB, of which the current CSKY
28  * implementations will "only" be able to use 1TB ...
29  */
30 #define TASK_SIZE	(PAGE_OFFSET - (PAGE_SIZE * 8))
31 
32 #ifdef __KERNEL__
33 #define STACK_TOP       TASK_SIZE
34 #define STACK_TOP_MAX   STACK_TOP
35 #endif
36 
37 /* This decides where the kernel will search for a free chunk of vm
38  * space during mmap's.
39  */
40 #define TASK_UNMAPPED_BASE      (TASK_SIZE / 3)
41 
42 struct thread_struct {
43 	unsigned long  sp;        /* kernel stack pointer */
44 	unsigned long  trap_no;   /* saved status register */
45 
46 	/* FPU regs */
47 	struct user_fp __aligned(16) user_fp;
48 };
49 
50 #define INIT_THREAD  { \
51 	.sp = sizeof(init_stack) + (unsigned long) &init_stack, \
52 }
53 
54 /*
55  * Do necessary setup to start up a newly executed thread.
56  *
57  * pass the data segment into user programs if it exists,
58  * it can't hurt anything as far as I can tell
59  */
60 #define start_thread(_regs, _pc, _usp)					\
61 do {									\
62 	set_fs(USER_DS); /* reads from user space */			\
63 	(_regs)->pc = (_pc);						\
64 	(_regs)->regs[1] = 0; /* ABIV1 is R7, uClibc_main rtdl arg */	\
65 	(_regs)->regs[2] = 0;						\
66 	(_regs)->regs[3] = 0; /* ABIV2 is R7, use it? */		\
67 	(_regs)->sr &= ~PS_S;						\
68 	(_regs)->usp = (_usp);						\
69 } while (0)
70 
71 /* Forward declaration, a strange C thing */
72 struct task_struct;
73 
74 /* Free all resources held by a thread. */
75 static inline void release_thread(struct task_struct *dead_task)
76 {
77 }
78 
79 /* Prepare to copy thread state - unlazy all lazy status */
80 #define prepare_to_copy(tsk)    do { } while (0)
81 
82 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
83 
84 unsigned long __get_wchan(struct task_struct *p);
85 
86 #define KSTK_EIP(tsk)		(task_pt_regs(tsk)->pc)
87 #define KSTK_ESP(tsk)		(task_pt_regs(tsk)->usp)
88 
89 #define task_pt_regs(p) \
90 	((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
91 
92 #define cpu_relax() barrier()
93 
94 #endif /* __ASM_CSKY_PROCESSOR_H */
95