aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach/mips
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach/mips')
-rw-r--r--sysdeps/mach/mips/Dist1
-rw-r--r--sysdeps/mach/mips/Makefile3
-rw-r--r--sysdeps/mach/mips/cacheflush.c44
-rw-r--r--sysdeps/mach/mips/machine-lock.h73
-rw-r--r--sysdeps/mach/mips/machine-sp.h38
-rw-r--r--sysdeps/mach/mips/syscall.S37
-rw-r--r--sysdeps/mach/mips/sysdep.h69
-rw-r--r--sysdeps/mach/mips/thread_state.h37
8 files changed, 302 insertions, 0 deletions
diff --git a/sysdeps/mach/mips/Dist b/sysdeps/mach/mips/Dist
new file mode 100644
index 0000000..f2699bf
--- /dev/null
+++ b/sysdeps/mach/mips/Dist
@@ -0,0 +1 @@
+cacheflush.c
diff --git a/sysdeps/mach/mips/Makefile b/sysdeps/mach/mips/Makefile
new file mode 100644
index 0000000..a890ae7
--- /dev/null
+++ b/sysdeps/mach/mips/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),gnulib)
+sysdep_routines += cacheflush
+endif
diff --git a/sysdeps/mach/mips/cacheflush.c b/sysdeps/mach/mips/cacheflush.c
new file mode 100644
index 0000000..5325e6f
--- /dev/null
+++ b/sysdeps/mach/mips/cacheflush.c
@@ -0,0 +1,44 @@
+/* Flush the insn cache after GCC writes a closure on the stack. Mach/MIPS.
+Copyright (C) 1994 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <mach.h>
+#include <mach/vm_attributes.h>
+
+/* Stupid name, but this is what GCC generates (config/mips/mips.h). */
+void
+cacheflush (void *addr, size_t size, int flag)
+{
+ vm_machine_attribute_val_t val;
+
+ switch (flag)
+ {
+ case 0: /* ? */
+ val = MATTR_VAL_DCACHE_FLUSH;
+ case 1: /* This is the only value GCC uses. */
+ val = MATTR_VAL_ICACHE_FLUSH;
+ break;
+ default:
+ val = MATTR_VAL_CACHE_FLUSH;
+ }
+
+ __vm_machine_attribute (__mach_task_self (),
+ (vm_address_t) addr, size,
+ MATTR_CACHE,
+ &val);
+}
diff --git a/sysdeps/mach/mips/machine-lock.h b/sysdeps/mach/mips/machine-lock.h
new file mode 100644
index 0000000..628aae4
--- /dev/null
+++ b/sysdeps/mach/mips/machine-lock.h
@@ -0,0 +1,73 @@
+/* Machine-specific definition for spin locks. MIPS version.
+Copyright (C) 1994 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#ifndef _MACHINE_LOCK_H
+#define _MACHINE_LOCK_H
+
+/* The type of a spin lock variable. */
+
+typedef __volatile int __spin_lock_t;
+
+/* Value to initialize `__spin_lock_t' variables to. */
+
+#define __SPIN_LOCK_INITIALIZER 0
+
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+/* Unlock LOCK. */
+
+_EXTERN_INLINE void
+__spin_unlock (__spin_lock_t *__lock)
+{
+ *__lock = 0;
+}
+
+/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
+
+_EXTERN_INLINE int
+__spin_try_lock (register __spin_lock_t *__lock)
+{
+ register int __rtn;
+ __asm__ __volatile (".set noreorder");
+#if 0
+ __asm__ __volatile ("lw %0,0(%1)": "=r" (__rtn) : "r" (__lock));
+ __asm__ __volatile ("sw %0,0(%0)": : "r" (__lock));
+ __asm__ __volatile ("xor %0,%1,%0": "=r" (__rtn) : "r" (__lock));
+#else
+ /* Use the Mach microkernel's emulated TAS pseudo-instruction. */
+ register int __rtn __asm__ ("a0");
+ __asm__ __volatile (".word 0xf ! %0 " : "=r" (__rtn) : "0" (__lock));
+#endif
+ __asm__ __volatile (".set reorder");
+ return __rtn ^ (int) __lock;
+}
+
+/* Return nonzero if LOCK is locked. */
+
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+ return *__lock != 0;
+}
+
+
+#endif /* machine-lock.h */
diff --git a/sysdeps/mach/mips/machine-sp.h b/sysdeps/mach/mips/machine-sp.h
new file mode 100644
index 0000000..7406658
--- /dev/null
+++ b/sysdeps/mach/mips/machine-sp.h
@@ -0,0 +1,38 @@
+/* Machine-specific function to return the stack pointer. MIPS version.
+Copyright (C) 1994 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
+
+/* Return the current stack pointer. */
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+_EXTERN_INLINE void *
+__thread_stack_pointer (void)
+{
+ void *__sp__;
+ __asm__ ("move %0,$29" : "=r" (__sp__));
+ return __sp__;
+}
+
+#endif /* machine-sp.h */
+
diff --git a/sysdeps/mach/mips/syscall.S b/sysdeps/mach/mips/syscall.S
new file mode 100644
index 0000000..bf56b40
--- /dev/null
+++ b/sysdeps/mach/mips/syscall.S
@@ -0,0 +1,37 @@
+/* Copyright (C) 1994 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <sysdep.h>
+
+ENTRY (syscall)
+ .frame sp,0,ra
+ move v0, a0 /* Load system call number from first arg. */
+ move a0, a1 /* Move the next three args up a register. */
+ move a1, a2
+ move a2, a3
+ /* Load the remaining possible args (up to 11) from the stack. */
+ lw t0,16(sp)
+ lw t1,20(sp)
+ lw t2,24(sp)
+ lw t3,28(sp)
+ lw t4,32(sp)
+ lw t5,36(sp)
+ lw t6,40(sp)
+ syscall /* Do the system call. */
+ j ra /* Return to caller. */
+ .end syscall
diff --git a/sysdeps/mach/mips/sysdep.h b/sysdeps/mach/mips/sysdep.h
new file mode 100644
index 0000000..7609be5
--- /dev/null
+++ b/sysdeps/mach/mips/sysdep.h
@@ -0,0 +1,69 @@
+/* Copyright (C) 1991, 1992, 1993, 1994 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#define MOVE(x,y) move y , x
+
+#if 0
+#define LOSE asm volatile ("1: b 1b")
+#endif
+
+#define SNARF_ARGS(argc, argv, envp) \
+ do \
+ { \
+ int *entry_sp; \
+ register char **p; \
+ \
+ asm ("addu %0,$30,4" : "=r" (entry_sp)); \
+ \
+ argc = *entry_sp; \
+ argv = (char **) (entry_sp + 1); \
+ p = argv; \
+ while (*p++ != NULL) \
+ ; \
+ if (p >= (char **) argv[0]) \
+ --p; \
+ envp = p; \
+ } while (0)
+
+#define CALL_WITH_SP(fn, sp) \
+ ({ register int __fn = fn, __sp = (int) sp; \
+ asm volatile ("move $sp,%0; j %1" : : "r" (__sp), "r" (__fn));})
+
+#define STACK_GROWTH_DOWN
+
+#ifdef P40
+#include <syscall.h>
+
+#define SYSCALL(name, args) \
+ .globl syscall_error; \
+ kernel_trap(name,SYS_##name,args); \
+ beq $1,$0,1f; \
+ j syscall_error; \
+1:
+
+#define SYSCALL__(name, args) \
+ .globl syscall_error; \
+ kernel_trap(__##name,SYS_##name,args); \
+ beq $1,$0,1f; \
+ j syscall_error; \
+1:
+
+#define ret j ra; nop
+#endif
+
+#include_next <sysdep.h>
diff --git a/sysdeps/mach/mips/thread_state.h b/sysdeps/mach/mips/thread_state.h
new file mode 100644
index 0000000..f4f4b42
--- /dev/null
+++ b/sysdeps/mach/mips/thread_state.h
@@ -0,0 +1,37 @@
+/* Mach thread state definitions for machine-independent code. MIPS version.
+Copyright (C) 1994 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#define MACHINE_THREAD_STATE_FLAVOR MIPS_THREAD_STATE
+#define MACHINE_THREAD_STATE_COUNT MIPS_THREAD_STATE_COUNT
+
+#define machine_thread_state mips_thread_state
+
+#define PC pc
+#define SP r29
+#define SYSRETURN r2
+
+struct machine_thread_all_state
+ {
+ int set; /* Mask of bits (1 << FLAVOR). */
+ struct mips_thread_state basic;
+ struct mips_exc_state exc;
+ struct mips_float_state fpu;
+ };
+
+#include_next <thread_state.h>