1/* cpu.h --- declarations for the RL78 core. 2 3 Copyright (C) 2005-2023 Free Software Foundation, Inc. 4 Contributed by Red Hat, Inc. 5 6 This file is part of the GNU simulators. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 3 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program. If not, see <http://www.gnu.org/licenses/>. 20*/ 21 22#ifndef SIM_RL78_CPU_H_ 23#define SIM_RL78_CPU_H_ 24 25#include <stdint.h> 26#include <setjmp.h> 27 28#include "opcode/rl78.h" 29 30extern int verbose; 31extern int trace; 32 33typedef uint8_t QI; 34typedef uint16_t HI; 35typedef uint32_t SI; 36 37extern int rl78_in_gdb; 38 39SI get_reg (RL78_Register); 40SI set_reg (RL78_Register, SI); 41 42extern SI pc; 43 44 45extern const char * const reg_names[]; 46 47void init_cpu (void); 48void set_flags (int mask, int newbits); 49void set_c (int); 50int get_c (void); 51 52const char *bits (int v, int b); 53 54int condition_true (RL78_Condition cond_id, int val); 55 56/* Instruction step return codes. 57 Suppose one of the decode_* functions below returns a value R: 58 - If RL78_STEPPED (R), then the single-step completed normally. 59 - If RL78_HIT_BREAK (R), then the program hit a breakpoint. 60 - If RL78_EXITED (R), then the program has done an 'exit' system 61 call, and the exit code is RL78_EXIT_STATUS (R). 62 - If RL78_STOPPED (R), then a signal (number RL78_STOP_SIG (R)) was 63 generated. 64 65 For building step return codes: 66 - RL78_MAKE_STEPPED is the return code for finishing a normal step. 67 - RL78_MAKE_HIT_BREAK is the return code for hitting a breakpoint. 68 - RL78_MAKE_EXITED (C) is the return code for exiting with status C. 69 - RL78_MAKE_STOPPED (S) is the return code for stopping on signal S. */ 70#define RL78_MAKE_STEPPED() (1) 71#define RL78_MAKE_HIT_BREAK() (2) 72#define RL78_MAKE_EXITED(c) (((int) (c) << 8) + 3) 73#define RL78_MAKE_STOPPED(s) (((int) (s) << 8) + 4) 74 75#define RL78_STEPPED(r) ((r) == RL78_MAKE_STEPPED ()) 76#define RL78_HIT_BREAK(r) ((r) == RL78_MAKE_HIT_BREAK ()) 77#define RL78_EXITED(r) (((r) & 0xff) == 3) 78#define RL78_EXIT_STATUS(r) ((r) >> 8) 79#define RL78_STOPPED(r) (((r) & 0xff) == 4) 80#define RL78_STOP_SIG(r) ((r) >> 8) 81 82/* The step result for the current step. Global to allow 83 communication between the stepping function and the system 84 calls. */ 85extern int step_result; 86 87extern int decode_opcode (void); 88 89extern int trace_register_words; 90extern void trace_register_changes (void); 91extern void generate_access_exception (void); 92extern jmp_buf decode_jmp_buf; 93 94extern long long total_clocks; 95extern int pending_clocks; 96extern int timer_enabled; 97extern void dump_counts_per_insn (const char * filename); 98extern unsigned int counts_per_insn[0x100000]; 99 100extern int rl78_g10_mode; 101extern int g13_multiply; 102extern int g14_multiply; 103 104#endif 105