1 /* $Id: process.c,v 1.113 2000/11/08 08:14:58 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>
20 #include <linux/smp.h>
21 #include <linux/smp_lock.h>
22 #include <linux/stddef.h>
23 #include <linux/unistd.h>
24 #include <linux/ptrace.h>
25 #include <linux/malloc.h>
26 #include <linux/user.h>
27 #include <linux/a.out.h>
28 #include <linux/config.h>
29 #include <linux/reboot.h>
30 #include <linux/delay.h>
32 #include <asm/oplib.h>
33 #include <asm/uaccess.h>
34 #include <asm/system.h>
36 #include <asm/pgalloc.h>
37 #include <asm/pgtable.h>
38 #include <asm/processor.h>
39 #include <asm/pstate.h>
41 #include <asm/fpumacro.h>
43 /* #define VERBOSE_SHOWREGS */
48 * the idle loop on a Sparc... ;)
52 if (current
->pid
!= 0)
55 /* endless idle loop with no priority at all */
57 current
->counter
= -100;
61 /* If current->need_resched is zero we should really
62 * setup for a system wakup event and execute a shutdown
65 * But this requires writing back the contents of the
66 * L2 cache etc. so implement this later. -DaveM
68 while (!current
->need_resched
)
80 * the idle loop on a UltraMultiPenguin...
82 #define idle_me_harder() (cpu_data[current->processor].idle_volume += 1)
83 #define unidle_me() (cpu_data[current->processor].idle_volume = 0)
87 current
->counter
= -100;
91 if (current
->need_resched
!= 0) {
98 /* The store ordering is so that IRQ handlers on
99 * other cpus see our increasing idleness for the buddy
100 * redistribution algorithm. -DaveM
102 membar("#StoreStore | #StoreLoad");
108 extern char reboot_command
[];
110 #ifdef CONFIG_SUN_CONSOLE
111 extern void (*prom_palette
)(int);
112 extern int serial_console
;
115 void machine_halt(void)
120 #ifdef CONFIG_SUN_CONSOLE
121 if (!serial_console
&& prom_palette
)
125 panic("Halt failed!");
128 void machine_restart(char * cmd
)
136 p
= strchr (reboot_command
, '\n');
138 #ifdef CONFIG_SUN_CONSOLE
139 if (!serial_console
&& prom_palette
)
145 prom_reboot(reboot_command
);
147 panic("Reboot failed!");
150 static void show_regwindow32(struct pt_regs
*regs
)
152 struct reg_window32
*rw
;
153 struct reg_window32 r_w
;
156 __asm__
__volatile__ ("flushw");
157 rw
= (struct reg_window32
*)((long)(unsigned)regs
->u_regs
[14]);
160 if (copy_from_user (&r_w
, rw
, sizeof(r_w
))) {
166 printk("l0: %08x l1: %08x l2: %08x l3: %08x "
167 "l4: %08x l5: %08x l6: %08x l7: %08x\n",
168 rw
->locals
[0], rw
->locals
[1], rw
->locals
[2], rw
->locals
[3],
169 rw
->locals
[4], rw
->locals
[5], rw
->locals
[6], rw
->locals
[7]);
170 printk("i0: %08x i1: %08x i2: %08x i3: %08x "
171 "i4: %08x i5: %08x i6: %08x i7: %08x\n",
172 rw
->ins
[0], rw
->ins
[1], rw
->ins
[2], rw
->ins
[3],
173 rw
->ins
[4], rw
->ins
[5], rw
->ins
[6], rw
->ins
[7]);
176 static void show_regwindow(struct pt_regs
*regs
)
178 struct reg_window
*rw
;
179 struct reg_window r_w
;
182 if ((regs
->tstate
& TSTATE_PRIV
) || !(current
->thread
.flags
& SPARC_FLAG_32BIT
)) {
183 __asm__
__volatile__ ("flushw");
184 rw
= (struct reg_window
*)(regs
->u_regs
[14] + STACK_BIAS
);
185 if (!(regs
->tstate
& TSTATE_PRIV
)) {
188 if (copy_from_user (&r_w
, rw
, sizeof(r_w
))) {
196 show_regwindow32(regs
);
199 printk("l0: %016lx l1: %016lx l2: %016lx l3: %016lx\n",
200 rw
->locals
[0], rw
->locals
[1], rw
->locals
[2], rw
->locals
[3]);
201 printk("l4: %016lx l5: %016lx l6: %016lx l7: %016lx\n",
202 rw
->locals
[4], rw
->locals
[5], rw
->locals
[6], rw
->locals
[7]);
203 printk("i0: %016lx i1: %016lx i2: %016lx i3: %016lx\n",
204 rw
->ins
[0], rw
->ins
[1], rw
->ins
[2], rw
->ins
[3]);
205 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
206 rw
->ins
[4], rw
->ins
[5], rw
->ins
[6], rw
->ins
[7]);
209 void show_stackframe(struct sparc_stackf
*sf
)
215 printk("l0: %016lx l1: %016lx l2: %016lx l3: %016lx\n"
216 "l4: %016lx l5: %016lx l6: %016lx l7: %016lx\n",
217 sf
->locals
[0], sf
->locals
[1], sf
->locals
[2], sf
->locals
[3],
218 sf
->locals
[4], sf
->locals
[5], sf
->locals
[6], sf
->locals
[7]);
219 printk("i0: %016lx i1: %016lx i2: %016lx i3: %016lx\n"
220 "i4: %016lx i5: %016lx fp: %016lx ret_pc: %016lx\n",
221 sf
->ins
[0], sf
->ins
[1], sf
->ins
[2], sf
->ins
[3],
222 sf
->ins
[4], sf
->ins
[5], (unsigned long)sf
->fp
, sf
->callers_pc
);
223 printk("sp: %016lx x0: %016lx x1: %016lx x2: %016lx\n"
224 "x3: %016lx x4: %016lx x5: %016lx xx: %016lx\n",
225 (unsigned long)sf
->structptr
, sf
->xargs
[0], sf
->xargs
[1],
226 sf
->xargs
[2], sf
->xargs
[3], sf
->xargs
[4], sf
->xargs
[5],
228 size
= ((unsigned long)sf
->fp
) - ((unsigned long)sf
);
229 size
-= STACKFRAME_SZ
;
230 stk
= (unsigned long *)((unsigned long)sf
+ STACKFRAME_SZ
);
233 printk("s%d: %016lx\n", i
++, *stk
++);
234 } while ((size
-= sizeof(unsigned long)));
237 void show_stackframe32(struct sparc_stackf32
*sf
)
243 printk("l0: %08x l1: %08x l2: %08x l3: %08x\n",
244 sf
->locals
[0], sf
->locals
[1], sf
->locals
[2], sf
->locals
[3]);
245 printk("l4: %08x l5: %08x l6: %08x l7: %08x\n",
246 sf
->locals
[4], sf
->locals
[5], sf
->locals
[6], sf
->locals
[7]);
247 printk("i0: %08x i1: %08x i2: %08x i3: %08x\n",
248 sf
->ins
[0], sf
->ins
[1], sf
->ins
[2], sf
->ins
[3]);
249 printk("i4: %08x i5: %08x fp: %08x ret_pc: %08x\n",
250 sf
->ins
[4], sf
->ins
[5], sf
->fp
, sf
->callers_pc
);
251 printk("sp: %08x x0: %08x x1: %08x x2: %08x\n"
252 "x3: %08x x4: %08x x5: %08x xx: %08x\n",
253 sf
->structptr
, sf
->xargs
[0], sf
->xargs
[1],
254 sf
->xargs
[2], sf
->xargs
[3], sf
->xargs
[4], sf
->xargs
[5],
256 size
= ((unsigned long)sf
->fp
) - ((unsigned long)sf
);
257 size
-= STACKFRAME32_SZ
;
258 stk
= (unsigned *)((unsigned long)sf
+ STACKFRAME32_SZ
);
261 printk("s%d: %08x\n", i
++, *stk
++);
262 } while ((size
-= sizeof(unsigned)));
266 static spinlock_t regdump_lock
= SPIN_LOCK_UNLOCKED
;
269 void __show_regs(struct pt_regs
* regs
)
274 spin_lock_irqsave(®dump_lock
, flags
);
275 printk("CPU[%d]: local_irq_count[%u] irqs_running[%d]\n",
277 local_irq_count(smp_processor_id()),
280 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x\n", regs
->tstate
,
281 regs
->tpc
, regs
->tnpc
, regs
->y
);
282 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
283 regs
->u_regs
[0], regs
->u_regs
[1], regs
->u_regs
[2],
285 printk("g4: %016lx g5: %016lx g6: %016lx g7: %016lx\n",
286 regs
->u_regs
[4], regs
->u_regs
[5], regs
->u_regs
[6],
288 printk("o0: %016lx o1: %016lx o2: %016lx o3: %016lx\n",
289 regs
->u_regs
[8], regs
->u_regs
[9], regs
->u_regs
[10],
291 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
292 regs
->u_regs
[12], regs
->u_regs
[13], regs
->u_regs
[14],
294 show_regwindow(regs
);
296 spin_unlock_irqrestore(®dump_lock
, flags
);
300 #ifdef VERBOSE_SHOWREGS
301 static void idump_from_user (unsigned int *pc
)
306 if((((unsigned long) pc
) & 3))
310 for(i
= -3; i
< 6; i
++) {
312 printk("%c%08x%c",i
?' ':'<',code
,i
?' ':'>');
319 void show_regs(struct pt_regs
*regs
)
321 #ifdef VERBOSE_SHOWREGS
322 extern long etrap
, etraptl1
;
327 extern void smp_report_regs(void);
333 #ifdef VERBOSE_SHOWREGS
334 if (regs
->tpc
>= &etrap
&& regs
->tpc
< &etraptl1
&&
335 regs
->u_regs
[14] >= (long)current
- PAGE_SIZE
&&
336 regs
->u_regs
[14] < (long)current
+ 6 * PAGE_SIZE
) {
337 printk ("*********parent**********\n");
338 __show_regs((struct pt_regs
*)(regs
->u_regs
[14] + STACK_BIAS
+ REGWIN_SZ
));
339 idump_from_user(((struct pt_regs
*)(regs
->u_regs
[14] + STACK_BIAS
+ REGWIN_SZ
))->tpc
);
340 printk ("*********endpar**********\n");
345 void show_regs32(struct pt_regs32
*regs
)
347 printk("PSR: %08x PC: %08x NPC: %08x Y: %08x\n", regs
->psr
,
348 regs
->pc
, regs
->npc
, regs
->y
);
349 printk("g0: %08x g1: %08x g2: %08x g3: %08x ",
350 regs
->u_regs
[0], regs
->u_regs
[1], regs
->u_regs
[2],
352 printk("g4: %08x g5: %08x g6: %08x g7: %08x\n",
353 regs
->u_regs
[4], regs
->u_regs
[5], regs
->u_regs
[6],
355 printk("o0: %08x o1: %08x o2: %08x o3: %08x ",
356 regs
->u_regs
[8], regs
->u_regs
[9], regs
->u_regs
[10],
358 printk("o4: %08x o5: %08x sp: %08x ret_pc: %08x\n",
359 regs
->u_regs
[12], regs
->u_regs
[13], regs
->u_regs
[14],
363 void show_thread(struct thread_struct
*thread
)
368 printk("kregs: 0x%016lx\n", (unsigned long)thread
->kregs
);
369 show_regs(thread
->kregs
);
371 printk("ksp: 0x%016lx\n", thread
->ksp
);
373 if (thread
->w_saved
) {
374 for (i
= 0; i
< NSWINS
; i
++) {
375 if (!thread
->rwbuf_stkptrs
[i
])
377 printk("reg_window[%d]:\n", i
);
378 printk("stack ptr: 0x%016lx\n", thread
->rwbuf_stkptrs
[i
]);
380 printk("w_saved: 0x%04x\n", thread
->w_saved
);
383 printk("flags: 0x%08x\n", thread
->flags
);
384 printk("current_ds: 0x%x\n", thread
->current_ds
.seg
);
387 /* Free current thread data structures etc.. */
388 void exit_thread(void)
390 struct thread_struct
*t
= ¤t
->thread
;
393 if (t
->utraps
[0] < 2)
399 /* Turn off performance counters if on. */
400 if (t
->flags
& SPARC_FLAG_PERFCTR
) {
401 t
->user_cntd0
= t
->user_cntd1
= NULL
;
403 t
->flags
&= ~(SPARC_FLAG_PERFCTR
);
408 void flush_thread(void)
410 struct thread_struct
*t
= ¤t
->thread
;
413 if (t
->flags
& SPARC_FLAG_32BIT
) {
414 struct mm_struct
*mm
= current
->mm
;
415 pgd_t
*pgd0
= &mm
->pgd
[0];
416 unsigned long pgd_cache
;
418 if (pgd_none(*pgd0
)) {
419 pmd_t
*page
= get_pmd_fast();
421 (void) get_pmd_slow(pgd0
, 0);
425 pgd_cache
= pgd_val(*pgd0
) << 11UL;
426 __asm__
__volatile__("stxa %0, [%1] %2"
435 /* Turn off performance counters if on. */
436 if (t
->flags
& SPARC_FLAG_PERFCTR
) {
437 t
->user_cntd0
= t
->user_cntd1
= NULL
;
439 t
->flags
&= ~(SPARC_FLAG_PERFCTR
);
443 /* Clear FPU register state. */
446 if (t
->current_ds
.seg
!= ASI_AIUS
)
449 /* Init new signal delivery disposition. */
450 t
->flags
&= ~SPARC_FLAG_NEWSIGNALS
;
453 /* It's a bit more tricky when 64-bit tasks are involved... */
454 static unsigned long clone_stackframe(unsigned long csp
, unsigned long psp
)
456 unsigned long fp
, distance
, rval
;
458 if (!(current
->thread
.flags
& SPARC_FLAG_32BIT
)) {
461 __get_user(fp
, &(((struct reg_window
*)psp
)->ins
[6]));
463 __get_user(fp
, &(((struct reg_window32
*)psp
)->ins
[6]));
465 /* Now 8-byte align the stack as this is mandatory in the
466 * Sparc ABI due to how register windows work. This hides
467 * the restriction from thread libraries etc. -DaveM
472 rval
= (csp
- distance
);
473 if (copy_in_user(rval
, psp
, distance
))
475 else if (current
->thread
.flags
& SPARC_FLAG_32BIT
) {
476 if (put_user(((u32
)csp
), &(((struct reg_window32
*)rval
)->ins
[6])))
479 if (put_user(((u64
)csp
- STACK_BIAS
),
480 &(((struct reg_window
*)rval
)->ins
[6])))
483 rval
= rval
- STACK_BIAS
;
489 /* Standard stuff. */
490 static inline void shift_window_buffer(int first_win
, int last_win
,
491 struct thread_struct
*t
)
495 for (i
= first_win
; i
< last_win
; i
++) {
496 t
->rwbuf_stkptrs
[i
] = t
->rwbuf_stkptrs
[i
+1];
497 memcpy(&t
->reg_window
[i
], &t
->reg_window
[i
+1],
498 sizeof(struct reg_window
));
502 void synchronize_user_stack(void)
504 struct thread_struct
*t
= ¤t
->thread
;
505 unsigned long window
;
507 flush_user_windows();
508 if ((window
= t
->w_saved
) != 0) {
509 int winsize
= REGWIN_SZ
;
512 if (t
->flags
& SPARC_FLAG_32BIT
)
513 winsize
= REGWIN32_SZ
;
519 unsigned long sp
= (t
->rwbuf_stkptrs
[window
] + bias
);
520 struct reg_window
*rwin
= &t
->reg_window
[window
];
522 if (!copy_to_user((char *)sp
, rwin
, winsize
)) {
523 shift_window_buffer(window
, t
->w_saved
- 1, t
);
530 void fault_in_user_windows(void)
532 struct thread_struct
*t
= ¤t
->thread
;
533 unsigned long window
;
534 int winsize
= REGWIN_SZ
;
537 if (t
->flags
& SPARC_FLAG_32BIT
)
538 winsize
= REGWIN32_SZ
;
542 flush_user_windows();
548 unsigned long sp
= (t
->rwbuf_stkptrs
[window
] + bias
);
549 struct reg_window
*rwin
= &t
->reg_window
[window
];
551 if (copy_to_user((char *)sp
, rwin
, winsize
))
559 t
->w_saved
= window
+ 1;
563 /* Copy a Sparc thread. The fork() return value conventions
564 * under SunOS are nothing short of bletcherous:
565 * Parent --> %o0 == childs pid, %o1 == 0
566 * Child --> %o0 == parents pid, %o1 == 1
568 * NOTE: We have a separate fork kpsr/kwim because
569 * the parent could change these values between
570 * sys_fork invocation and when we reach here
571 * if the parent should sleep while trying to
572 * allocate the task_struct and kernel stack in
575 int copy_thread(int nr
, unsigned long clone_flags
, unsigned long sp
,
576 unsigned long unused
,
577 struct task_struct
*p
, struct pt_regs
*regs
)
579 struct thread_struct
*t
= &p
->thread
;
580 char *child_trap_frame
;
582 /* Calculate offset to stack_frame & pt_regs */
583 child_trap_frame
= ((char *)p
) + ((PAGE_SIZE
<< 1) - (TRACEREG_SZ
+REGWIN_SZ
));
584 memcpy(child_trap_frame
, (((struct reg_window
*)regs
)-1), (TRACEREG_SZ
+REGWIN_SZ
));
585 t
->ksp
= ((unsigned long) child_trap_frame
) - STACK_BIAS
;
586 t
->flags
|= SPARC_FLAG_NEWCHILD
;
587 t
->kregs
= (struct pt_regs
*)(child_trap_frame
+sizeof(struct reg_window
));
588 t
->cwp
= (regs
->tstate
+ 1) & TSTATE_CWP
;
591 if (regs
->tstate
& TSTATE_PRIV
) {
592 /* Special case, if we are spawning a kernel thread from
593 * a userspace task (via KMOD, NFS, or similar) we must
594 * disable performance counters in the child because the
595 * address space and protection realm are changing.
597 if (t
->flags
& SPARC_FLAG_PERFCTR
) {
598 t
->user_cntd0
= t
->user_cntd1
= NULL
;
600 t
->flags
&= ~(SPARC_FLAG_PERFCTR
);
602 t
->kregs
->u_regs
[UREG_FP
] = p
->thread
.ksp
;
603 t
->current_ds
= KERNEL_DS
;
604 flush_register_windows();
605 memcpy((void *)(t
->ksp
+ STACK_BIAS
),
606 (void *)(regs
->u_regs
[UREG_FP
] + STACK_BIAS
),
607 sizeof(struct reg_window
));
608 t
->kregs
->u_regs
[UREG_G6
] = (unsigned long) p
;
610 if (t
->flags
& SPARC_FLAG_32BIT
) {
611 sp
&= 0x00000000ffffffffUL
;
612 regs
->u_regs
[UREG_FP
] &= 0x00000000ffffffffUL
;
614 t
->kregs
->u_regs
[UREG_FP
] = sp
;
615 t
->current_ds
= USER_DS
;
616 if (sp
!= regs
->u_regs
[UREG_FP
]) {
619 csp
= clone_stackframe(sp
, regs
->u_regs
[UREG_FP
]);
622 t
->kregs
->u_regs
[UREG_FP
] = csp
;
628 /* Set the return value for the child. */
629 t
->kregs
->u_regs
[UREG_I0
] = current
->pid
;
630 t
->kregs
->u_regs
[UREG_I1
] = 1;
632 /* Set the second return value for the parent. */
633 regs
->u_regs
[UREG_I1
] = 0;
639 * This is the mechanism for creating a new kernel thread.
641 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
642 * who haven't done an "execve()") should use this: it will work within
643 * a system call from a "real" process, but the process memory space will
644 * not be free'd until both the parent and the child have exited.
646 pid_t
kernel_thread(int (*fn
)(void *), void * arg
, unsigned long flags
)
650 /* If the parent runs before fn(arg) is called by the child,
651 * the input registers of this function can be clobbered.
652 * So we stash 'fn' and 'arg' into global registers which
653 * will not be modified by the parent.
655 __asm__
__volatile("mov %4, %%g2\n\t" /* Save FN into global */
656 "mov %5, %%g3\n\t" /* Save ARG into global */
657 "mov %1, %%g1\n\t" /* Clone syscall nr. */
658 "mov %2, %%o0\n\t" /* Clone flags. */
659 "mov 0, %%o1\n\t" /* usp arg == 0 */
660 "t 0x6d\n\t" /* Linux/Sparc clone(). */
661 "brz,a,pn %%o1, 1f\n\t" /* Parent, just return. */
663 "jmpl %%g2, %%o7\n\t" /* Call the function. */
664 " mov %%g3, %%o0\n\t" /* Set arg in delay. */
666 "t 0x6d\n\t" /* Linux/Sparc exit(). */
667 /* Notreached by child. */
670 "i" (__NR_clone
), "r" (flags
| CLONE_VM
),
671 "i" (__NR_exit
), "r" (fn
), "r" (arg
) :
672 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
677 * fill in the user structure for a core dump..
679 void dump_thread(struct pt_regs
* regs
, struct user
* dump
)
682 /* Only should be used for SunOS and ancient a.out
683 * SparcLinux binaries... Fixme some day when bored.
684 * But for now at least plug the security hole :-)
686 memset(dump
, 0, sizeof(struct user
));
688 unsigned long first_stack_page
;
689 dump
->magic
= SUNOS_CORE_MAGIC
;
690 dump
->len
= sizeof(struct user
);
691 dump
->regs
.psr
= regs
->psr
;
692 dump
->regs
.pc
= regs
->pc
;
693 dump
->regs
.npc
= regs
->npc
;
694 dump
->regs
.y
= regs
->y
;
696 memcpy(&dump
->regs
.regs
[0], ®s
->u_regs
[1], (sizeof(unsigned long) * 15));
697 dump
->u_tsize
= (((unsigned long) current
->mm
->end_code
) -
698 ((unsigned long) current
->mm
->start_code
)) & ~(PAGE_SIZE
- 1);
699 dump
->u_dsize
= ((unsigned long) (current
->mm
->brk
+ (PAGE_SIZE
-1)));
700 dump
->u_dsize
-= dump
->u_tsize
;
701 dump
->u_dsize
&= ~(PAGE_SIZE
- 1);
702 first_stack_page
= (regs
->u_regs
[UREG_FP
] & ~(PAGE_SIZE
- 1));
703 dump
->u_ssize
= (TASK_SIZE
- first_stack_page
) & ~(PAGE_SIZE
- 1);
704 memcpy(&dump
->fpu
.fpstatus
.fregs
.regs
[0], ¤t
->thread
.float_regs
[0], (sizeof(unsigned long) * 32));
705 dump
->fpu
.fpstatus
.fsr
= current
->thread
.fsr
;
706 dump
->fpu
.fpstatus
.flags
= dump
->fpu
.fpstatus
.extra
= 0;
712 unsigned int pr_regs
[32];
713 unsigned long pr_dregs
[16];
715 unsigned int __unused
;
717 unsigned char pr_qcnt
;
718 unsigned char pr_q_entrysize
;
720 unsigned int pr_q
[64];
724 * fill in the fpu structure for a core dump.
726 int dump_fpu (struct pt_regs
* regs
, elf_fpregset_t
* fpregs
)
728 unsigned long *kfpregs
= (unsigned long *)(((char *)current
) + AOFF_task_fpregs
);
729 unsigned long fprs
= current
->thread
.fpsaved
[0];
731 if ((current
->thread
.flags
& SPARC_FLAG_32BIT
) != 0) {
732 elf_fpregset_t32
*fpregs32
= (elf_fpregset_t32
*)fpregs
;
735 memcpy(&fpregs32
->pr_fr
.pr_regs
[0], kfpregs
,
736 sizeof(unsigned int) * 32);
738 memset(&fpregs32
->pr_fr
.pr_regs
[0], 0,
739 sizeof(unsigned int) * 32);
740 fpregs32
->pr_qcnt
= 0;
741 fpregs32
->pr_q_entrysize
= 8;
742 memset(&fpregs32
->pr_q
[0], 0,
743 (sizeof(unsigned int) * 64));
744 if (fprs
& FPRS_FEF
) {
745 fpregs32
->pr_fsr
= (unsigned int) current
->thread
.xfsr
[0];
748 fpregs32
->pr_fsr
= 0;
753 memcpy(&fpregs
->pr_regs
[0], kfpregs
,
754 sizeof(unsigned int) * 32);
756 memset(&fpregs
->pr_regs
[0], 0,
757 sizeof(unsigned int) * 32);
759 memcpy(&fpregs
->pr_regs
[16], kfpregs
+16,
760 sizeof(unsigned int) * 32);
762 memset(&fpregs
->pr_regs
[16], 0,
763 sizeof(unsigned int) * 32);
764 if(fprs
& FPRS_FEF
) {
765 fpregs
->pr_fsr
= current
->thread
.xfsr
[0];
766 fpregs
->pr_gsr
= current
->thread
.gsr
[0];
768 fpregs
->pr_fsr
= fpregs
->pr_gsr
= 0;
770 fpregs
->pr_fprs
= fprs
;
776 * sparc_execve() executes a new program after the asm stub has set
777 * things up for us. This should basically do what I want it to.
779 asmlinkage
int sparc_execve(struct pt_regs
*regs
)
784 /* User register window flush is done by entry.S */
786 /* Check for indirect call. */
787 if (regs
->u_regs
[UREG_G1
] == 0)
790 filename
= getname((char *)regs
->u_regs
[base
+ UREG_I0
]);
791 error
= PTR_ERR(filename
);
792 if (IS_ERR(filename
))
794 error
= do_execve(filename
, (char **) regs
->u_regs
[base
+ UREG_I1
],
795 (char **) regs
->u_regs
[base
+ UREG_I2
], regs
);
799 current
->thread
.xfsr
[0] = 0;
800 current
->thread
.fpsaved
[0] = 0;
801 regs
->tstate
&= ~TSTATE_PEF
;