svn commit: r270700 - projects/arm64/sys/arm64/arm64
Andrew Turner
andrew at FreeBSD.org
Wed Aug 27 09:26:30 UTC 2014
Author: andrew
Date: Wed Aug 27 09:26:29 2014
New Revision: 270700
URL: http://svnweb.freebsd.org/changeset/base/270700
Log:
Start to support system calls by adding the kernel side. The system
call id is stored in x8 while arguments are passed in registers
x0 to x7.
Modified:
projects/arm64/sys/arm64/arm64/trap.c
projects/arm64/sys/arm64/arm64/vm_machdep.c
Modified: projects/arm64/sys/arm64/arm64/trap.c
==============================================================================
--- projects/arm64/sys/arm64/arm64/trap.c Wed Aug 27 09:26:21 2014 (r270699)
+++ projects/arm64/sys/arm64/arm64/trap.c Wed Aug 27 09:26:29 2014 (r270700)
@@ -32,7 +32,11 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mutex.h>
+#include <sys/pioctl.h>
#include <sys/proc.h>
+#include <sys/ptrace.h>
+#include <sys/syscall.h>
+#include <sys/sysent.h>
#include <vm/vm.h>
#include <vm/pmap.h>
@@ -50,8 +54,52 @@ void do_el0_error(struct trapframe *);
int
cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
{
+ struct proc *p;
+ register_t *ap;
+ int nap;
+
+ nap = 8;
+ p = td->td_proc;
+ ap = td->td_frame->tf_x;
+
+ sa->code = td->td_frame->tf_x[8];
+
+ if (sa->code == SYS_syscall || sa->code == SYS___syscall) {
+ panic("TODO: syscall/__syscall");
+ }
+
+ if (p->p_sysent->sv_mask)
+ sa->code &= p->p_sysent->sv_mask;
+ if (sa->code >= p->p_sysent->sv_size)
+ sa->callp = &p->p_sysent->sv_table[0];
+ else
+ sa->callp = &p->p_sysent->sv_table[sa->code];
+
+ sa->narg = sa->callp->sy_narg;
+ memcpy(sa->args, ap, nap * sizeof(register_t));
+ if (sa->narg > nap)
+ panic("TODO: Could we have more then 8 args?");
+
+ td->td_retval[0] = 0;
+ td->td_retval[1] = 0;
+
+ return (0);
+}
+
+#include "../../kern/subr_syscall.c"
+
+static void
+svc_handler(struct trapframe *frame)
+{
+ struct syscall_args sa;
+ struct thread *td;
+ int error;
- panic("cpu_fetch_syscall_args");
+ td = curthread;
+ td->td_frame = frame;
+
+ error = syscallenter(td, &sa);
+ syscallret(td, error, &sa);
}
static void
@@ -167,6 +215,9 @@ do_el0_sync(struct trapframe *frame)
printf("spsr: %llx\n", frame->tf_spsr);
switch(exception) {
+ case 0x15:
+ svc_handler(frame);
+ break;
case 0x20:
case 0x24:
data_abort(frame, esr, 1);
Modified: projects/arm64/sys/arm64/arm64/vm_machdep.c
==============================================================================
--- projects/arm64/sys/arm64/arm64/vm_machdep.c Wed Aug 27 09:26:21 2014 (r270699)
+++ projects/arm64/sys/arm64/arm64/vm_machdep.c Wed Aug 27 09:26:29 2014 (r270700)
@@ -98,8 +98,25 @@ cpu_thread_swapout(struct thread *td)
void
cpu_set_syscall_retval(struct thread *td, int error)
{
+ struct trapframe *frame;
- panic("cpu_set_syscall_retval");
+ frame = td->td_frame;
+
+ printf("cpu_set_syscall_retval %d\n", error);
+ switch (error) {
+ case 0:
+ frame->tf_x[0] = td->td_retval[0];
+ frame->tf_x[1] = td->td_retval[1];
+ break;
+ case ERESTART:
+ frame->tf_elr -= 4;
+ break;
+ case EJUSTRETURN:
+ break;
+ default:
+ frame->tf_x[0] = error;
+ break;
+ }
}
/*
More information about the svn-src-projects
mailing list