xref: /openbmc/linux/arch/nios2/include/asm/processor.h (revision 234489ac)
1 /*
2  * Copyright (C) 2013 Altera Corporation
3  * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
4  * Copyright (C) 2004 Microtronix Datacom Ltd
5  * Copyright (C) 2001 Ken Hill (khill@microtronix.com)
6  *                    Vic Phillips (vic@microtronix.com)
7  *
8  * based on SPARC asm/processor_32.h which is:
9  *
10  * Copyright (C) 1994 David S. Miller
11  *
12  * This file is subject to the terms and conditions of the GNU General Public
13  * License.  See the file "COPYING" in the main directory of this archive
14  * for more details.
15  */
16 
17 #ifndef _ASM_NIOS2_PROCESSOR_H
18 #define _ASM_NIOS2_PROCESSOR_H
19 
20 #include <asm/ptrace.h>
21 #include <asm/registers.h>
22 #include <asm/page.h>
23 
24 #define NIOS2_FLAG_KTHREAD	0x00000001	/* task is a kernel thread */
25 
26 #define NIOS2_OP_NOP		0x1883a
27 #define NIOS2_OP_BREAK		0x3da03a
28 
29 #ifdef __KERNEL__
30 
31 #define STACK_TOP	TASK_SIZE
32 #define STACK_TOP_MAX	STACK_TOP
33 
34 #endif /* __KERNEL__ */
35 
36 /* Kuser helpers is mapped to this user space address */
37 #define KUSER_BASE		0x1000
38 #define KUSER_SIZE		(PAGE_SIZE)
39 #ifndef __ASSEMBLY__
40 
41 # define TASK_SIZE		0x7FFF0000UL
42 # define TASK_UNMAPPED_BASE	(PAGE_ALIGN(TASK_SIZE / 3))
43 
44 /* The Nios processor specific thread struct. */
45 struct thread_struct {
46 	struct pt_regs *kregs;
47 
48 	/* Context switch saved kernel state. */
49 	unsigned long ksp;
50 	unsigned long kpsr;
51 };
52 
53 # define INIT_THREAD {			\
54 	.kregs	= NULL,			\
55 	.ksp	= 0,			\
56 	.kpsr	= 0,			\
57 }
58 
59 extern void start_thread(struct pt_regs *regs, unsigned long pc,
60 			unsigned long sp);
61 
62 struct task_struct;
63 
64 extern unsigned long __get_wchan(struct task_struct *p);
65 
66 #define task_pt_regs(p) \
67 	((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
68 
69 /* Used by procfs */
70 #define KSTK_EIP(tsk)	((tsk)->thread.kregs->ea)
71 #define KSTK_ESP(tsk)	((tsk)->thread.kregs->sp)
72 
73 #define cpu_relax()	barrier()
74 
75 #endif /* __ASSEMBLY__ */
76 
77 #endif /* _ASM_NIOS2_PROCESSOR_H */
78