1
0

001_arches.patch 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. ---
  2. harness/main.c | 10 ++
  3. src/libaio.h | 1
  4. src/syscall-m68k.h | 78 +++++++++++++++++
  5. src/syscall-mips.h | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++
  6. src/syscall-parisc.h | 146 +++++++++++++++++++++++++++++++++
  7. src/syscall-sparc.h | 20 +++-
  8. src/syscall.h | 6 +
  9. 7 files changed, 479 insertions(+), 5 deletions(-)
  10. --- /dev/null
  11. +++ b/src/syscall-m68k.h
  12. @@ -0,0 +1,78 @@
  13. +#define __NR_io_setup 241
  14. +#define __NR_io_destroy 242
  15. +#define __NR_io_getevents 243
  16. +#define __NR_io_submit 244
  17. +#define __NR_io_cancel 245
  18. +
  19. +#define io_syscall1(type,fname,sname,atype,a) \
  20. +type fname(atype a) \
  21. +{ \
  22. +register long __res __asm__ ("%d0") = __NR_##sname; \
  23. +register long __a __asm__ ("%d1") = (long)(a); \
  24. +__asm__ __volatile__ ("trap #0" \
  25. + : "+d" (__res) \
  26. + : "d" (__a) ); \
  27. +return (type) __res; \
  28. +}
  29. +
  30. +#define io_syscall2(type,fname,sname,atype,a,btype,b) \
  31. +type fname(atype a,btype b) \
  32. +{ \
  33. +register long __res __asm__ ("%d0") = __NR_##sname; \
  34. +register long __a __asm__ ("%d1") = (long)(a); \
  35. +register long __b __asm__ ("%d2") = (long)(b); \
  36. +__asm__ __volatile__ ("trap #0" \
  37. + : "+d" (__res) \
  38. + : "d" (__a), "d" (__b) \
  39. + ); \
  40. +return (type) __res; \
  41. +}
  42. +
  43. +#define io_syscall3(type,fname,sname,atype,a,btype,b,ctype,c) \
  44. +type fname(atype a,btype b,ctype c) \
  45. +{ \
  46. +register long __res __asm__ ("%d0") = __NR_##sname; \
  47. +register long __a __asm__ ("%d1") = (long)(a); \
  48. +register long __b __asm__ ("%d2") = (long)(b); \
  49. +register long __c __asm__ ("%d3") = (long)(c); \
  50. +__asm__ __volatile__ ("trap #0" \
  51. + : "+d" (__res) \
  52. + : "d" (__a), "d" (__b), \
  53. + "d" (__c) \
  54. + ); \
  55. +return (type) __res; \
  56. +}
  57. +
  58. +#define io_syscall4(type,fname,sname,atype,a,btype,b,ctype,c,dtype,d) \
  59. +type fname (atype a, btype b, ctype c, dtype d) \
  60. +{ \
  61. +register long __res __asm__ ("%d0") = __NR_##sname; \
  62. +register long __a __asm__ ("%d1") = (long)(a); \
  63. +register long __b __asm__ ("%d2") = (long)(b); \
  64. +register long __c __asm__ ("%d3") = (long)(c); \
  65. +register long __d __asm__ ("%d4") = (long)(d); \
  66. +__asm__ __volatile__ ("trap #0" \
  67. + : "+d" (__res) \
  68. + : "d" (__a), "d" (__b), \
  69. + "d" (__c), "d" (__d) \
  70. + ); \
  71. +return (type) __res; \
  72. +}
  73. +
  74. +#define io_syscall5(type,fname,sname,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
  75. +type fname (atype a,btype b,ctype c,dtype d,etype e) \
  76. +{ \
  77. +register long __res __asm__ ("%d0") = __NR_##sname; \
  78. +register long __a __asm__ ("%d1") = (long)(a); \
  79. +register long __b __asm__ ("%d2") = (long)(b); \
  80. +register long __c __asm__ ("%d3") = (long)(c); \
  81. +register long __d __asm__ ("%d4") = (long)(d); \
  82. +register long __e __asm__ ("%d5") = (long)(e); \
  83. +__asm__ __volatile__ ("trap #0" \
  84. + : "+d" (__res) \
  85. + : "d" (__a), "d" (__b), \
  86. + "d" (__c), "d" (__d), "d" (__e) \
  87. + ); \
  88. +return (type) __res; \
  89. +}
  90. +
  91. --- a/src/syscall.h
  92. +++ b/src/syscall.h
  93. @@ -28,6 +28,12 @@
  94. #include "syscall-sparc.h"
  95. #elif defined(__aarch64__)
  96. #include "syscall-arm64.h"
  97. +#elif defined(__m68k__)
  98. +#include "syscall-m68k.h"
  99. +#elif defined(__hppa__)
  100. +#include "syscall-parisc.h"
  101. +#elif defined(__mips__)
  102. +#include "syscall-mips.h"
  103. #else
  104. #warning "using generic syscall method"
  105. #include "syscall-generic.h"
  106. --- /dev/null
  107. +++ b/src/syscall-mips.h
  108. @@ -0,0 +1,223 @@
  109. +/*
  110. + * This file is subject to the terms and conditions of the GNU General Public
  111. + * License. See the file "COPYING" in the main directory of this archive
  112. + * for more details.
  113. + *
  114. + * Copyright (C) 1995, 96, 97, 98, 99, 2000 by Ralf Baechle
  115. + * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  116. + *
  117. + * Changed system calls macros _syscall5 - _syscall7 to push args 5 to 7 onto
  118. + * the stack. Robin Farine for ACN S.A, Copyright (C) 1996 by ACN S.A
  119. + */
  120. +
  121. +#ifndef _MIPS_SIM_ABI32
  122. +#define _MIPS_SIM_ABI32 1
  123. +#define _MIPS_SIM_NABI32 2
  124. +#define _MIPS_SIM_ABI64 3
  125. +#endif
  126. +
  127. +#if _MIPS_SIM == _MIPS_SIM_ABI32
  128. +
  129. +/*
  130. + * Linux o32 style syscalls are in the range from 4000 to 4999.
  131. + */
  132. +#define __NR_Linux 4000
  133. +#define __NR_io_setup (__NR_Linux + 241)
  134. +#define __NR_io_destroy (__NR_Linux + 242)
  135. +#define __NR_io_getevents (__NR_Linux + 243)
  136. +#define __NR_io_submit (__NR_Linux + 244)
  137. +#define __NR_io_cancel (__NR_Linux + 245)
  138. +
  139. +#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
  140. +
  141. +#if _MIPS_SIM == _MIPS_SIM_ABI64
  142. +
  143. +/*
  144. + * Linux 64-bit syscalls are in the range from 5000 to 5999.
  145. + */
  146. +#define __NR_Linux 5000
  147. +#define __NR_io_setup (__NR_Linux + 200)
  148. +#define __NR_io_destroy (__NR_Linux + 201)
  149. +#define __NR_io_getevents (__NR_Linux + 202)
  150. +#define __NR_io_submit (__NR_Linux + 203)
  151. +#define __NR_io_cancel (__NR_Linux + 204)
  152. +#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
  153. +
  154. +#if _MIPS_SIM == _MIPS_SIM_NABI32
  155. +
  156. +/*
  157. + * Linux N32 syscalls are in the range from 6000 to 6999.
  158. + */
  159. +#define __NR_Linux 6000
  160. +#define __NR_io_setup (__NR_Linux + 200)
  161. +#define __NR_io_destroy (__NR_Linux + 201)
  162. +#define __NR_io_getevents (__NR_Linux + 202)
  163. +#define __NR_io_submit (__NR_Linux + 203)
  164. +#define __NR_io_cancel (__NR_Linux + 204)
  165. +#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
  166. +
  167. +#define io_syscall1(type,fname,sname,atype,a) \
  168. +type fname(atype a) \
  169. +{ \
  170. + register unsigned long __a0 asm("$4") = (unsigned long) a; \
  171. + register unsigned long __a3 asm("$7"); \
  172. + unsigned long __v0; \
  173. + \
  174. + __asm__ volatile ( \
  175. + ".set\tnoreorder\n\t" \
  176. + "li\t$2, %3\t\t\t# " #fname "\n\t" \
  177. + "syscall\n\t" \
  178. + "move\t%0, $2\n\t" \
  179. + ".set\treorder" \
  180. + : "=&r" (__v0), "=r" (__a3) \
  181. + : "r" (__a0), "i" (__NR_##sname) \
  182. + : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
  183. + "memory"); \
  184. + \
  185. + if (__a3 == 0) \
  186. + return (type) __v0; \
  187. + return (type) -1; \
  188. +}
  189. +
  190. +#define io_syscall2(type,fname,sname,atype,a,btype,b) \
  191. +type fname(atype a, btype b) \
  192. +{ \
  193. + register unsigned long __a0 asm("$4") = (unsigned long) a; \
  194. + register unsigned long __a1 asm("$5") = (unsigned long) b; \
  195. + register unsigned long __a3 asm("$7"); \
  196. + unsigned long __v0; \
  197. + \
  198. + __asm__ volatile ( \
  199. + ".set\tnoreorder\n\t" \
  200. + "li\t$2, %4\t\t\t# " #fname "\n\t" \
  201. + "syscall\n\t" \
  202. + "move\t%0, $2\n\t" \
  203. + ".set\treorder" \
  204. + : "=&r" (__v0), "=r" (__a3) \
  205. + : "r" (__a0), "r" (__a1), "i" (__NR_##sname) \
  206. + : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
  207. + "memory"); \
  208. + \
  209. + if (__a3 == 0) \
  210. + return (type) __v0; \
  211. + return (type) -1; \
  212. +}
  213. +
  214. +#define io_syscall3(type,fname,sname,atype,a,btype,b,ctype,c) \
  215. +type fname(atype a, btype b, ctype c) \
  216. +{ \
  217. + register unsigned long __a0 asm("$4") = (unsigned long) a; \
  218. + register unsigned long __a1 asm("$5") = (unsigned long) b; \
  219. + register unsigned long __a2 asm("$6") = (unsigned long) c; \
  220. + register unsigned long __a3 asm("$7"); \
  221. + unsigned long __v0; \
  222. + \
  223. + __asm__ volatile ( \
  224. + ".set\tnoreorder\n\t" \
  225. + "li\t$2, %5\t\t\t# " #fname "\n\t" \
  226. + "syscall\n\t" \
  227. + "move\t%0, $2\n\t" \
  228. + ".set\treorder" \
  229. + : "=&r" (__v0), "=r" (__a3) \
  230. + : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##sname) \
  231. + : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
  232. + "memory"); \
  233. + \
  234. + if (__a3 == 0) \
  235. + return (type) __v0; \
  236. + return (type) -1; \
  237. +}
  238. +
  239. +#define io_syscall4(type,fname,sname,atype,a,btype,b,ctype,c,dtype,d) \
  240. +type fname(atype a, btype b, ctype c, dtype d) \
  241. +{ \
  242. + register unsigned long __a0 asm("$4") = (unsigned long) a; \
  243. + register unsigned long __a1 asm("$5") = (unsigned long) b; \
  244. + register unsigned long __a2 asm("$6") = (unsigned long) c; \
  245. + register unsigned long __a3 asm("$7") = (unsigned long) d; \
  246. + unsigned long __v0; \
  247. + \
  248. + __asm__ volatile ( \
  249. + ".set\tnoreorder\n\t" \
  250. + "li\t$2, %5\t\t\t# " #fname "\n\t" \
  251. + "syscall\n\t" \
  252. + "move\t%0, $2\n\t" \
  253. + ".set\treorder" \
  254. + : "=&r" (__v0), "+r" (__a3) \
  255. + : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##sname) \
  256. + : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
  257. + "memory"); \
  258. + \
  259. + if (__a3 == 0) \
  260. + return (type) __v0; \
  261. + return (type) -1; \
  262. +}
  263. +
  264. +#if (_MIPS_SIM == _MIPS_SIM_ABI32)
  265. +
  266. +/*
  267. + * Using those means your brain needs more than an oil change ;-)
  268. + */
  269. +
  270. +#define io_syscall5(type,fname,sname,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
  271. +type fname(atype a, btype b, ctype c, dtype d, etype e) \
  272. +{ \
  273. + register unsigned long __a0 asm("$4") = (unsigned long) a; \
  274. + register unsigned long __a1 asm("$5") = (unsigned long) b; \
  275. + register unsigned long __a2 asm("$6") = (unsigned long) c; \
  276. + register unsigned long __a3 asm("$7") = (unsigned long) d; \
  277. + unsigned long __v0; \
  278. + \
  279. + __asm__ volatile ( \
  280. + ".set\tnoreorder\n\t" \
  281. + "lw\t$2, %6\n\t" \
  282. + "subu\t$29, 32\n\t" \
  283. + "sw\t$2, 16($29)\n\t" \
  284. + "li\t$2, %5\t\t\t# " #fname "\n\t" \
  285. + "syscall\n\t" \
  286. + "move\t%0, $2\n\t" \
  287. + "addiu\t$29, 32\n\t" \
  288. + ".set\treorder" \
  289. + : "=&r" (__v0), "+r" (__a3) \
  290. + : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##sname), \
  291. + "m" ((unsigned long)e) \
  292. + : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
  293. + "memory"); \
  294. + \
  295. + if (__a3 == 0) \
  296. + return (type) __v0; \
  297. + return (type) -1; \
  298. +}
  299. +
  300. +#endif /* (_MIPS_SIM == _MIPS_SIM_ABI32) */
  301. +
  302. +#if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
  303. +
  304. +#define io_syscall5(type,fname,sname,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
  305. +type fname (atype a,btype b,ctype c,dtype d,etype e) \
  306. +{ \
  307. + register unsigned long __a0 asm("$4") = (unsigned long) a; \
  308. + register unsigned long __a1 asm("$5") = (unsigned long) b; \
  309. + register unsigned long __a2 asm("$6") = (unsigned long) c; \
  310. + register unsigned long __a3 asm("$7") = (unsigned long) d; \
  311. + register unsigned long __a4 asm("$8") = (unsigned long) e; \
  312. + unsigned long __v0; \
  313. + \
  314. + __asm__ volatile ( \
  315. + ".set\tnoreorder\n\t" \
  316. + "li\t$2, %6\t\t\t# " #fname "\n\t" \
  317. + "syscall\n\t" \
  318. + "move\t%0, $2\n\t" \
  319. + ".set\treorder" \
  320. + : "=&r" (__v0), "+r" (__a3) \
  321. + : "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "i" (__NR_##sname) \
  322. + : "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
  323. + "memory"); \
  324. + \
  325. + if (__a3 == 0) \
  326. + return (type) __v0; \
  327. + return (type) -1; \
  328. +}
  329. +
  330. +#endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */
  331. +
  332. --- a/src/libaio.h
  333. +++ b/src/libaio.h
  334. @@ -66,6 +66,7 @@ typedef enum io_iocb_cmd {
  335. /* big endian, 64 bits */
  336. #elif defined(__powerpc64__) || defined(__s390x__) || \
  337. + (defined(__hppa__) && defined(__arch64__)) || \
  338. (defined(__sparc__) && defined(__arch64__)) || \
  339. (defined(__aarch64__) && defined(__AARCH64EB__))
  340. #define PADDED(x, y) unsigned y; x
  341. --- /dev/null
  342. +++ b/src/syscall-parisc.h
  343. @@ -0,0 +1,146 @@
  344. +/*
  345. + * Linux system call numbers.
  346. + *
  347. + * Cary Coutant says that we should just use another syscall gateway
  348. + * page to avoid clashing with the HPUX space, and I think he's right:
  349. + * it will would keep a branch out of our syscall entry path, at the
  350. + * very least. If we decide to change it later, we can ``just'' tweak
  351. + * the LINUX_GATEWAY_ADDR define at the bottom and make __NR_Linux be
  352. + * 1024 or something. Oh, and recompile libc. =)
  353. + *
  354. + * 64-bit HPUX binaries get the syscall gateway address passed in a register
  355. + * from the kernel at startup, which seems a sane strategy.
  356. + */
  357. +
  358. +#define __NR_Linux 0
  359. +#define __NR_io_setup (__NR_Linux + 215)
  360. +#define __NR_io_destroy (__NR_Linux + 216)
  361. +#define __NR_io_getevents (__NR_Linux + 217)
  362. +#define __NR_io_submit (__NR_Linux + 218)
  363. +#define __NR_io_cancel (__NR_Linux + 219)
  364. +
  365. +#define SYS_ify(syscall_name) __NR_##syscall_name
  366. +
  367. +/* Assume all syscalls are done from PIC code just to be
  368. + * safe. The worst case scenario is that you lose a register
  369. + * and save/restore r19 across the syscall. */
  370. +#define PIC
  371. +
  372. +/* Definition taken from glibc 2.3.3
  373. + * sysdeps/unix/sysv/linux/hppa/sysdep.h
  374. + */
  375. +
  376. +#ifdef PIC
  377. +/* WARNING: CANNOT BE USED IN A NOP! */
  378. +# define K_STW_ASM_PIC " copy %%r19, %%r4\n"
  379. +# define K_LDW_ASM_PIC " copy %%r4, %%r19\n"
  380. +# define K_USING_GR4 "%r4",
  381. +#else
  382. +# define K_STW_ASM_PIC " \n"
  383. +# define K_LDW_ASM_PIC " \n"
  384. +# define K_USING_GR4
  385. +#endif
  386. +
  387. +/* GCC has to be warned that a syscall may clobber all the ABI
  388. + registers listed as "caller-saves", see page 8, Table 2
  389. + in section 2.2.6 of the PA-RISC RUN-TIME architecture
  390. + document. However! r28 is the result and will conflict with
  391. + the clobber list so it is left out. Also the input arguments
  392. + registers r20 -> r26 will conflict with the list so they
  393. + are treated specially. Although r19 is clobbered by the syscall
  394. + we cannot say this because it would violate ABI, thus we say
  395. + r4 is clobbered and use that register to save/restore r19
  396. + across the syscall. */
  397. +
  398. +#define K_CALL_CLOB_REGS "%r1", "%r2", K_USING_GR4 \
  399. + "%r20", "%r29", "%r31"
  400. +
  401. +#undef K_INLINE_SYSCALL
  402. +#define K_INLINE_SYSCALL(name, nr, args...) ({ \
  403. + long __sys_res; \
  404. + { \
  405. + register unsigned long __res __asm__("r28"); \
  406. + K_LOAD_ARGS_##nr(args) \
  407. + /* FIXME: HACK stw/ldw r19 around syscall */ \
  408. + __asm__ volatile( \
  409. + K_STW_ASM_PIC \
  410. + " ble 0x100(%%sr2, %%r0)\n" \
  411. + " ldi %1, %%r20\n" \
  412. + K_LDW_ASM_PIC \
  413. + : "=r" (__res) \
  414. + : "i" (SYS_ify(name)) K_ASM_ARGS_##nr \
  415. + : "memory", K_CALL_CLOB_REGS K_CLOB_ARGS_##nr \
  416. + ); \
  417. + __sys_res = (long)__res; \
  418. + } \
  419. + __sys_res; \
  420. +})
  421. +
  422. +#define K_LOAD_ARGS_0()
  423. +#define K_LOAD_ARGS_1(r26) \
  424. + register unsigned long __r26 __asm__("r26") = (unsigned long)(r26); \
  425. + K_LOAD_ARGS_0()
  426. +#define K_LOAD_ARGS_2(r26,r25) \
  427. + register unsigned long __r25 __asm__("r25") = (unsigned long)(r25); \
  428. + K_LOAD_ARGS_1(r26)
  429. +#define K_LOAD_ARGS_3(r26,r25,r24) \
  430. + register unsigned long __r24 __asm__("r24") = (unsigned long)(r24); \
  431. + K_LOAD_ARGS_2(r26,r25)
  432. +#define K_LOAD_ARGS_4(r26,r25,r24,r23) \
  433. + register unsigned long __r23 __asm__("r23") = (unsigned long)(r23); \
  434. + K_LOAD_ARGS_3(r26,r25,r24)
  435. +#define K_LOAD_ARGS_5(r26,r25,r24,r23,r22) \
  436. + register unsigned long __r22 __asm__("r22") = (unsigned long)(r22); \
  437. + K_LOAD_ARGS_4(r26,r25,r24,r23)
  438. +#define K_LOAD_ARGS_6(r26,r25,r24,r23,r22,r21) \
  439. + register unsigned long __r21 __asm__("r21") = (unsigned long)(r21); \
  440. + K_LOAD_ARGS_5(r26,r25,r24,r23,r22)
  441. +
  442. +/* Even with zero args we use r20 for the syscall number */
  443. +#define K_ASM_ARGS_0
  444. +#define K_ASM_ARGS_1 K_ASM_ARGS_0, "r" (__r26)
  445. +#define K_ASM_ARGS_2 K_ASM_ARGS_1, "r" (__r25)
  446. +#define K_ASM_ARGS_3 K_ASM_ARGS_2, "r" (__r24)
  447. +#define K_ASM_ARGS_4 K_ASM_ARGS_3, "r" (__r23)
  448. +#define K_ASM_ARGS_5 K_ASM_ARGS_4, "r" (__r22)
  449. +#define K_ASM_ARGS_6 K_ASM_ARGS_5, "r" (__r21)
  450. +
  451. +/* The registers not listed as inputs but clobbered */
  452. +#define K_CLOB_ARGS_6
  453. +#define K_CLOB_ARGS_5 K_CLOB_ARGS_6, "%r21"
  454. +#define K_CLOB_ARGS_4 K_CLOB_ARGS_5, "%r22"
  455. +#define K_CLOB_ARGS_3 K_CLOB_ARGS_4, "%r23"
  456. +#define K_CLOB_ARGS_2 K_CLOB_ARGS_3, "%r24"
  457. +#define K_CLOB_ARGS_1 K_CLOB_ARGS_2, "%r25"
  458. +#define K_CLOB_ARGS_0 K_CLOB_ARGS_1, "%r26"
  459. +
  460. +#define io_syscall1(type,fname,sname,type1,arg1) \
  461. +type fname(type1 arg1) \
  462. +{ \
  463. + return K_INLINE_SYSCALL(sname, 1, arg1); \
  464. +}
  465. +
  466. +#define io_syscall2(type,fname,sname,type1,arg1,type2,arg2) \
  467. +type fname(type1 arg1, type2 arg2) \
  468. +{ \
  469. + return K_INLINE_SYSCALL(sname, 2, arg1, arg2); \
  470. +}
  471. +
  472. +#define io_syscall3(type,fname,sname,type1,arg1,type2,arg2,type3,arg3) \
  473. +type fname(type1 arg1, type2 arg2, type3 arg3) \
  474. +{ \
  475. + return K_INLINE_SYSCALL(sname, 3, arg1, arg2, arg3); \
  476. +}
  477. +
  478. +#define io_syscall4(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  479. +type fname(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  480. +{ \
  481. + return K_INLINE_SYSCALL(sname, 4, arg1, arg2, arg3, arg4); \
  482. +}
  483. +
  484. +#define io_syscall5(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
  485. +type fname(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
  486. +{ \
  487. + return K_INLINE_SYSCALL(sname, 5, arg1, arg2, arg3, arg4, arg5); \
  488. +}
  489. +
  490. --- a/harness/main.c
  491. +++ b/harness/main.c
  492. @@ -12,7 +12,17 @@
  493. #include <libaio.h>
  494. #if __LP64__ == 0
  495. +#if defined(__i386__) || defined(__powerpc__) || defined(__mips__)
  496. #define KERNEL_RW_POINTER ((void *)0xc0010000)
  497. +#elif defined(__arm__) || defined(__m68k__) || defined(__s390__)
  498. +#define KERNEL_RW_POINTER ((void *)0x00010000)
  499. +#elif defined(__hppa__)
  500. +#define KERNEL_RW_POINTER ((void *)0x10100000)
  501. +#elif defined(__sparc__)
  502. +#define KERNEL_RW_POINTER ((void *)0xf0010000)
  503. +#else
  504. +#error Unknown kernel memory address.
  505. +#endif
  506. #else
  507. //#warning Not really sure where kernel memory is. Guessing.
  508. #define KERNEL_RW_POINTER ((void *)0xffffffff81000000)
  509. --- a/src/syscall-sparc.h
  510. +++ b/src/syscall-sparc.h
  511. @@ -20,7 +20,9 @@ __asm__ __volatile__ ("t 0x10\n\t" \
  512. : "=r" (__res), "=&r" (__o0) \
  513. : "1" (__o0), "r" (__g1) \
  514. : "cc"); \
  515. -return (type) __res; \
  516. +if (__res < -255 || __res >= 0) \
  517. + return (type) __res; \
  518. +return -1; \
  519. }
  520. #define io_syscall2(type,fname,sname,type1,arg1,type2,arg2) \
  521. @@ -38,7 +40,9 @@ __asm__ __volatile__ ("t 0x10\n\t" \
  522. : "=r" (__res), "=&r" (__o0) \
  523. : "1" (__o0), "r" (__o1), "r" (__g1) \
  524. : "cc"); \
  525. -return (type) __res; \
  526. +if (__res < -255 || __res >= 0) \
  527. + return (type) __res; \
  528. +return -1; \
  529. }
  530. #define io_syscall3(type,fname,sname,type1,arg1,type2,arg2,type3,arg3) \
  531. @@ -57,7 +61,9 @@ __asm__ __volatile__ ("t 0x10\n\t" \
  532. : "=r" (__res), "=&r" (__o0) \
  533. : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
  534. : "cc"); \
  535. -return (type) __res; \
  536. +if (__res < -255 || __res >= 0) \
  537. + return (type) __res; \
  538. +return -1; \
  539. }
  540. #define io_syscall4(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  541. @@ -77,7 +83,9 @@ __asm__ __volatile__ ("t 0x10\n\t" \
  542. : "=r" (__res), "=&r" (__o0) \
  543. : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
  544. : "cc"); \
  545. -return (type) __res; \
  546. +if (__res < -255 || __res >= 0) \
  547. + return (type) __res; \
  548. +return -1; \
  549. }
  550. #define io_syscall5(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
  551. @@ -99,5 +107,7 @@ __asm__ __volatile__ ("t 0x10\n\t" \
  552. : "=r" (__res), "=&r" (__o0) \
  553. : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
  554. : "cc"); \
  555. -return (type) __res; \
  556. +if (__res < -255 || __res >= 0) \
  557. + return (type) __res; \
  558. +return -1; \
  559. }