diff options
Diffstat (limited to 'arch/arm26/kernel/process.c')
| -rw-r--r-- | arch/arm26/kernel/process.c | 392 |
1 files changed, 0 insertions, 392 deletions
diff --git a/arch/arm26/kernel/process.c b/arch/arm26/kernel/process.c deleted file mode 100644 index dcd81e62ff4e..000000000000 --- a/arch/arm26/kernel/process.c +++ /dev/null | |||
| @@ -1,392 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * linux/arch/arm26/kernel/process.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 2003 Ian Molton - adapted for ARM26 | ||
| 5 | * Copyright (C) 1996-2000 Russell King - Converted to ARM. | ||
| 6 | * Origional Copyright (C) 1995 Linus Torvalds | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License version 2 as | ||
| 10 | * published by the Free Software Foundation. | ||
| 11 | */ | ||
| 12 | #include <stdarg.h> | ||
| 13 | |||
| 14 | #include <linux/module.h> | ||
| 15 | #include <linux/sched.h> | ||
| 16 | #include <linux/kernel.h> | ||
| 17 | #include <linux/mm.h> | ||
| 18 | #include <linux/stddef.h> | ||
| 19 | #include <linux/unistd.h> | ||
| 20 | #include <linux/ptrace.h> | ||
| 21 | #include <linux/slab.h> | ||
| 22 | #include <linux/user.h> | ||
| 23 | #include <linux/a.out.h> | ||
| 24 | #include <linux/delay.h> | ||
| 25 | #include <linux/reboot.h> | ||
| 26 | #include <linux/interrupt.h> | ||
| 27 | #include <linux/init.h> | ||
| 28 | |||
| 29 | #include <asm/system.h> | ||
| 30 | #include <asm/io.h> | ||
| 31 | #include <asm/leds.h> | ||
| 32 | #include <asm/processor.h> | ||
| 33 | #include <asm/uaccess.h> | ||
| 34 | |||
| 35 | extern const char *processor_modes[]; | ||
| 36 | extern void setup_mm_for_reboot(char mode); | ||
| 37 | |||
| 38 | static volatile int hlt_counter; | ||
| 39 | |||
| 40 | void disable_hlt(void) | ||
| 41 | { | ||
| 42 | hlt_counter++; | ||
| 43 | } | ||
| 44 | |||
| 45 | EXPORT_SYMBOL(disable_hlt); | ||
| 46 | |||
| 47 | void enable_hlt(void) | ||
| 48 | { | ||
| 49 | hlt_counter--; | ||
| 50 | } | ||
| 51 | |||
| 52 | EXPORT_SYMBOL(enable_hlt); | ||
| 53 | |||
| 54 | static int __init nohlt_setup(char *__unused) | ||
| 55 | { | ||
| 56 | hlt_counter = 1; | ||
| 57 | return 1; | ||
| 58 | } | ||
| 59 | |||
| 60 | static int __init hlt_setup(char *__unused) | ||
| 61 | { | ||
| 62 | hlt_counter = 0; | ||
| 63 | return 1; | ||
| 64 | } | ||
| 65 | |||
| 66 | __setup("nohlt", nohlt_setup); | ||
| 67 | __setup("hlt", hlt_setup); | ||
| 68 | |||
| 69 | /* | ||
| 70 | * This is our default idle handler. We need to disable | ||
| 71 | * interrupts here to ensure we don't miss a wakeup call. | ||
| 72 | */ | ||
| 73 | void cpu_idle(void) | ||
| 74 | { | ||
| 75 | /* endless idle loop with no priority at all */ | ||
| 76 | while (1) { | ||
| 77 | while (!need_resched()) | ||
| 78 | cpu_relax(); | ||
| 79 | preempt_enable_no_resched(); | ||
| 80 | schedule(); | ||
| 81 | preempt_disable(); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | static char reboot_mode = 'h'; | ||
| 86 | |||
| 87 | int __init reboot_setup(char *str) | ||
| 88 | { | ||
| 89 | reboot_mode = str[0]; | ||
| 90 | return 1; | ||
| 91 | } | ||
| 92 | |||
| 93 | __setup("reboot=", reboot_setup); | ||
| 94 | |||
| 95 | /* ARM26 cant do these but we still need to define them. */ | ||
| 96 | void machine_halt(void) | ||
| 97 | { | ||
| 98 | } | ||
| 99 | void machine_power_off(void) | ||
| 100 | { | ||
| 101 | } | ||
| 102 | |||
| 103 | void machine_restart(char * __unused) | ||
| 104 | { | ||
| 105 | /* | ||
| 106 | * Clean and disable cache, and turn off interrupts | ||
| 107 | */ | ||
| 108 | cpu_proc_fin(); | ||
| 109 | |||
| 110 | /* | ||
| 111 | * Tell the mm system that we are going to reboot - | ||
| 112 | * we may need it to insert some 1:1 mappings so that | ||
| 113 | * soft boot works. | ||
| 114 | */ | ||
| 115 | setup_mm_for_reboot(reboot_mode); | ||
| 116 | |||
| 117 | /* | ||
| 118 | * copy branch instruction to reset location and call it | ||
| 119 | */ | ||
| 120 | |||
| 121 | *(unsigned long *)0 = *(unsigned long *)0x03800000; | ||
| 122 | ((void(*)(void))0)(); | ||
| 123 | |||
| 124 | /* | ||
| 125 | * Whoops - the architecture was unable to reboot. | ||
| 126 | * Tell the user! Should never happen... | ||
| 127 | */ | ||
| 128 | mdelay(1000); | ||
| 129 | printk("Reboot failed -- System halted\n"); | ||
| 130 | while (1); | ||
| 131 | } | ||
| 132 | |||
| 133 | void show_regs(struct pt_regs * regs) | ||
| 134 | { | ||
| 135 | unsigned long flags; | ||
| 136 | |||
| 137 | flags = condition_codes(regs); | ||
| 138 | |||
| 139 | printk("pc : [<%08lx>] lr : [<%08lx>] %s\n" | ||
| 140 | "sp : %08lx ip : %08lx fp : %08lx\n", | ||
| 141 | instruction_pointer(regs), | ||
| 142 | regs->ARM_lr, print_tainted(), regs->ARM_sp, | ||
| 143 | regs->ARM_ip, regs->ARM_fp); | ||
| 144 | printk("r10: %08lx r9 : %08lx r8 : %08lx\n", | ||
| 145 | regs->ARM_r10, regs->ARM_r9, | ||
| 146 | regs->ARM_r8); | ||
| 147 | printk("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n", | ||
| 148 | regs->ARM_r7, regs->ARM_r6, | ||
| 149 | regs->ARM_r5, regs->ARM_r4); | ||
| 150 | printk("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n", | ||
| 151 | regs->ARM_r3, regs->ARM_r2, | ||
| 152 | regs->ARM_r1, regs->ARM_r0); | ||
| 153 | printk("Flags: %c%c%c%c", | ||
| 154 | flags & PSR_N_BIT ? 'N' : 'n', | ||
| 155 | flags & PSR_Z_BIT ? 'Z' : 'z', | ||
| 156 | flags & PSR_C_BIT ? 'C' : 'c', | ||
| 157 | flags & PSR_V_BIT ? 'V' : 'v'); | ||
| 158 | printk(" IRQs o%s FIQs o%s Mode %s Segment %s\n", | ||
| 159 | interrupts_enabled(regs) ? "n" : "ff", | ||
| 160 | fast_interrupts_enabled(regs) ? "n" : "ff", | ||
| 161 | processor_modes[processor_mode(regs)], | ||
| 162 | get_fs() == get_ds() ? "kernel" : "user"); | ||
| 163 | } | ||
| 164 | |||
| 165 | void show_fpregs(struct user_fp *regs) | ||
| 166 | { | ||
| 167 | int i; | ||
| 168 | |||
| 169 | for (i = 0; i < 8; i++) { | ||
| 170 | unsigned long *p; | ||
| 171 | char type; | ||
| 172 | |||
| 173 | p = (unsigned long *)(regs->fpregs + i); | ||
| 174 | |||
| 175 | switch (regs->ftype[i]) { | ||
| 176 | case 1: type = 'f'; break; | ||
| 177 | case 2: type = 'd'; break; | ||
| 178 | case 3: type = 'e'; break; | ||
| 179 | default: type = '?'; break; | ||
| 180 | } | ||
| 181 | if (regs->init_flag) | ||
| 182 | type = '?'; | ||
| 183 | |||
| 184 | printk(" f%d(%c): %08lx %08lx %08lx%c", | ||
| 185 | i, type, p[0], p[1], p[2], i & 1 ? '\n' : ' '); | ||
| 186 | } | ||
| 187 | |||
| 188 | |||
| 189 | printk("FPSR: %08lx FPCR: %08lx\n", | ||
| 190 | (unsigned long)regs->fpsr, | ||
| 191 | (unsigned long)regs->fpcr); | ||
| 192 | } | ||
| 193 | |||
| 194 | /* | ||
| 195 | * Task structure and kernel stack allocation. | ||
| 196 | */ | ||
| 197 | static unsigned long *thread_info_head; | ||
| 198 | static unsigned int nr_thread_info; | ||
| 199 | |||
| 200 | extern unsigned long get_page_8k(int priority); | ||
| 201 | extern void free_page_8k(unsigned long page); | ||
| 202 | |||
| 203 | // FIXME - is this valid? | ||
| 204 | #define EXTRA_TASK_STRUCT 0 | ||
| 205 | #define ll_alloc_task_struct() ((struct thread_info *)get_page_8k(GFP_KERNEL)) | ||
| 206 | #define ll_free_task_struct(p) free_page_8k((unsigned long)(p)) | ||
| 207 | |||
| 208 | //FIXME - do we use *task param below looks like we dont, which is ok? | ||
| 209 | //FIXME - if EXTRA_TASK_STRUCT is zero we can optimise the below away permanently. *IF* its supposed to be zero. | ||
| 210 | struct thread_info *alloc_thread_info(struct task_struct *task) | ||
| 211 | { | ||
| 212 | struct thread_info *thread = NULL; | ||
| 213 | |||
| 214 | if (EXTRA_TASK_STRUCT) { | ||
| 215 | unsigned long *p = thread_info_head; | ||
| 216 | |||
| 217 | if (p) { | ||
| 218 | thread_info_head = (unsigned long *)p[0]; | ||
| 219 | nr_thread_info -= 1; | ||
| 220 | } | ||
| 221 | thread = (struct thread_info *)p; | ||
| 222 | } | ||
| 223 | |||
| 224 | if (!thread) | ||
| 225 | thread = ll_alloc_task_struct(); | ||
| 226 | |||
| 227 | #ifdef CONFIG_MAGIC_SYSRQ | ||
| 228 | /* | ||
| 229 | * The stack must be cleared if you want SYSRQ-T to | ||
| 230 | * give sensible stack usage information | ||
| 231 | */ | ||
| 232 | if (thread) { | ||
| 233 | char *p = (char *)thread; | ||
| 234 | memzero(p+KERNEL_STACK_SIZE, KERNEL_STACK_SIZE); | ||
| 235 | } | ||
| 236 | #endif | ||
| 237 | return thread; | ||
| 238 | } | ||
| 239 | |||
| 240 | void free_thread_info(struct thread_info *thread) | ||
| 241 | { | ||
| 242 | if (EXTRA_TASK_STRUCT && nr_thread_info < EXTRA_TASK_STRUCT) { | ||
| 243 | unsigned long *p = (unsigned long *)thread; | ||
| 244 | p[0] = (unsigned long)thread_info_head; | ||
| 245 | thread_info_head = p; | ||
| 246 | nr_thread_info += 1; | ||
| 247 | } else | ||
| 248 | ll_free_task_struct(thread); | ||
| 249 | } | ||
| 250 | |||
| 251 | /* | ||
| 252 | * Free current thread data structures etc.. | ||
| 253 | */ | ||
| 254 | void exit_thread(void) | ||
| 255 | { | ||
| 256 | } | ||
| 257 | |||
| 258 | void flush_thread(void) | ||
| 259 | { | ||
| 260 | struct thread_info *thread = current_thread_info(); | ||
| 261 | struct task_struct *tsk = current; | ||
| 262 | |||
| 263 | memset(&tsk->thread.debug, 0, sizeof(struct debug_info)); | ||
| 264 | memset(&thread->fpstate, 0, sizeof(union fp_state)); | ||
| 265 | |||
| 266 | clear_used_math(); | ||
| 267 | } | ||
| 268 | |||
| 269 | void release_thread(struct task_struct *dead_task) | ||
| 270 | { | ||
| 271 | } | ||
| 272 | |||
| 273 | asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); | ||
| 274 | |||
| 275 | int | ||
| 276 | copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start, | ||
| 277 | unsigned long unused, struct task_struct *p, struct pt_regs *regs) | ||
| 278 | { | ||
| 279 | struct thread_info *thread = task_thread_info(p); | ||
| 280 | struct pt_regs *childregs = task_pt_regs(p); | ||
| 281 | |||
| 282 | *childregs = *regs; | ||
| 283 | childregs->ARM_r0 = 0; | ||
| 284 | childregs->ARM_sp = stack_start; | ||
| 285 | |||
| 286 | memset(&thread->cpu_context, 0, sizeof(struct cpu_context_save)); | ||
| 287 | thread->cpu_context.sp = (unsigned long)childregs; | ||
| 288 | thread->cpu_context.pc = (unsigned long)ret_from_fork | MODE_SVC26 | PSR_I_BIT; | ||
| 289 | |||
| 290 | return 0; | ||
| 291 | } | ||
| 292 | |||
| 293 | /* | ||
| 294 | * fill in the fpe structure for a core dump... | ||
| 295 | */ | ||
| 296 | int dump_fpu (struct pt_regs *regs, struct user_fp *fp) | ||
| 297 | { | ||
| 298 | struct thread_info *thread = current_thread_info(); | ||
| 299 | int used_math = !!used_math(); | ||
| 300 | |||
| 301 | if (used_math) | ||
| 302 | memcpy(fp, &thread->fpstate.soft, sizeof (*fp)); | ||
| 303 | |||
| 304 | return used_math; | ||
| 305 | } | ||
| 306 | |||
| 307 | /* | ||
| 308 | * fill in the user structure for a core dump.. | ||
| 309 | */ | ||
| 310 | void dump_thread(struct pt_regs * regs, struct user * dump) | ||
| 311 | { | ||
| 312 | struct task_struct *tsk = current; | ||
| 313 | |||
| 314 | dump->magic = CMAGIC; | ||
| 315 | dump->start_code = tsk->mm->start_code; | ||
| 316 | dump->start_stack = regs->ARM_sp & ~(PAGE_SIZE - 1); | ||
| 317 | |||
| 318 | dump->u_tsize = (tsk->mm->end_code - tsk->mm->start_code) >> PAGE_SHIFT; | ||
| 319 | dump->u_dsize = (tsk->mm->brk - tsk->mm->start_data + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
| 320 | dump->u_ssize = 0; | ||
| 321 | |||
| 322 | dump->u_debugreg[0] = tsk->thread.debug.bp[0].address; | ||
| 323 | dump->u_debugreg[1] = tsk->thread.debug.bp[1].address; | ||
| 324 | dump->u_debugreg[2] = tsk->thread.debug.bp[0].insn; | ||
| 325 | dump->u_debugreg[3] = tsk->thread.debug.bp[1].insn; | ||
| 326 | dump->u_debugreg[4] = tsk->thread.debug.nsaved; | ||
| 327 | |||
| 328 | if (dump->start_stack < 0x04000000) | ||
| 329 | dump->u_ssize = (0x04000000 - dump->start_stack) >> PAGE_SHIFT; | ||
| 330 | |||
| 331 | dump->regs = *regs; | ||
| 332 | dump->u_fpvalid = dump_fpu (regs, &dump->u_fp); | ||
| 333 | } | ||
| 334 | |||
| 335 | /* | ||
| 336 | * Shuffle the argument into the correct register before calling the | ||
| 337 | * thread function. r1 is the thread argument, r2 is the pointer to | ||
| 338 | * the thread function, and r3 points to the exit function. | ||
| 339 | * FIXME - make sure this is right - the older code used to zero fp | ||
| 340 | * and cause the parent to call sys_exit (do_exit in this version) | ||
| 341 | */ | ||
| 342 | extern void kernel_thread_helper(void); | ||
| 343 | |||
| 344 | asm( ".section .text\n" | ||
| 345 | " .align\n" | ||
| 346 | " .type kernel_thread_helper, #function\n" | ||
| 347 | "kernel_thread_helper:\n" | ||
| 348 | " mov r0, r1\n" | ||
| 349 | " mov lr, r3\n" | ||
| 350 | " mov pc, r2\n" | ||
| 351 | " .size kernel_thread_helper, . - kernel_thread_helper\n" | ||
| 352 | " .previous"); | ||
| 353 | |||
| 354 | /* | ||
| 355 | * Create a kernel thread. | ||
| 356 | */ | ||
| 357 | pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) | ||
| 358 | { | ||
| 359 | struct pt_regs regs; | ||
| 360 | |||
| 361 | memset(®s, 0, sizeof(regs)); | ||
| 362 | |||
| 363 | regs.ARM_r1 = (unsigned long)arg; | ||
| 364 | regs.ARM_r2 = (unsigned long)fn; | ||
| 365 | regs.ARM_r3 = (unsigned long)do_exit; | ||
| 366 | regs.ARM_pc = (unsigned long)kernel_thread_helper | MODE_SVC26; | ||
| 367 | |||
| 368 | return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL); | ||
| 369 | } | ||
| 370 | EXPORT_SYMBOL(kernel_thread); | ||
| 371 | |||
| 372 | |||
| 373 | unsigned long get_wchan(struct task_struct *p) | ||
| 374 | { | ||
| 375 | unsigned long fp, lr; | ||
| 376 | unsigned long stack_page; | ||
| 377 | int count = 0; | ||
| 378 | if (!p || p == current || p->state == TASK_RUNNING) | ||
| 379 | return 0; | ||
| 380 | |||
| 381 | stack_page = 4096 + (unsigned long)p; | ||
| 382 | fp = thread_saved_fp(p); | ||
| 383 | do { | ||
| 384 | if (fp < stack_page || fp > 4092+stack_page) | ||
| 385 | return 0; | ||
| 386 | lr = pc_pointer (((unsigned long *)fp)[-1]); | ||
| 387 | if (!in_sched_functions(lr)) | ||
| 388 | return lr; | ||
| 389 | fp = *(unsigned long *) (fp - 12); | ||
| 390 | } while (count ++ < 16); | ||
| 391 | return 0; | ||
| 392 | } | ||
