1 /* src/vm/jit/powerpc64/linux/md-os.c - machine dependent PowerPC64 Linux functions
3 Copyright (C) 1996-2005, 2006, 2007 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 $Id: md-os.c 7311 2007-02-09 13:20:27Z twisti $
37 #include "vm/jit/powerpc64/linux/md-abi.h"
39 #if defined(ENABLE_THREADS)
40 # include "threads/native/threads.h"
43 #include "vm/exceptions.h"
44 #include "vm/signallocal.h"
46 #include "vm/jit/asmpart.h"
48 #if defined(ENABLE_PROFILING)
49 # include "vm/jit/optimizing/profile.h"
52 #include "vm/jit/stacktrace.h"
55 /* md_signal_handler_sigsegv ***************************************************
57 NullPointerException signal handler for hardware null pointer
60 *******************************************************************************/
62 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
74 _uc = (ucontext_t *) _p;
75 _mc = &(_uc->uc_mcontext);
77 pv = (u1 *) _mc->gp_regs[REG_PV];
78 sp = (u1 *) _mc->gp_regs[REG_SP];
79 ra = (u1 *) _mc->gp_regs[PT_LNK]; /* this is correct for leafs */
80 xpc = (u1 *) _mc->gp_regs[PT_NIP];
82 instr = *((u4 *) xpc);
83 reg = (instr >> 16) & 0x1f;
84 addr = _mc->gp_regs[reg];
87 _mc->gp_regs[REG_ITMP1_XPTR] =
88 (ptrint) stacktrace_hardware_nullpointerexception(pv, sp, ra, xpc);
90 _mc->gp_regs[REG_ITMP2_XPC] = (ptrint) xpc;
91 _mc->gp_regs[PT_NIP] = (ptrint) asm_handle_exception;
94 codegen_get_pv_from_pc(xpc);
96 /* this should not happen */
103 /* md_signal_handler_sigusr2 ***************************************************
105 Signal handler for profiling sampling.
107 *******************************************************************************/
109 #if defined(ENABLE_THREADS)
110 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
119 _uc = (ucontext_t *) _p;
120 _mc = &(_uc->uc_mcontext);
122 pc = (u1 *) _mc->gp_regs[PT_NIP];
128 void thread_restartcriticalsection(ucontext_t *_uc)
134 _mc = &(_uc->uc_mcontext);
136 pc = (u1 *) _mc->gp_regs[PT_NIP];
138 critical = critical_find_restart_point(pc);
140 if (critical != NULL)
141 _mc->gp_regs[PT_NIP] = (ptrint) critical;
147 * These are local overrides for various environment variables in Emacs.
148 * Please do not remove this and leave it at the end of the file, where
149 * Emacs will automagically detect them.
150 * ---------------------------------------------------------------------
153 * indent-tabs-mode: t