コード例 #1
0
static void
cloudabi64_set_syscall_retval(struct thread *td, int error)
{
    struct trapframe *frame = td->td_frame;

    switch (error) {
    case 0:
        /* System call succeeded. */
        frame->tf_x[0] = td->td_retval[0];
        frame->tf_x[1] = td->td_retval[1];
        frame->tf_spsr &= ~PSR_C;
        break;
    case ERESTART:
        /* Restart system call. */
        frame->tf_elr -= 4;
        break;
    case EJUSTRETURN:
        break;
    default:
        /* System call returned an error. */
        frame->tf_x[0] = cloudabi_convert_errno(error);
        frame->tf_spsr |= PSR_C;
        break;
    }
}
コード例 #2
0
static void
cloudabi32_set_syscall_retval(struct thread *td, int error)
{
	struct trapframe *frame = td->td_frame;

	switch (error) {
	case 0:
		/*
		 * System call succeeded.
		 *
		 * Simply copy out the 64-bit return values into the
		 * same buffer provided for system call arguments. The
		 * vDSO will copy them to the right spot, truncating
		 * pointers and size_t values to 32 bits.
		 */
		frame->tf_rax = copyout(td->td_retval, (void *)frame->tf_rcx,
		    sizeof(td->td_retval)) == 0 ? 0 : CLOUDABI_EFAULT;
		break;
	case ERESTART:
		/* Restart system call. */
		frame->tf_rip -= frame->tf_err;
		frame->tf_r10 = frame->tf_rcx;
		set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
		break;
	case EJUSTRETURN:
		break;
	default:
		/* System call returned an error. */
		frame->tf_rax = cloudabi_convert_errno(error);
		break;
	}
}
コード例 #3
0
static int
aarch64_cloudabi64_fetch_retval(struct trussinfo *trussinfo, long *retval,
    int *errorp)
{
	struct reg regs;
	lwpid_t tid;

	tid = trussinfo->curthread->tid;
	if (ptrace(PT_GETREGS, tid, (caddr_t)&regs, 0) == -1) {
		fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
		return (-1);
	}

	retval[0] = regs.x[0];
	retval[1] = regs.x[1];
	*errorp = (regs.spsr & PSR_C) != 0;
	if (*errorp)
		retval[0] = cloudabi_convert_errno(retval[0]);
	return (0);
}