(cpu_frame_reg, cpu_print_frame): Remove.
(cpu_m68hc11_push_uint8, cpu_m68hc11_pop_uint8): Cleanup.
(cpu_m68hc11_push_uint16, cpu_m68hc11_pop_uint16): Likewise.
(cpu_m68hc12_push_uint8, cpu_m68hc12_push_uint16): Likewise.
(cpu_m68hc12_pop_uint8, cpu_m68hc12_pop_uint16): Likewise.
* m68hc11_sim.c (cpu_find_frame): Remove.
(cpu_create_frame_list): Remove.
(cpu_remove_frame_list, cpu_create_frame, cpu_free_frame): Remove.
(cpu_frame_reg, cpu_print_frame, cpu_update_frame): Remove.
(cpu_call): Cleanup to remove #if HAVE_FRAME and calls to the above.
(cpu_update_frame): Likewise.
(cpu_return): Likewise.
(cpu_reset): Likewise.
(cpu_initialize): Likewise.
* interp.c (sim_do_command): Remove call to cpu_print_frame.
+2002-03-07 Stephane Carrez <Stephane.Carrez@worldnet.fr>
+
+ * sim-main.h (cpu_frame, cpu_frame_list): Remove.
+ (cpu_frame_reg, cpu_print_frame): Remove.
+ (cpu_m68hc11_push_uint8, cpu_m68hc11_pop_uint8): Cleanup.
+ (cpu_m68hc11_push_uint16, cpu_m68hc11_pop_uint16): Likewise.
+ (cpu_m68hc12_push_uint8, cpu_m68hc12_push_uint16): Likewise.
+ (cpu_m68hc12_pop_uint8, cpu_m68hc12_pop_uint16): Likewise.
+ * m68hc11_sim.c (cpu_find_frame): Remove.
+ (cpu_create_frame_list): Remove.
+ (cpu_remove_frame_list, cpu_create_frame, cpu_free_frame): Remove.
+ (cpu_frame_reg, cpu_print_frame, cpu_update_frame): Remove.
+ (cpu_call): Cleanup to remove #if HAVE_FRAME and calls to the above.
+ (cpu_update_frame): Likewise.
+ (cpu_return): Likewise.
+ (cpu_reset): Likewise.
+ (cpu_initialize): Likewise.
+ * interp.c (sim_do_command): Remove call to cpu_print_frame.
+
2002-03-07 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* interrupts.c (interrupts_reset): New function, setup interrupt
-/* interp.c -- Simulator for Motorola 68HC11
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+/* interp.c -- Simulator for Motorola 68HC11/68HC12
+ Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Written by Stephane Carrez (stcarrez@worldnet.fr)
This file is part of GDB, the GNU debugger.
{
if (strncmp (cmd, "info", sizeof ("info") - 1) == 0)
sim_get_info (sd, &cmd[4]);
- else if (strncmp (cmd, "frame", sizeof ("frame") - 1) == 0)
- cpu_print_frame (sd, STATE_CPU (sd, 0));
else if (strncmp (cmd, mm_cmd, strlen (mm_cmd) == 0))
sim_io_eprintf (sd,
"`memory-map' command replaced by `sim memory'\n");
#include "sim-module.h"
#include "sim-options.h"
-void cpu_free_frame (sim_cpu* cpu, struct cpu_frame *frame);
-
enum {
OPTION_CPU_RESET = OPTION_START,
OPTION_EMUL_OS,
return SIM_RC_OK;
}
-/* Tentative to keep track of the cpu frame. */
-struct cpu_frame*
-cpu_find_frame (sim_cpu *cpu, uint16 sp)
-{
- struct cpu_frame_list *flist;
-
- flist = cpu->cpu_frames;
- while (flist)
- {
- struct cpu_frame *frame;
-
- frame = flist->frame;
- while (frame)
- {
- if (frame->sp_low <= sp && frame->sp_high >= sp)
- {
- cpu->cpu_current_frame = flist;
- return frame;
- }
-
- frame = frame->up;
- }
- flist = flist->next;
- }
- return 0;
-}
-
-struct cpu_frame_list*
-cpu_create_frame_list (sim_cpu *cpu)
-{
- struct cpu_frame_list *flist;
-
- flist = (struct cpu_frame_list*) malloc (sizeof (struct cpu_frame_list));
- flist->frame = 0;
- flist->next = cpu->cpu_frames;
- flist->prev = 0;
- if (flist->next)
- flist->next->prev = flist;
- cpu->cpu_frames = flist;
- cpu->cpu_current_frame = flist;
- return flist;
-}
-
-void
-cpu_remove_frame_list (sim_cpu *cpu, struct cpu_frame_list *flist)
-{
- struct cpu_frame *frame;
-
- if (flist->prev == 0)
- cpu->cpu_frames = flist->next;
- else
- flist->prev->next = flist->next;
- if (flist->next)
- flist->next->prev = flist->prev;
-
- frame = flist->frame;
- while (frame)
- {
- struct cpu_frame* up = frame->up;
- cpu_free_frame (cpu, frame);
- frame = up;
- }
- free (flist);
-}
-
-struct cpu_frame*
-cpu_create_frame (sim_cpu *cpu, uint16 pc, uint16 sp)
-{
- struct cpu_frame *frame;
-
- frame = (struct cpu_frame*) malloc (sizeof(struct cpu_frame));
- frame->up = 0;
- frame->pc = pc;
- frame->sp_low = sp;
- frame->sp_high = sp;
- return frame;
-}
-
-void
-cpu_free_frame (sim_cpu *cpu, struct cpu_frame *frame)
-{
- free (frame);
-}
-
-uint16
-cpu_frame_reg (sim_cpu *cpu, uint16 rn)
-{
- struct cpu_frame *frame;
-
- if (cpu->cpu_current_frame == 0)
- return 0;
-
- frame = cpu->cpu_current_frame->frame;
- while (frame)
- {
- if (rn == 0)
- return frame->sp_high;
- frame = frame->up;
- rn--;
- }
- return 0;
-}
-
void
cpu_call (sim_cpu *cpu, uint16 addr)
{
-#if HAVE_FRAME
- uint16 pc = cpu->cpu_insn_pc;
- uint16 sp;
- struct cpu_frame_list *flist;
- struct cpu_frame* frame;
- struct cpu_frame* new_frame;
-#endif
cpu_set_pc (cpu, addr);
-#if HAVE_FRAME
- sp = cpu_get_sp (cpu);
-
- cpu->cpu_need_update_frame = 0;
- flist = cpu->cpu_current_frame;
- if (flist == 0)
- flist = cpu_create_frame_list (cpu);
-
- frame = flist->frame;
- if (frame && frame->sp_low > sp)
- frame->sp_low = sp;
-
- new_frame = cpu_create_frame (cpu, pc, sp);
- new_frame->up = frame;
- flist->frame = new_frame;
-#endif
-}
-
-void
-cpu_update_frame (sim_cpu *cpu, int do_create)
-{
-#if HAVE_FRAME
- struct cpu_frame *frame;
-
- frame = cpu_find_frame (cpu, cpu_get_sp (cpu));
- if (frame)
- {
- while (frame != cpu->cpu_current_frame->frame)
- {
- struct cpu_frame* up;
-
- up = cpu->cpu_current_frame->frame->up;
- cpu_free_frame (cpu, cpu->cpu_current_frame->frame);
- cpu->cpu_current_frame->frame = up;
- }
- return;
- }
-
- if (do_create)
- {
- cpu_create_frame_list (cpu);
- frame = cpu_create_frame (cpu, cpu_get_pc (cpu), cpu_get_sp (cpu));
- cpu->cpu_current_frame->frame = frame;
- }
-#endif
}
void
cpu_return (sim_cpu *cpu)
{
-#if HAVE_FRAME
- uint16 sp = cpu_get_sp (cpu);
- struct cpu_frame *frame;
- struct cpu_frame_list *flist;
-
- cpu->cpu_need_update_frame = 0;
- flist = cpu->cpu_current_frame;
- if (flist && flist->frame && flist->frame->up)
- {
- frame = flist->frame->up;
- if (frame->sp_low <= sp && frame->sp_high >= sp)
- {
- cpu_free_frame (cpu, flist->frame);
- flist->frame = frame;
- return;
- }
- }
- cpu_update_frame (cpu, 1);
-#endif
-}
-
-void
-cpu_print_frame (SIM_DESC sd, sim_cpu *cpu)
-{
- struct cpu_frame* frame;
- int level = 0;
-
- if (cpu->cpu_current_frame == 0 || cpu->cpu_current_frame->frame == 0)
- {
- sim_io_printf (sd, "No frame.\n");
- return;
- }
- sim_io_printf (sd, " # PC SP-L SP-H\n");
- frame = cpu->cpu_current_frame->frame;
- while (frame)
- {
- sim_io_printf (sd, "%3d 0x%04x 0x%04x 0x%04x\n",
- level, frame->pc, frame->sp_low, frame->sp_high);
- frame = frame->up;
- level++;
- }
}
/* Set the stack pointer and re-compute the current frame. */
cpu_set_sp (sim_cpu *cpu, uint16 val)
{
cpu->cpu_regs.sp = val;
- cpu_update_frame (cpu, 0);
}
uint16
cpu->cpu_running = 1;
cpu->cpu_stop_on_interrupt = 0;
cpu->cpu_frequency = 8 * 1000 * 1000;
- cpu->cpu_frames = 0;
- cpu->cpu_current_frame = 0;
cpu->cpu_use_elf_start = 0;
cpu->cpu_elf_start = 0;
cpu->cpu_use_local_config = 0;
int
cpu_reset (sim_cpu *cpu)
{
- cpu->cpu_need_update_frame = 0;
- cpu->cpu_current_frame = 0;
- while (cpu->cpu_frames)
- cpu_remove_frame_list (cpu, cpu->cpu_frames);
-
/* Initialize the config register.
It is only initialized at reset time. */
memset (cpu->ios, 0, sizeof (cpu->ios));
/* sim-main.h -- Simulator for Motorola 68HC11 & 68HC12
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Written by Stephane Carrez (stcarrez@worldnet.fr)
This file is part of GDB, the GNU debugger.
M6812_WAV
};
-#define CPU_POP 1
-#define CPU_PUSH 2
-
#define M6811_MAX_PORTS (0x03f+1)
#define M6812_MAX_PORTS (0x3ff+1)
#define MAX_PORTS (M6812_MAX_PORTS)
-/* Tentative to keep track of the stack frame.
- The frame is updated each time a call or a return are made.
- We also have to take into account changes of stack pointer
- (either thread switch or longjmp). */
-struct cpu_frame
-{
- struct cpu_frame *up;
- uint16 pc;
- uint16 sp_low;
- uint16 sp_high;
-};
-
-/* Represents a list of frames (or a thread). */
-struct cpu_frame_list
-{
- struct cpu_frame_list *next;
- struct cpu_frame_list *prev;
- struct cpu_frame *frame;
-};
-
struct _sim_cpu;
typedef void (* cpu_interp) (struct _sim_cpu*);
/* CPU interrupts. */
struct interrupts cpu_interrupts;
- struct cpu_frame_list *cpu_frames;
- struct cpu_frame_list *cpu_current_frame;
- int cpu_need_update_frame;
-
/* Pointer to the interpretor routine. */
cpu_interp cpu_interpretor;
memory_write8 (proc, addr, val);
proc->cpu_regs.sp = addr - 1;
- proc->cpu_need_update_frame |= CPU_PUSH;
}
inline void
memory_write16 (proc, addr, val);
proc->cpu_regs.sp = addr - 1;
- proc->cpu_need_update_frame |= CPU_PUSH;
}
inline uint8
val = memory_read8 (proc, addr + 1);
proc->cpu_regs.sp = addr + 1;
- proc->cpu_need_update_frame |= CPU_POP;
return val;
}
val = memory_read16 (proc, addr + 1);
proc->cpu_regs.sp = addr + 2;
- proc->cpu_need_update_frame |= CPU_POP;
return val;
}
addr --;
memory_write8 (proc, addr, val);
proc->cpu_regs.sp = addr;
- proc->cpu_need_update_frame |= CPU_PUSH;
}
inline void
addr -= 2;
memory_write16 (proc, addr, val);
proc->cpu_regs.sp = addr;
- proc->cpu_need_update_frame |= CPU_PUSH;
}
inline uint8
val = memory_read8 (proc, addr);
proc->cpu_regs.sp = addr + 1;
- proc->cpu_need_update_frame |= CPU_POP;
return val;
}
val = memory_read16 (proc, addr);
proc->cpu_regs.sp = addr + 2;
- proc->cpu_need_update_frame |= CPU_POP;
return val;
}
extern int cpu_initialize (SIM_DESC sd, sim_cpu *cpu);
-extern void cpu_print_frame (SIM_DESC sd, sim_cpu *cpu);
extern void cpu_set_sp (sim_cpu *cpu, uint16 val);
-extern uint16 cpu_frame_reg (sim_cpu *cpu, uint16 rn);
extern int cpu_reset (sim_cpu *cpu);
extern int cpu_restart (sim_cpu *cpu);
extern void sim_memory_error (sim_cpu *cpu, SIM_SIGNAL excep,