Subject: N32 patch proposal 2.0
To: None <port-mips@netbsd.org>
From: Emmanuel Dreyfus <manu@netbsd.org>
List: port-mips
Date: 01/05/2002 21:09:17
Hi!

Here is a new version of the my proposition for introducing setregs_n32.
It should address the indirection problem that was raised here.

setregs1 is inlined, so there is no additionnal overhead for NetBSD native.

If nobody gets totally disgusted by this patch, I'd like to commit it soon,
I'm getting some trouble to manage all the patches I have in my tree ;o)


Index: include/elf_machdep.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/include/elf_machdep.h,v
retrieving revision 1.8
diff -r1.8 elf_machdep.h
94a99,102
> #define setregs_o32 setregs
> void setregs __P((struct proc*, struct exec_package*, u_long stack));
> void setregs_n32 __P((struct proc*, struct exec_package*, u_long stack));
> inline void setregs1 __P((struct proc*, struct exec_package*, u_long stack));
Index: include/proc.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/include/proc.h,v
retrieving revision 1.13
diff -r1.13 proc.h
61a62
> #define MDP_ABI_N32   0x0002  /* 0 for o32 ABI, 1 for n32 ABI */
Index: mips/mips_machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/mips/mips_machdep.c,v
retrieving revision 1.120
diff -r1.120 mips_machdep.c
83a84
> #include <mips/elf_machdep.h>
613c614,630
< /*
---
> 
> /* 
>  * Set registers on exec.
>  * This is used for binaries using the o32 ABI, 
>  * which include native NetBSD ELF32 binaries.
>  * setregs_o32 is a synonym to setregs.
>  */
> void
> setregs(p, pack, stack)
>       struct proc *p;
>       struct exec_package *pack;
>       u_long stack;
> {
>       return setregs1(p, pack, stack);
> }
> 
> /* 
614a632,655
>  * This is used for binaries using the n32 ABI,
>  * for now, only IRIX n32 ELF binaries use this
>  */ 
> void
> setregs_n32(p, pack, stack)
>       struct proc *p;
>       struct exec_package *pack;
>       u_long stack;
> {
>       struct frame *f = (struct frame *)p->p_md.md_regs;
>       
>       setregs1(p, pack, stack);
> 
>       /* Enable 64 bit instructions (eg: sd) */
>       f->f_regs[SR] |= (MIPS3_SR_XX | MIPS3_SR_UX); 
> 
>       /* Remember this process uses the N32 ABI */
>       p->p_md.md_flags |= MDP_ABI_N32;
> 
>       return;
> }
> 
> /*
>  * Set register on exec code common to o32 ABI and n32 ABI.
620,621c661,662
< void
< setregs(p, pack, stack)
---
> inline void
> setregs1(p, pack, stack)

-- 
Emmanuel Dreyfus
manu@netbsd.org