1 /* $Id: process.c,v 1.100 1999/08/31 04:39:39 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/pgtable.h>
37 #include <asm/processor.h>
38 #include <asm/pstate.h>
40 #include <asm/fpumacro.h>
42 /* #define VERBOSE_SHOWREGS */
47 * the idle loop on a Sparc... ;)
51 if (current
->pid
!= 0)
54 /* endless idle loop with no priority at all */
55 current
->priority
= 0;
56 current
->counter
= -100;
60 /* If current->need_resched is zero we should really
61 * setup for a system wakup event and execute a shutdown
64 * But this requires writing back the contents of the
65 * L2 cache etc. so implement this later. -DaveM
76 * the idle loop on a UltraMultiPenguin...
78 #define idle_me_harder() (cpu_data[current->processor].idle_volume += 1)
79 #define unidle_me() (cpu_data[current->processor].idle_volume = 0)
82 current
->priority
= 0;
83 current
->counter
= -100;
87 if (current
->need_resched
!= 0) {
94 /* The store ordering is so that IRQ handlers on
95 * other cpus see our increasing idleness for the buddy
96 * redistribution algorithm. -DaveM
98 membar("#StoreStore | #StoreLoad");
104 extern char reboot_command
[];
106 #ifdef CONFIG_SUN_CONSOLE
107 extern void (*prom_palette
)(int);
108 extern int serial_console
;
111 void machine_halt(void)
116 #ifdef CONFIG_SUN_CONSOLE
117 if (!serial_console
&& prom_palette
)
121 panic("Halt failed!");
124 void machine_restart(char * cmd
)
132 p
= strchr (reboot_command
, '\n');
134 #ifdef CONFIG_SUN_CONSOLE
135 if (!serial_console
&& prom_palette
)
141 prom_reboot(reboot_command
);
143 panic("Reboot failed!");
146 static void show_regwindow32(struct pt_regs
*regs
)
148 struct reg_window32
*rw
;
149 struct reg_window32 r_w
;
152 __asm__
__volatile__ ("flushw");
153 rw
= (struct reg_window32
*)((long)(unsigned)regs
->u_regs
[14]);
156 if (copy_from_user (&r_w
, rw
, sizeof(r_w
))) {
162 printk("l0: %08x l1: %08x l2: %08x l3: %08x "
163 "l4: %08x l5: %08x l6: %08x l7: %08x\n",
164 rw
->locals
[0], rw
->locals
[1], rw
->locals
[2], rw
->locals
[3],
165 rw
->locals
[4], rw
->locals
[5], rw
->locals
[6], rw
->locals
[7]);
166 printk("i0: %08x i1: %08x i2: %08x i3: %08x "
167 "i4: %08x i5: %08x i6: %08x i7: %08x\n",
168 rw
->ins
[0], rw
->ins
[1], rw
->ins
[2], rw
->ins
[3],
169 rw
->ins
[4], rw
->ins
[5], rw
->ins
[6], rw
->ins
[7]);
172 static void show_regwindow(struct pt_regs
*regs
)
174 struct reg_window
*rw
;
175 struct reg_window r_w
;
178 if ((regs
->tstate
& TSTATE_PRIV
) || !(current
->thread
.flags
& SPARC_FLAG_32BIT
)) {
179 __asm__
__volatile__ ("flushw");
180 rw
= (struct reg_window
*)(regs
->u_regs
[14] + STACK_BIAS
);
181 if (!(regs
->tstate
& TSTATE_PRIV
)) {
184 if (copy_from_user (&r_w
, rw
, sizeof(r_w
))) {
192 show_regwindow32(regs
);
195 printk("l0: %016lx l1: %016lx l2: %016lx l3: %016lx\n",
196 rw
->locals
[0], rw
->locals
[1], rw
->locals
[2], rw
->locals
[3]);
197 printk("l4: %016lx l5: %016lx l6: %016lx l7: %016lx\n",
198 rw
->locals
[4], rw
->locals
[5], rw
->locals
[6], rw
->locals
[7]);
199 printk("i0: %016lx i1: %016lx i2: %016lx i3: %016lx\n",
200 rw
->ins
[0], rw
->ins
[1], rw
->ins
[2], rw
->ins
[3]);
201 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
202 rw
->ins
[4], rw
->ins
[5], rw
->ins
[6], rw
->ins
[7]);
205 void show_stackframe(struct sparc_stackf
*sf
)
211 printk("l0: %016lx l1: %016lx l2: %016lx l3: %016lx\n"
212 "l4: %016lx l5: %016lx l6: %016lx l7: %016lx\n",
213 sf
->locals
[0], sf
->locals
[1], sf
->locals
[2], sf
->locals
[3],
214 sf
->locals
[4], sf
->locals
[5], sf
->locals
[6], sf
->locals
[7]);
215 printk("i0: %016lx i1: %016lx i2: %016lx i3: %016lx\n"
216 "i4: %016lx i5: %016lx fp: %016lx ret_pc: %016lx\n",
217 sf
->ins
[0], sf
->ins
[1], sf
->ins
[2], sf
->ins
[3],
218 sf
->ins
[4], sf
->ins
[5], (unsigned long)sf
->fp
, sf
->callers_pc
);
219 printk("sp: %016lx x0: %016lx x1: %016lx x2: %016lx\n"
220 "x3: %016lx x4: %016lx x5: %016lx xx: %016lx\n",
221 (unsigned long)sf
->structptr
, sf
->xargs
[0], sf
->xargs
[1],
222 sf
->xargs
[2], sf
->xargs
[3], sf
->xargs
[4], sf
->xargs
[5],
224 size
= ((unsigned long)sf
->fp
) - ((unsigned long)sf
);
225 size
-= STACKFRAME_SZ
;
226 stk
= (unsigned long *)((unsigned long)sf
+ STACKFRAME_SZ
);
229 printk("s%d: %016lx\n", i
++, *stk
++);
230 } while ((size
-= sizeof(unsigned long)));
233 void show_stackframe32(struct sparc_stackf32
*sf
)
239 printk("l0: %08x l1: %08x l2: %08x l3: %08x\n",
240 sf
->locals
[0], sf
->locals
[1], sf
->locals
[2], sf
->locals
[3]);
241 printk("l4: %08x l5: %08x l6: %08x l7: %08x\n",
242 sf
->locals
[4], sf
->locals
[5], sf
->locals
[6], sf
->locals
[7]);
243 printk("i0: %08x i1: %08x i2: %08x i3: %08x\n",
244 sf
->ins
[0], sf
->ins
[1], sf
->ins
[2], sf
->ins
[3]);
245 printk("i4: %08x i5: %08x fp: %08x ret_pc: %08x\n",
246 sf
->ins
[4], sf
->ins
[5], sf
->fp
, sf
->callers_pc
);
247 printk("sp: %08x x0: %08x x1: %08x x2: %08x\n"
248 "x3: %08x x4: %08x x5: %08x xx: %08x\n",
249 sf
->structptr
, sf
->xargs
[0], sf
->xargs
[1],
250 sf
->xargs
[2], sf
->xargs
[3], sf
->xargs
[4], sf
->xargs
[5],
252 size
= ((unsigned long)sf
->fp
) - ((unsigned long)sf
);
253 size
-= STACKFRAME32_SZ
;
254 stk
= (unsigned *)((unsigned long)sf
+ STACKFRAME32_SZ
);
257 printk("s%d: %08x\n", i
++, *stk
++);
258 } while ((size
-= sizeof(unsigned)));
262 static spinlock_t regdump_lock
= SPIN_LOCK_UNLOCKED
;
265 void __show_regs(struct pt_regs
* regs
)
270 spin_lock_irqsave(®dump_lock
, flags
);
271 printk("CPU[%d]: local_irq_count[%ld] global_irq_count[%d]\n",
272 smp_processor_id(), local_irq_count
,
273 atomic_read(&global_irq_count
));
275 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x\n", regs
->tstate
,
276 regs
->tpc
, regs
->tnpc
, regs
->y
);
277 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
278 regs
->u_regs
[0], regs
->u_regs
[1], regs
->u_regs
[2],
280 printk("g4: %016lx g5: %016lx g6: %016lx g7: %016lx\n",
281 regs
->u_regs
[4], regs
->u_regs
[5], regs
->u_regs
[6],
283 printk("o0: %016lx o1: %016lx o2: %016lx o3: %016lx\n",
284 regs
->u_regs
[8], regs
->u_regs
[9], regs
->u_regs
[10],
286 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
287 regs
->u_regs
[12], regs
->u_regs
[13], regs
->u_regs
[14],
289 show_regwindow(regs
);
291 spin_unlock_irqrestore(®dump_lock
, flags
);
295 #ifdef VERBOSE_SHOWREGS
296 static void idump_from_user (unsigned int *pc
)
301 if((((unsigned long) pc
) & 3))
305 for(i
= -3; i
< 6; i
++) {
307 printk("%c%08x%c",i
?' ':'<',code
,i
?' ':'>');
314 void show_regs(struct pt_regs
*regs
)
316 #ifdef VERBOSE_SHOWREGS
317 extern long etrap
, etraptl1
;
322 extern void smp_report_regs(void);
328 #ifdef VERBOSE_SHOWREGS
329 if (regs
->tpc
>= &etrap
&& regs
->tpc
< &etraptl1
&&
330 regs
->u_regs
[14] >= (long)current
- PAGE_SIZE
&&
331 regs
->u_regs
[14] < (long)current
+ 6 * PAGE_SIZE
) {
332 printk ("*********parent**********\n");
333 __show_regs((struct pt_regs
*)(regs
->u_regs
[14] + STACK_BIAS
+ REGWIN_SZ
));
334 idump_from_user(((struct pt_regs
*)(regs
->u_regs
[14] + STACK_BIAS
+ REGWIN_SZ
))->tpc
);
335 printk ("*********endpar**********\n");
340 void show_regs32(struct pt_regs32
*regs
)
342 printk("PSR: %08x PC: %08x NPC: %08x Y: %08x\n", regs
->psr
,
343 regs
->pc
, regs
->npc
, regs
->y
);
344 printk("g0: %08x g1: %08x g2: %08x g3: %08x ",
345 regs
->u_regs
[0], regs
->u_regs
[1], regs
->u_regs
[2],
347 printk("g4: %08x g5: %08x g6: %08x g7: %08x\n",
348 regs
->u_regs
[4], regs
->u_regs
[5], regs
->u_regs
[6],
350 printk("o0: %08x o1: %08x o2: %08x o3: %08x ",
351 regs
->u_regs
[8], regs
->u_regs
[9], regs
->u_regs
[10],
353 printk("o4: %08x o5: %08x sp: %08x ret_pc: %08x\n",
354 regs
->u_regs
[12], regs
->u_regs
[13], regs
->u_regs
[14],
358 void show_thread(struct thread_struct
*thread
)
363 printk("kregs: 0x%016lx\n", (unsigned long)thread
->kregs
);
364 show_regs(thread
->kregs
);
366 printk("sig_address: 0x%016lx\n", thread
->sig_address
);
367 printk("sig_desc: 0x%016lx\n", thread
->sig_desc
);
368 printk("ksp: 0x%016lx\n", thread
->ksp
);
370 if (thread
->w_saved
) {
371 for (i
= 0; i
< NSWINS
; i
++) {
372 if (!thread
->rwbuf_stkptrs
[i
])
374 printk("reg_window[%d]:\n", i
);
375 printk("stack ptr: 0x%016lx\n", thread
->rwbuf_stkptrs
[i
]);
377 printk("w_saved: 0x%04x\n", thread
->w_saved
);
380 printk("flags: 0x%08x\n", thread
->flags
);
381 printk("current_ds: 0x%x\n", thread
->current_ds
.seg
);
384 /* Free current thread data structures etc.. */
385 void exit_thread(void)
387 struct thread_struct
*t
= ¤t
->thread
;
390 if (t
->utraps
[0] < 2)
396 /* Turn off performance counters if on. */
397 if (t
->flags
& SPARC_FLAG_PERFCTR
) {
398 t
->user_cntd0
= t
->user_cntd1
= NULL
;
400 t
->flags
&= ~(SPARC_FLAG_PERFCTR
);
405 void flush_thread(void)
407 struct thread_struct
*t
= ¤t
->thread
;
410 if (t
->flags
& SPARC_FLAG_32BIT
) {
411 struct mm_struct
*mm
= current
->mm
;
412 pgd_t
*pgd0
= &mm
->pgd
[0];
413 unsigned long pgd_cache
;
415 if (pgd_none(*pgd0
)) {
416 pmd_t
*page
= get_pmd_fast();
418 (void) get_pmd_slow(pgd0
, 0);
422 pgd_cache
= pgd_val(*pgd0
) << 11UL;
423 __asm__
__volatile__("stxa %0, [%1] %2"
432 /* Turn off performance counters if on. */
433 if (t
->flags
& SPARC_FLAG_PERFCTR
) {
434 t
->user_cntd0
= t
->user_cntd1
= NULL
;
436 t
->flags
&= ~(SPARC_FLAG_PERFCTR
);
440 /* Clear FPU register state. */
443 if (t
->current_ds
.seg
!= ASI_AIUS
)
446 /* Init new signal delivery disposition. */
447 t
->flags
&= ~SPARC_FLAG_NEWSIGNALS
;
450 /* It's a bit more tricky when 64-bit tasks are involved... */
451 static unsigned long clone_stackframe(unsigned long csp
, unsigned long psp
)
453 unsigned long fp
, distance
, rval
;
455 if(!(current
->thread
.flags
& SPARC_FLAG_32BIT
)) {
458 __get_user(fp
, &(((struct reg_window
*)psp
)->ins
[6]));
460 __get_user(fp
, &(((struct reg_window32
*)psp
)->ins
[6]));
462 /* Now 8-byte align the stack as this is mandatory in the
463 * Sparc ABI due to how register windows work. This hides
464 * the restriction from thread libraries etc. -DaveM
469 rval
= (csp
- distance
);
470 if(copy_in_user(rval
, psp
, distance
))
472 else if(current
->thread
.flags
& SPARC_FLAG_32BIT
) {
473 if(put_user(((u32
)csp
), &(((struct reg_window32
*)rval
)->ins
[6])))
476 if(put_user(((u64
)csp
- STACK_BIAS
),
477 &(((struct reg_window
*)rval
)->ins
[6])))
480 rval
= rval
- STACK_BIAS
;
486 /* Standard stuff. */
487 static inline void shift_window_buffer(int first_win
, int last_win
,
488 struct thread_struct
*t
)
492 for(i
= first_win
; i
< last_win
; i
++) {
493 t
->rwbuf_stkptrs
[i
] = t
->rwbuf_stkptrs
[i
+1];
494 memcpy(&t
->reg_window
[i
], &t
->reg_window
[i
+1],
495 sizeof(struct reg_window
));
499 void synchronize_user_stack(void)
501 struct thread_struct
*t
= ¤t
->thread
;
502 unsigned long window
;
504 flush_user_windows();
505 if((window
= t
->w_saved
) != 0) {
506 int winsize
= REGWIN_SZ
;
509 if(t
->flags
& SPARC_FLAG_32BIT
)
510 winsize
= REGWIN32_SZ
;
516 unsigned long sp
= (t
->rwbuf_stkptrs
[window
] + bias
);
517 struct reg_window
*rwin
= &t
->reg_window
[window
];
519 if(!copy_to_user((char *)sp
, rwin
, winsize
)) {
520 shift_window_buffer(window
, t
->w_saved
- 1, t
);
527 void fault_in_user_windows(struct pt_regs
*regs
)
529 struct thread_struct
*t
= ¤t
->thread
;
530 unsigned long window
;
531 int winsize
= REGWIN_SZ
;
534 if(t
->flags
& SPARC_FLAG_32BIT
)
535 winsize
= REGWIN32_SZ
;
538 flush_user_windows();
543 unsigned long sp
= (t
->rwbuf_stkptrs
[window
] + bias
);
544 struct reg_window
*rwin
= &t
->reg_window
[window
];
546 if(copy_to_user((char *)sp
, rwin
, winsize
))
556 /* Copy a Sparc thread. The fork() return value conventions
557 * under SunOS are nothing short of bletcherous:
558 * Parent --> %o0 == childs pid, %o1 == 0
559 * Child --> %o0 == parents pid, %o1 == 1
561 * NOTE: We have a separate fork kpsr/kwim because
562 * the parent could change these values between
563 * sys_fork invocation and when we reach here
564 * if the parent should sleep while trying to
565 * allocate the task_struct and kernel stack in
568 int copy_thread(int nr
, unsigned long clone_flags
, unsigned long sp
,
569 struct task_struct
*p
, struct pt_regs
*regs
)
571 struct thread_struct
*t
= &p
->thread
;
572 char *child_trap_frame
;
574 /* Calculate offset to stack_frame & pt_regs */
575 child_trap_frame
= ((char *)p
) + ((PAGE_SIZE
<< 1) - (TRACEREG_SZ
+REGWIN_SZ
));
576 memcpy(child_trap_frame
, (((struct reg_window
*)regs
)-1), (TRACEREG_SZ
+REGWIN_SZ
));
577 t
->ksp
= ((unsigned long) child_trap_frame
) - STACK_BIAS
;
578 t
->flags
|= SPARC_FLAG_NEWCHILD
;
579 t
->kregs
= (struct pt_regs
*)(child_trap_frame
+sizeof(struct reg_window
));
580 t
->cwp
= (regs
->tstate
+ 1) & TSTATE_CWP
;
582 if(regs
->tstate
& TSTATE_PRIV
) {
583 /* Special case, if we are spawning a kernel thread from
584 * a userspace task (via KMOD, NFS, or similar) we must
585 * disable performance counters in the child because the
586 * address space and protection realm are changing.
588 if (t
->flags
& SPARC_FLAG_PERFCTR
) {
589 t
->user_cntd0
= t
->user_cntd1
= NULL
;
591 t
->flags
&= ~(SPARC_FLAG_PERFCTR
);
593 t
->kregs
->u_regs
[UREG_FP
] = p
->thread
.ksp
;
594 t
->current_ds
= KERNEL_DS
;
595 flush_register_windows();
596 memcpy((void *)(t
->ksp
+ STACK_BIAS
),
597 (void *)(regs
->u_regs
[UREG_FP
] + STACK_BIAS
),
598 sizeof(struct reg_window
));
599 t
->kregs
->u_regs
[UREG_G6
] = (unsigned long) p
;
601 if(t
->flags
& SPARC_FLAG_32BIT
) {
602 sp
&= 0x00000000ffffffffUL
;
603 regs
->u_regs
[UREG_FP
] &= 0x00000000ffffffffUL
;
605 t
->kregs
->u_regs
[UREG_FP
] = sp
;
606 t
->current_ds
= USER_DS
;
607 if (sp
!= regs
->u_regs
[UREG_FP
]) {
610 csp
= clone_stackframe(sp
, regs
->u_regs
[UREG_FP
]);
613 t
->kregs
->u_regs
[UREG_FP
] = csp
;
619 /* Set the return value for the child. */
620 t
->kregs
->u_regs
[UREG_I0
] = current
->pid
;
621 t
->kregs
->u_regs
[UREG_I1
] = 1;
623 /* Set the second return value for the parent. */
624 regs
->u_regs
[UREG_I1
] = 0;
626 printk("\ncopy_thread: c(%p[mm(%p:%p)]) p(%p[mm(%p:%p)])\n",
627 current
, current
->mm
, current
->active_mm
,
628 p
, p
->mm
, p
->active_mm
);
629 printk("copy_thread: c MM_ctx(%016lx) MM_pgd(%016lx)\n",
630 (current
->mm
? current
->mm
->context
: 0),
631 (current
->mm
? pgd_val(current
->mm
->pgd
[0]) : 0));
632 printk("copy_thread: p MM_ctx(%016lx) MM_pgd(%08x)\n",
633 (p
->mm
? p
->mm
->context
: 0),
634 (p
->mm
? pgd_val(p
->mm
->pgd
[0]) : 0));
635 printk("copy_thread: c->flags(%x) p->flags(%x) ",
636 current
->thread
.flags
, p
->thread
.flags
);
642 * This is the mechanism for creating a new kernel thread.
644 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
645 * who haven't done an "execve()") should use this: it will work within
646 * a system call from a "real" process, but the process memory space will
647 * not be free'd until both the parent and the child have exited.
649 pid_t
kernel_thread(int (*fn
)(void *), void * arg
, unsigned long flags
)
653 __asm__
__volatile("mov %1, %%g1\n\t"
654 "mov %2, %%o0\n\t" /* Clone flags. */
655 "mov 0, %%o1\n\t" /* usp arg == 0 */
656 "t 0x6d\n\t" /* Linux/Sparc clone(). */
657 "brz,a,pn %%o1, 1f\n\t" /* Parent, just return. */
659 "jmpl %4, %%o7\n\t" /* Call the function. */
660 " mov %5, %%o0\n\t" /* Set arg in delay. */
662 "t 0x6d\n\t" /* Linux/Sparc exit(). */
663 /* Notreached by child. */
666 "i" (__NR_clone
), "r" (flags
| CLONE_VM
),
667 "i" (__NR_exit
), "r" (fn
), "r" (arg
) :
668 "g1", "o0", "o1", "memory", "cc");
673 * fill in the user structure for a core dump..
675 void dump_thread(struct pt_regs
* regs
, struct user
* dump
)
678 /* Only should be used for SunOS and ancient a.out
679 * SparcLinux binaries... Fixme some day when bored.
680 * But for now at least plug the security hole :-)
682 memset(dump
, 0, sizeof(struct user
));
684 unsigned long first_stack_page
;
685 dump
->magic
= SUNOS_CORE_MAGIC
;
686 dump
->len
= sizeof(struct user
);
687 dump
->regs
.psr
= regs
->psr
;
688 dump
->regs
.pc
= regs
->pc
;
689 dump
->regs
.npc
= regs
->npc
;
690 dump
->regs
.y
= regs
->y
;
692 memcpy(&dump
->regs
.regs
[0], ®s
->u_regs
[1], (sizeof(unsigned long) * 15));
693 dump
->u_tsize
= (((unsigned long) current
->mm
->end_code
) -
694 ((unsigned long) current
->mm
->start_code
)) & ~(PAGE_SIZE
- 1);
695 dump
->u_dsize
= ((unsigned long) (current
->mm
->brk
+ (PAGE_SIZE
-1)));
696 dump
->u_dsize
-= dump
->u_tsize
;
697 dump
->u_dsize
&= ~(PAGE_SIZE
- 1);
698 first_stack_page
= (regs
->u_regs
[UREG_FP
] & ~(PAGE_SIZE
- 1));
699 dump
->u_ssize
= (TASK_SIZE
- first_stack_page
) & ~(PAGE_SIZE
- 1);
700 memcpy(&dump
->fpu
.fpstatus
.fregs
.regs
[0], ¤t
->thread
.float_regs
[0], (sizeof(unsigned long) * 32));
701 dump
->fpu
.fpstatus
.fsr
= current
->thread
.fsr
;
702 dump
->fpu
.fpstatus
.flags
= dump
->fpu
.fpstatus
.extra
= 0;
703 dump
->sigcode
= current
->thread
.sig_desc
;
709 unsigned int pr_regs
[32];
710 unsigned long pr_dregs
[16];
712 unsigned int __unused
;
714 unsigned char pr_qcnt
;
715 unsigned char pr_q_entrysize
;
717 unsigned int pr_q
[64];
721 * fill in the fpu structure for a core dump.
723 int dump_fpu (struct pt_regs
* regs
, elf_fpregset_t
* fpregs
)
725 unsigned long *kfpregs
= (unsigned long *)(((char *)current
) + AOFF_task_fpregs
);
726 unsigned long fprs
= current
->thread
.fpsaved
[0];
728 if ((current
->thread
.flags
& SPARC_FLAG_32BIT
) != 0) {
729 elf_fpregset_t32
*fpregs32
= (elf_fpregset_t32
*)fpregs
;
732 memcpy(&fpregs32
->pr_fr
.pr_regs
[0], kfpregs
,
733 sizeof(unsigned int) * 32);
735 memset(&fpregs32
->pr_fr
.pr_regs
[0], 0,
736 sizeof(unsigned int) * 32);
737 fpregs32
->pr_qcnt
= 0;
738 fpregs32
->pr_q_entrysize
= 8;
739 memset(&fpregs32
->pr_q
[0], 0,
740 (sizeof(unsigned int) * 64));
741 if (fprs
& FPRS_FEF
) {
742 fpregs32
->pr_fsr
= (unsigned int) current
->thread
.xfsr
[0];
745 fpregs32
->pr_fsr
= 0;
750 memcpy(&fpregs
->pr_regs
[0], kfpregs
,
751 sizeof(unsigned int) * 32);
753 memset(&fpregs
->pr_regs
[0], 0,
754 sizeof(unsigned int) * 32);
756 memcpy(&fpregs
->pr_regs
[16], kfpregs
+16,
757 sizeof(unsigned int) * 32);
759 memset(&fpregs
->pr_regs
[16], 0,
760 sizeof(unsigned int) * 32);
761 if(fprs
& FPRS_FEF
) {
762 fpregs
->pr_fsr
= current
->thread
.xfsr
[0];
763 fpregs
->pr_gsr
= current
->thread
.gsr
[0];
765 fpregs
->pr_fsr
= fpregs
->pr_gsr
= 0;
767 fpregs
->pr_fprs
= fprs
;
773 * sparc_execve() executes a new program after the asm stub has set
774 * things up for us. This should basically do what I want it to.
776 asmlinkage
int sparc_execve(struct pt_regs
*regs
)
781 /* User register window flush is done by entry.S */
783 /* Check for indirect call. */
784 if(regs
->u_regs
[UREG_G1
] == 0)
788 filename
= getname((char *)regs
->u_regs
[base
+ UREG_I0
]);
789 error
= PTR_ERR(filename
);
792 error
= do_execve(filename
, (char **) regs
->u_regs
[base
+ UREG_I1
],
793 (char **) regs
->u_regs
[base
+ UREG_I2
], regs
);
797 current
->thread
.xfsr
[0] = 0;
798 current
->thread
.fpsaved
[0] = 0;
799 regs
->tstate
&= ~TSTATE_PEF
;