syscall.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. *
  5. * This file is part of GNU Mes.
  6. *
  7. * GNU Mes is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * GNU Mes is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <errno.h>
  21. #include <linux/x86/syscall.h>
  22. int
  23. __sys_call (int sys_call)
  24. {
  25. asm ("!8 ldr____%r7,(%fp,+#$i8)");
  26. asm ("swi____$0");
  27. }
  28. int
  29. __sys_call1 (int sys_call, int one)
  30. {
  31. asm ("!8 ldr____%r7,(%fp,+#$i8)");
  32. asm ("!12 ldr____%r0,(%fp,+#$i8)");
  33. asm ("swi____$0");
  34. }
  35. int
  36. __sys_call2 (int sys_call, int one, int two)
  37. {
  38. asm ("!8 ldr____%r7,(%fp,+#$i8)");
  39. asm ("!12 ldr____%r0,(%fp,+#$i8)");
  40. asm ("!16 ldr____%r1,(%fp,+#$i8)");
  41. asm ("swi____$0");
  42. }
  43. int
  44. __sys_call3 (int sys_call, int one, int two, int three)
  45. {
  46. asm ("!8 ldr____%r7,(%fp,+#$i8)");
  47. asm ("!12 ldr____%r0,(%fp,+#$i8)");
  48. asm ("!16 ldr____%r1,(%fp,+#$i8)");
  49. asm ("!20 ldr____%r2,(%fp,+#$i8)");
  50. asm ("swi____$0");
  51. }
  52. int
  53. __sys_call4 (int sys_call, int one, int two, int three, int four)
  54. {
  55. asm ("!8 ldr____%r7,(%fp,+#$i8)");
  56. asm ("!12 ldr____%r0,(%fp,+#$i8)");
  57. asm ("!16 ldr____%r1,(%fp,+#$i8)");
  58. asm ("!20 ldr____%r2,(%fp,+#$i8)");
  59. asm ("!24 ldr____%r3,(%fp,+#$i8)");
  60. asm ("swi____$0");
  61. }
  62. int
  63. __sys_call6 (int sys_call, int one, int two, int three, int four, int five, int six)
  64. {
  65. asm ("!8 ldr____%r7,(%fp,+#$i8)");
  66. asm ("!12 ldr____%r0,(%fp,+#$i8)");
  67. asm ("!16 ldr____%r1,(%fp,+#$i8)");
  68. asm ("!20 ldr____%r2,(%fp,+#$i8)");
  69. asm ("!24 ldr____%r3,(%fp,+#$i8)");
  70. asm ("!28 ldr____%r4,(%fp,+#$i8)");
  71. asm ("!32 ldr____%r5,(%fp,+#$i8)");
  72. asm ("swi____$0");
  73. }
  74. int
  75. _sys_call (int sys_call)
  76. {
  77. int r = __sys_call (sys_call);
  78. if (r < 0)
  79. {
  80. errno = -r;
  81. r = -1;
  82. }
  83. else
  84. errno = 0;
  85. return r;
  86. }
  87. int
  88. _sys_call1 (int sys_call, int one)
  89. {
  90. int r = __sys_call1 (sys_call, one);
  91. if (r < 0)
  92. {
  93. errno = -r;
  94. r = -1;
  95. }
  96. else
  97. errno = 0;
  98. return r;
  99. }
  100. int
  101. _sys_call2 (int sys_call, int one, int two)
  102. {
  103. int r = __sys_call2 (sys_call, one, two);
  104. if (r < 0)
  105. {
  106. errno = -r;
  107. r = -1;
  108. }
  109. else
  110. errno = 0;
  111. return r;
  112. }
  113. int
  114. _sys_call3 (int sys_call, int one, int two, int three)
  115. {
  116. int r = __sys_call3 (sys_call, one, two, three);
  117. if (r < 0)
  118. {
  119. errno = -r;
  120. r = -1;
  121. }
  122. else
  123. errno = 0;
  124. return r;
  125. }
  126. int
  127. _sys_call4 (int sys_call, int one, int two, int three, int four)
  128. {
  129. int r = __sys_call4 (sys_call, one, two, three, four);
  130. if (r < 0)
  131. {
  132. errno = -r;
  133. r = -1;
  134. }
  135. else
  136. errno = 0;
  137. return r;
  138. }
  139. int
  140. _sys_call6 (int sys_call, int one, int two, int three, int four, int five, int six)
  141. {
  142. int r = __sys_call6 (sys_call, one, two, three, four, five, six);
  143. if (r < 0)
  144. {
  145. errno = -r;
  146. r = -1;
  147. }
  148. else
  149. errno = 0;
  150. return r;
  151. }