1 /* src/vm/jit/sparc64/solaris/md-os.c - machine dependent SPARC Solaris 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 4357 2006-01-22 23:33:38Z twisti $
36 /* work around name clash */
41 #include "vm/jit/sparc64/codegen.h"
42 #include "vm/jit/sparc64/md-abi.h"
44 #include "vm/exceptions.h"
45 #include "vm/signallocal.h"
46 #include "vm/stringlocal.h"
47 #include "vm/jit/asmpart.h"
48 #include "vm/jit/stacktrace.h"
51 ptrint md_get_reg_from_context(mcontext_t *_mc, u4 rindex)
57 /* return 0 for REG_ZERO */
65 /* register is in global or out range, available in context */
66 val = _mc->gregs[rindex + 3];
72 /* register is local or in, need to fetch from regsave area on stack */
74 window = (s8 *) (_mc->gregs[REG_O6] + BIAS);
75 val = window[rindex - 16];
83 /* md_signal_handler_sigsegv ***************************************************
85 NullPointerException signal handler for hardware null pointer
88 *******************************************************************************/
90 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
108 _uc = (ucontext_t *) _p;
109 _mc = &_uc->uc_mcontext;
111 pv = (u1 *) md_get_reg_from_context(_mc, REG_PV_CALLEE);
112 sp = (u1 *) _mc->gregs[REG_O6];
113 ra = (u1 *) md_get_reg_from_context(_mc, REG_RA_CALLEE);
114 xpc = (u1 *) _mc->gregs[REG_PC];
117 /* get exception-throwing instruction */
119 mcode = *((u4 *) xpc);
121 d = M_OP3_GET_RD(mcode);
122 s1 = M_OP3_GET_RS(mcode);
123 disp = M_OP3_GET_IMM(mcode);
125 /* flush register windows? */
127 val = md_get_reg_from_context(_mc, d);
129 /* check for special-load */
131 if (s1 == REG_ZERO) {
132 /* we use the exception type as load displacement */
137 /* This is a normal NPE: addr must be NULL and the NPE-type
140 addr = md_get_reg_from_context(_mc, s1);
144 /* create stackframeinfo */
146 stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
148 /* Handle the type. */
150 p = signal_handle(xpc, type, val);
152 /* remove stackframeinfo */
154 stacktrace_remove_stackframeinfo(&sfi);
158 _mc->gregs[REG_G2] = (intptr_t) p; /* REG_ITMP2_XPTR */
159 _mc->gregs[REG_G3] = (intptr_t) xpc; /* REG_ITMP3_XPC */
160 _mc->gregs[REG_PC] = (intptr_t) asm_handle_exception;
161 _mc->gregs[REG_nPC] = (intptr_t) asm_handle_exception + 4;
165 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
166 void thread_restartcriticalsection(ucontext_t *_uc)
171 _mc = &_uc->uc_mcontext;
173 critical = thread_checkcritical((void *) _mc->sc_pc);
176 _mc->sc_pc = (ptrint) critical;
181 /* md_icacheflush **************************************************************
183 Calls the system's function to flush the instruction cache.
185 *******************************************************************************/
187 void md_icacheflush(u1 *addr, s4 nbytes)
193 /* zero the least significant 3 bits to align on a 64-bit boundary */
194 addr = (u1 *) (((ptrint) addr) & -8l);
210 * These are local overrides for various environment variables in Emacs.
211 * Please do not remove this and leave it at the end of the file, where
212 * Emacs will automagically detect them.
213 * ---------------------------------------------------------------------
216 * indent-tabs-mode: t