sim-main.h 17 KB

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