1 /* $Id: process.c,v 1.131 2002/02/09 19:49:30 davem Exp $
2 * arch/sparc64/kernel/process.c
4 * Copyright (C) 1995, 1996 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
6 * Copyright (C) 1997, 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
10 * This file handles the architecture-dependent parts of process handling..
13 #define __KERNEL_SYSCALLS__
16 #include <linux/errno.h>
17 #include <linux/sched.h>
18 #include <linux/kernel.h>
19 #include <linux/kallsyms.h>
21 #include <linux/smp.h>
22 #include <linux/smp_lock.h>
23 #include <linux/stddef.h>
24 #include <linux/unistd.h>
25 #include <linux/ptrace.h>
26 #include <linux/slab.h>
27 #include <linux/user.h>
28 #include <linux/a.out.h>
29 #include <linux/config.h>
30 #include <linux/reboot.h>
31 #include <linux/delay.h>
33 #include <asm/oplib.h>
34 #include <asm/uaccess.h>
35 #include <asm/system.h>
37 #include <asm/pgalloc.h>
38 #include <asm/pgtable.h>
39 #include <asm/processor.h>
40 #include <asm/pstate.h>
42 #include <asm/fpumacro.h>
45 /* #define VERBOSE_SHOWREGS */
48 * Nothing special yet...
50 void default_idle(void)
57 * the idle loop on a Sparc... ;)
61 if (current
->pid
!= 0)
64 /* endless idle loop with no priority at all */
66 /* If current->work.need_resched is zero we should really
67 * setup for a system wakup event and execute a shutdown
70 * But this requires writing back the contents of the
71 * L2 cache etc. so implement this later. -DaveM
73 while (!need_resched())
85 * the idle loop on a UltraMultiPenguin...
87 #define idle_me_harder() (cpu_data[smp_processor_id()].idle_volume += 1)
88 #define unidle_me() (cpu_data[smp_processor_id()].idle_volume = 0)
91 set_thread_flag(TIF_POLLING_NRFLAG
);
95 clear_thread_flag(TIF_POLLING_NRFLAG
);
97 set_thread_flag(TIF_POLLING_NRFLAG
);
102 /* The store ordering is so that IRQ handlers on
103 * other cpus see our increasing idleness for the buddy
104 * redistribution algorithm. -DaveM
106 membar("#StoreStore | #StoreLoad");
112 extern char reboot_command
[];
114 extern void (*prom_palette
)(int);
115 extern void (*prom_keyboard
)(void);
117 void machine_halt(void)
119 if (!serial_console
&& prom_palette
)
124 panic("Halt failed!");
127 void machine_alt_power_off(void)
129 if (!serial_console
&& prom_palette
)
133 prom_halt_power_off();
134 panic("Power-off failed!");
137 void machine_restart(char * cmd
)
141 p
= strchr (reboot_command
, '\n');
143 if (!serial_console
&& prom_palette
)
150 prom_reboot(reboot_command
);
152 panic("Reboot failed!");
155 static void show_regwindow32(struct pt_regs
*regs
)
157 struct reg_window32
*rw
;
158 struct reg_window32 r_w
;
161 __asm__
__volatile__ ("flushw");
162 rw
= (struct reg_window32
*)((long)(unsigned)regs
->u_regs
[14]);
165 if (copy_from_user (&r_w
, rw
, sizeof(r_w
))) {
171 printk("l0: %08x l1: %08x l2: %08x l3: %08x "
172 "l4: %08x l5: %08x l6: %08x l7: %08x\n",
173 rw
->locals
[0], rw
->locals
[1], rw
->locals
[2], rw
->locals
[3],
174 rw
->locals
[4], rw
->locals
[5], rw
->locals
[6], rw
->locals
[7]);
175 printk("i0: %08x i1: %08x i2: %08x i3: %08x "
176 "i4: %08x i5: %08x i6: %08x i7: %08x\n",
177 rw
->ins
[0], rw
->ins
[1], rw
->ins
[2], rw
->ins
[3],
178 rw
->ins
[4], rw
->ins
[5], rw
->ins
[6], rw
->ins
[7]);
181 static void show_regwindow(struct pt_regs
*regs
)
183 struct reg_window
*rw
;
184 struct reg_window r_w
;
187 if ((regs
->tstate
& TSTATE_PRIV
) || !(test_thread_flag(TIF_32BIT
))) {
188 __asm__
__volatile__ ("flushw");
189 rw
= (struct reg_window
*)(regs
->u_regs
[14] + STACK_BIAS
);
190 if (!(regs
->tstate
& TSTATE_PRIV
)) {
193 if (copy_from_user (&r_w
, rw
, sizeof(r_w
))) {
201 show_regwindow32(regs
);
204 printk("l0: %016lx l1: %016lx l2: %016lx l3: %016lx\n",
205 rw
->locals
[0], rw
->locals
[1], rw
->locals
[2], rw
->locals
[3]);
206 printk("l4: %016lx l5: %016lx l6: %016lx l7: %016lx\n",
207 rw
->locals
[4], rw
->locals
[5], rw
->locals
[6], rw
->locals
[7]);
208 printk("i0: %016lx i1: %016lx i2: %016lx i3: %016lx\n",
209 rw
->ins
[0], rw
->ins
[1], rw
->ins
[2], rw
->ins
[3]);
210 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
211 rw
->ins
[4], rw
->ins
[5], rw
->ins
[6], rw
->ins
[7]);
214 void show_stackframe(struct sparc_stackf
*sf
)
220 printk("l0: %016lx l1: %016lx l2: %016lx l3: %016lx\n"
221 "l4: %016lx l5: %016lx l6: %016lx l7: %016lx\n",
222 sf
->locals
[0], sf
->locals
[1], sf
->locals
[2], sf
->locals
[3],
223 sf
->locals
[4], sf
->locals
[5], sf
->locals
[6], sf
->locals
[7]);
224 printk("i0: %016lx i1: %016lx i2: %016lx i3: %016lx\n"
225 "i4: %016lx i5: %016lx fp: %016lx ret_pc: %016lx\n",
226 sf
->ins
[0], sf
->ins
[1], sf
->ins
[2], sf
->ins
[3],
227 sf
->ins
[4], sf
->ins
[5], (unsigned long)sf
->fp
, sf
->callers_pc
);
228 printk("sp: %016lx x0: %016lx x1: %016lx x2: %016lx\n"
229 "x3: %016lx x4: %016lx x5: %016lx xx: %016lx\n",
230 (unsigned long)sf
->structptr
, sf
->xargs
[0], sf
->xargs
[1],
231 sf
->xargs
[2], sf
->xargs
[3], sf
->xargs
[4], sf
->xargs
[5],
233 size
= ((unsigned long)sf
->fp
) - ((unsigned long)sf
);
234 size
-= STACKFRAME_SZ
;
235 stk
= (unsigned long *)((unsigned long)sf
+ STACKFRAME_SZ
);
238 printk("s%d: %016lx\n", i
++, *stk
++);
239 } while ((size
-= sizeof(unsigned long)));
242 void show_stackframe32(struct sparc_stackf32
*sf
)
248 printk("l0: %08x l1: %08x l2: %08x l3: %08x\n",
249 sf
->locals
[0], sf
->locals
[1], sf
->locals
[2], sf
->locals
[3]);
250 printk("l4: %08x l5: %08x l6: %08x l7: %08x\n",
251 sf
->locals
[4], sf
->locals
[5], sf
->locals
[6], sf
->locals
[7]);
252 printk("i0: %08x i1: %08x i2: %08x i3: %08x\n",
253 sf
->ins
[0], sf
->ins
[1], sf
->ins
[2], sf
->ins
[3]);
254 printk("i4: %08x i5: %08x fp: %08x ret_pc: %08x\n",
255 sf
->ins
[4], sf
->ins
[5], sf
->fp
, sf
->callers_pc
);
256 printk("sp: %08x x0: %08x x1: %08x x2: %08x\n"
257 "x3: %08x x4: %08x x5: %08x xx: %08x\n",
258 sf
->structptr
, sf
->xargs
[0], sf
->xargs
[1],
259 sf
->xargs
[2], sf
->xargs
[3], sf
->xargs
[4], sf
->xargs
[5],
261 size
= ((unsigned long)sf
->fp
) - ((unsigned long)sf
);
262 size
-= STACKFRAME32_SZ
;
263 stk
= (unsigned *)((unsigned long)sf
+ STACKFRAME32_SZ
);
266 printk("s%d: %08x\n", i
++, *stk
++);
267 } while ((size
-= sizeof(unsigned)));
271 static spinlock_t regdump_lock
= SPIN_LOCK_UNLOCKED
;
274 void __show_regs(struct pt_regs
* regs
)
279 /* Protect against xcall ipis which might lead to livelock on the lock */
280 __asm__
__volatile__("rdpr %%pstate, %0\n\t"
281 "wrpr %0, %1, %%pstate"
284 spin_lock(®dump_lock
);
286 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs
->tstate
,
287 regs
->tpc
, regs
->tnpc
, regs
->y
, print_tainted());
288 print_symbol("TPC: <%s>\n", regs
->tpc
);
289 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
290 regs
->u_regs
[0], regs
->u_regs
[1], regs
->u_regs
[2],
292 printk("g4: %016lx g5: %016lx g6: %016lx g7: %016lx\n",
293 regs
->u_regs
[4], regs
->u_regs
[5], regs
->u_regs
[6],
295 printk("o0: %016lx o1: %016lx o2: %016lx o3: %016lx\n",
296 regs
->u_regs
[8], regs
->u_regs
[9], regs
->u_regs
[10],
298 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
299 regs
->u_regs
[12], regs
->u_regs
[13], regs
->u_regs
[14],
301 show_regwindow(regs
);
303 spin_unlock(®dump_lock
);
304 __asm__
__volatile__("wrpr %0, 0, %%pstate"
309 #ifdef VERBOSE_SHOWREGS
310 static void idump_from_user (unsigned int *pc
)
315 if((((unsigned long) pc
) & 3))
319 for(i
= -3; i
< 6; i
++) {
321 printk("%c%08x%c",i
?' ':'<',code
,i
?' ':'>');
328 void show_regs(struct pt_regs
*regs
)
330 #ifdef VERBOSE_SHOWREGS
331 extern long etrap
, etraptl1
;
336 extern void smp_report_regs(void);
342 #ifdef VERBOSE_SHOWREGS
343 if (regs
->tpc
>= &etrap
&& regs
->tpc
< &etraptl1
&&
344 regs
->u_regs
[14] >= (long)current
- PAGE_SIZE
&&
345 regs
->u_regs
[14] < (long)current
+ 6 * PAGE_SIZE
) {
346 printk ("*********parent**********\n");
347 __show_regs((struct pt_regs
*)(regs
->u_regs
[14] + PTREGS_OFF
));
348 idump_from_user(((struct pt_regs
*)(regs
->u_regs
[14] + PTREGS_OFF
))->tpc
);
349 printk ("*********endpar**********\n");
354 void show_regs32(struct pt_regs32
*regs
)
356 printk("PSR: %08x PC: %08x NPC: %08x Y: %08x %s\n", regs
->psr
,
357 regs
->pc
, regs
->npc
, regs
->y
, print_tainted());
358 printk("g0: %08x g1: %08x g2: %08x g3: %08x ",
359 regs
->u_regs
[0], regs
->u_regs
[1], regs
->u_regs
[2],
361 printk("g4: %08x g5: %08x g6: %08x g7: %08x\n",
362 regs
->u_regs
[4], regs
->u_regs
[5], regs
->u_regs
[6],
364 printk("o0: %08x o1: %08x o2: %08x o3: %08x ",
365 regs
->u_regs
[8], regs
->u_regs
[9], regs
->u_regs
[10],
367 printk("o4: %08x o5: %08x sp: %08x ret_pc: %08x\n",
368 regs
->u_regs
[12], regs
->u_regs
[13], regs
->u_regs
[14],
372 unsigned long thread_saved_pc(struct task_struct
*tsk
)
374 struct thread_info
*ti
= tsk
->thread_info
;
375 unsigned long ret
= 0xdeadbeefUL
;
379 sp
= (unsigned long *)(ti
->ksp
+ STACK_BIAS
);
380 if (((unsigned long)sp
& (sizeof(long) - 1)) == 0UL &&
383 fp
= (unsigned long *)(sp
[14] + STACK_BIAS
);
384 if (((unsigned long)fp
& (sizeof(long) - 1)) == 0UL)
391 /* Free current thread data structures etc.. */
392 void exit_thread(void)
394 struct thread_info
*t
= current_thread_info();
397 if (t
->utraps
[0] < 2)
403 if (test_and_clear_thread_flag(TIF_PERFCTR
)) {
404 t
->user_cntd0
= t
->user_cntd1
= NULL
;
410 void flush_thread(void)
412 struct thread_info
*t
= current_thread_info();
414 if (t
->flags
& _TIF_ABI_PENDING
)
415 t
->flags
^= (_TIF_ABI_PENDING
| _TIF_32BIT
);
418 unsigned long pgd_cache
= 0UL;
419 if (test_thread_flag(TIF_32BIT
)) {
420 struct mm_struct
*mm
= t
->task
->mm
;
421 pgd_t
*pgd0
= &mm
->pgd
[0];
423 if (pgd_none(*pgd0
)) {
424 pmd_t
*page
= pmd_alloc_one_fast(NULL
, 0);
426 page
= pmd_alloc_one(NULL
, 0);
429 pgd_cache
= pgd_val(*pgd0
) << 11UL;
431 __asm__
__volatile__("stxa %0, [%1] %2\n\t"
438 set_thread_wsaved(0);
440 /* Turn off performance counters if on. */
441 if (test_and_clear_thread_flag(TIF_PERFCTR
)) {
442 t
->user_cntd0
= t
->user_cntd1
= NULL
;
447 /* Clear FPU register state. */
450 if (get_thread_current_ds() != ASI_AIUS
)
453 /* Init new signal delivery disposition. */
454 clear_thread_flag(TIF_NEWSIGNALS
);
457 /* It's a bit more tricky when 64-bit tasks are involved... */
458 static unsigned long clone_stackframe(unsigned long csp
, unsigned long psp
)
460 unsigned long fp
, distance
, rval
;
462 if (!(test_thread_flag(TIF_32BIT
))) {
465 __get_user(fp
, &(((struct reg_window
*)psp
)->ins
[6]));
468 __get_user(fp
, &(((struct reg_window32
*)psp
)->ins
[6]));
470 /* Now 8-byte align the stack as this is mandatory in the
471 * Sparc ABI due to how register windows work. This hides
472 * the restriction from thread libraries etc. -DaveM
477 rval
= (csp
- distance
);
478 if (copy_in_user((void __user
*) rval
, (void __user
*) psp
, distance
))
480 else if (test_thread_flag(TIF_32BIT
)) {
481 if (put_user(((u32
)csp
), &(((struct reg_window32
*)rval
)->ins
[6])))
484 if (put_user(((u64
)csp
- STACK_BIAS
),
485 &(((struct reg_window
*)rval
)->ins
[6])))
488 rval
= rval
- STACK_BIAS
;
494 /* Standard stuff. */
495 static inline void shift_window_buffer(int first_win
, int last_win
,
496 struct thread_info
*t
)
500 for (i
= first_win
; i
< last_win
; i
++) {
501 t
->rwbuf_stkptrs
[i
] = t
->rwbuf_stkptrs
[i
+1];
502 memcpy(&t
->reg_window
[i
], &t
->reg_window
[i
+1],
503 sizeof(struct reg_window
));
507 void synchronize_user_stack(void)
509 struct thread_info
*t
= current_thread_info();
510 unsigned long window
;
512 flush_user_windows();
513 if ((window
= get_thread_wsaved()) != 0) {
514 int winsize
= sizeof(struct reg_window
);
517 if (test_thread_flag(TIF_32BIT
))
518 winsize
= sizeof(struct reg_window32
);
524 unsigned long sp
= (t
->rwbuf_stkptrs
[window
] + bias
);
525 struct reg_window
*rwin
= &t
->reg_window
[window
];
527 if (!copy_to_user((char *)sp
, rwin
, winsize
)) {
528 shift_window_buffer(window
, get_thread_wsaved() - 1, t
);
529 set_thread_wsaved(get_thread_wsaved() - 1);
535 void fault_in_user_windows(void)
537 struct thread_info
*t
= current_thread_info();
538 unsigned long window
;
539 int winsize
= sizeof(struct reg_window
);
542 if (test_thread_flag(TIF_32BIT
))
543 winsize
= sizeof(struct reg_window32
);
547 flush_user_windows();
548 window
= get_thread_wsaved();
553 unsigned long sp
= (t
->rwbuf_stkptrs
[window
] + bias
);
554 struct reg_window
*rwin
= &t
->reg_window
[window
];
556 if (copy_to_user((char *)sp
, rwin
, winsize
))
560 set_thread_wsaved(0);
564 set_thread_wsaved(window
+ 1);
568 asmlinkage
int sparc_do_fork(unsigned long clone_flags
,
569 unsigned long stack_start
,
570 struct pt_regs
*regs
,
571 unsigned long stack_size
)
573 unsigned long parent_tid_ptr
= 0;
574 unsigned long child_tid_ptr
= 0;
576 clone_flags
&= ~CLONE_IDLETASK
;
578 if (clone_flags
& (CLONE_CHILD_SETTID
| CLONE_CHILD_CLEARTID
)) {
579 parent_tid_ptr
= regs
->u_regs
[UREG_G2
];
580 child_tid_ptr
= regs
->u_regs
[UREG_G3
];
581 if (test_thread_flag(TIF_32BIT
)) {
582 parent_tid_ptr
&= 0xffffffff;
583 child_tid_ptr
&= 0xffffffff;
587 return do_fork(clone_flags
, stack_start
,
589 (int *) parent_tid_ptr
,
590 (int *) child_tid_ptr
);
593 /* Copy a Sparc thread. The fork() return value conventions
594 * under SunOS are nothing short of bletcherous:
595 * Parent --> %o0 == childs pid, %o1 == 0
596 * Child --> %o0 == parents pid, %o1 == 1
598 int copy_thread(int nr
, unsigned long clone_flags
, unsigned long sp
,
599 unsigned long unused
,
600 struct task_struct
*p
, struct pt_regs
*regs
)
602 struct thread_info
*t
= p
->thread_info
;
603 char *child_trap_frame
;
605 #ifdef CONFIG_DEBUG_SPINLOCK
606 p
->thread
.smp_lock_count
= 0;
607 p
->thread
.smp_lock_pc
= 0;
610 p
->set_child_tid
= p
->clear_child_tid
= NULL
;
612 /* Calculate offset to stack_frame & pt_regs */
613 child_trap_frame
= ((char *)t
) + (THREAD_SIZE
- (TRACEREG_SZ
+STACKFRAME_SZ
));
614 memcpy(child_trap_frame
, (((struct sparc_stackf
*)regs
)-1), (TRACEREG_SZ
+STACKFRAME_SZ
));
616 t
->flags
= (t
->flags
& ~((0xffUL
<< TI_FLAG_CWP_SHIFT
) | (0xffUL
<< TI_FLAG_CURRENT_DS_SHIFT
))) |
618 (((regs
->tstate
+ 1) & TSTATE_CWP
) << TI_FLAG_CWP_SHIFT
);
619 t
->ksp
= ((unsigned long) child_trap_frame
) - STACK_BIAS
;
620 t
->kregs
= (struct pt_regs
*)(child_trap_frame
+sizeof(struct sparc_stackf
));
623 if (regs
->tstate
& TSTATE_PRIV
) {
624 /* Special case, if we are spawning a kernel thread from
625 * a userspace task (via KMOD, NFS, or similar) we must
626 * disable performance counters in the child because the
627 * address space and protection realm are changing.
629 if (t
->flags
& _TIF_PERFCTR
) {
630 t
->user_cntd0
= t
->user_cntd1
= NULL
;
632 t
->flags
&= ~_TIF_PERFCTR
;
634 t
->kregs
->u_regs
[UREG_FP
] = t
->ksp
;
635 t
->flags
|= ((long)ASI_P
<< TI_FLAG_CURRENT_DS_SHIFT
);
636 flush_register_windows();
637 memcpy((void *)(t
->ksp
+ STACK_BIAS
),
638 (void *)(regs
->u_regs
[UREG_FP
] + STACK_BIAS
),
639 sizeof(struct sparc_stackf
));
640 t
->kregs
->u_regs
[UREG_G6
] = (unsigned long) t
;
641 t
->kregs
->u_regs
[UREG_G4
] = (unsigned long) t
->task
;
643 if (t
->flags
& _TIF_32BIT
) {
644 sp
&= 0x00000000ffffffffUL
;
645 regs
->u_regs
[UREG_FP
] &= 0x00000000ffffffffUL
;
647 t
->kregs
->u_regs
[UREG_FP
] = sp
;
648 t
->flags
|= ((long)ASI_AIUS
<< TI_FLAG_CURRENT_DS_SHIFT
);
649 if (sp
!= regs
->u_regs
[UREG_FP
]) {
652 csp
= clone_stackframe(sp
, regs
->u_regs
[UREG_FP
]);
655 t
->kregs
->u_regs
[UREG_FP
] = csp
;
661 /* Set the return value for the child. */
662 t
->kregs
->u_regs
[UREG_I0
] = current
->pid
;
663 t
->kregs
->u_regs
[UREG_I1
] = 1;
665 /* Set the second return value for the parent. */
666 regs
->u_regs
[UREG_I1
] = 0;
672 * This is the mechanism for creating a new kernel thread.
674 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
675 * who haven't done an "execve()") should use this: it will work within
676 * a system call from a "real" process, but the process memory space will
677 * not be free'd until both the parent and the child have exited.
679 pid_t
kernel_thread(int (*fn
)(void *), void * arg
, unsigned long flags
)
683 /* If the parent runs before fn(arg) is called by the child,
684 * the input registers of this function can be clobbered.
685 * So we stash 'fn' and 'arg' into global registers which
686 * will not be modified by the parent.
688 __asm__
__volatile("mov %4, %%g2\n\t" /* Save FN into global */
689 "mov %5, %%g3\n\t" /* Save ARG into global */
690 "mov %1, %%g1\n\t" /* Clone syscall nr. */
691 "mov %2, %%o0\n\t" /* Clone flags. */
692 "mov 0, %%o1\n\t" /* usp arg == 0 */
693 "t 0x6d\n\t" /* Linux/Sparc clone(). */
694 "brz,a,pn %%o1, 1f\n\t" /* Parent, just return. */
696 "jmpl %%g2, %%o7\n\t" /* Call the function. */
697 " mov %%g3, %%o0\n\t" /* Set arg in delay. */
699 "t 0x6d\n\t" /* Linux/Sparc exit(). */
700 /* Notreached by child. */
703 "i" (__NR_clone
), "r" (flags
| CLONE_VM
| CLONE_UNTRACED
),
704 "i" (__NR_exit
), "r" (fn
), "r" (arg
) :
705 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
710 * fill in the user structure for a core dump..
712 void dump_thread(struct pt_regs
* regs
, struct user
* dump
)
714 /* Only should be used for SunOS and ancient a.out
715 * SparcLinux binaries... Not worth implementing.
717 memset(dump
, 0, sizeof(struct user
));
722 unsigned int pr_regs
[32];
723 unsigned long pr_dregs
[16];
725 unsigned int __unused
;
727 unsigned char pr_qcnt
;
728 unsigned char pr_q_entrysize
;
730 unsigned int pr_q
[64];
734 * fill in the fpu structure for a core dump.
736 int dump_fpu (struct pt_regs
* regs
, elf_fpregset_t
* fpregs
)
738 unsigned long *kfpregs
= current_thread_info()->fpregs
;
739 unsigned long fprs
= current_thread_info()->fpsaved
[0];
741 if (test_thread_flag(TIF_32BIT
)) {
742 elf_fpregset_t32
*fpregs32
= (elf_fpregset_t32
*)fpregs
;
745 memcpy(&fpregs32
->pr_fr
.pr_regs
[0], kfpregs
,
746 sizeof(unsigned int) * 32);
748 memset(&fpregs32
->pr_fr
.pr_regs
[0], 0,
749 sizeof(unsigned int) * 32);
750 fpregs32
->pr_qcnt
= 0;
751 fpregs32
->pr_q_entrysize
= 8;
752 memset(&fpregs32
->pr_q
[0], 0,
753 (sizeof(unsigned int) * 64));
754 if (fprs
& FPRS_FEF
) {
755 fpregs32
->pr_fsr
= (unsigned int) current_thread_info()->xfsr
[0];
758 fpregs32
->pr_fsr
= 0;
763 memcpy(&fpregs
->pr_regs
[0], kfpregs
,
764 sizeof(unsigned int) * 32);
766 memset(&fpregs
->pr_regs
[0], 0,
767 sizeof(unsigned int) * 32);
769 memcpy(&fpregs
->pr_regs
[16], kfpregs
+16,
770 sizeof(unsigned int) * 32);
772 memset(&fpregs
->pr_regs
[16], 0,
773 sizeof(unsigned int) * 32);
774 if(fprs
& FPRS_FEF
) {
775 fpregs
->pr_fsr
= current_thread_info()->xfsr
[0];
776 fpregs
->pr_gsr
= current_thread_info()->gsr
[0];
778 fpregs
->pr_fsr
= fpregs
->pr_gsr
= 0;
780 fpregs
->pr_fprs
= fprs
;
786 * sparc_execve() executes a new program after the asm stub has set
787 * things up for us. This should basically do what I want it to.
789 asmlinkage
int sparc_execve(struct pt_regs
*regs
)
794 /* User register window flush is done by entry.S */
796 /* Check for indirect call. */
797 if (regs
->u_regs
[UREG_G1
] == 0)
800 filename
= getname((char *)regs
->u_regs
[base
+ UREG_I0
]);
801 error
= PTR_ERR(filename
);
802 if (IS_ERR(filename
))
804 error
= do_execve(filename
, (char **) regs
->u_regs
[base
+ UREG_I1
],
805 (char **) regs
->u_regs
[base
+ UREG_I2
], regs
);
809 current_thread_info()->xfsr
[0] = 0;
810 current_thread_info()->fpsaved
[0] = 0;
811 regs
->tstate
&= ~TSTATE_PEF
;
812 current
->ptrace
&= ~PT_DTRACE
;
818 extern void scheduling_functions_start_here(void);
819 extern void scheduling_functions_end_here(void);
821 unsigned long get_wchan(struct task_struct
*task
)
823 unsigned long pc
, fp
, bias
= 0;
824 unsigned long thread_info_base
;
825 struct reg_window
*rw
;
826 unsigned long ret
= 0;
829 if (!task
|| task
== current
||
830 task
->state
== TASK_RUNNING
)
833 thread_info_base
= (unsigned long) task
->thread_info
;
835 fp
= task
->thread_info
->ksp
+ bias
;
838 /* Bogus frame pointer? */
839 if (fp
< (thread_info_base
+ sizeof(struct thread_info
)) ||
840 fp
>= (thread_info_base
+ THREAD_SIZE
))
842 rw
= (struct reg_window
*) fp
;
844 if (pc
< ((unsigned long) scheduling_functions_start_here
) ||
845 pc
>= ((unsigned long) scheduling_functions_end_here
)) {
849 fp
= rw
->ins
[6] + bias
;
850 } while (++count
< 16);