sim-main.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. /* sim-main.h -- Simulator for Motorola 68HC11 & 68HC12
  2. Copyright (C) 1999-2022 Free Software Foundation, Inc.
  3. Written by Stephane Carrez (stcarrez@nerim.fr)
  4. This file is part of GDB, the GNU debugger.
  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. #ifndef _SIM_MAIN_H
  16. #define _SIM_MAIN_H
  17. #include "sim-basics.h"
  18. #include "sim-base.h"
  19. #include "bfd.h"
  20. #include "opcode/m68hc11.h"
  21. #include "sim/sim.h"
  22. #include "opcode/m68hc11.h"
  23. #include "sim-signal.h"
  24. #include "sim-types.h"
  25. struct _sim_cpu;
  26. #include "interrupts.h"
  27. #include <setjmp.h>
  28. /* Specifies the level of mapping for the IO, EEprom, nvram and external
  29. RAM. IO registers are mapped over everything and the external RAM
  30. is last (ie, it can be hidden by everything above it in the list). */
  31. enum m68hc11_map_level
  32. {
  33. M6811_IO_LEVEL,
  34. M6811_EEPROM_LEVEL,
  35. M6811_NVRAM_LEVEL,
  36. M6811_RAM_LEVEL
  37. };
  38. enum cpu_type
  39. {
  40. CPU_M6811,
  41. CPU_M6812
  42. };
  43. #define X_REGNUM 0
  44. #define D_REGNUM 1
  45. #define Y_REGNUM 2
  46. #define SP_REGNUM 3
  47. #define PC_REGNUM 4
  48. #define A_REGNUM 5
  49. #define B_REGNUM 6
  50. #define PSW_REGNUM 7
  51. #define PAGE_REGNUM 8
  52. #define Z_REGNUM 9
  53. typedef struct m6811_regs {
  54. unsigned short d;
  55. unsigned short ix;
  56. unsigned short iy;
  57. unsigned short sp;
  58. unsigned short pc;
  59. unsigned char ccr;
  60. unsigned short page;
  61. } m6811_regs;
  62. /* Description of 68HC11 IO registers. Such description is only provided
  63. for the info command to display the current setting of IO registers
  64. from GDB. */
  65. struct io_reg_desc
  66. {
  67. int mask;
  68. const char *short_name;
  69. const char *long_name;
  70. };
  71. typedef struct io_reg_desc io_reg_desc;
  72. extern void print_io_reg_desc (SIM_DESC sd, io_reg_desc *desc, int val,
  73. int mode);
  74. extern void print_io_byte (SIM_DESC sd, const char *name,
  75. io_reg_desc *desc, uint8_t val, uint16_t addr);
  76. extern void print_io_word (SIM_DESC sd, const char *name,
  77. io_reg_desc *desc, uint16_t val, uint16_t addr);
  78. /* List of special 68HC11&68HC12 instructions that are not handled by the
  79. 'gencode.c' generator. These complex instructions are implemented
  80. by 'cpu_special'. */
  81. enum M6811_Special
  82. {
  83. /* 68HC11 instructions. */
  84. M6811_DAA,
  85. M6811_EMUL_SYSCALL,
  86. M6811_ILLEGAL,
  87. M6811_RTI,
  88. M6811_STOP,
  89. M6811_SWI,
  90. M6811_TEST,
  91. M6811_WAI,
  92. /* 68HC12 instructions. */
  93. M6812_BGND,
  94. M6812_CALL,
  95. M6812_CALL_INDIRECT,
  96. M6812_IDIVS,
  97. M6812_EDIV,
  98. M6812_EDIVS,
  99. M6812_EMACS,
  100. M6812_EMUL,
  101. M6812_EMULS,
  102. M6812_ETBL,
  103. M6812_MEM,
  104. M6812_REV,
  105. M6812_REVW,
  106. M6812_RTC,
  107. M6812_RTI,
  108. M6812_WAV
  109. };
  110. #define M6811_MAX_PORTS (0x03f+1)
  111. #define M6812_MAX_PORTS (0x3ff+1)
  112. #define MAX_PORTS (M6812_MAX_PORTS)
  113. struct _sim_cpu;
  114. typedef void (* cpu_interp) (struct _sim_cpu*);
  115. struct _sim_cpu {
  116. /* CPU registers. */
  117. struct m6811_regs cpu_regs;
  118. /* CPU interrupts. */
  119. struct interrupts cpu_interrupts;
  120. /* Pointer to the interpretor routine. */
  121. cpu_interp cpu_interpretor;
  122. /* Pointer to the architecture currently configured in the simulator. */
  123. const struct bfd_arch_info *cpu_configured_arch;
  124. /* CPU absolute cycle time. The cycle time is updated after
  125. each instruction, by the number of cycles taken by the instruction.
  126. It is cleared only when reset occurs. */
  127. int64_t cpu_absolute_cycle;
  128. /* Number of cycles to increment after the current instruction.
  129. This is also the number of ticks for the generic event scheduler. */
  130. uint8_t cpu_current_cycle;
  131. int cpu_emul_syscall;
  132. int cpu_is_initialized;
  133. int cpu_running;
  134. int cpu_check_memory;
  135. int cpu_stop_on_interrupt;
  136. /* When this is set, start execution of program at address specified
  137. in the ELF header. This is used for testing some programs that do not
  138. have an interrupt table linked with them. Programs created during the
  139. GCC validation are like this. A normal 68HC11 does not behave like
  140. this (unless there is some OS or downloadable feature). */
  141. int cpu_use_elf_start;
  142. /* The starting address specified in ELF header. */
  143. int cpu_elf_start;
  144. uint16_t cpu_insn_pc;
  145. /* CPU frequency. This is the quartz frequency. It is divided by 4 to
  146. get the cycle time. This is used for the timer rate and for the baud
  147. rate generation. */
  148. unsigned long cpu_frequency;
  149. /* The mode in which the CPU is configured (MODA and MODB pins). */
  150. unsigned int cpu_mode;
  151. const char* cpu_start_mode;
  152. /* The cpu being configured. */
  153. enum cpu_type cpu_type;
  154. /* Initial value of the CONFIG register. */
  155. uint8_t cpu_config;
  156. uint8_t cpu_use_local_config;
  157. uint8_t ios[MAX_PORTS];
  158. /* Memory bank parameters which describe how the memory bank window
  159. is mapped in memory and how to convert it in virtual address. */
  160. uint16_t bank_start;
  161. uint16_t bank_end;
  162. address_word bank_virtual;
  163. unsigned bank_shift;
  164. struct hw *hw_cpu;
  165. /* ... base type ... */
  166. sim_cpu_base base;
  167. };
  168. /* Returns the cpu absolute cycle time (A virtual counter incremented
  169. at each 68HC11 E clock). */
  170. #define cpu_current_cycle(cpu) ((cpu)->cpu_absolute_cycle)
  171. #define cpu_add_cycles(cpu, T) ((cpu)->cpu_current_cycle += (int64_t) (T))
  172. #define cpu_is_running(cpu) ((cpu)->cpu_running)
  173. /* Get the IO/RAM base addresses depending on the M6811_INIT register. */
  174. #define cpu_get_io_base(cpu) \
  175. (((uint16_t)(((cpu)->ios[M6811_INIT]) & 0x0F)) << 12)
  176. #define cpu_get_reg_base(cpu) \
  177. (((uint16_t)(((cpu)->ios[M6811_INIT]) & 0xF0)) << 8)
  178. /* Returns the different CPU registers. */
  179. #define cpu_get_ccr(cpu) ((cpu)->cpu_regs.ccr)
  180. #define cpu_get_pc(cpu) ((cpu)->cpu_regs.pc)
  181. #define cpu_get_d(cpu) ((cpu)->cpu_regs.d)
  182. #define cpu_get_x(cpu) ((cpu)->cpu_regs.ix)
  183. #define cpu_get_y(cpu) ((cpu)->cpu_regs.iy)
  184. #define cpu_get_sp(cpu) ((cpu)->cpu_regs.sp)
  185. #define cpu_get_a(cpu) (((cpu)->cpu_regs.d >> 8) & 0x0FF)
  186. #define cpu_get_b(cpu) ((cpu)->cpu_regs.d & 0x0FF)
  187. #define cpu_get_page(cpu) ((cpu)->cpu_regs.page)
  188. /* 68HC12 specific and Motorola internal registers. */
  189. #define cpu_get_tmp3(cpu) (0)
  190. #define cpu_get_tmp2(cpu) (0)
  191. #define cpu_set_d(cpu, val) ((cpu)->cpu_regs.d = (val))
  192. #define cpu_set_x(cpu, val) ((cpu)->cpu_regs.ix = (val))
  193. #define cpu_set_y(cpu, val) ((cpu)->cpu_regs.iy = (val))
  194. #define cpu_set_page(cpu, val) ((cpu)->cpu_regs.page = (val))
  195. /* 68HC12 specific and Motorola internal registers. */
  196. #define cpu_set_tmp3(cpu, val) (0)
  197. #define cpu_set_tmp2(cpu, val) (void) (0)
  198. #if 0
  199. /* This is a function in m68hc11_sim.c to keep track of the frame. */
  200. #define cpu_set_sp(cpu, val) ((cpu)->cpu_regs.sp = (val))
  201. #endif
  202. #define cpu_set_pc(cpu, val) ((cpu)->cpu_regs.pc = (val))
  203. #define cpu_set_a(cpu, val) \
  204. cpu_set_d(cpu, ((val) << 8) | cpu_get_b (cpu))
  205. #define cpu_set_b(cpu, val) \
  206. cpu_set_d(cpu, ((cpu_get_a (cpu)) << 8) | ((val) & 0x0FF))
  207. #define cpu_set_ccr(cpu, val) ((cpu)->cpu_regs.ccr = (val))
  208. #define cpu_get_ccr_H(cpu) ((cpu_get_ccr (cpu) & M6811_H_BIT) ? 1 : 0)
  209. #define cpu_get_ccr_X(cpu) ((cpu_get_ccr (cpu) & M6811_X_BIT) ? 1 : 0)
  210. #define cpu_get_ccr_S(cpu) ((cpu_get_ccr (cpu) & M6811_S_BIT) ? 1 : 0)
  211. #define cpu_get_ccr_N(cpu) ((cpu_get_ccr (cpu) & M6811_N_BIT) ? 1 : 0)
  212. #define cpu_get_ccr_V(cpu) ((cpu_get_ccr (cpu) & M6811_V_BIT) ? 1 : 0)
  213. #define cpu_get_ccr_C(cpu) ((cpu_get_ccr (cpu) & M6811_C_BIT) ? 1 : 0)
  214. #define cpu_get_ccr_Z(cpu) ((cpu_get_ccr (cpu) & M6811_Z_BIT) ? 1 : 0)
  215. #define cpu_get_ccr_I(cpu) ((cpu_get_ccr (cpu) & M6811_I_BIT) ? 1 : 0)
  216. #define cpu_set_ccr_flag(S, B, V) \
  217. cpu_set_ccr (S, (cpu_get_ccr (S) & ~(B)) | ((V) ? (B) : 0))
  218. #define cpu_set_ccr_H(cpu, val) cpu_set_ccr_flag (cpu, M6811_H_BIT, val)
  219. #define cpu_set_ccr_X(cpu, val) cpu_set_ccr_flag (cpu, M6811_X_BIT, val)
  220. #define cpu_set_ccr_S(cpu, val) cpu_set_ccr_flag (cpu, M6811_S_BIT, val)
  221. #define cpu_set_ccr_N(cpu, val) cpu_set_ccr_flag (cpu, M6811_N_BIT, val)
  222. #define cpu_set_ccr_V(cpu, val) cpu_set_ccr_flag (cpu, M6811_V_BIT, val)
  223. #define cpu_set_ccr_C(cpu, val) cpu_set_ccr_flag (cpu, M6811_C_BIT, val)
  224. #define cpu_set_ccr_Z(cpu, val) cpu_set_ccr_flag (cpu, M6811_Z_BIT, val)
  225. #define cpu_set_ccr_I(cpu, val) cpu_set_ccr_flag (cpu, M6811_I_BIT, val)
  226. extern void cpu_memory_exception (sim_cpu *cpu,
  227. SIM_SIGNAL excep,
  228. uint16_t addr,
  229. const char *message);
  230. STATIC_INLINE UNUSED address_word
  231. phys_to_virt (sim_cpu *cpu, address_word addr)
  232. {
  233. if (addr >= cpu->bank_start && addr < cpu->bank_end)
  234. return ((address_word) (addr - cpu->bank_start)
  235. + (((address_word) cpu->cpu_regs.page) << cpu->bank_shift)
  236. + cpu->bank_virtual);
  237. else
  238. return (address_word) (addr);
  239. }
  240. STATIC_INLINE UNUSED uint8_t
  241. memory_read8 (sim_cpu *cpu, uint16_t addr)
  242. {
  243. uint8_t val;
  244. if (sim_core_read_buffer (CPU_STATE (cpu), cpu, 0, &val, addr, 1) != 1)
  245. {
  246. cpu_memory_exception (cpu, SIM_SIGSEGV, addr,
  247. "Read error");
  248. }
  249. return val;
  250. }
  251. STATIC_INLINE UNUSED void
  252. memory_write8 (sim_cpu *cpu, uint16_t addr, uint8_t val)
  253. {
  254. if (sim_core_write_buffer (CPU_STATE (cpu), cpu, 0, &val, addr, 1) != 1)
  255. {
  256. cpu_memory_exception (cpu, SIM_SIGSEGV, addr,
  257. "Write error");
  258. }
  259. }
  260. STATIC_INLINE UNUSED uint16_t
  261. memory_read16 (sim_cpu *cpu, uint16_t addr)
  262. {
  263. uint8_t b[2];
  264. if (sim_core_read_buffer (CPU_STATE (cpu), cpu, 0, b, addr, 2) != 2)
  265. {
  266. cpu_memory_exception (cpu, SIM_SIGSEGV, addr,
  267. "Read error");
  268. }
  269. return (((uint16_t) (b[0])) << 8) | ((uint16_t) b[1]);
  270. }
  271. STATIC_INLINE UNUSED void
  272. memory_write16 (sim_cpu *cpu, uint16_t addr, uint16_t val)
  273. {
  274. uint8_t b[2];
  275. b[0] = val >> 8;
  276. b[1] = val;
  277. if (sim_core_write_buffer (CPU_STATE (cpu), cpu, 0, b, addr, 2) != 2)
  278. {
  279. cpu_memory_exception (cpu, SIM_SIGSEGV, addr,
  280. "Write error");
  281. }
  282. }
  283. extern void
  284. cpu_ccr_update_tst8 (sim_cpu *cpu, uint8_t val);
  285. STATIC_INLINE UNUSED void
  286. cpu_ccr_update_tst16 (sim_cpu *cpu, uint16_t val)
  287. {
  288. cpu_set_ccr_V (cpu, 0);
  289. cpu_set_ccr_N (cpu, val & 0x8000 ? 1 : 0);
  290. cpu_set_ccr_Z (cpu, val == 0 ? 1 : 0);
  291. }
  292. STATIC_INLINE UNUSED void
  293. cpu_ccr_update_shift8 (sim_cpu *cpu, uint8_t val)
  294. {
  295. cpu_set_ccr_N (cpu, val & 0x80 ? 1 : 0);
  296. cpu_set_ccr_Z (cpu, val == 0 ? 1 : 0);
  297. cpu_set_ccr_V (cpu, cpu_get_ccr_N (cpu) ^ cpu_get_ccr_C (cpu));
  298. }
  299. STATIC_INLINE UNUSED void
  300. cpu_ccr_update_shift16 (sim_cpu *cpu, uint16_t val)
  301. {
  302. cpu_set_ccr_N (cpu, val & 0x8000 ? 1 : 0);
  303. cpu_set_ccr_Z (cpu, val == 0 ? 1 : 0);
  304. cpu_set_ccr_V (cpu, cpu_get_ccr_N (cpu) ^ cpu_get_ccr_C (cpu));
  305. }
  306. STATIC_INLINE UNUSED void
  307. cpu_ccr_update_add8 (sim_cpu *cpu, uint8_t r, uint8_t a, uint8_t b)
  308. {
  309. cpu_set_ccr_C (cpu, ((a & b) | (b & ~r) | (a & ~r)) & 0x80 ? 1 : 0);
  310. cpu_set_ccr_V (cpu, ((a & b & ~r) | (~a & ~b & r)) & 0x80 ? 1 : 0);
  311. cpu_set_ccr_Z (cpu, r == 0);
  312. cpu_set_ccr_N (cpu, r & 0x80 ? 1 : 0);
  313. }
  314. STATIC_INLINE UNUSED void
  315. cpu_ccr_update_sub8 (sim_cpu *cpu, uint8_t r, uint8_t a, uint8_t b)
  316. {
  317. cpu_set_ccr_C (cpu, ((~a & b) | (b & r) | (~a & r)) & 0x80 ? 1 : 0);
  318. cpu_set_ccr_V (cpu, ((a & ~b & ~r) | (~a & b & r)) & 0x80 ? 1 : 0);
  319. cpu_set_ccr_Z (cpu, r == 0);
  320. cpu_set_ccr_N (cpu, r & 0x80 ? 1 : 0);
  321. }
  322. STATIC_INLINE UNUSED void
  323. cpu_ccr_update_add16 (sim_cpu *cpu, uint16_t r, uint16_t a, uint16_t b)
  324. {
  325. cpu_set_ccr_C (cpu, ((a & b) | (b & ~r) | (a & ~r)) & 0x8000 ? 1 : 0);
  326. cpu_set_ccr_V (cpu, ((a & b & ~r) | (~a & ~b & r)) & 0x8000 ? 1 : 0);
  327. cpu_set_ccr_Z (cpu, r == 0);
  328. cpu_set_ccr_N (cpu, r & 0x8000 ? 1 : 0);
  329. }
  330. STATIC_INLINE UNUSED void
  331. cpu_ccr_update_sub16 (sim_cpu *cpu, uint16_t r, uint16_t a, uint16_t b)
  332. {
  333. cpu_set_ccr_C (cpu, ((~a & b) | (b & r) | (~a & r)) & 0x8000 ? 1 : 0);
  334. cpu_set_ccr_V (cpu, ((a & ~b & ~r) | (~a & b & r)) & 0x8000 ? 1 : 0);
  335. cpu_set_ccr_Z (cpu, r == 0);
  336. cpu_set_ccr_N (cpu, r & 0x8000 ? 1 : 0);
  337. }
  338. /* Push and pop instructions for 68HC11 (next-available stack mode). */
  339. STATIC_INLINE UNUSED void
  340. cpu_m68hc11_push_uint8 (sim_cpu *cpu, uint8_t val)
  341. {
  342. uint16_t addr = cpu->cpu_regs.sp;
  343. memory_write8 (cpu, addr, val);
  344. cpu->cpu_regs.sp = addr - 1;
  345. }
  346. STATIC_INLINE UNUSED void
  347. cpu_m68hc11_push_uint16 (sim_cpu *cpu, uint16_t val)
  348. {
  349. uint16_t addr = cpu->cpu_regs.sp - 1;
  350. memory_write16 (cpu, addr, val);
  351. cpu->cpu_regs.sp = addr - 1;
  352. }
  353. STATIC_INLINE UNUSED uint8_t
  354. cpu_m68hc11_pop_uint8 (sim_cpu *cpu)
  355. {
  356. uint16_t addr = cpu->cpu_regs.sp;
  357. uint8_t val;
  358. val = memory_read8 (cpu, addr + 1);
  359. cpu->cpu_regs.sp = addr + 1;
  360. return val;
  361. }
  362. STATIC_INLINE UNUSED uint16_t
  363. cpu_m68hc11_pop_uint16 (sim_cpu *cpu)
  364. {
  365. uint16_t addr = cpu->cpu_regs.sp;
  366. uint16_t val;
  367. val = memory_read16 (cpu, addr + 1);
  368. cpu->cpu_regs.sp = addr + 2;
  369. return val;
  370. }
  371. /* Push and pop instructions for 68HC12 (last-used stack mode). */
  372. STATIC_INLINE UNUSED void
  373. cpu_m68hc12_push_uint8 (sim_cpu *cpu, uint8_t val)
  374. {
  375. uint16_t addr = cpu->cpu_regs.sp;
  376. addr --;
  377. memory_write8 (cpu, addr, val);
  378. cpu->cpu_regs.sp = addr;
  379. }
  380. STATIC_INLINE UNUSED void
  381. cpu_m68hc12_push_uint16 (sim_cpu *cpu, uint16_t val)
  382. {
  383. uint16_t addr = cpu->cpu_regs.sp;
  384. addr -= 2;
  385. memory_write16 (cpu, addr, val);
  386. cpu->cpu_regs.sp = addr;
  387. }
  388. STATIC_INLINE UNUSED uint8_t
  389. cpu_m68hc12_pop_uint8 (sim_cpu *cpu)
  390. {
  391. uint16_t addr = cpu->cpu_regs.sp;
  392. uint8_t val;
  393. val = memory_read8 (cpu, addr);
  394. cpu->cpu_regs.sp = addr + 1;
  395. return val;
  396. }
  397. STATIC_INLINE UNUSED uint16_t
  398. cpu_m68hc12_pop_uint16 (sim_cpu *cpu)
  399. {
  400. uint16_t addr = cpu->cpu_regs.sp;
  401. uint16_t val;
  402. val = memory_read16 (cpu, addr);
  403. cpu->cpu_regs.sp = addr + 2;
  404. return val;
  405. }
  406. /* Fetch a 8/16 bit value and update the PC. */
  407. STATIC_INLINE UNUSED uint8_t
  408. cpu_fetch8 (sim_cpu *cpu)
  409. {
  410. uint16_t addr = cpu->cpu_regs.pc;
  411. uint8_t val;
  412. val = memory_read8 (cpu, addr);
  413. cpu->cpu_regs.pc = addr + 1;
  414. return val;
  415. }
  416. STATIC_INLINE UNUSED uint16_t
  417. cpu_fetch16 (sim_cpu *cpu)
  418. {
  419. uint16_t addr = cpu->cpu_regs.pc;
  420. uint16_t val;
  421. val = memory_read16 (cpu, addr);
  422. cpu->cpu_regs.pc = addr + 2;
  423. return val;
  424. }
  425. extern void cpu_call (sim_cpu *cpu, uint16_t addr);
  426. extern void cpu_exg (sim_cpu *cpu, uint8_t code);
  427. extern void cpu_dbcc (sim_cpu *cpu);
  428. extern void cpu_special (sim_cpu *cpu, enum M6811_Special special);
  429. extern void cpu_move8 (sim_cpu *cpu, uint8_t op);
  430. extern void cpu_move16 (sim_cpu *cpu, uint8_t op);
  431. extern uint16_t cpu_fetch_relbranch (sim_cpu *cpu);
  432. extern uint16_t cpu_fetch_relbranch16 (sim_cpu *cpu);
  433. extern void cpu_push_all (sim_cpu *cpu);
  434. extern void cpu_single_step (sim_cpu *cpu);
  435. extern void cpu_info (SIM_DESC sd, sim_cpu *cpu);
  436. extern int cpu_initialize (SIM_DESC sd, sim_cpu *cpu);
  437. /* Returns the address of a 68HC12 indexed operand.
  438. Pre and post modifications are handled on the source register. */
  439. extern uint16_t cpu_get_indexed_operand_addr (sim_cpu *cpu, int restricted);
  440. extern void cpu_return (sim_cpu *cpu);
  441. extern void cpu_set_sp (sim_cpu *cpu, uint16_t val);
  442. extern int cpu_reset (sim_cpu *cpu);
  443. extern int cpu_restart (sim_cpu *cpu);
  444. extern void sim_memory_error (sim_cpu *cpu, SIM_SIGNAL excep,
  445. uint16_t addr, const char *message, ...);
  446. extern void emul_os (int op, sim_cpu *cpu);
  447. extern void cpu_interp_m6811 (sim_cpu *cpu);
  448. extern void cpu_interp_m6812 (sim_cpu *cpu);
  449. extern int m68hc11cpu_set_oscillator (SIM_DESC sd, const char *port,
  450. double ton, double toff,
  451. int64_t repeat);
  452. extern int m68hc11cpu_clear_oscillator (SIM_DESC sd, const char *port);
  453. extern void m68hc11cpu_set_port (struct hw *me, sim_cpu *cpu,
  454. unsigned addr, uint8_t val);
  455. extern void sim_board_reset (SIM_DESC sd);
  456. #define PRINT_TIME 0x01
  457. #define PRINT_CYCLE 0x02
  458. extern const char *cycle_to_string (sim_cpu *cpu, int64_t t, int flags);
  459. #endif