[PATCH libaio 04/11] Fix and improve MIPS support
authorGuillem Jover <guillem@hadrons.org>
Wed, 14 Aug 2019 01:18:50 +0000 (03:18 +0200)
committerGuillem Jover <guillem@debian.org>
Thu, 11 Nov 2021 03:56:01 +0000 (03:56 +0000)
Fix structure padding for MIPS 64, add syscall definitions, and the
kernel R/W pointer.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Gbp-Pq: Name 0004-Fix-and-improve-MIPS-support.patch

harness/main.c
src/libaio.h
src/syscall-mips.h [new file with mode: 0644]
src/syscall.h

index 0eed7bdac551916550dcd1f07f89ee9fcb42372e..33d8e468cdea98a81413be7338eb8a95665c461c 100644 (file)
@@ -12,7 +12,7 @@
 #include <libaio.h>
 
 #if __LP64__ == 0
-#if defined(__i386__) || defined(__powerpc__)
+#if defined(__i386__) || defined(__powerpc__) || defined(__mips__)
 #define KERNEL_RW_POINTER      ((void *)0xc0010000)
 #elif defined(__arm__) || defined(__s390__)
 #define KERNEL_RW_POINTER      ((void *)0x00010000)
index 8b333820a6dac8df0e7dce26c3de336a03ba3d4a..26b07f9db228db04a376ce436fed2313bbb67b02 100644 (file)
@@ -52,7 +52,9 @@ typedef enum io_iocb_cmd {
 
 /* little endian, 32 bits */
 #if defined(__i386__) || (defined(__arm__) && !defined(__ARMEB__)) || \
-    defined(__sh__) || defined(__bfin__) || defined(__MIPSEL__) || \
+    defined(__sh__) || \
+    defined(__bfin__) || \
+    (defined(__MIPSEL__) && !defined(__mips64)) || \
     defined(__cris__) || (defined(__riscv) && __riscv_xlen == 32) || \
     (defined(__GNUC__) && defined(__BYTE_ORDER__) && \
          __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_LONG__ == 4)
@@ -62,6 +64,7 @@ typedef enum io_iocb_cmd {
 
 /* little endian, 64 bits */
 #elif defined(__ia64__) || defined(__x86_64__) || defined(__alpha__) || \
+      (defined(__mips64) && defined(__MIPSEL__)) || \
       (defined(__aarch64__) && defined(__AARCH64EL__)) || \
       (defined(__riscv) && __riscv_xlen == 64) || \
       (defined(__GNUC__) && defined(__BYTE_ORDER__) && \
@@ -73,6 +76,7 @@ typedef enum io_iocb_cmd {
 /* big endian, 64 bits */
 #elif defined(__powerpc64__) || defined(__s390x__) || \
       (defined(__sparc__) && defined(__arch64__)) || \
+      (defined(__mips64) && defined(__MIPSEB__)) || \
       (defined(__aarch64__) && defined(__AARCH64EB__)) || \
       (defined(__GNUC__) && defined(__BYTE_ORDER__) && \
            __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ && __SIZEOF_LONG__ == 8)
diff --git a/src/syscall-mips.h b/src/syscall-mips.h
new file mode 100644 (file)
index 0000000..2c4245e
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1995, 96, 97, 98, 99, 2000 by Ralf Baechle
+ * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ */
+
+#ifndef _MIPS_SIM_ABI32
+#define _MIPS_SIM_ABI32                        1
+#define _MIPS_SIM_NABI32               2
+#define _MIPS_SIM_ABI64                        3
+#endif
+
+#if _MIPS_SIM == _MIPS_SIM_ABI32
+
+/*
+ * Linux o32 style syscalls are in the range from 4000 to 4999.
+ */
+#define __NR_Linux                     4000
+#define __NR_io_setup                  (__NR_Linux + 241)
+#define __NR_io_destroy                        (__NR_Linux + 242)
+#define __NR_io_getevents              (__NR_Linux + 243)
+#define __NR_io_submit                 (__NR_Linux + 244)
+#define __NR_io_cancel                 (__NR_Linux + 245)
+
+#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
+
+#if _MIPS_SIM == _MIPS_SIM_ABI64
+
+/*
+ * Linux 64-bit syscalls are in the range from 5000 to 5999.
+ */
+#define __NR_Linux                     5000
+#define __NR_io_setup                  (__NR_Linux + 200)
+#define __NR_io_destroy                        (__NR_Linux + 201)
+#define __NR_io_getevents              (__NR_Linux + 202)
+#define __NR_io_submit                 (__NR_Linux + 203)
+#define __NR_io_cancel                 (__NR_Linux + 204)
+#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
+
+#if _MIPS_SIM == _MIPS_SIM_NABI32
+
+/*
+ * Linux N32 syscalls are in the range from 6000 to 6999.
+ */
+#define __NR_Linux                     6000
+#define __NR_io_setup                  (__NR_Linux + 200)
+#define __NR_io_destroy                        (__NR_Linux + 201)
+#define __NR_io_getevents              (__NR_Linux + 202)
+#define __NR_io_submit                 (__NR_Linux + 203)
+#define __NR_io_cancel                 (__NR_Linux + 204)
+#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
index b53da4c226fff5e92e7da6b184dfd438ce050549..db78e28190b711c9656263b3505e5512b09869a6 100644 (file)
@@ -27,6 +27,8 @@
 #include "syscall-arm.h"
 #elif defined(__sparc__)
 #include "syscall-sparc.h"
+#elif defined(__mips__)
+#include "syscall-mips.h"
 #elif defined(__aarch64__) || defined(__riscv)
 #include "syscall-generic.h"
 #else