diff options
Diffstat (limited to 'arch/microblaze')
-rw-r--r-- | arch/microblaze/include/asm/processor.h | 95 | ||||
-rw-r--r-- | arch/microblaze/include/asm/registers.h | 21 | ||||
-rw-r--r-- | arch/microblaze/include/asm/segment.h | 20 | ||||
-rw-r--r-- | arch/microblaze/kernel/process.c | 58 |
4 files changed, 181 insertions, 13 deletions
diff --git a/arch/microblaze/include/asm/processor.h b/arch/microblaze/include/asm/processor.h index 9329029d2614..563c6b9453f0 100644 --- a/arch/microblaze/include/asm/processor.h +++ b/arch/microblaze/include/asm/processor.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2008 Michal Simek | 2 | * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> |
3 | * Copyright (C) 2008 PetaLogix | 3 | * Copyright (C) 2008-2009 PetaLogix |
4 | * Copyright (C) 2006 Atmark Techno, Inc. | 4 | * Copyright (C) 2006 Atmark Techno, Inc. |
5 | * | 5 | * |
6 | * This file is subject to the terms and conditions of the GNU General Public | 6 | * This file is subject to the terms and conditions of the GNU General Public |
@@ -26,14 +26,15 @@ extern const struct seq_operations cpuinfo_op; | |||
26 | # define cpu_sleep() do {} while (0) | 26 | # define cpu_sleep() do {} while (0) |
27 | # define prepare_to_copy(tsk) do {} while (0) | 27 | # define prepare_to_copy(tsk) do {} while (0) |
28 | 28 | ||
29 | # endif /* __ASSEMBLY__ */ | ||
30 | |||
31 | #define task_pt_regs(tsk) \ | 29 | #define task_pt_regs(tsk) \ |
32 | (((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1) | 30 | (((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1) |
33 | 31 | ||
34 | /* Do necessary setup to start up a newly executed thread. */ | 32 | /* Do necessary setup to start up a newly executed thread. */ |
35 | void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp); | 33 | void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp); |
36 | 34 | ||
35 | # endif /* __ASSEMBLY__ */ | ||
36 | |||
37 | # ifndef CONFIG_MMU | ||
37 | /* | 38 | /* |
38 | * User space process size: memory size | 39 | * User space process size: memory size |
39 | * | 40 | * |
@@ -85,4 +86,90 @@ extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); | |||
85 | # define KSTK_EIP(tsk) (0) | 86 | # define KSTK_EIP(tsk) (0) |
86 | # define KSTK_ESP(tsk) (0) | 87 | # define KSTK_ESP(tsk) (0) |
87 | 88 | ||
89 | # else /* CONFIG_MMU */ | ||
90 | |||
91 | /* | ||
92 | * This is used to define STACK_TOP, and with MMU it must be below | ||
93 | * kernel base to select the correct PGD when handling MMU exceptions. | ||
94 | */ | ||
95 | # define TASK_SIZE (CONFIG_KERNEL_START) | ||
96 | |||
97 | /* | ||
98 | * This decides where the kernel will search for a free chunk of vm | ||
99 | * space during mmap's. | ||
100 | */ | ||
101 | # define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3) | ||
102 | |||
103 | # define THREAD_KSP 0 | ||
104 | |||
105 | # ifndef __ASSEMBLY__ | ||
106 | |||
107 | /* | ||
108 | * Default implementation of macro that returns current | ||
109 | * instruction pointer ("program counter"). | ||
110 | */ | ||
111 | # define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
112 | |||
113 | /* If you change this, you must change the associated assembly-languages | ||
114 | * constants defined below, THREAD_*. | ||
115 | */ | ||
116 | struct thread_struct { | ||
117 | /* kernel stack pointer (must be first field in structure) */ | ||
118 | unsigned long ksp; | ||
119 | unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */ | ||
120 | void *pgdir; /* root of page-table tree */ | ||
121 | struct pt_regs *regs; /* Pointer to saved register state */ | ||
122 | }; | ||
123 | |||
124 | # define INIT_THREAD { \ | ||
125 | .ksp = sizeof init_stack + (unsigned long)init_stack, \ | ||
126 | .pgdir = swapper_pg_dir, \ | ||
127 | } | ||
128 | |||
129 | /* Do necessary setup to start up a newly executed thread. */ | ||
130 | void start_thread(struct pt_regs *regs, | ||
131 | unsigned long pc, unsigned long usp); | ||
132 | |||
133 | /* Free all resources held by a thread. */ | ||
134 | extern inline void release_thread(struct task_struct *dead_task) | ||
135 | { | ||
136 | } | ||
137 | |||
138 | extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); | ||
139 | |||
140 | /* Free current thread data structures etc. */ | ||
141 | static inline void exit_thread(void) | ||
142 | { | ||
143 | } | ||
144 | |||
145 | /* Return saved (kernel) PC of a blocked thread. */ | ||
146 | # define thread_saved_pc(tsk) \ | ||
147 | ((tsk)->thread.regs ? (tsk)->thread.regs->r15 : 0) | ||
148 | |||
149 | unsigned long get_wchan(struct task_struct *p); | ||
150 | |||
151 | /* The size allocated for kernel stacks. This _must_ be a power of two! */ | ||
152 | # define KERNEL_STACK_SIZE 0x2000 | ||
153 | |||
154 | /* Return some info about the user process TASK. */ | ||
155 | # define task_tos(task) ((unsigned long)(task) + KERNEL_STACK_SIZE) | ||
156 | # define task_regs(task) ((struct pt_regs *)task_tos(task) - 1) | ||
157 | |||
158 | # define task_pt_regs_plus_args(tsk) \ | ||
159 | (((void *)task_pt_regs(tsk)) - STATE_SAVE_ARG_SPACE) | ||
160 | |||
161 | # define task_sp(task) (task_regs(task)->r1) | ||
162 | # define task_pc(task) (task_regs(task)->pc) | ||
163 | /* Grotty old names for some. */ | ||
164 | # define KSTK_EIP(task) (task_pc(task)) | ||
165 | # define KSTK_ESP(task) (task_sp(task)) | ||
166 | |||
167 | /* FIXME */ | ||
168 | # define deactivate_mm(tsk, mm) do { } while (0) | ||
169 | |||
170 | # define STACK_TOP TASK_SIZE | ||
171 | # define STACK_TOP_MAX STACK_TOP | ||
172 | |||
173 | # endif /* __ASSEMBLY__ */ | ||
174 | # endif /* CONFIG_MMU */ | ||
88 | #endif /* _ASM_MICROBLAZE_PROCESSOR_H */ | 175 | #endif /* _ASM_MICROBLAZE_PROCESSOR_H */ |
diff --git a/arch/microblaze/include/asm/registers.h b/arch/microblaze/include/asm/registers.h index 834142d9356f..68c3afb73877 100644 --- a/arch/microblaze/include/asm/registers.h +++ b/arch/microblaze/include/asm/registers.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2008 Michal Simek | 2 | * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> |
3 | * Copyright (C) 2008 PetaLogix | 3 | * Copyright (C) 2008-2009 PetaLogix |
4 | * Copyright (C) 2006 Atmark Techno, Inc. | 4 | * Copyright (C) 2006 Atmark Techno, Inc. |
5 | * | 5 | * |
6 | * This file is subject to the terms and conditions of the GNU General Public | 6 | * This file is subject to the terms and conditions of the GNU General Public |
@@ -30,4 +30,21 @@ | |||
30 | #define FSR_UF (1<<1) /* Underflow */ | 30 | #define FSR_UF (1<<1) /* Underflow */ |
31 | #define FSR_DO (1<<0) /* Denormalized operand error */ | 31 | #define FSR_DO (1<<0) /* Denormalized operand error */ |
32 | 32 | ||
33 | # ifdef CONFIG_MMU | ||
34 | /* Machine State Register (MSR) Fields */ | ||
35 | # define MSR_UM (1<<11) /* User Mode */ | ||
36 | # define MSR_UMS (1<<12) /* User Mode Save */ | ||
37 | # define MSR_VM (1<<13) /* Virtual Mode */ | ||
38 | # define MSR_VMS (1<<14) /* Virtual Mode Save */ | ||
39 | |||
40 | # define MSR_KERNEL (MSR_EE | MSR_VM) | ||
41 | /* # define MSR_USER (MSR_KERNEL | MSR_UM | MSR_IE) */ | ||
42 | # define MSR_KERNEL_VMS (MSR_EE | MSR_VMS) | ||
43 | /* # define MSR_USER_VMS (MSR_KERNEL_VMS | MSR_UMS | MSR_IE) */ | ||
44 | |||
45 | /* Exception State Register (ESR) Fields */ | ||
46 | # define ESR_DIZ (1<<11) /* Zone Protection */ | ||
47 | # define ESR_S (1<<10) /* Store instruction */ | ||
48 | |||
49 | # endif /* CONFIG_MMU */ | ||
33 | #endif /* _ASM_MICROBLAZE_REGISTERS_H */ | 50 | #endif /* _ASM_MICROBLAZE_REGISTERS_H */ |
diff --git a/arch/microblaze/include/asm/segment.h b/arch/microblaze/include/asm/segment.h index 7f5dcc56eea1..0e7102c3fb11 100644 --- a/arch/microblaze/include/asm/segment.h +++ b/arch/microblaze/include/asm/segment.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2008 Michal Simek | 2 | * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> |
3 | * Copyright (C) 2008 PetaLogix | 3 | * Copyright (C) 2008-2009 PetaLogix |
4 | * Copyright (C) 2006 Atmark Techno, Inc. | 4 | * Copyright (C) 2006 Atmark Techno, Inc. |
5 | * | 5 | * |
6 | * This file is subject to the terms and conditions of the GNU General Public | 6 | * This file is subject to the terms and conditions of the GNU General Public |
@@ -11,7 +11,7 @@ | |||
11 | #ifndef _ASM_MICROBLAZE_SEGMENT_H | 11 | #ifndef _ASM_MICROBLAZE_SEGMENT_H |
12 | #define _ASM_MICROBLAZE_SEGMENT_H | 12 | #define _ASM_MICROBLAZE_SEGMENT_H |
13 | 13 | ||
14 | #ifndef __ASSEMBLY__ | 14 | # ifndef __ASSEMBLY__ |
15 | 15 | ||
16 | typedef struct { | 16 | typedef struct { |
17 | unsigned long seg; | 17 | unsigned long seg; |
@@ -29,15 +29,21 @@ typedef struct { | |||
29 | * | 29 | * |
30 | * For non-MMU arch like Microblaze, KERNEL_DS and USER_DS is equal. | 30 | * For non-MMU arch like Microblaze, KERNEL_DS and USER_DS is equal. |
31 | */ | 31 | */ |
32 | # define KERNEL_DS ((mm_segment_t){0}) | 32 | # define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) |
33 | |||
34 | # ifndef CONFIG_MMU | ||
35 | # define KERNEL_DS MAKE_MM_SEG(0) | ||
33 | # define USER_DS KERNEL_DS | 36 | # define USER_DS KERNEL_DS |
37 | # else | ||
38 | # define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF) | ||
39 | # define USER_DS MAKE_MM_SEG(TASK_SIZE - 1) | ||
40 | # endif | ||
34 | 41 | ||
35 | # define get_ds() (KERNEL_DS) | 42 | # define get_ds() (KERNEL_DS) |
36 | # define get_fs() (current_thread_info()->addr_limit) | 43 | # define get_fs() (current_thread_info()->addr_limit) |
37 | # define set_fs(x) \ | 44 | # define set_fs(val) (current_thread_info()->addr_limit = (val)) |
38 | do { current_thread_info()->addr_limit = (x); } while (0) | ||
39 | 45 | ||
40 | # define segment_eq(a, b) ((a).seg == (b).seg) | 46 | # define segment_eq(a, b) ((a).seg == (b).seg) |
41 | 47 | ||
42 | # endif /* __ASSEMBLY__ */ | 48 | # endif /* __ASSEMBLY__ */ |
43 | #endif /* _ASM_MICROBLAZE_SEGMENT_H */ | 49 | #endif /* _ASM_MICROBLAZE_SEGMENT_H */ |
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c index 685ad71ced50..00b12c6d5326 100644 --- a/arch/microblaze/kernel/process.c +++ b/arch/microblaze/kernel/process.c | |||
@@ -126,9 +126,54 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
126 | else | 126 | else |
127 | childregs->r1 = ((unsigned long) ti) + THREAD_SIZE; | 127 | childregs->r1 = ((unsigned long) ti) + THREAD_SIZE; |
128 | 128 | ||
129 | #ifndef CONFIG_MMU | ||
129 | memset(&ti->cpu_context, 0, sizeof(struct cpu_context)); | 130 | memset(&ti->cpu_context, 0, sizeof(struct cpu_context)); |
130 | ti->cpu_context.r1 = (unsigned long)childregs; | 131 | ti->cpu_context.r1 = (unsigned long)childregs; |
131 | ti->cpu_context.msr = (unsigned long)childregs->msr; | 132 | ti->cpu_context.msr = (unsigned long)childregs->msr; |
133 | #else | ||
134 | |||
135 | /* if creating a kernel thread then update the current reg (we don't | ||
136 | * want to use the parent's value when restoring by POP_STATE) */ | ||
137 | if (kernel_mode(regs)) | ||
138 | /* save new current on stack to use POP_STATE */ | ||
139 | childregs->CURRENT_TASK = (unsigned long)p; | ||
140 | /* if returning to user then use the parent's value of this register */ | ||
141 | |||
142 | /* if we're creating a new kernel thread then just zeroing all | ||
143 | * the registers. That's OK for a brand new thread.*/ | ||
144 | /* Pls. note that some of them will be restored in POP_STATE */ | ||
145 | if (kernel_mode(regs)) | ||
146 | memset(&ti->cpu_context, 0, sizeof(struct cpu_context)); | ||
147 | /* if this thread is created for fork/vfork/clone, then we want to | ||
148 | * restore all the parent's context */ | ||
149 | /* in addition to the registers which will be restored by POP_STATE */ | ||
150 | else { | ||
151 | ti->cpu_context = *(struct cpu_context *)regs; | ||
152 | childregs->msr |= MSR_UMS; | ||
153 | } | ||
154 | |||
155 | /* FIXME STATE_SAVE_PT_OFFSET; */ | ||
156 | ti->cpu_context.r1 = (unsigned long)childregs - STATE_SAVE_ARG_SPACE; | ||
157 | /* we should consider the fact that childregs is a copy of the parent | ||
158 | * regs which were saved immediately after entering the kernel state | ||
159 | * before enabling VM. This MSR will be restored in switch_to and | ||
160 | * RETURN() and we want to have the right machine state there | ||
161 | * specifically this state must have INTs disabled before and enabled | ||
162 | * after performing rtbd | ||
163 | * compose the right MSR for RETURN(). It will work for switch_to also | ||
164 | * excepting for VM and UMS | ||
165 | * don't touch UMS , CARRY and cache bits | ||
166 | * right now MSR is a copy of parent one */ | ||
167 | childregs->msr |= MSR_BIP; | ||
168 | childregs->msr &= ~MSR_EIP; | ||
169 | childregs->msr |= MSR_IE; | ||
170 | childregs->msr &= ~MSR_VM; | ||
171 | childregs->msr |= MSR_VMS; | ||
172 | childregs->msr |= MSR_EE; /* exceptions will be enabled*/ | ||
173 | |||
174 | ti->cpu_context.msr = (childregs->msr|MSR_VM); | ||
175 | ti->cpu_context.msr &= ~MSR_UMS; /* switch_to to kernel mode */ | ||
176 | #endif | ||
132 | ti->cpu_context.r15 = (unsigned long)ret_from_fork - 8; | 177 | ti->cpu_context.r15 = (unsigned long)ret_from_fork - 8; |
133 | 178 | ||
134 | if (clone_flags & CLONE_SETTLS) | 179 | if (clone_flags & CLONE_SETTLS) |
@@ -137,6 +182,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
137 | return 0; | 182 | return 0; |
138 | } | 183 | } |
139 | 184 | ||
185 | #ifndef CONFIG_MMU | ||
140 | /* | 186 | /* |
141 | * Return saved PC of a blocked thread. | 187 | * Return saved PC of a blocked thread. |
142 | */ | 188 | */ |
@@ -151,6 +197,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk) | |||
151 | else | 197 | else |
152 | return ctx->r14; | 198 | return ctx->r14; |
153 | } | 199 | } |
200 | #endif | ||
154 | 201 | ||
155 | static void kernel_thread_helper(int (*fn)(void *), void *arg) | 202 | static void kernel_thread_helper(int (*fn)(void *), void *arg) |
156 | { | 203 | { |
@@ -189,3 +236,14 @@ void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp) | |||
189 | regs->r1 = usp; | 236 | regs->r1 = usp; |
190 | regs->pt_mode = 0; | 237 | regs->pt_mode = 0; |
191 | } | 238 | } |
239 | |||
240 | #ifdef CONFIG_MMU | ||
241 | #include <linux/elfcore.h> | ||
242 | /* | ||
243 | * Set up a thread for executing a new program | ||
244 | */ | ||
245 | int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs) | ||
246 | { | ||
247 | return 0; /* MicroBlaze has no separate FPU registers */ | ||
248 | } | ||
249 | #endif /* CONFIG_MMU */ | ||