summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/mips
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/mips')
-rw-r--r--libc/sysdeps/linux/mips/bits/atomicity.h98
-rw-r--r--libc/sysdeps/linux/mips/bits/machine-gmon.h68
-rw-r--r--libc/sysdeps/linux/mips/bits/sigcontextinfo.h27
-rw-r--r--libc/sysdeps/linux/mips/bits/stackinfo.h28
4 files changed, 221 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/mips/bits/atomicity.h b/libc/sysdeps/linux/mips/bits/atomicity.h
new file mode 100644
index 000000000..bccacd9c9
--- /dev/null
+++ b/libc/sysdeps/linux/mips/bits/atomicity.h
@@ -0,0 +1,98 @@
+/* Low-level functions for atomic operations. Mips version.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MIPS_ATOMICITY_H
+#define _MIPS_ATOMICITY_H 1
+
+#include <inttypes.h>
+
+static inline int
+__attribute__ ((unused))
+exchange_and_add (volatile uint32_t *mem, int val)
+{
+ int result, tmp;
+
+ __asm__ __volatile__
+ ("/* Inline exchange & add */\n"
+ "1:\n\t"
+ ".set push\n\t"
+ ".set mips2\n\t"
+ "ll %0,%3\n\t"
+ "addu %1,%4,%0\n\t"
+ "sc %1,%2\n\t"
+ ".set pop\n\t"
+ "beqz %1,1b\n\t"
+ "/* End exchange & add */"
+ : "=&r"(result), "=&r"(tmp), "=m"(*mem)
+ : "m" (*mem), "r"(val)
+ : "memory");
+
+ return result;
+}
+
+static inline void
+__attribute__ ((unused))
+atomic_add (volatile uint32_t *mem, int val)
+{
+ int result;
+
+ __asm__ __volatile__
+ ("/* Inline atomic add */\n"
+ "1:\n\t"
+ ".set push\n\t"
+ ".set mips2\n\t"
+ "ll %0,%2\n\t"
+ "addu %0,%3,%0\n\t"
+ "sc %0,%1\n\t"
+ ".set pop\n\t"
+ "beqz %0,1b\n\t"
+ "/* End atomic add */"
+ : "=&r"(result), "=m"(*mem)
+ : "m" (*mem), "r"(val)
+ : "memory");
+}
+
+static inline int
+__attribute__ ((unused))
+compare_and_swap (volatile long int *p, long int oldval, long int newval)
+{
+ long int ret, temp;
+
+ __asm__ __volatile__
+ ("/* Inline compare & swap */\n"
+ "1:\n\t"
+ ".set push\n\t"
+ ".set mips2\n\t"
+ "ll %1,%5\n\t"
+ "move %0,$0\n\t"
+ "bne %1,%3,2f\n\t"
+ "move %0,%4\n\t"
+ "sc %0,%2\n\t"
+ ".set pop\n\t"
+ "beqz %0,1b\n"
+ "2:\n\t"
+ "/* End compare & swap */"
+ : "=&r" (ret), "=&r" (temp), "=m" (*p)
+ : "r" (oldval), "r" (newval), "m" (*p)
+ : "memory");
+
+ return ret;
+}
+
+#endif /* atomicity.h */
diff --git a/libc/sysdeps/linux/mips/bits/machine-gmon.h b/libc/sysdeps/linux/mips/bits/machine-gmon.h
new file mode 100644
index 000000000..102da2c36
--- /dev/null
+++ b/libc/sysdeps/linux/mips/bits/machine-gmon.h
@@ -0,0 +1,68 @@
+/* Machine-specific calling sequence for `mcount' profiling function. MIPS
+ Copyright (C) 1996, 1997, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define _MCOUNT_DECL(frompc,selfpc) \
+static void __attribute_used__ __mcount (u_long frompc, u_long selfpc)
+
+/* Call __mcount with our the return PC for our caller,
+ and the return PC our caller will return to. */
+#ifdef __PIC__
+#define CPLOAD ".cpload $25;"
+#define CPRESTORE ".cprestore 44\n\t"
+#else
+#define CPLOAD
+#define CPRESTORE
+#endif
+
+#define MCOUNT asm(\
+ ".globl _mcount;\n\t" \
+ ".align 2;\n\t" \
+ ".type _mcount,@function;\n\t" \
+ ".ent _mcount\n\t" \
+ "_mcount:\n\t" \
+ ".frame $sp,44,$31\n\t" \
+ ".set noreorder;\n\t" \
+ ".set noat;\n\t" \
+ CPLOAD \
+ "subu $29,$29,48;\n\t" \
+ CPRESTORE \
+ "sw $4,24($29);\n\t" \
+ "sw $5,28($29);\n\t" \
+ "sw $6,32($29);\n\t" \
+ "sw $7,36($29);\n\t" \
+ "sw $2,40($29);\n\t" \
+ "sw $1,16($29);\n\t" \
+ "sw $31,20($29);\n\t" \
+ "move $5,$31;\n\t" \
+ "move $4,$1;\n\t" \
+ "jal __mcount;\n\t" \
+ "nop;\n\t" \
+ "lw $4,24($29);\n\t" \
+ "lw $5,28($29);\n\t" \
+ "lw $6,32($29);\n\t" \
+ "lw $7,36($29);\n\t" \
+ "lw $2,40($29);\n\t" \
+ "lw $31,20($29);\n\t" \
+ "lw $1,16($29);\n\t" \
+ "addu $29,$29,56;\n\t" \
+ "j $31;\n\t" \
+ "move $31,$1;\n\t" \
+ ".set reorder;\n\t" \
+ ".set at\n\t" \
+ ".end _mcount");
diff --git a/libc/sysdeps/linux/mips/bits/sigcontextinfo.h b/libc/sysdeps/linux/mips/bits/sigcontextinfo.h
new file mode 100644
index 000000000..a51c6f043
--- /dev/null
+++ b/libc/sysdeps/linux/mips/bits/sigcontextinfo.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+#define SIGCONTEXT unsigned long _code, struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS _code,
+#define GET_PC(ctx) ((void *) ctx->sc_pc)
+#define GET_FRAME(ctx) ((void *) ctx->sc_regs[30])
+#define GET_STACK(ctx) ((void *) ctx->sc_regs[29])
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/libc/sysdeps/linux/mips/bits/stackinfo.h b/libc/sysdeps/linux/mips/bits/stackinfo.h
new file mode 100644
index 000000000..86e3d621b
--- /dev/null
+++ b/libc/sysdeps/linux/mips/bits/stackinfo.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On MIPS the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */