002_arches_sh.patch (4810B)
1 From: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> 2 Subject: Add SH supprt 3 4 The test-suite logs can be found at: 5 6 <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=535288> 7 8 9 --- 10 harness/main.c | 2 - 11 src/libaio.h | 4 ++ 12 src/syscall-sh.h | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 13 src/syscall.h | 2 + 14 4 files changed, 84 insertions(+), 2 deletions(-) 15 16 17 --- a/harness/main.c 18 +++ b/harness/main.c 19 @@ -14,7 +14,7 @@ 20 #if __LP64__ == 0 21 #if defined(__i386__) || defined(__powerpc__) || defined(__mips__) 22 #define KERNEL_RW_POINTER ((void *)0xc0010000) 23 -#elif defined(__arm__) || defined(__m68k__) || defined(__s390__) 24 +#elif defined(__arm__) || defined(__m68k__) || defined(__s390__) || defined(__sh__) 25 #define KERNEL_RW_POINTER ((void *)0x00010000) 26 #elif defined(__hppa__) 27 #define KERNEL_RW_POINTER ((void *)0x10100000) 28 --- a/src/libaio.h 29 +++ b/src/libaio.h 30 @@ -51,7 +51,8 @@ typedef enum io_iocb_cmd { 31 32 /* little endian, 32 bits */ 33 #if defined(__i386__) || (defined(__arm__) && !defined(__ARMEB__)) || \ 34 - defined(__sh__) || defined(__bfin__) || defined(__MIPSEL__) || \ 35 + (defined(__sh__) && defined(__LITTLE_ENDIAN__)) || \ 36 + defined(__bfin__) || defined(__MIPSEL__) || \ 37 defined(__cris__) 38 #define PADDED(x, y) x; unsigned y 39 #define PADDEDptr(x, y) x; unsigned y 40 @@ -76,6 +77,7 @@ typedef enum io_iocb_cmd { 41 /* big endian, 32 bits */ 42 #elif defined(__PPC__) || defined(__s390__) || \ 43 (defined(__arm__) && defined(__ARMEB__)) || \ 44 + (defined(__sh__) && defined (__BIG_ENDIAN__)) || \ 45 defined(__sparc__) || defined(__MIPSEB__) || defined(__m68k__) || \ 46 defined(__hppa__) || defined(__frv__) || defined(__avr32__) 47 #define PADDED(x, y) unsigned y; x 48 --- /dev/null 49 +++ b/src/syscall-sh.h 50 @@ -0,0 +1,78 @@ 51 +/* Copy from ./arch/sh/include/asm/unistd_32.h */ 52 +#define __NR_io_setup 245 53 +#define __NR_io_destroy 246 54 +#define __NR_io_getevents 247 55 +#define __NR_io_submit 248 56 +#define __NR_io_cancel 249 57 + 58 +#define io_syscall1(type,fname,sname,type1,arg1) \ 59 +type fname(type1 arg1) \ 60 +{ \ 61 +register long __sc0 __asm__ ("r3") = __NR_##sname; \ 62 +register long __sc4 __asm__ ("r4") = (long) arg1; \ 63 +__asm__ __volatile__ ("trapa #0x11" \ 64 + : "=z" (__sc0) \ 65 + : "0" (__sc0), "r" (__sc4) \ 66 + : "memory"); \ 67 + return (type) __sc0;\ 68 +} 69 + 70 +#define io_syscall2(type,fname,sname,type1,arg1,type2,arg2) \ 71 +type fname(type1 arg1,type2 arg2) \ 72 +{ \ 73 +register long __sc0 __asm__ ("r3") = __NR_##sname; \ 74 +register long __sc4 __asm__ ("r4") = (long) arg1; \ 75 +register long __sc5 __asm__ ("r5") = (long) arg2; \ 76 + __asm__ __volatile__ ("trapa #0x12" \ 77 + : "=z" (__sc0) \ 78 + : "0" (__sc0), "r" (__sc4), "r" (__sc5) \ 79 + : "memory"); \ 80 + return (type) __sc0;\ 81 +} 82 + 83 +#define io_syscall3(type,fname,sname,type1,arg1,type2,arg2,type3,arg3) \ 84 +type fname(type1 arg1,type2 arg2,type3 arg3) \ 85 +{ \ 86 +register long __sc0 __asm__ ("r3") = __NR_##sname; \ 87 +register long __sc4 __asm__ ("r4") = (long) arg1; \ 88 +register long __sc5 __asm__ ("r5") = (long) arg2; \ 89 +register long __sc6 __asm__ ("r6") = (long) arg3; \ 90 + __asm__ __volatile__ ("trapa #0x13" \ 91 + : "=z" (__sc0) \ 92 + : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) \ 93 + : "memory"); \ 94 + return (type) __sc0;\ 95 +} 96 + 97 +#define io_syscall4(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ 98 +type fname(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ 99 +{ \ 100 +register long __sc0 __asm__ ("r3") = __NR_##sname; \ 101 +register long __sc4 __asm__ ("r4") = (long) arg1; \ 102 +register long __sc5 __asm__ ("r5") = (long) arg2; \ 103 +register long __sc6 __asm__ ("r6") = (long) arg3; \ 104 +register long __sc7 __asm__ ("r7") = (long) arg4; \ 105 +__asm__ __volatile__ ("trapa #0x14" \ 106 + : "=z" (__sc0) \ 107 + : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), \ 108 + "r" (__sc7) \ 109 + : "memory" ); \ 110 + return (type) __sc0;\ 111 +} 112 + 113 +#define io_syscall5(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ 114 +type fname(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ 115 +{ \ 116 +register long __sc3 __asm__ ("r3") = __NR_##sname; \ 117 +register long __sc4 __asm__ ("r4") = (long) arg1; \ 118 +register long __sc5 __asm__ ("r5") = (long) arg2; \ 119 +register long __sc6 __asm__ ("r6") = (long) arg3; \ 120 +register long __sc7 __asm__ ("r7") = (long) arg4; \ 121 +register long __sc0 __asm__ ("r0") = (long) arg5; \ 122 +__asm__ __volatile__ ("trapa #0x15" \ 123 + : "=z" (__sc0) \ 124 + : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \ 125 + "r" (__sc3) \ 126 + : "memory" ); \ 127 + return (type) __sc0;\ 128 +} 129 --- a/src/syscall.h 130 +++ b/src/syscall.h 131 @@ -34,6 +34,8 @@ 132 #include "syscall-parisc.h" 133 #elif defined(__mips__) 134 #include "syscall-mips.h" 135 +#elif defined(__sh__) 136 +#include "syscall-sh.h" 137 #else 138 #warning "using generic syscall method" 139 #include "syscall-generic.h"