Module Name: src Committed By: matt Date: Fri Aug 16 22:20:49 UTC 2013
Modified Files: src/lib/libc/arch/arm: SYS.h Log Message: Rework SYSTRAP for thumb. Add END to PSEUDO_NOERROR and PSEUDO To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/arch/arm/SYS.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/arch/arm/SYS.h diff -u src/lib/libc/arch/arm/SYS.h:1.12 src/lib/libc/arch/arm/SYS.h:1.13 --- src/lib/libc/arch/arm/SYS.h:1.12 Thu Aug 1 05:32:33 2013 +++ src/lib/libc/arch/arm/SYS.h Fri Aug 16 22:20:49 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: SYS.h,v 1.12 2013/08/01 05:32:33 matt Exp $ */ +/* $NetBSD: SYS.h,v 1.13 2013/08/16 22:20:49 matt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -38,12 +38,41 @@ #include <sys/syscall.h> #include <arm/swi.h> -#ifdef __STDC__ -#define SYSTRAP(x) swi SWI_OS_NETBSD | SYS_ ## x -#else -#define SYSTRAP(x) swi SWI_OS_NETBSD | SYS_/**/x +#ifndef __STDC__ +#error __STDC__ not defined #endif +#if !defined(__thumb__) +#define SYSTRAP(x) svc #SWI_OS_NETBSD | SYS_ ## x +#else +.macro emitsvc x + mov ip, r0 +.ifeq \x / 256 + movs r0, #\x +.else +#if defined(_ARM_ARCH_7) + movw r0, #\x +#else +.ifeq (\x & 3) + movs r0, #(\x / 4) + lsls r0, r0, #3 +.else +.ifeq (\x & 1) + movs r0, #(\x / 2) + lsls r0, r0, #1 +.else + movs r0, #(\x / 256) + lsls r0, r0, #8 + adds r0, r0, #(\x & 255) +.endif +.endif +#endif /* !_ARM_ARCH_7 */ +.endif + svc #255 +.endm +#define SYSTRAP(x) emitsvc SYS_ ## x +#endif /* __thumb__ */ + #define CERROR _C_LABEL(__cerror) #define CURBRK _C_LABEL(__curbrk) @@ -51,9 +80,15 @@ ENTRY(x); \ SYSTRAP(y) +#if !defined(__thumb__) || defined(_ARM_ARCH_T2) +#define _INVOKE_CERROR() bcs CERROR +#else +#define _INVOKE_CERROR() \ + bcc 86f; push {r4,lr}; bl CERROR; pop {r4,pc}; 86: +#endif #define _SYSCALL(x, y) \ _SYSCALL_NOERROR(x,y); \ - bcs CERROR + _INVOKE_CERROR() #define SYSCALL_NOERROR(x) \ _SYSCALL_NOERROR(x,x) @@ -64,11 +99,13 @@ #define PSEUDO_NOERROR(x,y) \ _SYSCALL_NOERROR(x,y); \ - RET + RET; \ + END(x) #define PSEUDO(x,y) \ _SYSCALL(x,y); \ - RET + RET; \ + END(x) #define RSYSCALL_NOERROR(x) \