diff options
| author | Roland McGrath <roland@gnu.org> | 2001-11-10 00:37:59 +0000 |
|---|---|---|
| committer | Roland McGrath <roland@gnu.org> | 2001-11-10 00:37:59 +0000 |
| commit | 7d0c5823985d8d2be48cbc23b5099633bedceef4 (patch) | |
| tree | 74f4b2b676d08cccbfa7bc926f5a061fbb6dac7a | |
| parent | d0bf7991d6e87ffd4f378b2f7af4b3f16dfa96ee (diff) | |
| download | glibc-7d0c5823985d8d2be48cbc23b5099633bedceef4.tar.xz glibc-7d0c5823985d8d2be48cbc23b5099633bedceef4.zip | |
Hurd/PowerPC port contributed by Peter Bruin <pjbruin@dds.nl>.
* NEWS: Mention it.
* sysdeps/mach/hurd/powerpc/exc2signal.c: New file.
* sysdeps/mach/hurd/powerpc/init-first.c: New file.
* sysdeps/mach/hurd/powerpc/intr-msg.h: New file.
* sysdeps/mach/hurd/powerpc/longjmp-ts.c: New file.
* sysdeps/mach/hurd/powerpc/register-dump.h: New file.
* sysdeps/mach/hurd/powerpc/sigreturn.c: New file.
* sysdeps/mach/hurd/powerpc/static-start.S: New file.
* sysdeps/mach/hurd/powerpc/trampoline.c: New file.
* sysdeps/mach/hurd/powerpc/bits/sigcontext.h: New file.
* sysdeps/mach/hurd/powerpc/Dist: New file.
| -rw-r--r-- | ChangeLog | 13 | ||||
| -rw-r--r-- | NEWS | 4 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/powerpc/Dist | 1 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/powerpc/bits/sigcontext.h | 76 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/powerpc/exc2signal.c | 74 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/powerpc/init-first.c | 333 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/powerpc/intr-msg.h | 99 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/powerpc/longjmp-ts.c | 56 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/powerpc/register-dump.h | 120 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/powerpc/sigreturn.c | 186 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/powerpc/static-start.S | 59 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/powerpc/trampoline.c | 256 |
12 files changed, 1276 insertions, 1 deletions
@@ -1,5 +1,18 @@ 2001-11-09 Roland McGrath <roland@frob.com> + Hurd/PowerPC port contributed by Peter Bruin <pjbruin@dds.nl>. + * NEWS: Mention it. + * sysdeps/mach/hurd/powerpc/exc2signal.c: New file. + * sysdeps/mach/hurd/powerpc/init-first.c: New file. + * sysdeps/mach/hurd/powerpc/intr-msg.h: New file. + * sysdeps/mach/hurd/powerpc/longjmp-ts.c: New file. + * sysdeps/mach/hurd/powerpc/register-dump.h: New file. + * sysdeps/mach/hurd/powerpc/sigreturn.c: New file. + * sysdeps/mach/hurd/powerpc/static-start.S: New file. + * sysdeps/mach/hurd/powerpc/trampoline.c: New file. + * sysdeps/mach/hurd/powerpc/bits/sigcontext.h: New file. + * sysdeps/mach/hurd/powerpc/Dist: New file. + * hurd/privports.c (__get_privileged_ports): Only contact the proc server if necessary for this call. Suggested by Neal H Walfield <neal@cs.uml.edu>. @@ -16,12 +16,14 @@ Version 2.2.5 * Andreas Jaeger contributed a port to x86_64/Linux. +* Peter Bruin contributed a port to PowerPC/Hurd. + * libc functions using I/O streams now can handle wide-oriented streams as well. * optimizations in the dynamic linker. binaries created by recent binutils versions start up quicker due to reduced time spend on relocations. - + Version 2.2.4 * Stephen Moshier implemented cosh, expm1, log1p, acos, sinh, tanh, diff --git a/sysdeps/mach/hurd/powerpc/Dist b/sysdeps/mach/hurd/powerpc/Dist new file mode 100644 index 0000000000..c58180257e --- /dev/null +++ b/sysdeps/mach/hurd/powerpc/Dist @@ -0,0 +1 @@ +static-start.S diff --git a/sysdeps/mach/hurd/powerpc/bits/sigcontext.h b/sysdeps/mach/hurd/powerpc/bits/sigcontext.h new file mode 100644 index 0000000000..6f14ec5c31 --- /dev/null +++ b/sysdeps/mach/hurd/powerpc/bits/sigcontext.h @@ -0,0 +1,76 @@ +/* Machine-dependent signal context structure for GNU Hurd. PowerPC version. + Copyright (C) 1991, 1992, 1994, 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 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _SIGNAL_H +# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead." +#endif + +/* Signal handlers are actually called: + void handler (int sig, int code, struct sigcontext *scp); */ + +/* State of this thread when the signal was taken. */ +struct sigcontext + { + /* These first members are machine-independent. */ + + int sc_onstack; /* Nonzero if running on sigstack. */ + __sigset_t sc_mask; /* Blocked signals to restore. */ + + /* MiG reply port this thread is using. */ + unsigned int sc_reply_port; + + /* Port this thread is doing an interruptible RPC on. */ + unsigned int sc_intr_port; + + /* Error code associated with this signal (interpreted as `error_t'). */ + int sc_error; + + /* All following members are machine-dependent. The rest of this + structure is written to be laid out identically to: + { + struct ppc_thread_state basic; + struct ppc_exc_state exc; + struct ppc_float_state fpu; + } + trampoline.c knows this, so it must be changed if this changes. */ + +#define sc_ppc_thread_state sc_srr0 /* Beginning of correspondence. */ +#define sc_pc sc_srr0 /* For sysdeps/generic/profil-counter.h. */ + unsigned int sc_srr0; + unsigned int sc_srr1; + unsigned int sc_gprs[32]; + unsigned int sc_cr; + unsigned int sc_xer; + unsigned int sc_lr; + unsigned int sc_ctr; + unsigned int sc_mq; + unsigned int sc_ts_pad; + +#define sc_ppc_exc_state sc_dar + unsigned int sc_dar; + unsigned int sc_dsisr; + unsigned int sc_exception; + unsigned int sc_es_pad0; + unsigned int sc_es_pad1[4]; + +#define sc_ppc_float_state sc_fprs[0] + double sc_fprs[32]; + unsigned int sc_fpscr_pad; + unsigned int sc_fpscr; + }; diff --git a/sysdeps/mach/hurd/powerpc/exc2signal.c b/sysdeps/mach/hurd/powerpc/exc2signal.c new file mode 100644 index 0000000000..7cea85daa0 --- /dev/null +++ b/sysdeps/mach/hurd/powerpc/exc2signal.c @@ -0,0 +1,74 @@ +/* Translate Mach exception codes into signal numbers. PowerPC version. + Copyright (C) 1991,92,94,96,97,2001 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 <hurd.h> +#include <hurd/signal.h> +#include <mach/exception.h> + +/* Translate the Mach exception codes, as received in an `exception_raise' RPC, + into a signal number and signal subcode. */ + +void +_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo) +{ + detail->error = 0; + + switch (detail->exc) + { + default: + *signo = SIGIOT; + detail->code = detail->exc; + break; + + case EXC_BAD_ACCESS: + if (detail->exc_code == KERN_PROTECTION_FAILURE) + *signo = SIGSEGV; + else + *signo = SIGBUS; + detail->code = detail->exc_subcode; + detail->error = detail->exc_code; + break; + + /* XXX there has got to be something more here */ + + case EXC_BAD_INSTRUCTION: + *signo = SIGILL; + detail->code = 0; + break; + + case EXC_ARITHMETIC: + *signo = SIGFPE; + detail->code = 0; + break; + + case EXC_EMULATION: + *signo = SIGEMT; + detail->code = 0; + break; + + case EXC_SOFTWARE: + *signo = SIGEMT; + detail->code = 0; + break; + + case EXC_BREAKPOINT: + *signo = SIGTRAP; + detail->code = 0; + } +} diff --git a/sysdeps/mach/hurd/powerpc/init-first.c b/sysdeps/mach/hurd/powerpc/init-first.c new file mode 100644 index 0000000000..25f5c53716 --- /dev/null +++ b/sysdeps/mach/hurd/powerpc/init-first.c @@ -0,0 +1,333 @@ +/* Initialization code run first thing by the ELF startup code. PowerPC/Hurd. + Copyright (C) 1995,96,97,98,99,2000,01 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 <assert.h> +#include <hurd.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <sysdep.h> +#include <set-hooks.h> +#include "hurdstartup.h" +#include "hurdmalloc.h" /* XXX */ + +extern void __mach_init (void); +extern void __libc_init (int, char **, char **); +#ifdef USE_NONOPTION_FLAGS +extern void __getopt_clean_environment (char **); +#endif +extern void __libc_global_ctors (void); + +unsigned int __hurd_threadvar_max; +unsigned long int __hurd_threadvar_stack_offset; +unsigned long int __hurd_threadvar_stack_mask; + +#ifndef SHARED +int __libc_enable_secure; +#endif +int __libc_multiple_libcs = 1; + +extern int __libc_argc; +extern char **__libc_argv; +extern char **_dl_argv; + +void *(*_cthread_init_routine) (void); /* Returns new SP to use. */ +void (*_cthread_exit_routine) (int status) __attribute__ ((__noreturn__)); + +#ifndef SHARED +static unsigned int return_address; /* Make init1 return to _start. */ +#endif + +/* Things that want to be run before _hurd_init or much anything else. + Importantly, these are called before anything tries to use malloc. */ +DEFINE_HOOK (_hurd_preinit_hook, (void)); + + +/* We call this once the Hurd magic is all set up and we are ready to be a + Posixoid program. This does the same things the generic version does. */ +static void internal_function +posixland_init (int argc, char **argv, char **envp) +{ + asm ("li 3,0xbb; .long 0"); + __libc_argc = argc; + __libc_argv = argv; + __environ = envp; + + __libc_init (argc, argv, envp); + +#ifdef USE_NONOPTION_FLAGS + /* This is a hack to make the special getopt in GNU libc working. */ + __getopt_clean_environment (__environ); +#endif + +#ifdef SHARED + __libc_global_ctors (); +#endif +} + + +static void +init1 (int *data) +{ + int argc = *data; + char **argv = (char **) &data[1]; + char **envp = &argv[argc + 1]; + struct hurd_startup_data *d; + + while (*envp) + ++envp; + d = (void *) ++envp; + + /* If we are the bootstrap task started by the kernel, + then after the environment pointers there is no Hurd + data block; the argument strings start there. */ + /* OSF Mach starts the bootstrap task with argc == 0. + XXX This fails if a non-bootstrap task gets started + with argc == 0. */ + if (argc && (void *) d != argv[0]) + { + _hurd_init_dtable = d->dtable; + _hurd_init_dtablesize = d->dtablesize; + +#if 0 /* We can't free the old stack because it contains the argument strings. */ + { + /* Check if the stack we are now on is different from + the one described by _hurd_stack_{base,size}. */ + + char dummy; + const vm_address_t newsp = (vm_address_t) &dummy; + + if (d->stack_size != 0 && (newsp < d->stack_base || + newsp - d->stack_base > d->stack_size)) + /* The new stack pointer does not intersect with the + stack the exec server set up for us, so free that stack. */ + __vm_deallocate (__mach_task_self (), d->stack_base, d->stack_size); + } +#endif + } + + if (argc && (void *) d != argv[0] && (d->portarray || d->intarray)) + /* Initialize library data structures, start signal processing, etc. */ + _hurd_init (d->flags, argv, + d->portarray, d->portarraysize, + d->intarray, d->intarraysize); + +#ifndef SHARED + __libc_enable_secure = d->flags & EXEC_SECURE; +#endif +} + + +static inline void +init (int *data) +{ + int argc = *data; + char **argv = (void *) (data + 1); + char **envp = &argv[argc + 1]; + struct hurd_startup_data *d; + unsigned long int threadvars[_HURD_THREADVAR_MAX]; + + /* Provide temporary storage for thread-specific variables on the startup + stack so the cthreads initialization code can use them for malloc et al, + or so we can use malloc below for the real threadvars array. */ + memset (threadvars, 0, sizeof threadvars); + __hurd_threadvar_stack_offset = (unsigned long int) threadvars; + + while (*envp) + ++envp; + d = (void *) ++envp; + + /* The user might have defined a value for this, to get more variables. + Otherwise it will be zero on startup. We must make sure it is set + properly before before cthreads initialization, so cthreads can know + how much space to leave for thread variables. */ + if (__hurd_threadvar_max < _HURD_THREADVAR_MAX) + __hurd_threadvar_max = _HURD_THREADVAR_MAX; + + + /* After possibly switching stacks, call `init1' (above) with the user + code as the return address, and the argument data immediately above + that on the stack. */ + + if (_cthread_init_routine) + { + /* Initialize cthreads, which will allocate us a new stack to run on. */ + void *newsp = (*_cthread_init_routine) (); + struct hurd_startup_data *od; +#ifdef SHARED + void *oldsp; + unsigned int i, data_offset; +#endif + + /* Copy per-thread variables from that temporary + area onto the new cthread stack. */ + memcpy (__hurd_threadvar_location_from_sp (0, newsp), + threadvars, sizeof threadvars); + + /* Copy the argdata from the old stack to the new one. */ + newsp = memcpy (newsp - ((char *) &d[1] - (char *) data), data, + (char *) d - (char *) data); + +#ifdef SHARED + /* And readjust the dynamic linker's idea of where the argument + vector lives. */ + assert (_dl_argv == argv); + _dl_argv = (void *) ((int *) newsp + 1); +#endif + + /* Set up the Hurd startup data block immediately following + the argument and environment pointers on the new stack. */ + od = (newsp + ((char *) d - (char *) data)); + if (!argc || (void *) argv[0] == d) + /* We were started up by the kernel with arguments on the stack. + There is no Hurd startup data, so zero the block. */ + memset (od, 0, sizeof *od); + else + /* Copy the Hurd startup data block to the new stack. */ + *od = *d; + +#ifndef SHARED + asm ("mtlr %0; mr 1,%1; li 0,0; mr 3,%1; stwu 0,-16(1); b init1" + : : "r" (return_address), "r" (newsp)); + (void) init1; /* To avoid `defined but not used' warning. */ + /* NOTREACHED */ +#else + /* Copy the rest of the stack. Don't call a function to do that, + because that will alter the current stack. */ + asm ("mr %0,1" : "=r" (oldsp)); + data_offset = (unsigned int) data - (unsigned int) oldsp; + newsp -= data_offset; + for (i = 0; i < data_offset / 4; i++) + ((unsigned int *)newsp)[i] = ((unsigned int *)oldsp)[i]; + + /* Relocate stack frames. */ + { + unsigned int *oldframe0 = (unsigned int *)oldsp; + unsigned int *oldframe1 = *(unsigned int **)oldframe0; + unsigned int *oldframe2 = *(unsigned int **)oldframe1; + unsigned int *newframe0 = (unsigned int *)newsp; + unsigned int *newframe1 = newframe0 + (unsigned int)(oldframe1 - oldframe0); + unsigned int *newframe2 = newframe1 + (unsigned int)(oldframe2 - oldframe1); + *(unsigned int **)newframe0 = newframe1; + *(unsigned int **)newframe1 = newframe2; + } + + asm ("mr 1,%0; mr 31,%0" : : "r" (newsp)); /* XXX */ + init1 (newsp + data_offset); +#endif + } + else + { + /* We are not using cthreads, so we will have just a single allocated + area for the per-thread variables of the main user thread. */ + unsigned long int *array; + unsigned int i; + + array = malloc (__hurd_threadvar_max * sizeof (unsigned long int)); + if (array == NULL) + __libc_fatal ("Can't allocate single-threaded thread variables."); + + /* Copy per-thread variables from the temporary array into the + newly malloc'd space. */ + memcpy (array, threadvars, sizeof threadvars); + __hurd_threadvar_stack_offset = (unsigned long int) array; + for (i = _HURD_THREADVAR_MAX; i < __hurd_threadvar_max; ++i) + array[i] = 0; + +#ifndef SHARED + asm ("mr 3,%0; mtlr %1; addi 1,3,-16; b init1" + : : "r" (data), "r" (return_address)); + /* NOTREACHED */ +#else + init1 (data); +#endif + } +} + + +/* Do the first essential initializations that must precede all else. */ +static inline void +first_init (void) +{ + /* Initialize data structures so we can do RPCs. */ + __mach_init (); + + RUN_HOOK (_hurd_preinit_hook, ()); +} + +#ifdef SHARED +/* This function is called specially by the dynamic linker to do early + initialization of the shared C library before normal initializers + expecting a Posixoid environment can run. It gets called with the + stack set up just as the user will see it, so it can switch stacks. */ + +void +_dl_init_first (int argc, ...) +{ + asm ("li 3,0xaa; .long 0"); + first_init (); + + init (&argc); +} +#endif + + +#ifdef SHARED +/* The regular posixland initialization is what goes into libc's + normal initializer. */ +/* NOTE! The linker notices the magical name `_init' and sets the DT_INIT + pointer in the dynamic section based solely on that. It is convention + for this function to be in the `.init' section, but the symbol name is + the only thing that really matters!! */ +strong_alias (posixland_init, _init); + + +void +__libc_init_first (int argc, char **argv, char **envp) +{ + /* Everything was done in the shared library initializer, _init. */ +} +#else +strong_alias (posixland_init, __libc_init_first); + + +void +_hurd_stack_setup (int *data) +{ + register unsigned int address; + asm ("mflr %0" : "=r" (address)); + return_address = address; + + first_init (); + + _hurd_startup ((void **) data, &init); +} +#endif + + +/* This function is defined here so that if this file ever gets into + ld.so we will get a link error. Having this file silently included + in ld.so causes disaster, because the _init definition above will + cause ld.so to gain an init function, which is not a cool thing. */ + +void +_dl_start (void) +{ + abort (); +} diff --git a/sysdeps/mach/hurd/powerpc/intr-msg.h b/sysdeps/mach/hurd/powerpc/intr-msg.h new file mode 100644 index 0000000000..244d7e67d9 --- /dev/null +++ b/sysdeps/mach/hurd/powerpc/intr-msg.h @@ -0,0 +1,99 @@ +/* Machine-dependent details of interruptible RPC messaging. PowerPC version. + Copyright (C) 1995,96,97,99,2001 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 INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify) \ +({ \ + error_t err; \ + asm (".globl _hurd_intr_rpc_msg_do_trap\n" \ + ".globl _hurd_intr_rpc_msg_in_trap\n" \ + " mr 3, %1\n" \ + " mr 4, %2\n" \ + " mr 5, %3\n" \ + " mr 6, %4\n" \ + " mr 7, %5\n" \ + " mr 8, %6\n" \ + " mr 9, %7\n" \ + " li 0, -25\n" \ + "_hurd_intr_rpc_msg_do_trap: sc\n" \ + "_hurd_intr_rpc_msg_in_trap: mr 3, %0\n" \ + : "=r" (err) \ + : "r" (msg), "r" (option), "r" (send_size), "r" (rcv_size), \ + "r" (rcv_name), "r" (timeout), "r" (notify) \ + : "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"); \ + err; \ +}) + +static void inline +INTR_MSG_BACK_OUT (struct ppc_thread_state *state) +{ + return; +} + +#include "hurdfault.h" + +/* This cannot be an inline function because it |
