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 7888 2007-05-09 08:36:16Z tbfg $
37 #include "vm/jit/powerpc64/codegen.h"
38 #include "vm/jit/powerpc64/linux/md-abi.h"
40 #if defined(ENABLE_THREADS)
41 # include "threads/native/threads.h"
44 #include "vm/exceptions.h"
45 #include "vm/signallocal.h"
47 #include "vm/jit/asmpart.h"
49 #if defined(ENABLE_PROFILING)
50 # include "vm/jit/optimizing/profile.h"
53 #include "vm/jit/stacktrace.h"
56 /* md_signal_handler_sigsegv ***************************************************
58 Signal handler for hardware-exceptions.
60 *******************************************************************************/
62 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
79 _uc = (ucontext_t *) _p;
80 _mc = &(_uc->uc_mcontext);
82 /* get register values */
83 pv = (u1*) _mc->gp_regs[REG_PV];
84 sp = (u1*) _mc->gp_regs[REG_SP];
85 ra = (u1*) _mc->gp_regs[PT_LNK]; /* correct for leafs */
86 xpc =(u1*) _mc->gp_regs[PT_NIP];
88 /* get the throwing instruction */
91 s1 = M_INSTR_OP2_IMM_A(mcode);
92 disp = M_INSTR_OP2_IMM_I(mcode);
93 d = M_INSTR_OP2_IMM_D(mcode);
95 val = _mc->gp_regs[d];
98 /* we use the exception type as load displacement */
102 addr = _mc->gp_regs[s1];
105 e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
107 _mc->gp_regs[REG_ITMP1] = (ptrint) e;
108 _mc->gp_regs[REG_ITMP2_XPC] = (ptrint) xpc;
109 _mc->gp_regs[PT_NIP] = (ptrint) asm_handle_exception;
113 /* md_signal_handler_sigusr2 ***************************************************
115 Signal handler for profiling sampling.
117 *******************************************************************************/
119 #if defined(ENABLE_THREADS)
120 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
129 _uc = (ucontext_t *) _p;
130 _mc = &(_uc->uc_mcontext);
132 pc = (u1 *) _mc->gp_regs[PT_NIP];
138 void md_critical_section_restart(ucontext_t *_uc)
144 _mc = &(_uc->uc_mcontext);
146 pc = (u1 *) _mc->gp_regs[PT_NIP];
148 critical = critical_find_restart_point(pc);
150 if (critical != NULL) {
151 log_println("md_critical_section_restart: pc=%p, npc=%p", pc, critical);
152 _mc->gp_regs[PT_NIP] = (ptrint) critical;
159 * These are local overrides for various environment variables in Emacs.
160 * Please do not remove this and leave it at the end of the file, where
161 * Emacs will automagically detect them.
162 * ---------------------------------------------------------------------
165 * indent-tabs-mode: t