1 /* src/vm/jit/powerpc/darwin/md-os.c - machine dependent PowerPC Darwin 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: Christian Thalinger
29 $Id: md-os.c 7596 2007-03-28 21:05:53Z twisti $
42 #include "vm/jit/powerpc/codegen.h"
43 #include "vm/jit/powerpc/darwin/md-abi.h"
45 #include "vm/exceptions.h"
46 #include "vm/global.h"
47 #include "vm/signallocal.h"
48 #include "vm/stringlocal.h"
49 #include "vm/jit/asmpart.h"
50 #include "vm/jit/stacktrace.h"
53 /* md_signal_handler_sigsegv ***************************************************
55 NullPointerException signal handler for hardware null pointer
58 *******************************************************************************/
60 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
64 ppc_thread_state_t *_ss;
78 _uc = (ucontext_t *) _p;
79 _mc = _uc->uc_mcontext;
82 /* get register values */
86 ra = (u1 *) _ss->lr; /* this is correct for leafs */
87 xpc = (u1 *) _ss->srr0;
89 /* get exception-throwing instruction */
91 mcode = *((u4 *) xpc);
93 s1 = M_INSTR_OP2_IMM_A(mcode);
94 disp = M_INSTR_OP2_IMM_I(mcode);
95 d = M_INSTR_OP2_IMM_D(mcode);
101 e = exceptions_new_hardware_exception(pv, sp, ra, xpc, s1, disp, addr, val);
105 _ss->r11 = (ptrint) e;
106 _ss->r12 = (ptrint) xpc;
107 _ss->srr0 = (ptrint) asm_handle_exception;
111 /* md_signal_handler_sigusr2 ***************************************************
113 Signal handler for profiling sampling.
115 *******************************************************************************/
117 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
122 ppc_thread_state_t *_ss;
127 _uc = (ucontext_t *) _p;
128 _mc = _uc->uc_mcontext;
131 pc = (u1 *) _ss->srr0;
137 #if defined(ENABLE_THREADS)
138 void thread_restartcriticalsection(ucontext_t *_uc)
141 ppc_thread_state_t *_ss;
144 _mc = _uc->uc_mcontext;
147 critical = critical_find_restart_point((void *) _ss->srr0);
150 _ss->srr0 = (ptrint) critical;
156 * These are local overrides for various environment variables in Emacs.
157 * Please do not remove this and leave it at the end of the file, where
158 * Emacs will automagically detect them.
159 * ---------------------------------------------------------------------
162 * indent-tabs-mode: t