1 /* src/vm/jit/arm/linux/md.c - machine dependent arm linux functions
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Michael Starzinger
30 $Id: md.c 166 2006-01-22 23:38:44Z twisti $
41 #include "vm/jit/arm/md-abi.h"
43 #define ucontext broken_glibc_ucontext
44 #define ucontext_t broken_glibc_ucontext_t
49 typedef struct ucontext {
50 unsigned long uc_flags;
51 struct ucontext *uc_link;
53 struct sigcontext uc_mcontext;
57 #define scontext_t struct sigcontext
59 #include "mm/memory.h"
60 #include "vm/exceptions.h"
61 #include "vm/signallocal.h"
62 #include "vm/stringlocal.h"
63 #include "vm/jit/asmpart.h"
64 #include "vm/jit/stacktrace.h"
67 /* md_signal_handler_sigsegv ***************************************************
69 NullPointerException signal handler for hardware null pointer
72 *******************************************************************************/
74 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
87 _uc = (ucontext_t*) _p;
88 _sc = &_uc->uc_mcontext;
90 /* ATTENTION: glibc included messed up kernel headers */
91 /* we needed a workaround for the ucontext structure */
93 addr = (ptrint) siginfo->si_addr;
94 /*xpc = (u1*) _mc->gregs[REG_PC];*/
95 xpc = (u1*) _sc->arm_pc;
98 base = *((s4*) _sc + OFFSET(scontext_t, arm_r0)/4 + ((instr >> 16) & 0x0f));
101 pv = (u1*) _sc->arm_ip;
102 sp = (u1*) _sc->arm_sp;
103 ra = (u1*) _sc->arm_lr; /* this is correct for leafs */
105 _sc->arm_r10 = (ptrint) stacktrace_hardware_nullpointerexception(pv, sp, ra, xpc);
106 _sc->arm_fp = (ptrint) xpc;
107 _sc->arm_pc = (ptrint) asm_handle_exception;
110 codegen_get_pv_from_pc(xpc);
112 /* this should not happen */
119 /* thread_restartcriticalsection ***********************************************
123 *******************************************************************************/
125 #if defined(ENABLE_THREADS)
126 void thread_restartcriticalsection(ucontext_t *_uc)
131 _sc = &_uc->uc_mcontext;
133 critical = critical_find_restart_point((void *) _sc->arm_pc);
136 _sc->arm_pc = (ptrint) critical;
142 * These are local overrides for various environment variables in Emacs.
143 * Please do not remove this and leave it at the end of the file, where
144 * Emacs will automagically detect them.
145 * ---------------------------------------------------------------------
148 * indent-tabs-mode: t