cpu.h 3.2 KB

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