diff options
author | Stephane Carrez <stcarrez@nerim.fr> | 2002-03-07 19:06:34 +0000 |
---|---|---|
committer | Stephane Carrez <stcarrez@nerim.fr> | 2002-03-07 19:06:34 +0000 |
commit | 5abb9efa086f5bd9eeacf3911d0b528cc522b870 (patch) | |
tree | d081c24a425d30f89832fc8eee6c70431728a0a9 | |
parent | 261289656f5d50f63fb39e917569b6a00ecf438d (diff) | |
download | gdb-5abb9efa086f5bd9eeacf3911d0b528cc522b870.zip gdb-5abb9efa086f5bd9eeacf3911d0b528cc522b870.tar.gz gdb-5abb9efa086f5bd9eeacf3911d0b528cc522b870.tar.bz2 |
* 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.
-rw-r--r-- | sim/m68hc11/ChangeLog | 19 | ||||
-rw-r--r-- | sim/m68hc11/interp.c | 6 | ||||
-rw-r--r-- | sim/m68hc11/m68hc11_sim.c | 206 | ||||
-rw-r--r-- | sim/m68hc11/sim-main.h | 39 |
4 files changed, 22 insertions, 248 deletions
diff --git a/sim/m68hc11/ChangeLog b/sim/m68hc11/ChangeLog index f0ab92c..7c2f7a1 100644 --- a/sim/m68hc11/ChangeLog +++ b/sim/m68hc11/ChangeLog @@ -1,5 +1,24 @@ 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 vector address according to cpu mode. (interrupts_initialize): Move reset portion to the above. diff --git a/sim/m68hc11/interp.c b/sim/m68hc11/interp.c index c34facd..cba7232 100644 --- a/sim/m68hc11/interp.c +++ b/sim/m68hc11/interp.c @@ -1,5 +1,5 @@ -/* 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. @@ -590,8 +590,6 @@ sim_do_command (SIM_DESC sd, char *cmd) { 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"); diff --git a/sim/m68hc11/m68hc11_sim.c b/sim/m68hc11/m68hc11_sim.c index 40dda42..7cf5e08 100644 --- a/sim/m68hc11/m68hc11_sim.c +++ b/sim/m68hc11/m68hc11_sim.c @@ -23,8 +23,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * #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, @@ -88,213 +86,17 @@ cpu_option_handler (SIM_DESC sd, sim_cpu *cpu, 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. */ @@ -302,7 +104,6 @@ void cpu_set_sp (sim_cpu *cpu, uint16 val) { cpu->cpu_regs.sp = val; - cpu_update_frame (cpu, 0); } uint16 @@ -653,8 +454,6 @@ cpu_initialize (SIM_DESC sd, sim_cpu *cpu) 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; @@ -671,11 +470,6 @@ cpu_initialize (SIM_DESC sd, sim_cpu *cpu) 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)); diff --git a/sim/m68hc11/sim-main.h b/sim/m68hc11/sim-main.h index a88c800..21c1fc9 100644 --- a/sim/m68hc11/sim-main.h +++ b/sim/m68hc11/sim-main.h @@ -1,5 +1,5 @@ /* 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. @@ -141,33 +141,10 @@ enum M6811_Special 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*); @@ -179,10 +156,6 @@ 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; @@ -433,7 +406,6 @@ cpu_m68hc11_push_uint8 (sim_cpu *proc, uint8 val) memory_write8 (proc, addr, val); proc->cpu_regs.sp = addr - 1; - proc->cpu_need_update_frame |= CPU_PUSH; } inline void @@ -443,7 +415,6 @@ cpu_m68hc11_push_uint16 (sim_cpu *proc, uint16 val) memory_write16 (proc, addr, val); proc->cpu_regs.sp = addr - 1; - proc->cpu_need_update_frame |= CPU_PUSH; } inline uint8 @@ -454,7 +425,6 @@ cpu_m68hc11_pop_uint8 (sim_cpu *proc) val = memory_read8 (proc, addr + 1); proc->cpu_regs.sp = addr + 1; - proc->cpu_need_update_frame |= CPU_POP; return val; } @@ -466,7 +436,6 @@ cpu_m68hc11_pop_uint16 (sim_cpu *proc) val = memory_read16 (proc, addr + 1); proc->cpu_regs.sp = addr + 2; - proc->cpu_need_update_frame |= CPU_POP; return val; } @@ -479,7 +448,6 @@ cpu_m68hc12_push_uint8 (sim_cpu *proc, uint8 val) addr --; memory_write8 (proc, addr, val); proc->cpu_regs.sp = addr; - proc->cpu_need_update_frame |= CPU_PUSH; } inline void @@ -490,7 +458,6 @@ cpu_m68hc12_push_uint16 (sim_cpu *proc, uint16 val) addr -= 2; memory_write16 (proc, addr, val); proc->cpu_regs.sp = addr; - proc->cpu_need_update_frame |= CPU_PUSH; } inline uint8 @@ -501,7 +468,6 @@ cpu_m68hc12_pop_uint8 (sim_cpu *proc) val = memory_read8 (proc, addr); proc->cpu_regs.sp = addr + 1; - proc->cpu_need_update_frame |= CPU_POP; return val; } @@ -513,7 +479,6 @@ cpu_m68hc12_pop_uint16 (sim_cpu *proc) val = memory_read16 (proc, addr); proc->cpu_regs.sp = addr + 2; - proc->cpu_need_update_frame |= CPU_POP; return val; } @@ -556,9 +521,7 @@ extern void cpu_info (SIM_DESC sd, sim_cpu *proc); 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, |