sp += 2*HPPA_FRAME_SIZE + 20*4;  *HPPA_FRAME_CARG(0, sp) = tf->tf_sp; *HPPA_FRAME_CARG(1, sp) = KERNMODE(func); *HPPA_FRAME_CARG(2, sp) = (register_t)arg; *(register_t*)(osp) = (sp - HPPA_FRAME_SIZE); *(register_t*)(sp + HPPA_FRAME_PSP) = osp;
*(register_t*)(osp - HPPA_FRAME_SIZE) = 0;
cpu_fork(p1, p2, stack, stacksize, func, arg)	struct proc *p1, *p2;	void *stack;	size_t stacksize;	void (*func)(void *);	void *arg;{	extern paddr_t fpu_curpcb;	/* from locore.S */	struct pcb *pcbp;	struct trapframe *tf;	register_t sp, osp;#ifdef DIAGNOSTIC	if (round_page(sizeof(struct user)) > NBPG)		panic("USPACE too small for user");#endif	if (p1->p_md.md_regs->tf_cr30 == fpu_curpcb)		fpu_save(fpu_curpcb);	pcbp = &p2->p_addr->u_pcb;	bcopy(&p1->p_addr->u_pcb, pcbp, sizeof(*pcbp));	/* space is cached for the copy{in,out}'s pleasure */	pcbp->pcb_space = p2->p_vmspace->vm_map.pmap->pm_space;	pcbp->pcb_uva = (vaddr_t)p2->p_addr;	/* reset any of the pending FPU exceptions from parent */	pcbp->pcb_fpregs[0] = HPPA_FPU_FORK(pcbp->pcb_fpregs[0]);	pcbp->pcb_fpregs[1] = 0;	pcbp->pcb_fpregs[2] = 0;	pcbp->pcb_fpregs[3] = 0;	fdcache(HPPA_SID_KERNEL, (vaddr_t)&pcbp->pcb_fpregs[0], 8 * 4);	sp = (register_t)p2->p_addr + NBPG;	p2->p_md.md_regs = tf = (struct trapframe *)sp;	sp += sizeof(struct trapframe);	bcopy(p1->p_md.md_regs, tf, sizeof(*tf));	/*	 * cpu_swapin() is supposed to fill out all the PAs	 * we gonna need in locore	 */	cpu_swapin(p2);	tf->tf_sr0 = tf->tf_sr1 = tf->tf_sr2 = tf->tf_sr3 =	tf->tf_sr4 = tf->tf_sr5 = tf->tf_sr6 =	tf->tf_iisq_head = tf->tf_iisq_tail =		p2->p_vmspace->vm_map.pmap->pm_space;	tf->tf_pidr1 = tf->tf_pidr2 = pmap_sid2pid(tf->tf_sr0);	/*	 * theoretically these could be inherited from the father,	 * but just in case.	 */	tf->tf_sr7 = HPPA_SID_KERNEL;	mfctl(CR_EIEM, tf->tf_eiem);	tf->tf_ipsw = PSL_C | PSL_Q | PSL_P | PSL_D | PSL_I /* | PSL_L */;	/*	 * If specified, give the child a different stack.	 */	if (stack != NULL)		tf->tf_sp = (register_t)stack;	/*	 * Build a stack frame for the cpu_switch & co.	 */	osp = sp + HPPA_FRAME_SIZE;	sp += 2*HPPA_FRAME_SIZE + 20*4; /* std frame + calee-save registers */	*HPPA_FRAME_CARG(0, sp) = tf->tf_sp;	*HPPA_FRAME_CARG(1, sp) = KERNMODE(func);	*HPPA_FRAME_CARG(2, sp) = (register_t)arg;	*(register_t*)(osp) = (sp - HPPA_FRAME_SIZE);	*(register_t*)(sp + HPPA_FRAME_PSP) = osp;	*(register_t*)(osp + HPPA_FRAME_CRP) = (register_t)&switch_trampoline;	*(register_t*)(osp + HPPA_FRAME_SL) = 0;	/* cpl */	tf->tf_sp = sp;	fdcache(HPPA_SID_KERNEL, (vaddr_t)p2->p_addr, sp - (vaddr_t)p2->p_addr);}