WIP FPC-III support
[linux/fpc-iii.git] / arch / nds32 / include / asm / processor.h
blobb82369c7659d4dedeeec151859654bad0a789749
1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2005-2017 Andes Technology Corporation
4 #ifndef __ASM_NDS32_PROCESSOR_H
5 #define __ASM_NDS32_PROCESSOR_H
7 #ifdef __KERNEL__
9 #include <asm/ptrace.h>
10 #include <asm/types.h>
11 #include <asm/sigcontext.h>
13 #define KERNEL_STACK_SIZE PAGE_SIZE
14 #define STACK_TOP TASK_SIZE
15 #define STACK_TOP_MAX TASK_SIZE
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;
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;
39 struct fpu_struct fpu;
42 #define INIT_THREAD { }
44 #ifdef __NDS32_EB__
45 #define PSW_DE PSW_mskBE
46 #else
47 #define PSW_DE 0x0
48 #endif
50 #ifdef CONFIG_WBNA
51 #define PSW_valWBNA PSW_mskWBNA
52 #else
53 #define PSW_valWBNA 0x0
54 #endif
56 #ifdef CONFIG_HWZOL
57 #define PSW_valINIT (PSW_CPL_ANY | PSW_mskAEN | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE)
58 #else
59 #define PSW_valINIT (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE)
60 #endif
62 #define start_thread(regs,pc,stack) \
63 ({ \
64 memzero(regs, sizeof(struct pt_regs)); \
65 forget_syscall(regs); \
66 regs->ipsw = PSW_valINIT; \
67 regs->ir0 = (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_SYSTEM | PSW_INTL_1); \
68 regs->ipc = pc; \
69 regs->sp = stack; \
72 /* Forward declaration, a strange C thing */
73 struct task_struct;
75 /* Free all resources held by a thread. */
76 #define release_thread(thread) do { } while(0)
77 #if IS_ENABLED(CONFIG_FPU)
78 #if !IS_ENABLED(CONFIG_UNLAZU_FPU)
79 extern struct task_struct *last_task_used_math;
80 #endif
81 #endif
83 /* Prepare to copy thread state - unlazy all lazy status */
84 #define prepare_to_copy(tsk) do { } while (0)
86 unsigned long get_wchan(struct task_struct *p);
88 #define cpu_relax() barrier()
90 #define task_pt_regs(task) \
91 ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE \
92 - 8) - 1)
95 * Create a new kernel thread
97 extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
99 #define KSTK_EIP(tsk) instruction_pointer(task_pt_regs(tsk))
100 #define KSTK_ESP(tsk) user_stack_pointer(task_pt_regs(tsk))
102 #endif
104 #endif /* __ASM_NDS32_PROCESSOR_H */