OMAP: DISPC: Fix to disable also interface clocks. 2nd.
[linux-ginger.git] / arch / sh / kernel / process_64.c
blob0283d8133075b0507d04d5ca5417a3a6c1425017
1 /*
2 * arch/sh/kernel/process_64.c
4 * This file handles the architecture-dependent parts of process handling..
6 * Copyright (C) 2000, 2001 Paolo Alberelli
7 * Copyright (C) 2003 - 2007 Paul Mundt
8 * Copyright (C) 2003, 2004 Richard Curnow
10 * Started from SH3/4 version:
11 * Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
13 * In turn started from i386 version:
14 * Copyright (C) 1995 Linus Torvalds
16 * This file is subject to the terms and conditions of the GNU General Public
17 * License. See the file "COPYING" in the main directory of this archive
18 * for more details.
20 #include <linux/mm.h>
21 #include <linux/fs.h>
22 #include <linux/ptrace.h>
23 #include <linux/reboot.h>
24 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/proc_fs.h>
27 #include <linux/io.h>
28 #include <asm/uaccess.h>
29 #include <asm/pgtable.h>
30 #include <asm/mmu_context.h>
31 #include <asm/fpu.h>
33 struct task_struct *last_task_used_math = NULL;
35 static int hlt_counter = 1;
37 #define HARD_IDLE_TIMEOUT (HZ / 3)
39 void disable_hlt(void)
41 hlt_counter++;
44 void enable_hlt(void)
46 hlt_counter--;
49 static int __init nohlt_setup(char *__unused)
51 hlt_counter = 1;
52 return 1;
55 static int __init hlt_setup(char *__unused)
57 hlt_counter = 0;
58 return 1;
61 __setup("nohlt", nohlt_setup);
62 __setup("hlt", hlt_setup);
64 static inline void hlt(void)
66 __asm__ __volatile__ ("sleep" : : : "memory");
70 * The idle loop on a uniprocessor SH..
72 void cpu_idle(void)
74 /* endless idle loop with no priority at all */
75 while (1) {
76 if (hlt_counter) {
77 while (!need_resched())
78 cpu_relax();
79 } else {
80 local_irq_disable();
81 while (!need_resched()) {
82 local_irq_enable();
83 hlt();
84 local_irq_disable();
86 local_irq_enable();
88 preempt_enable_no_resched();
89 schedule();
90 preempt_disable();
95 void machine_restart(char * __unused)
97 extern void phys_stext(void);
99 phys_stext();
102 void machine_halt(void)
104 for (;;);
107 void machine_power_off(void)
109 #if 0
110 /* Disable watchdog timer */
111 ctrl_outl(0xa5000000, WTCSR);
112 /* Configure deep standby on sleep */
113 ctrl_outl(0x03, STBCR);
114 #endif
116 __asm__ __volatile__ (
117 "sleep\n\t"
118 "synci\n\t"
119 "nop;nop;nop;nop\n\t"
122 panic("Unexpected wakeup!\n");
125 void (*pm_power_off)(void) = machine_power_off;
126 EXPORT_SYMBOL(pm_power_off);
128 void show_regs(struct pt_regs * regs)
130 unsigned long long ah, al, bh, bl, ch, cl;
132 printk("\n");
134 ah = (regs->pc) >> 32;
135 al = (regs->pc) & 0xffffffff;
136 bh = (regs->regs[18]) >> 32;
137 bl = (regs->regs[18]) & 0xffffffff;
138 ch = (regs->regs[15]) >> 32;
139 cl = (regs->regs[15]) & 0xffffffff;
140 printk("PC : %08Lx%08Lx LINK: %08Lx%08Lx SP : %08Lx%08Lx\n",
141 ah, al, bh, bl, ch, cl);
143 ah = (regs->sr) >> 32;
144 al = (regs->sr) & 0xffffffff;
145 asm volatile ("getcon " __TEA ", %0" : "=r" (bh));
146 asm volatile ("getcon " __TEA ", %0" : "=r" (bl));
147 bh = (bh) >> 32;
148 bl = (bl) & 0xffffffff;
149 asm volatile ("getcon " __KCR0 ", %0" : "=r" (ch));
150 asm volatile ("getcon " __KCR0 ", %0" : "=r" (cl));
151 ch = (ch) >> 32;
152 cl = (cl) & 0xffffffff;
153 printk("SR : %08Lx%08Lx TEA : %08Lx%08Lx KCR0: %08Lx%08Lx\n",
154 ah, al, bh, bl, ch, cl);
156 ah = (regs->regs[0]) >> 32;
157 al = (regs->regs[0]) & 0xffffffff;
158 bh = (regs->regs[1]) >> 32;
159 bl = (regs->regs[1]) & 0xffffffff;
160 ch = (regs->regs[2]) >> 32;
161 cl = (regs->regs[2]) & 0xffffffff;
162 printk("R0 : %08Lx%08Lx R1 : %08Lx%08Lx R2 : %08Lx%08Lx\n",
163 ah, al, bh, bl, ch, cl);
165 ah = (regs->regs[3]) >> 32;
166 al = (regs->regs[3]) & 0xffffffff;
167 bh = (regs->regs[4]) >> 32;
168 bl = (regs->regs[4]) & 0xffffffff;
169 ch = (regs->regs[5]) >> 32;
170 cl = (regs->regs[5]) & 0xffffffff;
171 printk("R3 : %08Lx%08Lx R4 : %08Lx%08Lx R5 : %08Lx%08Lx\n",
172 ah, al, bh, bl, ch, cl);
174 ah = (regs->regs[6]) >> 32;
175 al = (regs->regs[6]) & 0xffffffff;
176 bh = (regs->regs[7]) >> 32;
177 bl = (regs->regs[7]) & 0xffffffff;
178 ch = (regs->regs[8]) >> 32;
179 cl = (regs->regs[8]) & 0xffffffff;
180 printk("R6 : %08Lx%08Lx R7 : %08Lx%08Lx R8 : %08Lx%08Lx\n",
181 ah, al, bh, bl, ch, cl);
183 ah = (regs->regs[9]) >> 32;
184 al = (regs->regs[9]) & 0xffffffff;
185 bh = (regs->regs[10]) >> 32;
186 bl = (regs->regs[10]) & 0xffffffff;
187 ch = (regs->regs[11]) >> 32;
188 cl = (regs->regs[11]) & 0xffffffff;
189 printk("R9 : %08Lx%08Lx R10 : %08Lx%08Lx R11 : %08Lx%08Lx\n",
190 ah, al, bh, bl, ch, cl);
192 ah = (regs->regs[12]) >> 32;
193 al = (regs->regs[12]) & 0xffffffff;
194 bh = (regs->regs[13]) >> 32;
195 bl = (regs->regs[13]) & 0xffffffff;
196 ch = (regs->regs[14]) >> 32;
197 cl = (regs->regs[14]) & 0xffffffff;
198 printk("R12 : %08Lx%08Lx R13 : %08Lx%08Lx R14 : %08Lx%08Lx\n",
199 ah, al, bh, bl, ch, cl);
201 ah = (regs->regs[16]) >> 32;
202 al = (regs->regs[16]) & 0xffffffff;
203 bh = (regs->regs[17]) >> 32;
204 bl = (regs->regs[17]) & 0xffffffff;
205 ch = (regs->regs[19]) >> 32;
206 cl = (regs->regs[19]) & 0xffffffff;
207 printk("R16 : %08Lx%08Lx R17 : %08Lx%08Lx R19 : %08Lx%08Lx\n",
208 ah, al, bh, bl, ch, cl);
210 ah = (regs->regs[20]) >> 32;
211 al = (regs->regs[20]) & 0xffffffff;
212 bh = (regs->regs[21]) >> 32;
213 bl = (regs->regs[21]) & 0xffffffff;
214 ch = (regs->regs[22]) >> 32;
215 cl = (regs->regs[22]) & 0xffffffff;
216 printk("R20 : %08Lx%08Lx R21 : %08Lx%08Lx R22 : %08Lx%08Lx\n",
217 ah, al, bh, bl, ch, cl);
219 ah = (regs->regs[23]) >> 32;
220 al = (regs->regs[23]) & 0xffffffff;
221 bh = (regs->regs[24]) >> 32;
222 bl = (regs->regs[24]) & 0xffffffff;
223 ch = (regs->regs[25]) >> 32;
224 cl = (regs->regs[25]) & 0xffffffff;
225 printk("R23 : %08Lx%08Lx R24 : %08Lx%08Lx R25 : %08Lx%08Lx\n",
226 ah, al, bh, bl, ch, cl);
228 ah = (regs->regs[26]) >> 32;
229 al = (regs->regs[26]) & 0xffffffff;
230 bh = (regs->regs[27]) >> 32;
231 bl = (regs->regs[27]) & 0xffffffff;
232 ch = (regs->regs[28]) >> 32;
233 cl = (regs->regs[28]) & 0xffffffff;
234 printk("R26 : %08Lx%08Lx R27 : %08Lx%08Lx R28 : %08Lx%08Lx\n",
235 ah, al, bh, bl, ch, cl);
237 ah = (regs->regs[29]) >> 32;
238 al = (regs->regs[29]) & 0xffffffff;
239 bh = (regs->regs[30]) >> 32;
240 bl = (regs->regs[30]) & 0xffffffff;
241 ch = (regs->regs[31]) >> 32;
242 cl = (regs->regs[31]) & 0xffffffff;
243 printk("R29 : %08Lx%08Lx R30 : %08Lx%08Lx R31 : %08Lx%08Lx\n",
244 ah, al, bh, bl, ch, cl);
246 ah = (regs->regs[32]) >> 32;
247 al = (regs->regs[32]) & 0xffffffff;
248 bh = (regs->regs[33]) >> 32;
249 bl = (regs->regs[33]) & 0xffffffff;
250 ch = (regs->regs[34]) >> 32;
251 cl = (regs->regs[34]) & 0xffffffff;
252 printk("R32 : %08Lx%08Lx R33 : %08Lx%08Lx R34 : %08Lx%08Lx\n",
253 ah, al, bh, bl, ch, cl);
255 ah = (regs->regs[35]) >> 32;
256 al = (regs->regs[35]) & 0xffffffff;
257 bh = (regs->regs[36]) >> 32;
258 bl = (regs->regs[36]) & 0xffffffff;
259 ch = (regs->regs[37]) >> 32;
260 cl = (regs->regs[37]) & 0xffffffff;
261 printk("R35 : %08Lx%08Lx R36 : %08Lx%08Lx R37 : %08Lx%08Lx\n",
262 ah, al, bh, bl, ch, cl);
264 ah = (regs->regs[38]) >> 32;
265 al = (regs->regs[38]) & 0xffffffff;
266 bh = (regs->regs[39]) >> 32;
267 bl = (regs->regs[39]) & 0xffffffff;
268 ch = (regs->regs[40]) >> 32;
269 cl = (regs->regs[40]) & 0xffffffff;
270 printk("R38 : %08Lx%08Lx R39 : %08Lx%08Lx R40 : %08Lx%08Lx\n",
271 ah, al, bh, bl, ch, cl);
273 ah = (regs->regs[41]) >> 32;
274 al = (regs->regs[41]) & 0xffffffff;
275 bh = (regs->regs[42]) >> 32;
276 bl = (regs->regs[42]) & 0xffffffff;
277 ch = (regs->regs[43]) >> 32;
278 cl = (regs->regs[43]) & 0xffffffff;
279 printk("R41 : %08Lx%08Lx R42 : %08Lx%08Lx R43 : %08Lx%08Lx\n",
280 ah, al, bh, bl, ch, cl);
282 ah = (regs->regs[44]) >> 32;
283 al = (regs->regs[44]) & 0xffffffff;
284 bh = (regs->regs[45]) >> 32;
285 bl = (regs->regs[45]) & 0xffffffff;
286 ch = (regs->regs[46]) >> 32;
287 cl = (regs->regs[46]) & 0xffffffff;
288 printk("R44 : %08Lx%08Lx R45 : %08Lx%08Lx R46 : %08Lx%08Lx\n",
289 ah, al, bh, bl, ch, cl);
291 ah = (regs->regs[47]) >> 32;
292 al = (regs->regs[47]) & 0xffffffff;
293 bh = (regs->regs[48]) >> 32;
294 bl = (regs->regs[48]) & 0xffffffff;
295 ch = (regs->regs[49]) >> 32;
296 cl = (regs->regs[49]) & 0xffffffff;
297 printk("R47 : %08Lx%08Lx R48 : %08Lx%08Lx R49 : %08Lx%08Lx\n",
298 ah, al, bh, bl, ch, cl);
300 ah = (regs->regs[50]) >> 32;
301 al = (regs->regs[50]) & 0xffffffff;
302 bh = (regs->regs[51]) >> 32;
303 bl = (regs->regs[51]) & 0xffffffff;
304 ch = (regs->regs[52]) >> 32;
305 cl = (regs->regs[52]) & 0xffffffff;
306 printk("R50 : %08Lx%08Lx R51 : %08Lx%08Lx R52 : %08Lx%08Lx\n",
307 ah, al, bh, bl, ch, cl);
309 ah = (regs->regs[53]) >> 32;
310 al = (regs->regs[53]) & 0xffffffff;
311 bh = (regs->regs[54]) >> 32;
312 bl = (regs->regs[54]) & 0xffffffff;
313 ch = (regs->regs[55]) >> 32;
314 cl = (regs->regs[55]) & 0xffffffff;
315 printk("R53 : %08Lx%08Lx R54 : %08Lx%08Lx R55 : %08Lx%08Lx\n",
316 ah, al, bh, bl, ch, cl);
318 ah = (regs->regs[56]) >> 32;
319 al = (regs->regs[56]) & 0xffffffff;
320 bh = (regs->regs[57]) >> 32;
321 bl = (regs->regs[57]) & 0xffffffff;
322 ch = (regs->regs[58]) >> 32;
323 cl = (regs->regs[58]) & 0xffffffff;
324 printk("R56 : %08Lx%08Lx R57 : %08Lx%08Lx R58 : %08Lx%08Lx\n",
325 ah, al, bh, bl, ch, cl);
327 ah = (regs->regs[59]) >> 32;
328 al = (regs->regs[59]) & 0xffffffff;
329 bh = (regs->regs[60]) >> 32;
330 bl = (regs->regs[60]) & 0xffffffff;
331 ch = (regs->regs[61]) >> 32;
332 cl = (regs->regs[61]) & 0xffffffff;
333 printk("R59 : %08Lx%08Lx R60 : %08Lx%08Lx R61 : %08Lx%08Lx\n",
334 ah, al, bh, bl, ch, cl);
336 ah = (regs->regs[62]) >> 32;
337 al = (regs->regs[62]) & 0xffffffff;
338 bh = (regs->tregs[0]) >> 32;
339 bl = (regs->tregs[0]) & 0xffffffff;
340 ch = (regs->tregs[1]) >> 32;
341 cl = (regs->tregs[1]) & 0xffffffff;
342 printk("R62 : %08Lx%08Lx T0 : %08Lx%08Lx T1 : %08Lx%08Lx\n",
343 ah, al, bh, bl, ch, cl);
345 ah = (regs->tregs[2]) >> 32;
346 al = (regs->tregs[2]) & 0xffffffff;
347 bh = (regs->tregs[3]) >> 32;
348 bl = (regs->tregs[3]) & 0xffffffff;
349 ch = (regs->tregs[4]) >> 32;
350 cl = (regs->tregs[4]) & 0xffffffff;
351 printk("T2 : %08Lx%08Lx T3 : %08Lx%08Lx T4 : %08Lx%08Lx\n",
352 ah, al, bh, bl, ch, cl);
354 ah = (regs->tregs[5]) >> 32;
355 al = (regs->tregs[5]) & 0xffffffff;
356 bh = (regs->tregs[6]) >> 32;
357 bl = (regs->tregs[6]) & 0xffffffff;
358 ch = (regs->tregs[7]) >> 32;
359 cl = (regs->tregs[7]) & 0xffffffff;
360 printk("T5 : %08Lx%08Lx T6 : %08Lx%08Lx T7 : %08Lx%08Lx\n",
361 ah, al, bh, bl, ch, cl);
364 * If we're in kernel mode, dump the stack too..
366 if (!user_mode(regs)) {
367 void show_stack(struct task_struct *tsk, unsigned long *sp);
368 unsigned long sp = regs->regs[15] & 0xffffffff;
369 struct task_struct *tsk = get_current();
371 tsk->thread.kregs = regs;
373 show_stack(tsk, (unsigned long *)sp);
377 struct task_struct * alloc_task_struct(void)
379 /* Get task descriptor pages */
380 return (struct task_struct *)
381 __get_free_pages(GFP_KERNEL, get_order(THREAD_SIZE));
384 void free_task_struct(struct task_struct *p)
386 free_pages((unsigned long) p, get_order(THREAD_SIZE));
390 * Create a kernel thread
392 ATTRIB_NORET void kernel_thread_helper(void *arg, int (*fn)(void *))
394 do_exit(fn(arg));
398 * This is the mechanism for creating a new kernel thread.
400 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
401 * who haven't done an "execve()") should use this: it will work within
402 * a system call from a "real" process, but the process memory space will
403 * not be freed until both the parent and the child have exited.
405 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
407 struct pt_regs regs;
409 memset(&regs, 0, sizeof(regs));
410 regs.regs[2] = (unsigned long)arg;
411 regs.regs[3] = (unsigned long)fn;
413 regs.pc = (unsigned long)kernel_thread_helper;
414 regs.sr = (1 << 30);
416 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
417 &regs, 0, NULL, NULL);
421 * Free current thread data structures etc..
423 void exit_thread(void)
426 * See arch/sparc/kernel/process.c for the precedent for doing
427 * this -- RPC.
429 * The SH-5 FPU save/restore approach relies on
430 * last_task_used_math pointing to a live task_struct. When
431 * another task tries to use the FPU for the 1st time, the FPUDIS
432 * trap handling (see arch/sh/kernel/cpu/sh5/fpu.c) will save the
433 * existing FPU state to the FP regs field within
434 * last_task_used_math before re-loading the new task's FPU state
435 * (or initialising it if the FPU has been used before). So if
436 * last_task_used_math is stale, and its page has already been
437 * re-allocated for another use, the consequences are rather
438 * grim. Unless we null it here, there is no other path through
439 * which it would get safely nulled.
441 #ifdef CONFIG_SH_FPU
442 if (last_task_used_math == current) {
443 last_task_used_math = NULL;
445 #endif
448 void flush_thread(void)
451 /* Called by fs/exec.c (flush_old_exec) to remove traces of a
452 * previously running executable. */
453 #ifdef CONFIG_SH_FPU
454 if (last_task_used_math == current) {
455 last_task_used_math = NULL;
457 /* Force FPU state to be reinitialised after exec */
458 clear_used_math();
459 #endif
461 /* if we are a kernel thread, about to change to user thread,
462 * update kreg
464 if(current->thread.kregs==&fake_swapper_regs) {
465 current->thread.kregs =
466 ((struct pt_regs *)(THREAD_SIZE + (unsigned long) current) - 1);
467 current->thread.uregs = current->thread.kregs;
471 void release_thread(struct task_struct *dead_task)
473 /* do nothing */
476 /* Fill in the fpu structure for a core dump.. */
477 int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
479 #ifdef CONFIG_SH_FPU
480 int fpvalid;
481 struct task_struct *tsk = current;
483 fpvalid = !!tsk_used_math(tsk);
484 if (fpvalid) {
485 if (current == last_task_used_math) {
486 enable_fpu();
487 save_fpu(tsk, regs);
488 disable_fpu();
489 last_task_used_math = 0;
490 regs->sr |= SR_FD;
493 memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu));
496 return fpvalid;
497 #else
498 return 0; /* Task didn't use the fpu at all. */
499 #endif
502 asmlinkage void ret_from_fork(void);
504 int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
505 unsigned long unused,
506 struct task_struct *p, struct pt_regs *regs)
508 struct pt_regs *childregs;
509 unsigned long long se; /* Sign extension */
511 #ifdef CONFIG_SH_FPU
512 if(last_task_used_math == current) {
513 enable_fpu();
514 save_fpu(current, regs);
515 disable_fpu();
516 last_task_used_math = NULL;
517 regs->sr |= SR_FD;
519 #endif
520 /* Copy from sh version */
521 childregs = (struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1;
523 *childregs = *regs;
525 if (user_mode(regs)) {
526 childregs->regs[15] = usp;
527 p->thread.uregs = childregs;
528 } else {
529 childregs->regs[15] = (unsigned long)task_stack_page(p) + THREAD_SIZE;
532 childregs->regs[9] = 0; /* Set return value for child */
533 childregs->sr |= SR_FD; /* Invalidate FPU flag */
535 p->thread.sp = (unsigned long) childregs;
536 p->thread.pc = (unsigned long) ret_from_fork;
539 * Sign extend the edited stack.
540 * Note that thread.pc and thread.pc will stay
541 * 32-bit wide and context switch must take care
542 * of NEFF sign extension.
545 se = childregs->regs[15];
546 se = (se & NEFF_SIGN) ? (se | NEFF_MASK) : se;
547 childregs->regs[15] = se;
549 return 0;
552 asmlinkage int sys_fork(unsigned long r2, unsigned long r3,
553 unsigned long r4, unsigned long r5,
554 unsigned long r6, unsigned long r7,
555 struct pt_regs *pregs)
557 return do_fork(SIGCHLD, pregs->regs[15], pregs, 0, 0, 0);
560 asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
561 unsigned long r4, unsigned long r5,
562 unsigned long r6, unsigned long r7,
563 struct pt_regs *pregs)
565 if (!newsp)
566 newsp = pregs->regs[15];
567 return do_fork(clone_flags, newsp, pregs, 0, 0, 0);
571 * This is trivial, and on the face of it looks like it
572 * could equally well be done in user mode.
574 * Not so, for quite unobvious reasons - register pressure.
575 * In user mode vfork() cannot have a stack frame, and if
576 * done by calling the "clone()" system call directly, you
577 * do not have enough call-clobbered registers to hold all
578 * the information you need.
580 asmlinkage int sys_vfork(unsigned long r2, unsigned long r3,
581 unsigned long r4, unsigned long r5,
582 unsigned long r6, unsigned long r7,
583 struct pt_regs *pregs)
585 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, pregs->regs[15], pregs, 0, 0, 0);
589 * sys_execve() executes a new program.
591 asmlinkage int sys_execve(char *ufilename, char **uargv,
592 char **uenvp, unsigned long r5,
593 unsigned long r6, unsigned long r7,
594 struct pt_regs *pregs)
596 int error;
597 char *filename;
599 lock_kernel();
600 filename = getname((char __user *)ufilename);
601 error = PTR_ERR(filename);
602 if (IS_ERR(filename))
603 goto out;
605 error = do_execve(filename,
606 (char __user * __user *)uargv,
607 (char __user * __user *)uenvp,
608 pregs);
609 if (error == 0) {
610 task_lock(current);
611 current->ptrace &= ~PT_DTRACE;
612 task_unlock(current);
614 putname(filename);
615 out:
616 unlock_kernel();
617 return error;
621 * These bracket the sleeping functions..
623 extern void interruptible_sleep_on(wait_queue_head_t *q);
625 #define mid_sched ((unsigned long) interruptible_sleep_on)
627 #ifdef CONFIG_FRAME_POINTER
628 static int in_sh64_switch_to(unsigned long pc)
630 extern char __sh64_switch_to_end;
631 /* For a sleeping task, the PC is somewhere in the middle of the function,
632 so we don't have to worry about masking the LSB off */
633 return (pc >= (unsigned long) sh64_switch_to) &&
634 (pc < (unsigned long) &__sh64_switch_to_end);
636 #endif
638 unsigned long get_wchan(struct task_struct *p)
640 unsigned long pc;
642 if (!p || p == current || p->state == TASK_RUNNING)
643 return 0;
646 * The same comment as on the Alpha applies here, too ...
648 pc = thread_saved_pc(p);
650 #ifdef CONFIG_FRAME_POINTER
651 if (in_sh64_switch_to(pc)) {
652 unsigned long schedule_fp;
653 unsigned long sh64_switch_to_fp;
654 unsigned long schedule_caller_pc;
656 sh64_switch_to_fp = (long) p->thread.sp;
657 /* r14 is saved at offset 4 in the sh64_switch_to frame */
658 schedule_fp = *(unsigned long *) (long)(sh64_switch_to_fp + 4);
660 /* and the caller of 'schedule' is (currently!) saved at offset 24
661 in the frame of schedule (from disasm) */
662 schedule_caller_pc = *(unsigned long *) (long)(schedule_fp + 24);
663 return schedule_caller_pc;
665 #endif
666 return pc;
669 /* Provide a /proc/asids file that lists out the
670 ASIDs currently associated with the processes. (If the DM.PC register is
671 examined through the debug link, this shows ASID + PC. To make use of this,
672 the PID->ASID relationship needs to be known. This is primarily for
673 debugging.)
676 #if defined(CONFIG_SH64_PROC_ASIDS)
677 static int
678 asids_proc_info(char *buf, char **start, off_t fpos, int length, int *eof, void *data)
680 int len=0;
681 struct task_struct *p;
682 read_lock(&tasklist_lock);
683 for_each_process(p) {
684 int pid = p->pid;
686 if (!pid)
687 continue;
688 if (p->mm)
689 len += sprintf(buf+len, "%5d : %02lx\n", pid,
690 asid_cache(smp_processor_id()));
691 else
692 len += sprintf(buf+len, "%5d : (none)\n", pid);
694 read_unlock(&tasklist_lock);
695 *eof = 1;
696 return len;
699 static int __init register_proc_asids(void)
701 create_proc_read_entry("asids", 0, NULL, asids_proc_info, NULL);
702 return 0;
704 __initcall(register_proc_asids);
705 #endif