1 /* src/vm/jit/mips/irix/md-os.c - machine dependent MIPS IRIX 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
37 #include "vm/jit/mips/codegen.h"
38 #include "vm/jit/mips/md-abi.h"
40 #include "mm/gc-common.h"
42 #include "vm/global.h"
43 #include "vm/signallocal.h"
44 #include "vm/stringlocal.h"
46 #include "vm/jit/asmpart.h"
47 #include "vm/jit/codegen-common.h"
48 #include "vm/jit/stacktrace.h"
51 /* md_init *********************************************************************
53 Do some machine dependent initialization.
55 *******************************************************************************/
59 /* The Boehm GC initialization blocks the SIGSEGV signal. So we do a */
60 /* dummy allocation here to ensure that the GC is initialized. */
62 #if defined(ENABLE_GC_BOEHM)
67 /* Turn off flush-to-zero */
71 n.fc_word = get_fpc_csr();
72 n.fc_struct.flush = 0;
73 set_fpc_csr(n.fc_word);
78 /* md_signal_handler_sigsegv ***************************************************
80 Signal handler for hardware-exceptions.
82 *******************************************************************************/
84 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
101 _uc = (struct ucontext *) _p;
102 _mc = &_uc->uc_mcontext;
104 pv = (u1 *) _mc->gregs[REG_PV];
105 sp = (u1 *) _mc->gregs[REG_SP];
106 ra = (u1 *) _mc->gregs[REG_RA]; /* this is correct for leafs */
107 xpc = (u1 *) _mc->gregs[CTX_EPC];
109 /* get exception-throwing instruction */
111 mcode = *((u4 *) xpc);
113 d = M_ITYPE_GET_RT(mcode);
114 s1 = M_ITYPE_GET_RS(mcode);
115 disp = M_ITYPE_GET_IMM(mcode);
117 /* check for special-load */
119 if (s1 == REG_ZERO) {
120 /* we use the exception type as load displacement */
126 /* This is a normal NPE: addr must be NULL and the NPE-type
129 addr = _mc->gregs[s1];
134 /* Handle the type. */
136 p = signal_handle(type, val, pv, sp, ra, xpc, _p);
138 /* set registers (only if exception object ready) */
141 _mc->gregs[REG_ITMP1_XPTR] = (intptr_t) p;
142 _mc->gregs[REG_ITMP2_XPC] = (intptr_t) xpc;
143 _mc->gregs[CTX_EPC] = (intptr_t) asm_handle_exception;
148 /* md_critical_section_restart *************************************************
150 Search the critical sections tree for a matching section and set
151 the PC to the restart point, if necessary.
153 *******************************************************************************/
155 #if defined(ENABLE_THREADS)
156 void md_critical_section_restart(ucontext_t *_uc)
162 _mc = &_uc->uc_mcontext;
164 pc = (u1 *) _mc->gregs[CTX_EPC];
166 npc = critical_find_restart_point(pc);
169 log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc);
170 _mc->gregs[CTX_EPC] = (ptrint) npc;
177 * These are local overrides for various environment variables in Emacs.
178 * Please do not remove this and leave it at the end of the file, where
179 * Emacs will automagically detect them.
180 * ---------------------------------------------------------------------
183 * indent-tabs-mode: t