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)
8 * based on SPARC asm/processor_32.h which is:
10 * Copyright (C) 1994 David S. Miller
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
17 #ifndef _ASM_NIOS2_PROCESSOR_H
18 #define _ASM_NIOS2_PROCESSOR_H
20 #include <asm/ptrace.h>
21 #include <asm/registers.h>
24 #define NIOS2_FLAG_KTHREAD 0x00000001 /* task is a kernel thread */
26 #define NIOS2_OP_NOP 0x1883a
27 #define NIOS2_OP_BREAK 0x3da03a
31 #define STACK_TOP TASK_SIZE
32 #define STACK_TOP_MAX STACK_TOP
34 #endif /* __KERNEL__ */
36 /* Kuser helpers is mapped to this user space address */
37 #define KUSER_BASE 0x1000
38 #define KUSER_SIZE (PAGE_SIZE)
42 * Default implementation of macro that returns current
43 * instruction pointer ("program counter").
45 #define current_text_addr() ({ __label__ _l; _l: &&_l; })
47 # define TASK_SIZE 0x7FFF0000UL
48 # define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
50 /* The Nios processor specific thread struct. */
51 struct thread_struct
{
52 struct pt_regs
*kregs
;
54 /* Context switch saved kernel state. */
60 { &init_mm, (0), (0), __pgprot(0x0), VM_READ | VM_WRITE | VM_EXEC }
62 # define INIT_THREAD { \
68 extern void start_thread(struct pt_regs
*regs
, unsigned long pc
,
73 /* Free all resources held by a thread. */
74 static inline void release_thread(struct task_struct
*dead_task
)
78 /* Free current thread data structures etc.. */
79 static inline void exit_thread(void)
83 /* Return saved PC of a blocked thread. */
84 #define thread_saved_pc(tsk) ((tsk)->thread.kregs->ea)
86 extern unsigned long get_wchan(struct task_struct
*p
);
88 /* Prepare to copy thread state - unlazy all lazy status */
89 #define prepare_to_copy(tsk) do { } while (0)
91 #define task_pt_regs(p) \
92 ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
95 #define KSTK_EIP(tsk) ((tsk)->thread.kregs->ea)
96 #define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp)
98 #define cpu_relax() barrier()
99 #define cpu_relax_lowlatency() cpu_relax()
101 #endif /* __ASSEMBLY__ */
103 #endif /* _ASM_NIOS2_PROCESSOR_H */