2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * arch/sh64/kernel/process.c
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003 Paul Mundt
10 * Copyright (C) 2003, 2004 Richard Curnow
12 * Started from SH3/4 version:
13 * Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
15 * In turn started from i386 version:
16 * Copyright (C) 1995 Linus Torvalds
21 * This file handles the architecture-dependent parts of process handling..
24 /* Temporary flags/tests. All to be removed/undefined. BEGIN */
26 #define VM_SHOW_TABLES
28 #define VM_TEST_RTLBMISS
29 #define VM_TEST_WTLBMISS
33 /* Temporary flags/tests. All to be removed/undefined. END */
35 #define __KERNEL_SYSCALLS__
38 #include <linux/kernel.h>
39 #include <linux/rwsem.h>
41 #include <linux/smp.h>
42 #include <linux/smp_lock.h>
43 #include <linux/ptrace.h>
44 #include <linux/slab.h>
45 #include <linux/vmalloc.h>
46 #include <linux/user.h>
47 #include <linux/a.out.h>
48 #include <linux/interrupt.h>
49 #include <linux/unistd.h>
50 #include <linux/delay.h>
51 #include <linux/reboot.h>
52 #include <linux/init.h>
54 #include <asm/uaccess.h>
55 #include <asm/pgtable.h>
56 #include <asm/system.h>
58 #include <asm/processor.h> /* includes also <asm/registers.h> */
59 #include <asm/mmu_context.h>
63 #include <linux/irq.h>
65 struct task_struct *last_task_used_math = NULL;
70 static void print_PTE(long base)
73 long long x, y, *p = (long long *) base;
75 for (i=0; i< 512; i++, p++){
84 y = (*p) & 0xffffffff;
85 printk("%08Lx%08Lx ", x, y);
86 if (!((i+1)&0x3)) printk("\n");
92 static void print_DIR(long base)
95 long *p = (long *) base;
97 for (i=0; i< 512; i++, p++){
105 printk("%08lx ", *p);
106 if (!((i+1)&0x7)) printk("\n");
112 static void print_vmalloc_first_tables(void)
115 #define PRESENT 0x800 /* Bit 11 */
118 * Do it really dirty by looking at raw addresses,
119 * raw offsets, no types. If we used pgtable/pgalloc
120 * macros/definitions we could hide potential bugs.
122 * Note that pointers are 32-bit for CDC.
124 long pgdt, pmdt, ptet;
126 pgdt = (long) &swapper_pg_dir;
127 printk("-->PGD (0x%08lx):\n", pgdt);
131 /* VMALLOC pool is mapped at 0xc0000000, second (pointer) entry in PGD */
133 pmdt = (long) (* (long *) pgdt);
134 if (!(pmdt & PRESENT)) {
137 } else pmdt &= 0xfffff000;
139 printk("-->PMD (0x%08lx):\n", pmdt);
143 /* Get the pmdt displacement for 0xc0000000 */
146 /* just look at first two address ranges ... */
147 /* ... 0xc0000000 ... */
148 ptet = (long) (* (long *) pmdt);
149 if (!(ptet & PRESENT)) {
152 } else ptet &= 0xfffff000;
154 printk("-->PTE0 (0x%08lx):\n", ptet);
158 /* ... 0xc0001000 ... */
160 if (!(ptet & PRESENT)) {
163 } else ptet &= 0xfffff000;
164 printk("-->PTE1 (0x%08lx):\n", ptet);
169 #define print_vmalloc_first_tables()
170 #endif /* VM_SHOW_TABLES */
172 static void test_VM(void)
176 #ifdef VM_SHOW_TABLES
177 printk("Initial PGD/PMD/PTE\n");
179 print_vmalloc_first_tables();
181 printk("Allocating 2 bytes\n");
183 print_vmalloc_first_tables();
185 printk("Allocating 4100 bytes\n");
187 print_vmalloc_first_tables();
189 printk("Allocating 20234 bytes\n");
191 print_vmalloc_first_tables();
194 /* Here you may want to fault ! */
196 #ifdef VM_TEST_RTLBMISS
197 printk("Ready to fault upon read.\n");
199 printk("RTLBMISSed on area a !\n");
201 printk("RTLBMISSed on area a !\n");
204 #ifdef VM_TEST_WTLBMISS
205 printk("Ready to fault upon write.\n");
207 printk("WTLBMISSed on area b !\n");
210 #endif /* VM_TEST_FAULT */
212 printk("Deallocating the 4100 byte chunk\n");
214 print_vmalloc_first_tables();
216 printk("Deallocating the 2 byte chunk\n");
218 print_vmalloc_first_tables();
220 printk("Deallocating the last chunk\n");
222 print_vmalloc_first_tables();
225 extern unsigned long volatile jiffies;
227 unsigned long old_jiffies;
228 int pid = -1, pgid = -1;
230 void idle_trace(void)
233 _syscall0(int, getpid)
234 _syscall1(int, getpgid, int, pid)
237 /* VM allocation/deallocation simple test */
241 printk("Got all through to Idle !!\n");
242 printk("I'm now going to loop forever ...\n");
243 printk("Any ! below is a timer tick.\n");
244 printk("Any . below is a getpgid system call from pid = %d.\n", pid);
247 old_jiffies = jiffies;
251 if (old_jiffies != jiffies) {
252 old_jiffies = jiffies - old_jiffies;
253 switch (old_jiffies) {
267 printk("(%d!)", (int) old_jiffies);
269 old_jiffies = jiffies;
275 #define idle_trace() do { } while (0)
276 #endif /* IDLE_TRACE */
278 static int hlt_counter = 1;
280 #define HARD_IDLE_TIMEOUT (HZ / 3)
282 void disable_hlt(void)
287 void enable_hlt(void)
292 static int __init nohlt_setup(char *__unused)
298 static int __init hlt_setup(char *__unused)
304 __setup("nohlt", nohlt_setup);
305 __setup("hlt", hlt_setup);
307 static inline void hlt(void)
309 __asm__ __volatile__ ("sleep" : : : "memory");
313 * The idle loop on a uniprocessor SH..
317 /* endless idle loop with no priority at all */
320 while (!need_resched())
324 while (!need_resched()) {
332 preempt_enable_no_resched();
339 void machine_restart(char * __unused)
341 extern void phys_stext(void);
346 void machine_halt(void)
351 void machine_power_off(void)
353 extern void enter_deep_standby(void);
355 enter_deep_standby();
358 void (*pm_power_off)(void) = machine_power_off;
359 EXPORT_SYMBOL(pm_power_off);
361 void show_regs(struct pt_regs * regs)
363 unsigned long long ah, al, bh, bl, ch, cl;
367 ah = (regs->pc) >> 32;
368 al = (regs->pc) & 0xffffffff;
369 bh = (regs->regs[18]) >> 32;
370 bl = (regs->regs[18]) & 0xffffffff;
371 ch = (regs->regs[15]) >> 32;
372 cl = (regs->regs[15]) & 0xffffffff;
373 printk("PC : %08Lx%08Lx LINK: %08Lx%08Lx SP : %08Lx%08Lx\n",
374 ah, al, bh, bl, ch, cl);
376 ah = (regs->sr) >> 32;
377 al = (regs->sr) & 0xffffffff;
378 asm volatile ("getcon " __TEA ", %0" : "=r" (bh));
379 asm volatile ("getcon " __TEA ", %0" : "=r" (bl));
381 bl = (bl) & 0xffffffff;
382 asm volatile ("getcon " __KCR0 ", %0" : "=r" (ch));
383 asm volatile ("getcon " __KCR0 ", %0" : "=r" (cl));
385 cl = (cl) & 0xffffffff;
386 printk("SR : %08Lx%08Lx TEA : %08Lx%08Lx KCR0: %08Lx%08Lx\n",
387 ah, al, bh, bl, ch, cl);
389 ah = (regs->regs[0]) >> 32;
390 al = (regs->regs[0]) & 0xffffffff;
391 bh = (regs->regs[1]) >> 32;
392 bl = (regs->regs[1]) & 0xffffffff;
393 ch = (regs->regs[2]) >> 32;
394 cl = (regs->regs[2]) & 0xffffffff;
395 printk("R0 : %08Lx%08Lx R1 : %08Lx%08Lx R2 : %08Lx%08Lx\n",
396 ah, al, bh, bl, ch, cl);
398 ah = (regs->regs[3]) >> 32;
399 al = (regs->regs[3]) & 0xffffffff;
400 bh = (regs->regs[4]) >> 32;
401 bl = (regs->regs[4]) & 0xffffffff;
402 ch = (regs->regs[5]) >> 32;
403 cl = (regs->regs[5]) & 0xffffffff;
404 printk("R3 : %08Lx%08Lx R4 : %08Lx%08Lx R5 : %08Lx%08Lx\n",
405 ah, al, bh, bl, ch, cl);
407 ah = (regs->regs[6]) >> 32;
408 al = (regs->regs[6]) & 0xffffffff;
409 bh = (regs->regs[7]) >> 32;
410 bl = (regs->regs[7]) & 0xffffffff;
411 ch = (regs->regs[8]) >> 32;
412 cl = (regs->regs[8]) & 0xffffffff;
413 printk("R6 : %08Lx%08Lx R7 : %08Lx%08Lx R8 : %08Lx%08Lx\n",
414 ah, al, bh, bl, ch, cl);
416 ah = (regs->regs[9]) >> 32;
417 al = (regs->regs[9]) & 0xffffffff;
418 bh = (regs->regs[10]) >> 32;
419 bl = (regs->regs[10]) & 0xffffffff;
420 ch = (regs->regs[11]) >> 32;
421 cl = (regs->regs[11]) & 0xffffffff;
422 printk("R9 : %08Lx%08Lx R10 : %08Lx%08Lx R11 : %08Lx%08Lx\n",
423 ah, al, bh, bl, ch, cl);
425 ah = (regs->regs[12]) >> 32;
426 al = (regs->regs[12]) & 0xffffffff;
427 bh = (regs->regs[13]) >> 32;
428 bl = (regs->regs[13]) & 0xffffffff;
429 ch = (regs->regs[14]) >> 32;
430 cl = (regs->regs[14]) & 0xffffffff;
431 printk("R12 : %08Lx%08Lx R13 : %08Lx%08Lx R14 : %08Lx%08Lx\n",
432 ah, al, bh, bl, ch, cl);
434 ah = (regs->regs[16]) >> 32;
435 al = (regs->regs[16]) & 0xffffffff;
436 bh = (regs->regs[17]) >> 32;
437 bl = (regs->regs[17]) & 0xffffffff;
438 ch = (regs->regs[19]) >> 32;
439 cl = (regs->regs[19]) & 0xffffffff;
440 printk("R16 : %08Lx%08Lx R17 : %08Lx%08Lx R19 : %08Lx%08Lx\n",
441 ah, al, bh, bl, ch, cl);
443 ah = (regs->regs[20]) >> 32;
444 al = (regs->regs[20]) & 0xffffffff;
445 bh = (regs->regs[21]) >> 32;
446 bl = (regs->regs[21]) & 0xffffffff;
447 ch = (regs->regs[22]) >> 32;
448 cl = (regs->regs[22]) & 0xffffffff;
449 printk("R20 : %08Lx%08Lx R21 : %08Lx%08Lx R22 : %08Lx%08Lx\n",
450 ah, al, bh, bl, ch, cl);
452 ah = (regs->regs[23]) >> 32;
453 al = (regs->regs[23]) & 0xffffffff;
454 bh = (regs->regs[24]) >> 32;
455 bl = (regs->regs[24]) & 0xffffffff;
456 ch = (regs->regs[25]) >> 32;
457 cl = (regs->regs[25]) & 0xffffffff;
458 printk("R23 : %08Lx%08Lx R24 : %08Lx%08Lx R25 : %08Lx%08Lx\n",
459 ah, al, bh, bl, ch, cl);
461 ah = (regs->regs[26]) >> 32;
462 al = (regs->regs[26]) & 0xffffffff;
463 bh = (regs->regs[27]) >> 32;
464 bl = (regs->regs[27]) & 0xffffffff;
465 ch = (regs->regs[28]) >> 32;
466 cl = (regs->regs[28]) & 0xffffffff;
467 printk("R26 : %08Lx%08Lx R27 : %08Lx%08Lx R28 : %08Lx%08Lx\n",
468 ah, al, bh, bl, ch, cl);
470 ah = (regs->regs[29]) >> 32;
471 al = (regs->regs[29]) & 0xffffffff;
472 bh = (regs->regs[30]) >> 32;
473 bl = (regs->regs[30]) & 0xffffffff;
474 ch = (regs->regs[31]) >> 32;
475 cl = (regs->regs[31]) & 0xffffffff;
476 printk("R29 : %08Lx%08Lx R30 : %08Lx%08Lx R31 : %08Lx%08Lx\n",
477 ah, al, bh, bl, ch, cl);
479 ah = (regs->regs[32]) >> 32;
480 al = (regs->regs[32]) & 0xffffffff;
481 bh = (regs->regs[33]) >> 32;
482 bl = (regs->regs[33]) & 0xffffffff;
483 ch = (regs->regs[34]) >> 32;
484 cl = (regs->regs[34]) & 0xffffffff;
485 printk("R32 : %08Lx%08Lx R33 : %08Lx%08Lx R34 : %08Lx%08Lx\n",
486 ah, al, bh, bl, ch, cl);
488 ah = (regs->regs[35]) >> 32;
489 al = (regs->regs[35]) & 0xffffffff;
490 bh = (regs->regs[36]) >> 32;
491 bl = (regs->regs[36]) & 0xffffffff;
492 ch = (regs->regs[37]) >> 32;
493 cl = (regs->regs[37]) & 0xffffffff;
494 printk("R35 : %08Lx%08Lx R36 : %08Lx%08Lx R37 : %08Lx%08Lx\n",
495 ah, al, bh, bl, ch, cl);
497 ah = (regs->regs[38]) >> 32;
498 al = (regs->regs[38]) & 0xffffffff;
499 bh = (regs->regs[39]) >> 32;
500 bl = (regs->regs[39]) & 0xffffffff;
501 ch = (regs->regs[40]) >> 32;
502 cl = (regs->regs[40]) & 0xffffffff;
503 printk("R38 : %08Lx%08Lx R39 : %08Lx%08Lx R40 : %08Lx%08Lx\n",
504 ah, al, bh, bl, ch, cl);
506 ah = (regs->regs[41]) >> 32;
507 al = (regs->regs[41]) & 0xffffffff;
508 bh = (regs->regs[42]) >> 32;
509 bl = (regs->regs[42]) & 0xffffffff;
510 ch = (regs->regs[43]) >> 32;
511 cl = (regs->regs[43]) & 0xffffffff;
512 printk("R41 : %08Lx%08Lx R42 : %08Lx%08Lx R43 : %08Lx%08Lx\n",
513 ah, al, bh, bl, ch, cl);
515 ah = (regs->regs[44]) >> 32;
516 al = (regs->regs[44]) & 0xffffffff;
517 bh = (regs->regs[45]) >> 32;
518 bl = (regs->regs[45]) & 0xffffffff;
519 ch = (regs->regs[46]) >> 32;
520 cl = (regs->regs[46]) & 0xffffffff;
521 printk("R44 : %08Lx%08Lx R45 : %08Lx%08Lx R46 : %08Lx%08Lx\n",
522 ah, al, bh, bl, ch, cl);
524 ah = (regs->regs[47]) >> 32;
525 al = (regs->regs[47]) & 0xffffffff;
526 bh = (regs->regs[48]) >> 32;
527 bl = (regs->regs[48]) & 0xffffffff;
528 ch = (regs->regs[49]) >> 32;
529 cl = (regs->regs[49]) & 0xffffffff;
530 printk("R47 : %08Lx%08Lx R48 : %08Lx%08Lx R49 : %08Lx%08Lx\n",
531 ah, al, bh, bl, ch, cl);
533 ah = (regs->regs[50]) >> 32;
534 al = (regs->regs[50]) & 0xffffffff;
535 bh = (regs->regs[51]) >> 32;
536 bl = (regs->regs[51]) & 0xffffffff;
537 ch = (regs->regs[52]) >> 32;
538 cl = (regs->regs[52]) & 0xffffffff;
539 printk("R50 : %08Lx%08Lx R51 : %08Lx%08Lx R52 : %08Lx%08Lx\n",
540 ah, al, bh, bl, ch, cl);
542 ah = (regs->regs[53]) >> 32;
543 al = (regs->regs[53]) & 0xffffffff;
544 bh = (regs->regs[54]) >> 32;
545 bl = (regs->regs[54]) & 0xffffffff;
546 ch = (regs->regs[55]) >> 32;
547 cl = (regs->regs[55]) & 0xffffffff;
548 printk("R53 : %08Lx%08Lx R54 : %08Lx%08Lx R55 : %08Lx%08Lx\n",
549 ah, al, bh, bl, ch, cl);
551 ah = (regs->regs[56]) >> 32;
552 al = (regs->regs[56]) & 0xffffffff;
553 bh = (regs->regs[57]) >> 32;
554 bl = (regs->regs[57]) & 0xffffffff;
555 ch = (regs->regs[58]) >> 32;
556 cl = (regs->regs[58]) & 0xffffffff;
557 printk("R56 : %08Lx%08Lx R57 : %08Lx%08Lx R58 : %08Lx%08Lx\n",
558 ah, al, bh, bl, ch, cl);
560 ah = (regs->regs[59]) >> 32;
561 al = (regs->regs[59]) & 0xffffffff;
562 bh = (regs->regs[60]) >> 32;
563 bl = (regs->regs[60]) & 0xffffffff;
564 ch = (regs->regs[61]) >> 32;
565 cl = (regs->regs[61]) & 0xffffffff;
566 printk("R59 : %08Lx%08Lx R60 : %08Lx%08Lx R61 : %08Lx%08Lx\n",
567 ah, al, bh, bl, ch, cl);
569 ah = (regs->regs[62]) >> 32;
570 al = (regs->regs[62]) & 0xffffffff;
571 bh = (regs->tregs[0]) >> 32;
572 bl = (regs->tregs[0]) & 0xffffffff;
573 ch = (regs->tregs[1]) >> 32;
574 cl = (regs->tregs[1]) & 0xffffffff;
575 printk("R62 : %08Lx%08Lx T0 : %08Lx%08Lx T1 : %08Lx%08Lx\n",
576 ah, al, bh, bl, ch, cl);
578 ah = (regs->tregs[2]) >> 32;
579 al = (regs->tregs[2]) & 0xffffffff;
580 bh = (regs->tregs[3]) >> 32;
581 bl = (regs->tregs[3]) & 0xffffffff;
582 ch = (regs->tregs[4]) >> 32;
583 cl = (regs->tregs[4]) & 0xffffffff;
584 printk("T2 : %08Lx%08Lx T3 : %08Lx%08Lx T4 : %08Lx%08Lx\n",
585 ah, al, bh, bl, ch, cl);
587 ah = (regs->tregs[5]) >> 32;
588 al = (regs->tregs[5]) & 0xffffffff;
589 bh = (regs->tregs[6]) >> 32;
590 bl = (regs->tregs[6]) & 0xffffffff;
591 ch = (regs->tregs[7]) >> 32;
592 cl = (regs->tregs[7]) & 0xffffffff;
593 printk("T5 : %08Lx%08Lx T6 : %08Lx%08Lx T7 : %08Lx%08Lx\n",
594 ah, al, bh, bl, ch, cl);
597 * If we're in kernel mode, dump the stack too..
599 if (!user_mode(regs)) {
600 void show_stack(struct task_struct *tsk, unsigned long *sp);
601 unsigned long sp = regs->regs[15] & 0xffffffff;
602 struct task_struct *tsk = get_current();
604 tsk->thread.kregs = regs;
606 show_stack(tsk, (unsigned long *)sp);
610 struct task_struct * alloc_task_struct(void)
612 /* Get task descriptor pages */
613 return (struct task_struct *)
614 __get_free_pages(GFP_KERNEL, get_order(THREAD_SIZE));
617 void free_task_struct(struct task_struct *p)
619 free_pages((unsigned long) p, get_order(THREAD_SIZE));
623 * Create a kernel thread
627 * This is the mechanism for creating a new kernel thread.
629 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
630 * who haven't done an "execve()") should use this: it will work within
631 * a system call from a "real" process, but the process memory space will
632 * not be free'd until both the parent and the child have exited.
634 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
636 /* A bit less processor dependent than older sh ... */
639 static __inline__ _syscall2(int,clone,unsigned long,flags,unsigned long,newsp)
640 static __inline__ _syscall1(int,exit,int,ret)
642 reply = clone(flags | CLONE_VM, 0);
645 reply = exit(fn(arg));
652 * Free current thread data structures etc..
654 void exit_thread(void)
656 /* See arch/sparc/kernel/process.c for the precedent for doing this -- RPC.
658 The SH-5 FPU save/restore approach relies on last_task_used_math
659 pointing to a live task_struct. When another task tries to use the
660 FPU for the 1st time, the FPUDIS trap handling (see
661 arch/sh64/kernel/fpu.c) will save the existing FPU state to the
662 FP regs field within last_task_used_math before re-loading the new
663 task's FPU state (or initialising it if the FPU has been used
664 before). So if last_task_used_math is stale, and its page has already been
665 re-allocated for another use, the consequences are rather grim. Unless we
666 null it here, there is no other path through which it would get safely
670 if (last_task_used_math == current) {
671 last_task_used_math = NULL;
676 void flush_thread(void)
679 /* Called by fs/exec.c (flush_old_exec) to remove traces of a
680 * previously running executable. */
682 if (last_task_used_math == current) {
683 last_task_used_math = NULL;
685 /* Force FPU state to be reinitialised after exec */
689 /* if we are a kernel thread, about to change to user thread,
692 if(current->thread.kregs==&fake_swapper_regs) {
693 current->thread.kregs =
694 ((struct pt_regs *)(THREAD_SIZE + (unsigned long) current) - 1);
695 current->thread.uregs = current->thread.kregs;
699 void release_thread(struct task_struct *dead_task)
704 /* Fill in the fpu structure for a core dump.. */
705 int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
709 struct task_struct *tsk = current;
711 fpvalid = !!tsk_used_math(tsk);
713 if (current == last_task_used_math) {
715 fpsave(&tsk->thread.fpu.hard);
717 last_task_used_math = 0;
721 memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu));
726 return 0; /* Task didn't use the fpu at all. */
730 asmlinkage void ret_from_fork(void);
732 int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
733 unsigned long unused,
734 struct task_struct *p, struct pt_regs *regs)
736 struct pt_regs *childregs;
737 unsigned long long se; /* Sign extension */
740 if(last_task_used_math == current) {
742 fpsave(¤t->thread.fpu.hard);
744 last_task_used_math = NULL;
748 /* Copy from sh version */
749 childregs = (struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1;
753 if (user_mode(regs)) {
754 childregs->regs[15] = usp;
755 p->thread.uregs = childregs;
757 childregs->regs[15] = (unsigned long)task_stack_page(p) + THREAD_SIZE;
760 childregs->regs[9] = 0; /* Set return value for child */
761 childregs->sr |= SR_FD; /* Invalidate FPU flag */
763 p->thread.sp = (unsigned long) childregs;
764 p->thread.pc = (unsigned long) ret_from_fork;
767 * Sign extend the edited stack.
768 * Note that thread.pc and thread.pc will stay
769 * 32-bit wide and context switch must take care
770 * of NEFF sign extension.
773 se = childregs->regs[15];
774 se = (se & NEFF_SIGN) ? (se | NEFF_MASK) : se;
775 childregs->regs[15] = se;
780 asmlinkage int sys_fork(unsigned long r2, unsigned long r3,
781 unsigned long r4, unsigned long r5,
782 unsigned long r6, unsigned long r7,
783 struct pt_regs *pregs)
785 return do_fork(SIGCHLD, pregs->regs[15], pregs, 0, 0, 0);
788 asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
789 unsigned long r4, unsigned long r5,
790 unsigned long r6, unsigned long r7,
791 struct pt_regs *pregs)
794 newsp = pregs->regs[15];
795 return do_fork(clone_flags, newsp, pregs, 0, 0, 0);
799 * This is trivial, and on the face of it looks like it
800 * could equally well be done in user mode.
802 * Not so, for quite unobvious reasons - register pressure.
803 * In user mode vfork() cannot have a stack frame, and if
804 * done by calling the "clone()" system call directly, you
805 * do not have enough call-clobbered registers to hold all
806 * the information you need.
808 asmlinkage int sys_vfork(unsigned long r2, unsigned long r3,
809 unsigned long r4, unsigned long r5,
810 unsigned long r6, unsigned long r7,
811 struct pt_regs *pregs)
813 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, pregs->regs[15], pregs, 0, 0, 0);
817 * sys_execve() executes a new program.
819 asmlinkage int sys_execve(char *ufilename, char **uargv,
820 char **uenvp, unsigned long r5,
821 unsigned long r6, unsigned long r7,
822 struct pt_regs *pregs)
828 filename = getname((char __user *)ufilename);
829 error = PTR_ERR(filename);
830 if (IS_ERR(filename))
833 error = do_execve(filename,
834 (char __user * __user *)uargv,
835 (char __user * __user *)uenvp,
839 current->ptrace &= ~PT_DTRACE;
840 task_unlock(current);
849 * These bracket the sleeping functions..
851 extern void interruptible_sleep_on(wait_queue_head_t *q);
853 #define mid_sched ((unsigned long) interruptible_sleep_on)
855 static int in_sh64_switch_to(unsigned long pc)
857 extern char __sh64_switch_to_end;
858 /* For a sleeping task, the PC is somewhere in the middle of the function,
859 so we don't have to worry about masking the LSB off */
860 return (pc >= (unsigned long) sh64_switch_to) &&
861 (pc < (unsigned long) &__sh64_switch_to_end);
864 unsigned long get_wchan(struct task_struct *p)
866 unsigned long schedule_fp;
867 unsigned long sh64_switch_to_fp;
868 unsigned long schedule_caller_pc;
871 if (!p || p == current || p->state == TASK_RUNNING)
875 * The same comment as on the Alpha applies here, too ...
877 pc = thread_saved_pc(p);
879 #ifdef CONFIG_FRAME_POINTER
880 if (in_sh64_switch_to(pc)) {
881 sh64_switch_to_fp = (long) p->thread.sp;
882 /* r14 is saved at offset 4 in the sh64_switch_to frame */
883 schedule_fp = *(unsigned long *) (long)(sh64_switch_to_fp + 4);
885 /* and the caller of 'schedule' is (currently!) saved at offset 24
886 in the frame of schedule (from disasm) */
887 schedule_caller_pc = *(unsigned long *) (long)(schedule_fp + 24);
888 return schedule_caller_pc;
894 /* Provide a /proc/asids file that lists out the
895 ASIDs currently associated with the processes. (If the DM.PC register is
896 examined through the debug link, this shows ASID + PC. To make use of this,
897 the PID->ASID relationship needs to be known. This is primarily for
901 #if defined(CONFIG_SH64_PROC_ASIDS)
902 #include <linux/init.h>
903 #include <linux/proc_fs.h>
906 asids_proc_info(char *buf, char **start, off_t fpos, int length, int *eof, void *data)
909 struct task_struct *p;
910 read_lock(&tasklist_lock);
911 for_each_process(p) {
913 struct mm_struct *mm;
917 unsigned long asid, context;
918 context = mm->context;
919 asid = (context & 0xff);
920 len += sprintf(buf+len, "%5d : %02lx\n", pid, asid);
922 len += sprintf(buf+len, "%5d : (none)\n", pid);
925 read_unlock(&tasklist_lock);
930 static int __init register_proc_asids(void)
932 create_proc_read_entry("asids", 0, NULL, asids_proc_info, NULL);
936 __initcall(register_proc_asids);