FreeBSD/sys/powerpc/powerpc/exec_machdep.c
/*
 * Set set up registers on exec.
 */
Set set up registers on exec.
Set set up registers on exec .
void
exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
{
	struct trapframe	*tf;
	register_t		argc;
	tf = trapframe(td);
	bzero(tf, sizeof *tf);
	#ifdef __powerpc64__
	tf->fixreg[1] = -roundup(-stack + 48, 16);
	#else
	tf->fixreg[1] = -roundup(-stack + 8, 16);
	#endif
	argc = fuword((void *)stack);
        td->td_retval[0] = argc;
        td->td_retval[1] = stack + sizeof(register_t);
	tf->fixreg[3] = argc;
	tf->fixreg[4] = stack + sizeof(register_t);
	tf->fixreg[5] = stack + (2 + argc)*sizeof(register_t);
	tf->fixreg[6] = 0;				
	tf->fixreg[7] = 0;				
	tf->fixreg[8] = (register_t)imgp->ps_strings;	
	tf->srr0 = imgp->entry_addr;
	#ifdef __powerpc64__
	tf->fixreg[12] = imgp->entry_addr;
	tf->srr1 = PSL_SF | PSL_USERSET | PSL_FE_DFLT;
	if (mfmsr() & PSL_HV)
		tf->srr1 |= PSL_HV;
	#else
	tf->srr1 = PSL_USERSET | PSL_FE_DFLT;
	#endif
	td->td_pcb->pcb_flags = 0;
}
void exec_setregs ( struct thread * td , struct image_params * imgp , u_long stack ) { struct trapframe * tf ; register_t argc ; tf = trapframe ( td ) ; bzero ( tf , sizeof * tf ) ; #ifdef __powerpc64__ tf -> fixreg [ 1 ] = - roundup ( - stack + 48 , 16 ) ; #else tf -> fixreg [ 1 ] = - roundup ( - stack + 8 , 16 ) ; #endif argc = fuword ( ( void * ) stack ) ; td -> td_retval [ 0 ] = argc ; td -> td_retval [ 1 ] = stack + sizeof ( register_t ) ; tf -> fixreg [ 3 ] = argc ; tf -> fixreg [ 4 ] = stack + sizeof ( register_t ) ; tf -> fixreg [ 5 ] = stack + ( 2 + argc ) * sizeof ( register_t ) ; tf -> fixreg [ 6 ] = 0 ; tf -> fixreg [ 7 ] = 0 ; tf -> fixreg [ 8 ] = ( register_t ) imgp -> ps_strings ; tf -> srr0 = imgp -> entry_addr ; #ifdef __powerpc64__ tf -> fixreg [ 12 ] = imgp -> entry_addr ; tf -> srr1 = PSL_SF | PSL_USERSET | PSL_FE_DFLT ; if ( mfmsr ( ) & PSL_HV ) tf -> srr1 |= PSL_HV ; #else tf -> srr1 = PSL_USERSET | PSL_FE_DFLT ; #endif td -> td_pcb -> pcb_flags = 0 ; }
Set set up registers on exec.
Set set up registers on exec .
/*
	 * Set up arguments for _start():
	 *	_start(argc, argv, envp, obj, cleanup, ps_strings);
	 *
	 * Notes:
	 *	- obj and cleanup are the auxilliary and termination
	 *	  vectors.  They are fixed up by ld.elf_so.
	 *	- ps_strings is a NetBSD extention, and will be
	 * 	  ignored by executables which are strictly
	 *	  compliant with the SVR4 ABI.
	 *
	 * XXX We have to set both regs and retval here due to different
	 * XXX calling convention in trap.c and init_main.c.
	 */ /* Collect argc from the user stack */ /*
         * XXX PG: these get overwritten in the syscall return code.
         * execve() should return EJUSTRETURN, like it does on NetBSD.
         * Emulate by setting the syscall return value cells. The
         * registers still have to be set for init's fork trampoline.
         */ /* auxillary vector */ /* termination vector */ /* NetBSD extension */