1 /* src/vm/jit/mips/irix/md-os.c - machine dependent MIPS IRIX functions
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Andreas Krall
30 Changes: Christian Thalinger
32 $Id: md-os.c 4328 2006-01-20 13:33:37Z twisti $
45 #include "vm/jit/mips/md-abi.h"
48 #include "vm/exceptions.h"
49 #include "vm/global.h"
50 #include "vm/signallocal.h"
51 #include "vm/stringlocal.h"
52 #include "vm/jit/asmpart.h"
53 #include "vm/jit/stacktrace.h"
56 /* md_init *********************************************************************
58 Do some machine dependent initialization.
60 *******************************************************************************/
64 /* The Boehm GC initialization blocks the SIGSEGV signal. So we do a */
65 /* dummy allocation here to ensure that the GC is initialized. */
67 heap_allocate(1, 0, NULL);
70 /* Turn off flush-to-zero */
74 n.fc_word = get_fpc_csr();
75 n.fc_struct.flush = 0;
76 set_fpc_csr(n.fc_word);
81 /* md_signal_handler_sigsegv ***************************************************
83 NullPointerException signal handler for hardware null pointer
86 *******************************************************************************/
88 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
99 _uc = (struct ucontext *) _p;
100 _mc = &_uc->uc_mcontext;
102 instr = *((u4 *) (_mc->gregs[CTX_EPC]));
103 addr = _mc->gregs[(instr >> 21) & 0x1f];
106 pv = (u1 *) _mc->gregs[REG_PV];
107 sp = (u1 *) _mc->gregs[REG_SP];
108 ra = (u1 *) _mc->gregs[REG_RA]; /* this is correct for leafs */
109 xpc = (u1 *) _mc->gregs[CTX_EPC];
111 _mc->gregs[REG_ITMP1_XPTR] =
112 (ptrint) stacktrace_hardware_nullpointerexception(pv, sp, ra, xpc);
114 _mc->gregs[REG_ITMP2_XPC] = (ptrint) xpc;
115 _mc->gregs[CTX_EPC] = (ptrint) asm_handle_exception;
118 addr += (long) ((instr << 16) >> 16);
120 throw_cacao_exception_exit(string_java_lang_InternalError,
121 "faulting address: 0x%lx at 0x%lx\n",
122 addr, _mc->gregs[CTX_EPC]);
127 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
128 void thread_restartcriticalsection(ucontext_t *uc)
132 critical = thread_checkcritical((void*) uc->uc_mcontext.gregs[CTX_EPC]);
135 uc->uc_mcontext.gregs[CTX_EPC] = (ptrint) critical;
141 * These are local overrides for various environment variables in Emacs.
142 * Please do not remove this and leave it at the end of the file, where
143 * Emacs will automagically detect them.
144 * ---------------------------------------------------------------------
147 * indent-tabs-mode: t