1 /*--------------------------------------------------------------------*/
2 /*--- The core dispatch loop, for jumping to a code address. ---*/
3 /*--- dispatch-nanomips-linux.S ---*/
4 /*--------------------------------------------------------------------*/
6 # This file is part of Valgrind, a dynamic binary instrumentation
9 # Copyright (C) 2017-2018 RT-RK
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation; either version 2 of the
14 # License, or (at your option) any later version.
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 # General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 # The GNU General Public License is contained in the file COPYING.
28 #include "pub_core_basics_asm.h"
30 #if defined(VGP_nanomips_linux)
32 #include "pub_core_dispatch_asm.h"
33 #include "pub_core_transtab_asm.h"
34 #include "libvex_guest_offsets.h" /* for OFFSET_mips_PC */
37 # void VG_(disp_run_translations)( UWord* two_words,
41 # The dispatch loop. VG_(disp_run_translations) is used to run all
42 # translations, including no-redir ones.
45 .globl VG_(disp_run_translations)
46 VG_(disp_run_translations):
48 # a1 holds guest_state
55 # Load address of guest_state into guest state register ($s7)
58 # And jump into the code cache. Chained translations in
59 # the code cache run, until for whatever reason, they can't
60 # continue. When that happens, the translation in question
61 # will jump (or call) to one of the continuation points
66 # * Postamble and exit:
68 # At this point, $t4 and $t5 contain two
69 # words to be returned to the caller. $t4
70 # holds a TRC value, and $t5 optionally may
71 # hold another word (for CHAIN_ME exits, the
72 # address of the place to patch.)
74 # Restore $a0 from stack; holds address of two_words
76 sw $t4, 0($a0) # Store $t4 to two_words[0]
77 sw $t5, 4($a0) # Store $t5 to two_words[1]
85 # * Continuation points:
87 .global VG_(disp_cp_chain_me_to_slowEP)
88 VG_(disp_cp_chain_me_to_slowEP):
89 # We got called. The return address indicates
90 # where the patching needs to happen. Collect
91 # the return address and, exit back to C land,
92 # handing the caller the pair (Chain_me_S, RA) */
93 li $t4, VG_TRC_CHAIN_ME_TO_SLOW_EP
94 # 8 = mkLoadImm32_EXACTLY2
99 .global VG_(disp_cp_chain_me_to_fastEP)
100 VG_(disp_cp_chain_me_to_fastEP):
101 # We got called. The return address indicates
102 # where the patching needs to happen. Collect
103 # the return address and, exit back to C land,
104 # handing the caller the pair (Chain_me_S, RA) */
105 li $t4, VG_TRC_CHAIN_ME_TO_FAST_EP
106 # 8 = mkLoadImm32_EXACTLY2
111 .global VG_(disp_cp_xindir)
113 # /* Where are we going? */
114 lw $a7, OFFSET_mips32_PC($s7)
115 lw $t1, VG_(stats__n_xIndirs_32)
117 sw $t1, VG_(stats__n_xIndirs_32)
119 # try a fast lookup in the translation cache
120 # t2 = VG_TT_FAST_HASH(addr) * sizeof(ULong*)
121 # = (t2 >> 2 & VG_TT_FAST_MASK) << 3
123 li $t0, VG_TT_FAST_MASK
128 # t1 = (addr of VG_(tt_fast)) + t2
132 # t9 = VG_(tt_fast)[hash] :: ULong*
137 # little-endian, so comparing 1st 32bit word
138 bnec $t0, $a7, fast_lookup_failed
142 # %PC is up to date */
143 # back out decrement of the dispatch counter */
144 # hold dispatch_ctr in t0 (r8) */
145 lw $t1, VG_(stats__n_xIndirs_32)
147 sw $t1, VG_(stats__n_xIndirs_32)
148 li $t4, VG_TRC_INNER_FASTMISS
152 .global VG_(disp_cp_xassisted)
153 VG_(disp_cp_xassisted):
154 # guest-state-pointer contains the TRC. Put the value into the
160 .global VG_(disp_cp_evcheck_fail)
161 VG_(disp_cp_evcheck_fail):
162 li $t4, VG_TRC_INNER_COUNTERZERO
166 .size VG_(disp_run_translations), . - VG_(disp_run_translations)
170 # Let the linker know we don't need an executable stack
173 /*--------------------------------------------------------------------*/
174 /*--- end dispatch-nanomips-linux.S ---*/
175 /*--------------------------------------------------------------------*/