0004-Fix-and-improve-MIPS-support.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. From f9c8695989fea731c93d99c684482df5744b385c Mon Sep 17 00:00:00 2001
  2. From: Guillem Jover <guillem@hadrons.org>
  3. Date: Wed, 14 Aug 2019 03:18:50 +0200
  4. Subject: [PATCH libaio 04/11] Fix and improve MIPS support
  5. Fix structure padding for MIPS 64, add syscall definitions, and the
  6. kernel R/W pointer.
  7. Signed-off-by: Guillem Jover <guillem@hadrons.org>
  8. ---
  9. harness/main.c | 2 +-
  10. src/libaio.h | 6 +++++-
  11. src/syscall-mips.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++
  12. src/syscall.h | 2 ++
  13. 4 files changed, 62 insertions(+), 2 deletions(-)
  14. create mode 100644 src/syscall-mips.h
  15. diff --git a/harness/main.c b/harness/main.c
  16. index 0eed7bd..33d8e46 100644
  17. --- a/harness/main.c
  18. +++ b/harness/main.c
  19. @@ -12,7 +12,7 @@
  20. #include <libaio.h>
  21. #if __LP64__ == 0
  22. -#if defined(__i386__) || defined(__powerpc__)
  23. +#if defined(__i386__) || defined(__powerpc__) || defined(__mips__)
  24. #define KERNEL_RW_POINTER ((void *)0xc0010000)
  25. #elif defined(__arm__) || defined(__s390__)
  26. #define KERNEL_RW_POINTER ((void *)0x00010000)
  27. diff --git a/src/libaio.h b/src/libaio.h
  28. index 8b33382..26b07f9 100644
  29. --- a/src/libaio.h
  30. +++ b/src/libaio.h
  31. @@ -52,7 +52,9 @@ typedef enum io_iocb_cmd {
  32. /* little endian, 32 bits */
  33. #if defined(__i386__) || (defined(__arm__) && !defined(__ARMEB__)) || \
  34. - defined(__sh__) || defined(__bfin__) || defined(__MIPSEL__) || \
  35. + defined(__sh__) || \
  36. + defined(__bfin__) || \
  37. + (defined(__MIPSEL__) && !defined(__mips64)) || \
  38. defined(__cris__) || (defined(__riscv) && __riscv_xlen == 32) || \
  39. (defined(__GNUC__) && defined(__BYTE_ORDER__) && \
  40. __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_LONG__ == 4)
  41. @@ -62,6 +64,7 @@ typedef enum io_iocb_cmd {
  42. /* little endian, 64 bits */
  43. #elif defined(__ia64__) || defined(__x86_64__) || defined(__alpha__) || \
  44. + (defined(__mips64) && defined(__MIPSEL__)) || \
  45. (defined(__aarch64__) && defined(__AARCH64EL__)) || \
  46. (defined(__riscv) && __riscv_xlen == 64) || \
  47. (defined(__GNUC__) && defined(__BYTE_ORDER__) && \
  48. @@ -73,6 +76,7 @@ typedef enum io_iocb_cmd {
  49. /* big endian, 64 bits */
  50. #elif defined(__powerpc64__) || defined(__s390x__) || \
  51. (defined(__sparc__) && defined(__arch64__)) || \
  52. + (defined(__mips64) && defined(__MIPSEB__)) || \
  53. (defined(__aarch64__) && defined(__AARCH64EB__)) || \
  54. (defined(__GNUC__) && defined(__BYTE_ORDER__) && \
  55. __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ && __SIZEOF_LONG__ == 8)
  56. diff --git a/src/syscall-mips.h b/src/syscall-mips.h
  57. new file mode 100644
  58. index 0000000..2c4245e
  59. --- /dev/null
  60. +++ b/src/syscall-mips.h
  61. @@ -0,0 +1,54 @@
  62. +/*
  63. + * This file is subject to the terms and conditions of the GNU General Public
  64. + * License. See the file "COPYING" in the main directory of this archive
  65. + * for more details.
  66. + *
  67. + * Copyright (C) 1995, 96, 97, 98, 99, 2000 by Ralf Baechle
  68. + * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  69. + */
  70. +
  71. +#ifndef _MIPS_SIM_ABI32
  72. +#define _MIPS_SIM_ABI32 1
  73. +#define _MIPS_SIM_NABI32 2
  74. +#define _MIPS_SIM_ABI64 3
  75. +#endif
  76. +
  77. +#if _MIPS_SIM == _MIPS_SIM_ABI32
  78. +
  79. +/*
  80. + * Linux o32 style syscalls are in the range from 4000 to 4999.
  81. + */
  82. +#define __NR_Linux 4000
  83. +#define __NR_io_setup (__NR_Linux + 241)
  84. +#define __NR_io_destroy (__NR_Linux + 242)
  85. +#define __NR_io_getevents (__NR_Linux + 243)
  86. +#define __NR_io_submit (__NR_Linux + 244)
  87. +#define __NR_io_cancel (__NR_Linux + 245)
  88. +
  89. +#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
  90. +
  91. +#if _MIPS_SIM == _MIPS_SIM_ABI64
  92. +
  93. +/*
  94. + * Linux 64-bit syscalls are in the range from 5000 to 5999.
  95. + */
  96. +#define __NR_Linux 5000
  97. +#define __NR_io_setup (__NR_Linux + 200)
  98. +#define __NR_io_destroy (__NR_Linux + 201)
  99. +#define __NR_io_getevents (__NR_Linux + 202)
  100. +#define __NR_io_submit (__NR_Linux + 203)
  101. +#define __NR_io_cancel (__NR_Linux + 204)
  102. +#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
  103. +
  104. +#if _MIPS_SIM == _MIPS_SIM_NABI32
  105. +
  106. +/*
  107. + * Linux N32 syscalls are in the range from 6000 to 6999.
  108. + */
  109. +#define __NR_Linux 6000
  110. +#define __NR_io_setup (__NR_Linux + 200)
  111. +#define __NR_io_destroy (__NR_Linux + 201)
  112. +#define __NR_io_getevents (__NR_Linux + 202)
  113. +#define __NR_io_submit (__NR_Linux + 203)
  114. +#define __NR_io_cancel (__NR_Linux + 204)
  115. +#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
  116. diff --git a/src/syscall.h b/src/syscall.h
  117. index b53da4c..db78e28 100644
  118. --- a/src/syscall.h
  119. +++ b/src/syscall.h
  120. @@ -27,6 +27,8 @@
  121. #include "syscall-arm.h"
  122. #elif defined(__sparc__)
  123. #include "syscall-sparc.h"
  124. +#elif defined(__mips__)
  125. +#include "syscall-mips.h"
  126. #elif defined(__aarch64__) || defined(__riscv)
  127. #include "syscall-generic.h"
  128. #else
  129. --
  130. 2.26.0.292.g33ef6b2f38