Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Apr 2012 08:01:17 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r234053 - in projects/arm_eabi: lib/libc/arm sys/arm/arm
Message-ID:  <201204090801.q3981HqY049430@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Mon Apr  9 08:01:17 2012
New Revision: 234053
URL: http://svn.freebsd.org/changeset/base/234053

Log:
  Switch the syscall interface on EABI.
  
  The syscall we are after is now passed in r7. The value, while still placed
  in the instruction, is unused. r7 was chosen as it is what Linux uses and
  there is no point being different.
  
  This should help someone add Thumb support as we can now express all
  possible syscall values. The Thumb swi instruction only has 8 bits for the
  the syscall value.

Modified:
  projects/arm_eabi/lib/libc/arm/SYS.h
  projects/arm_eabi/sys/arm/arm/trap.c

Modified: projects/arm_eabi/lib/libc/arm/SYS.h
==============================================================================
--- projects/arm_eabi/lib/libc/arm/SYS.h	Mon Apr  9 04:44:39 2012	(r234052)
+++ projects/arm_eabi/lib/libc/arm/SYS.h	Mon Apr  9 08:01:17 2012	(r234053)
@@ -39,7 +39,15 @@
 #include <sys/syscall.h>
 #include <machine/swi.h>
 
+#ifdef __ARM_EABI__
+#define SYSTRAP(x)							\
+			mov ip, r7;					\
+			ldr r7, =SYS_ ## x;				\
+			swi 0 | SYS_ ## x;				\
+			mov r7, ip
+#else
 #define SYSTRAP(x)	swi 0 | SYS_ ## x
+#endif
 
 #define	CERROR		_C_LABEL(cerror)
 #define	CURBRK		_C_LABEL(curbrk)

Modified: projects/arm_eabi/sys/arm/arm/trap.c
==============================================================================
--- projects/arm_eabi/sys/arm/arm/trap.c	Mon Apr  9 04:44:39 2012	(r234052)
+++ projects/arm_eabi/sys/arm/arm/trap.c	Mon Apr  9 08:01:17 2012	(r234053)
@@ -868,7 +868,11 @@ cpu_fetch_syscall_args(struct thread *td
 	register_t *ap;
 	int error;
 
+#ifdef __ARM_EABI__
+	sa->code = td->td_frame->tf_r7;
+#else
 	sa->code = sa->insn & 0x000fffff;
+#endif
 	ap = &td->td_frame->tf_r0;
 	if (sa->code == SYS_syscall) {
 		sa->code = *ap++;
@@ -902,22 +906,24 @@ cpu_fetch_syscall_args(struct thread *td
 #include "../../kern/subr_syscall.c"
 
 static void
-syscall(struct thread *td, trapframe_t *frame, u_int32_t insn)
+syscall(struct thread *td, trapframe_t *frame)
 {
 	struct syscall_args sa;
 	int error;
 
-	td->td_frame = frame;
-	sa.insn = insn;
-	switch (insn & SWI_OS_MASK) {
+	sa.insn = *(u_int32_t *)(frame->tf_pc - INSN_SIZE);
+#ifndef __ARM_EABI__
+	/* TODO: Also add the above line when we don't need it in the EABI case */
+	switch (sa.insn & SWI_OS_MASK) {
 	case 0: /* XXX: we need our own one. */
-		sa.nap = 4;
 		break;
 	default:
 		call_trapsignal(td, SIGILL, 0);
 		userret(td, frame);
 		return;
 	}
+#endif
+	sa.nap = 4;
 
 	error = syscallenter(td, &sa);
 	KASSERT(error != 0 || td->td_ar == NULL,
@@ -929,7 +935,6 @@ void
 swi_handler(trapframe_t *frame)
 {
 	struct thread *td = curthread;
-	uint32_t insn;
 
 	td->td_frame = frame;
 	
@@ -943,7 +948,6 @@ swi_handler(trapframe_t *frame)
 		userret(td, frame);
 		return;
 	}
-	insn = *(u_int32_t *)(frame->tf_pc - INSN_SIZE);
 	/*
 	 * Enable interrupts if they were enabled before the exception.
 	 * Since all syscalls *should* come from user mode it will always
@@ -956,6 +960,6 @@ swi_handler(trapframe_t *frame)
 			enable_interrupts(F32_bit);
 	}
 	 
-	syscall(td, frame, insn);
+	syscall(td, frame);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204090801.q3981HqY049430>