1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file excenaupt in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "berberis/interpreter/riscv64/interpreter.h" 18 19 #include "berberis/decoder/riscv64/decoder.h" 20 #include "berberis/decoder/riscv64/semantics_player.h" 21 #include "berberis/guest_state/guest_addr.h" 22 #include "berberis/guest_state/guest_state.h" 23 24 #include "faulty_memory_accesses.h" 25 #include "interpreter.h" 26 27 namespace berberis { 28 InitInterpreter()29void InitInterpreter() { 30 AddFaultyMemoryAccessRecoveryCode(); 31 } 32 InterpretInsn(ThreadState * state)33void InterpretInsn(ThreadState* state) { 34 GuestAddr pc = state->cpu.insn_addr; 35 36 Interpreter interpreter(state); 37 SemanticsPlayer sem_player(&interpreter); 38 Decoder decoder(&sem_player); 39 uint8_t insn_len = decoder.Decode(ToHostAddr<const uint16_t>(pc)); 40 interpreter.FinalizeInsn(insn_len); 41 } 42 43 } // namespace berberis 44