Merge tag 's390-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
[sfrench/cifs-2.6.git] / arch / nds32 / include / asm / processor.h
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
3
4 #ifndef __ASM_NDS32_PROCESSOR_H
5 #define __ASM_NDS32_PROCESSOR_H
6
7 #ifdef __KERNEL__
8
9 #include <asm/ptrace.h>
10 #include <asm/types.h>
11 #include <asm/sigcontext.h>
12
13 #define KERNEL_STACK_SIZE       PAGE_SIZE
14 #define STACK_TOP       TASK_SIZE
15 #define STACK_TOP_MAX   TASK_SIZE
16
17 struct cpu_context {
18         unsigned long r6;
19         unsigned long r7;
20         unsigned long r8;
21         unsigned long r9;
22         unsigned long r10;
23         unsigned long r11;
24         unsigned long r12;
25         unsigned long r13;
26         unsigned long r14;
27         unsigned long fp;
28         unsigned long pc;
29         unsigned long sp;
30 };
31
32 struct thread_struct {
33         struct cpu_context cpu_context; /* cpu context */
34         /* fault info     */
35         unsigned long address;
36         unsigned long trap_no;
37         unsigned long error_code;
38 };
39
40 #define INIT_THREAD  {  }
41
42 #ifdef __NDS32_EB__
43 #define PSW_DE  PSW_mskBE
44 #else
45 #define PSW_DE  0x0
46 #endif
47
48 #ifdef CONFIG_WBNA
49 #define PSW_valWBNA     PSW_mskWBNA
50 #else
51 #define PSW_valWBNA     0x0
52 #endif
53
54 #ifdef CONFIG_HWZOL
55 #define PSW_valINIT (PSW_CPL_ANY | PSW_mskAEN | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE)
56 #else
57 #define PSW_valINIT (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE)
58 #endif
59
60 #define start_thread(regs,pc,stack)                     \
61 ({                                                      \
62         memzero(regs, sizeof(struct pt_regs));          \
63         forget_syscall(regs);                           \
64         regs->ipsw = PSW_valINIT;                       \
65         regs->ir0 = (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_SYSTEM | PSW_INTL_1);     \
66         regs->ipc = pc;                                 \
67         regs->sp = stack;                               \
68 })
69
70 /* Forward declaration, a strange C thing */
71 struct task_struct;
72
73 /* Free all resources held by a thread. */
74 #define release_thread(thread) do { } while(0)
75
76 /* Prepare to copy thread state - unlazy all lazy status */
77 #define prepare_to_copy(tsk)    do { } while (0)
78
79 unsigned long get_wchan(struct task_struct *p);
80
81 #define cpu_relax()                     barrier()
82
83 #define task_pt_regs(task) \
84         ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE \
85                 - 8) - 1)
86
87 /*
88  * Create a new kernel thread
89  */
90 extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
91
92 #define KSTK_EIP(tsk)   instruction_pointer(task_pt_regs(tsk))
93 #define KSTK_ESP(tsk)   user_stack_pointer(task_pt_regs(tsk))
94
95 #endif
96
97 #endif /* __ASM_NDS32_PROCESSOR_H */