diff options
author | Michal Simek <monstr@monstr.eu> | 2009-05-26 10:30:18 -0400 |
---|---|---|
committer | Michal Simek <monstr@monstr.eu> | 2009-05-26 10:45:18 -0400 |
commit | 5233806dfe6f88fb1a01db3729eeda78f65bcbd1 (patch) | |
tree | e96b2391809812b521f141b6a2ed6f3d7407db34 /arch/microblaze/include/asm | |
parent | 1f84e1ea0e87ad659cd6f6a6285d50c73a8d1a24 (diff) |
microblaze_mmu_v2: Update process creation for MMU
Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/microblaze/include/asm')
-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 |
3 files changed, 123 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 */ |