summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Moyer <jmoyer@redhat.com>2013-01-30 14:55:23 -0500
committerJeff Moyer <jmoyer@redhat.com>2013-01-31 15:44:17 -0500
commitd88423b54b84a483a36ee5c9c20397ce3102385b (patch)
tree71f7e95002db8c407e7d6f27035d9313c472cc0f
parent531f075f251a16ef712e4f8da2fcd13794369b3b (diff)
downloadlibaio-d88423b54b84a483a36ee5c9c20397ce3102385b.tar.gz
add arm64 (aarch64) support
The libaio.h changes came from Riku Voipio <riku.voipio@linaro.org>. The syscall-arm64.h file is an adapter version of the syscall-arm.h file. Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
-rw-r--r--src/libaio.h10
-rw-r--r--src/syscall-arm64.h101
-rw-r--r--src/syscall.h2
3 files changed, 113 insertions, 0 deletions
diff --git a/src/libaio.h b/src/libaio.h
index 18dbc2a..c03ff9c 100644
--- a/src/libaio.h
+++ b/src/libaio.h
@@ -91,6 +91,16 @@ typedef enum io_iocb_cmd {
#define PADDED(x, y) unsigned y; x
#define PADDEDptr(x, y) unsigned y; x
#define PADDEDul(x, y) unsigned y; unsigned long x
+#elif defined(__aarch64__)
+# if defined (__AARCH64EB__) /* big endian, 64 bits */
+#define PADDED(x, y) unsigned y; x
+#define PADDEDptr(x,y) x
+#define PADDEDul(x, y) unsigned long x
+# elif defined(__AARCH64EL__) /* little endian, 64 bits */
+#define PADDED(x, y) x, y
+#define PADDEDptr(x, y) x
+#define PADDEDul(x, y) unsigned long x
+# endif
#else
#error endian?
#endif
diff --git a/src/syscall-arm64.h b/src/syscall-arm64.h
new file mode 100644
index 0000000..031c571
--- /dev/null
+++ b/src/syscall-arm64.h
@@ -0,0 +1,101 @@
+/*
+ * linux/include/asm-arm/unistd.h
+ *
+ * Copyright (C) 2001-2005 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Please forward _all_ changes to this file to rmk@arm.linux.org.uk,
+ * no matter what the change is. Thanks!
+ */
+
+#define __NR_io_setup 0
+#define __NR_io_destroy 1
+#define __NR_io_submit 2
+#define __NR_io_cancel 3
+#define __NR_io_getevents 4
+
+#define __sys2(x) #x
+#define __sys1(x) __sys2(x)
+
+#define __SYS_REG(name) register long __sysreg __asm__("w8") = __NR_##name;
+#define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs
+#define __syscall(name) "svc\t#0"
+
+#define io_syscall1(type,fname,sname,type1,arg1) \
+type fname(type1 arg1) { \
+ __SYS_REG(sname) \
+ register long __x0 __asm__("x0") = (long)arg1; \
+ register long __res_x0 __asm__("x0"); \
+ __asm__ __volatile__ ( \
+ __syscall(sname) \
+ : "=r" (__res_x0) \
+ : __SYS_REG_LIST( "0" (__x0) ) \
+ : "memory" ); \
+ return (type) __res_x0; \
+}
+
+#define io_syscall2(type,fname,sname,type1,arg1,type2,arg2) \
+type fname(type1 arg1,type2 arg2) { \
+ __SYS_REG(sname) \
+ register long __x0 __asm__("x0") = (long)arg1; \
+ register long __x1 __asm__("x1") = (long)arg2; \
+ register long __res_x0 __asm__("x0"); \
+ __asm__ __volatile__ ( \
+ __syscall(sname) \
+ : "=r" (__res_x0) \
+ : __SYS_REG_LIST( "0" (__x0), "r" (__x1) ) \
+ : "memory" ); \
+ return (type) __res_x0; \
+}
+
+#define io_syscall3(type,fname,sname,type1,arg1,type2,arg2,type3,arg3) \
+type fname(type1 arg1,type2 arg2,type3 arg3) { \
+ __SYS_REG(sname) \
+ register long __x0 __asm__("x0") = (long)arg1; \
+ register long __x1 __asm__("x1") = (long)arg2; \
+ register long __x2 __asm__("x2") = (long)arg3; \
+ register long __res_x0 __asm__("x0"); \
+ __asm__ __volatile__ ( \
+ __syscall(sname) \
+ : "=r" (__res_x0) \
+ : __SYS_REG_LIST( "0" (__x0), "r" (__x1), "r" (__x2) ) \
+ : "memory" ); \
+ return (type) __res_x0; \
+}
+
+#define io_syscall4(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
+type fname(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
+ __SYS_REG(sname) \
+ register long __x0 __asm__("x0") = (long)arg1; \
+ register long __x1 __asm__("x1") = (long)arg2; \
+ register long __x2 __asm__("x2") = (long)arg3; \
+ register long __x3 __asm__("x3") = (long)arg4; \
+ register long __res_x0 __asm__("x0"); \
+ __asm__ __volatile__ ( \
+ __syscall(sname) \
+ : "=r" (__res_x0) \
+ : __SYS_REG_LIST( "0" (__x0), "r" (__x1), "r" (__x2), "r" (__x3) ) \
+ : "memory" ); \
+ return (type) __res_x0; \
+}
+
+#define io_syscall5(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
+type fname(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) {\
+ __SYS_REG(sname) \
+ register long __x0 __asm__("x0") = (long)arg1; \
+ register long __x1 __asm__("x1") = (long)arg2; \
+ register long __x2 __asm__("x2") = (long)arg3; \
+ register long __x3 __asm__("x3") = (long)arg4; \
+ register long __x4 __asm__("x4") = (long)arg5; \
+ register long __res_x0 __asm__("x0"); \
+ __asm__ __volatile__ ( \
+ __syscall(sname) \
+ : "=r" (__res_x0) \
+ : __SYS_REG_LIST( "0" (__x0), "r" (__x1), "r" (__x2), \
+ "r" (__x3), "r" (__x4) ) \
+ : "memory" ); \
+ return (type) __res_x0; \
+}
diff --git a/src/syscall.h b/src/syscall.h
index 62879a5..6ece660 100644
--- a/src/syscall.h
+++ b/src/syscall.h
@@ -26,6 +26,8 @@
#include "syscall-arm.h"
#elif defined(__sparc__)
#include "syscall-sparc.h"
+#elif defined(__aarch64__)
+#include "syscall-arm64.h"
#else
#error "add syscall-arch.h"
#endif