diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-12-22 20:10:10 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-12-22 20:10:10 +0000 |
commit | a334319f6530564d22e775935d9c91663623a1b4 (patch) | |
tree | b5877475619e4c938e98757d518bb1e9cbead751 /sysdeps/mach/mips | |
parent | 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (diff) | |
download | glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.gz glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.xz glibc-a334319f6530564d22e775935d9c91663623a1b4.zip |
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
Diffstat (limited to 'sysdeps/mach/mips')
-rw-r--r-- | sysdeps/mach/mips/Dist | 1 | ||||
-rw-r--r-- | sysdeps/mach/mips/Makefile | 3 | ||||
-rw-r--r-- | sysdeps/mach/mips/cacheflush.c | 44 | ||||
-rw-r--r-- | sysdeps/mach/mips/machine-lock.h | 92 | ||||
-rw-r--r-- | sysdeps/mach/mips/machine-sp.h | 38 | ||||
-rw-r--r-- | sysdeps/mach/mips/syscall.S | 48 | ||||
-rw-r--r-- | sysdeps/mach/mips/sysdep.h | 83 | ||||
-rw-r--r-- | sysdeps/mach/mips/thread_state.h | 42 |
8 files changed, 351 insertions, 0 deletions
diff --git a/sysdeps/mach/mips/Dist b/sysdeps/mach/mips/Dist new file mode 100644 index 0000000000..f2699bf887 --- /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 0000000000..a890ae7b46 --- /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 0000000000..2a283e3e89 --- /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) 1996, 1997 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. */ + +#include <mach.h> +#include <mach/vm_attributes.h> + +/* Stupid name, but this is what GCC generates (config/mips/mips.h). */ +void +cacheflush (void *addr, unsigned 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 0000000000..eccc720dfa --- /dev/null +++ b/sysdeps/mach/mips/machine-lock.h @@ -0,0 +1,92 @@ +/* Machine-specific definition for spin locks. MIPS version. + Copyright (C) 1996, 1997 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 _MACHINE_LOCK_H +#define _MACHINE_LOCK_H + +/* To get the TAS pseudo-instruction. */ +#include <mach/mips/mips_instruction.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) +{ +#if (__mips >= 2) + int __rtn; + + __asm__ __volatile (".set noreorder"); +#if (__mips64) + __asm__ __volatile ("lld %0,0(%1)" : "=r" (__rtn) : "r" (__lock)); +#else + __asm__ __volatile ("ll %0,0(%1)" : "=r" (__rtn) : "r" (__lock)); +#endif + if (__rtn) + return 0; + __asm__ __volatile ("move %0,%1" : "=r" (__rtn) : "r" (__lock)); +#if (__mips64) + __asm__ __volatile ("scd %0,0(%1)" : "=r" (__rtn) : "r" (__lock)); +#else + __asm__ __volatile ("sc %0,0(%1)" : "=r" (__rtn) : "r" (__lock)); +#endif + __asm__ __volatile (".set reorder"); + return __rtn; +#else + register int __rtn __asm__ ("a0"); + + /* Use the Mach microkernel's emulated TAS pseudo-instruction. */ + __asm__ __volatile (".set noreorder"); + __asm__ __volatile (".word %1" : "=r" (__rtn) : "i" (op_tas), "0" (__lock)); + __asm__ __volatile ("nop"); + __asm__ __volatile (".set reorder"); + return __rtn ^ (int) __lock; +#endif +} + +/* 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 0000000000..144356a39f --- /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) 1996, 1997 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 _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 0000000000..f2fc29df15 --- /dev/null +++ b/sysdeps/mach/mips/syscall.S @@ -0,0 +1,48 @@ +/* Copyright (C) 1996, 1997 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. */ + +#include <sysdep.h> + +#ifdef PIC + .option pic2 +#endif +ENTRY (syscall) + 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. */ +#ifdef __mips64 + ld t0,4*8(sp) + ld t1,5*8(sp) + ld t2,6*8(sp) + ld t3,7*8(sp) + ld t4,8*8(sp) + ld t5,9*8(sp) + ld t6,10*8(sp) +#else + lw t0,4*4(sp) + lw t1,5*4(sp) + lw t2,6*4(sp) + lw t3,7*4(sp) + lw t4,8*4(sp) + lw t5,9*4(sp) + lw t6,10*4(sp) +#endif + syscall /* Do the system call. */ + j ra /* Return to caller. */ diff --git a/sysdeps/mach/mips/sysdep.h b/sysdeps/mach/mips/sysdep.h new file mode 100644 index 0000000000..8136f95bf2 --- /dev/null +++ b/sysdeps/mach/mips/sysdep.h @@ -0,0 +1,83 @@ +/* Copyright (C) 1996, 1997 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 LOSE asm volatile ("1: b 1b") + +#define START_MACHDEP asm ("\ + .text\n\ + .globl _start\n\ + .ent _start\n\ +_start:\n\ + # Put initial SP in a0.\n\ + move $4, $29\n\ + # Jump to _start0; don't return.\n\ + j _start0\n\ + .end _start\n\ +"); +#define START_ARGS int *entry_sp +#define SNARF_ARGS(argc, argv, envp) \ + do \ + { \ + register char **p; \ + \ + 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 RETURN_TO(sp, pc, retval) \ + asm volatile ("move $29, %0; move $2, %2; move $25, %1; jr $25" \ + : : "r" (sp), "r" (pc), "r" (retval)) + +#define STACK_GROWTH_DOWN + +#include <syscall.h> + +#if defined (__ASSEMBLER__) + +#define ALIGN 2 + +#define MOVE(x,y) move y , x + +#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 <sysdeps/mach/sysdep.h> diff --git a/sysdeps/mach/mips/thread_state.h b/sysdeps/mach/mips/thread_state.h new file mode 100644 index 0000000000..a0800de2d0 --- /dev/null +++ b/sysdeps/mach/mips/thread_state.h @@ -0,0 +1,42 @@ +/* Mach thread state definitions for machine-independent code. MIPS version. + Copyright (C) 1996, 1997, 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. */ + +#define MACHINE_THREAD_STATE_FLAVOR MIPS_THREAD_STATE +#define MACHINE_THREAD_STATE_COUNT MIPS_THREAD_STATE_COUNT + +#ifdef __PIC__ +#define MACHINE_THREAD_STATE_SET_PC(ts, pc) \ + ((ts)->PC = (ts)->r25 = (unsigned long int) (pc)) +#endif + +#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 <sysdeps/mach/thread_state.h> |