1 /*
2  * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
3  * Copyright (C) 2008-2009 PetaLogix
4  * Copyright (C) 2006 Atmark Techno, Inc.
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License. See the file "COPYING" in the main directory of this archive
8  * for more details.
9  */
10 
11 #ifndef _ASM_MICROBLAZE_PROCESSOR_H
12 #define _ASM_MICROBLAZE_PROCESSOR_H
13 
14 #include <asm/ptrace.h>
15 #include <asm/setup.h>
16 #include <asm/registers.h>
17 #include <asm/entry.h>
18 #include <asm/current.h>
19 
20 # ifndef __ASSEMBLY__
21 /* from kernel/cpu/mb.c */
22 extern const struct seq_operations cpuinfo_op;
23 
24 # define cpu_relax()		barrier()
25 
26 #define task_pt_regs(tsk) \
27 		(((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1)
28 
29 /* Do necessary setup to start up a newly executed thread. */
30 void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp);
31 
32 extern void ret_from_fork(void);
33 extern void ret_from_kernel_thread(void);
34 
35 # endif /* __ASSEMBLY__ */
36 
37 # ifndef CONFIG_MMU
38 /*
39  * User space process size: memory size
40  *
41  * TASK_SIZE on MMU cpu is usually 1GB. However, on no-MMU arch, both
42  * user processes and the kernel is on the same memory region. They
43  * both share the memory space and that is limited by the amount of
44  * physical memory. thus, we set TASK_SIZE == amount of total memory.
45  */
46 # define TASK_SIZE	(0x81000000 - 0x80000000)
47 
48 /*
49  * This decides where the kernel will search for a free chunk of vm
50  * space during mmap's. We won't be using it
51  */
52 # define TASK_UNMAPPED_BASE	0
53 
54 /* definition in include/linux/sched.h */
55 struct task_struct;
56 
57 /* thread_struct is gone. use thread_info instead. */
58 struct thread_struct { };
59 # define INIT_THREAD	{ }
60 
61 /* Free all resources held by a thread. */
62 static inline void release_thread(struct task_struct *dead_task)
63 {
64 }
65 
66 extern unsigned long get_wchan(struct task_struct *p);
67 
68 # define KSTK_EIP(tsk)	(0)
69 # define KSTK_ESP(tsk)	(0)
70 
71 # else /* CONFIG_MMU */
72 
73 /*
74  * This is used to define STACK_TOP, and with MMU it must be below
75  * kernel base to select the correct PGD when handling MMU exceptions.
76  */
77 # define TASK_SIZE	(CONFIG_KERNEL_START)
78 
79 /*
80  * This decides where the kernel will search for a free chunk of vm
81  * space during mmap's.
82  */
83 # define TASK_UNMAPPED_BASE	(TASK_SIZE / 8 * 3)
84 
85 # define THREAD_KSP	0
86 
87 #  ifndef __ASSEMBLY__
88 
89 /* If you change this, you must change the associated assembly-languages
90  * constants defined below, THREAD_*.
91  */
92 struct thread_struct {
93 	/* kernel stack pointer (must be first field in structure) */
94 	unsigned long	ksp;
95 	unsigned long	ksp_limit;	/* if ksp <= ksp_limit stack overflow */
96 	void		*pgdir;		/* root of page-table tree */
97 	struct pt_regs	*regs;		/* Pointer to saved register state */
98 };
99 
100 #  define INIT_THREAD { \
101 	.ksp   = sizeof init_stack + (unsigned long)init_stack, \
102 	.pgdir = swapper_pg_dir, \
103 }
104 
105 /* Free all resources held by a thread. */
106 static inline void release_thread(struct task_struct *dead_task)
107 {
108 }
109 
110 unsigned long get_wchan(struct task_struct *p);
111 
112 /* The size allocated for kernel stacks. This _must_ be a power of two! */
113 # define KERNEL_STACK_SIZE	0x2000
114 
115 /* Return some info about the user process TASK.  */
116 #  define task_tos(task)	((unsigned long)(task) + KERNEL_STACK_SIZE)
117 #  define task_regs(task) ((struct pt_regs *)task_tos(task) - 1)
118 
119 #  define task_pt_regs_plus_args(tsk) \
120 	((void *)task_pt_regs(tsk))
121 
122 #  define task_sp(task)	(task_regs(task)->r1)
123 #  define task_pc(task)	(task_regs(task)->pc)
124 /* Grotty old names for some.  */
125 #  define KSTK_EIP(task)	(task_pc(task))
126 #  define KSTK_ESP(task)	(task_sp(task))
127 
128 /* FIXME */
129 #  define deactivate_mm(tsk, mm)	do { } while (0)
130 
131 #  define STACK_TOP	TASK_SIZE
132 #  define STACK_TOP_MAX	STACK_TOP
133 
134 #ifdef CONFIG_DEBUG_FS
135 extern struct dentry *of_debugfs_root;
136 #endif
137 
138 #  endif /* __ASSEMBLY__ */
139 # endif /* CONFIG_MMU */
140 #endif /* _ASM_MICROBLAZE_PROCESSOR_H */
141