Subject: Re: m88k system call convention
To: None <netbsd-ports@netbsd.org, nisimura@itc.aist-nara.ac.jp>
From: Toru Nishimura <nisimura@itc.aist-nara.ac.jp>
List: netbsd-ports
Date: 02/11/2000 20:56:53
> It's questionable extention to have 9,10,11th arguments in registers
> (no NetBSD syscall has them, and syscall() in various ports assumes
> args[8]).  If ever, such values on user stack should be accessed by
> copyin() in an appropriate way.

Alas... I could figure out 'args-on-stack' case only happens 'indirect
mmap'.   All other cases comfortably fit in 'args-in-trapframe' case.
Tentative sketch of syscall() would look like;

	code = frame->r13;
	ap = &frame->r2;
	uargused = 0;
	switch (code) {
	case SYS_syscall:
		code = ap[0];
		ap += 1;
		uargused = 1;
		break;
	case SYS___syscall:
		/*
		 * Like syscall, but code is a quad, so as to maintain
		 * quad alignment for the rest of the arguments.
		 */
		code = ap[_QUAD_LONGWORD];
		ap += 2;
		uargused = 2;
		break;
	}
	if (code < 0 || code >= nsys)
		callp += p->p_emul->e_nosys;
	else if (uargused == 0) {
		callp += code;
		memcpy(args, ap, callp->sy_argsize);
	}
	else {
		int argsize = (8 - nargused) * sizeof(register_t);

		callp += code;
		if (callp->sy_argsize <= argsize)
			memcpy(args, ap, callp->sy_argsize);
		else {
			/* only happens indirect mmap */
			memcpy(args, ap, argsize);
			error = copyin(
				(void *)(frame->r31 + 8 * sizeof(register_t)),
				(void *)((caddr_t)args + argsize),
				callp->sy_argsize - argsize);
			if (error) 
				goto bad;
		}
	}
--
Tohru Nishimura
Nara Institute of Science and Technology