📄 sim-main.h
字号:
/* sim-main.h -- Simulator for Motorola 68HC11 & 68HC12 Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Written by Stephane Carrez (stcarrez@nerim.fr)This file is part of GDB, the GNU debugger.This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public License alongwith this program; if not, write to the Free Software Foundation, Inc.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#ifndef _SIM_MAIN_H#define _SIM_MAIN_H#define WITH_MODULO_MEMORY 1#define WITH_WATCHPOINTS 1#define SIM_HANDLES_LMA 1#include "sim-basics.h"typedef address_word sim_cia;#include "sim-signal.h"#include "sim-base.h"#include "bfd.h"#include "opcode/m68hc11.h"#include "gdb/callback.h"#include "gdb/remote-sim.h"#include "opcode/m68hc11.h"#include "sim-types.h"typedef unsigned8 uint8;typedef unsigned16 uint16;typedef signed16 int16;typedef unsigned32 uint32;typedef signed32 int32;typedef unsigned64 uint64;typedef signed64 int64;struct _sim_cpu;#include "interrupts.h"#include <setjmp.h>/* Specifies the level of mapping for the IO, EEprom, nvram and external RAM. IO registers are mapped over everything and the external RAM is last (ie, it can be hidden by everything above it in the list). */enum m68hc11_map_level{ M6811_IO_LEVEL, M6811_EEPROM_LEVEL, M6811_NVRAM_LEVEL, M6811_RAM_LEVEL};enum cpu_type{ CPU_M6811, CPU_M6812};#define X_REGNUM 0#define D_REGNUM 1#define Y_REGNUM 2#define SP_REGNUM 3#define PC_REGNUM 4#define A_REGNUM 5#define B_REGNUM 6#define PSW_REGNUM 7#define PAGE_REGNUM 8#define Z_REGNUM 9typedef struct m6811_regs { unsigned short d; unsigned short ix; unsigned short iy; unsigned short sp; unsigned short pc; unsigned char ccr; unsigned short page;} m6811_regs;/* Description of 68HC11 IO registers. Such description is only provided for the info command to display the current setting of IO registers from GDB. */struct io_reg_desc{ int mask; const char *short_name; const char *long_name;};typedef struct io_reg_desc io_reg_desc;extern void print_io_reg_desc (SIM_DESC sd, io_reg_desc *desc, int val, int mode);extern void print_io_byte (SIM_DESC sd, const char *name, io_reg_desc *desc, uint8 val, uint16 addr);extern void print_io_word (SIM_DESC sd, const char *name, io_reg_desc *desc, uint16 val, uint16 addr);/* List of special 68HC11&68HC12 instructions that are not handled by the 'gencode.c' generator. These complex instructions are implemented by 'cpu_special'. */enum M6811_Special{ /* 68HC11 instructions. */ M6811_DAA, M6811_EMUL_SYSCALL, M6811_ILLEGAL, M6811_RTI, M6811_STOP, M6811_SWI, M6811_TEST, M6811_WAI, /* 68HC12 instructions. */ M6812_BGND, M6812_CALL, M6812_CALL_INDIRECT, M6812_IDIVS, M6812_EDIV, M6812_EDIVS, M6812_EMACS, M6812_EMUL, M6812_EMULS, M6812_ETBL, M6812_MEM, M6812_REV, M6812_REVW, M6812_RTC, M6812_RTI, M6812_WAV};#define M6811_MAX_PORTS (0x03f+1)#define M6812_MAX_PORTS (0x3ff+1)#define MAX_PORTS (M6812_MAX_PORTS)struct _sim_cpu;typedef void (* cpu_interp) (struct _sim_cpu*);struct _sim_cpu { /* CPU registers. */ struct m6811_regs cpu_regs; /* CPU interrupts. */ struct interrupts cpu_interrupts; /* Pointer to the interpretor routine. */ cpu_interp cpu_interpretor; /* Pointer to the architecture currently configured in the simulator. */ const struct bfd_arch_info *cpu_configured_arch; /* CPU absolute cycle time. The cycle time is updated after each instruction, by the number of cycles taken by the instruction. It is cleared only when reset occurs. */ signed64 cpu_absolute_cycle; /* Number of cycles to increment after the current instruction. This is also the number of ticks for the generic event scheduler. */ uint8 cpu_current_cycle; int cpu_emul_syscall; int cpu_is_initialized; int cpu_running; int cpu_check_memory; int cpu_stop_on_interrupt; /* When this is set, start execution of program at address specified in the ELF header. This is used for testing some programs that do not have an interrupt table linked with them. Programs created during the GCC validation are like this. A normal 68HC11 does not behave like this (unless there is some OS or downloadable feature). */ int cpu_use_elf_start; /* The starting address specified in ELF header. */ int cpu_elf_start; uint16 cpu_insn_pc; /* CPU frequency. This is the quartz frequency. It is divided by 4 to get the cycle time. This is used for the timer rate and for the baud rate generation. */ unsigned long cpu_frequency; /* The mode in which the CPU is configured (MODA and MODB pins). */ unsigned int cpu_mode; const char* cpu_start_mode; /* The cpu being configured. */ enum cpu_type cpu_type; /* Initial value of the CONFIG register. */ uint8 cpu_config; uint8 cpu_use_local_config; uint8 ios[MAX_PORTS]; /* Memory bank parameters which describe how the memory bank window is mapped in memory and how to convert it in virtual address. */ uint16 bank_start; uint16 bank_end; address_word bank_virtual; unsigned bank_shift; struct hw *hw_cpu; /* ... base type ... */ sim_cpu_base base;};/* Returns the cpu absolute cycle time (A virtual counter incremented at each 68HC11 E clock). */#define cpu_current_cycle(PROC) ((PROC)->cpu_absolute_cycle)#define cpu_add_cycles(PROC,T) ((PROC)->cpu_current_cycle += (signed64) (T))#define cpu_is_running(PROC) ((PROC)->cpu_running)/* Get the IO/RAM base addresses depending on the M6811_INIT register. */#define cpu_get_io_base(PROC) \ (((uint16)(((PROC)->ios[M6811_INIT]) & 0x0F))<<12)#define cpu_get_reg_base(PROC) \ (((uint16)(((PROC)->ios[M6811_INIT]) & 0xF0))<<8)/* Returns the different CPU registers. */#define cpu_get_ccr(PROC) ((PROC)->cpu_regs.ccr)#define cpu_get_pc(PROC) ((PROC)->cpu_regs.pc)#define cpu_get_d(PROC) ((PROC)->cpu_regs.d)#define cpu_get_x(PROC) ((PROC)->cpu_regs.ix)#define cpu_get_y(PROC) ((PROC)->cpu_regs.iy)#define cpu_get_sp(PROC) ((PROC)->cpu_regs.sp)#define cpu_get_a(PROC) ((PROC->cpu_regs.d >> 8) & 0x0FF)#define cpu_get_b(PROC) ((PROC->cpu_regs.d) & 0x0FF)#define cpu_get_page(PROC) ((PROC)->cpu_regs.page)/* 68HC12 specific and Motorola internal registers. */#define cpu_get_tmp3(PROC) (0)#define cpu_get_tmp2(PROC) (0)#define cpu_set_d(PROC,VAL) (((PROC)->cpu_regs.d) = (VAL))#define cpu_set_x(PROC,VAL) (((PROC)->cpu_regs.ix) = (VAL))#define cpu_set_y(PROC,VAL) (((PROC)->cpu_regs.iy) = (VAL))#define cpu_set_page(PROC,VAL) (((PROC)->cpu_regs.page) = (VAL))/* 68HC12 specific and Motorola internal registers. */#define cpu_set_tmp3(PROC,VAL) (0)#define cpu_set_tmp2(PROC,VAL) (void) (0)#if 0/* This is a function in m68hc11_sim.c to keep track of the frame. */#define cpu_set_sp(PROC,VAL) (((PROC)->cpu_regs.sp) = (VAL))#endif#define cpu_set_pc(PROC,VAL) (((PROC)->cpu_regs.pc) = (VAL))#define cpu_set_a(PROC,VAL) \ cpu_set_d(PROC,((VAL) << 8) | cpu_get_b(PROC))#define cpu_set_b(PROC,VAL) \ cpu_set_d(PROC,((cpu_get_a(PROC)) << 8)|(VAL & 0x0FF))#define cpu_set_ccr(PROC,VAL) ((PROC)->cpu_regs.ccr = (VAL))#define cpu_get_ccr_H(PROC) ((cpu_get_ccr(PROC) & M6811_H_BIT) ? 1: 0)#define cpu_get_ccr_X(PROC) ((cpu_get_ccr(PROC) & M6811_X_BIT) ? 1: 0)#define cpu_get_ccr_S(PROC) ((cpu_get_ccr(PROC) & M6811_S_BIT) ? 1: 0)#define cpu_get_ccr_N(PROC) ((cpu_get_ccr(PROC) & M6811_N_BIT) ? 1: 0)#define cpu_get_ccr_V(PROC) ((cpu_get_ccr(PROC) & M6811_V_BIT) ? 1: 0)#define cpu_get_ccr_C(PROC) ((cpu_get_ccr(PROC) & M6811_C_BIT) ? 1: 0)#define cpu_get_ccr_Z(PROC) ((cpu_get_ccr(PROC) & M6811_Z_BIT) ? 1: 0)#define cpu_get_ccr_I(PROC) ((cpu_get_ccr(PROC) & M6811_I_BIT) ? 1: 0)#define cpu_set_ccr_flag(S,B,V) \cpu_set_ccr(S,(cpu_get_ccr(S) & ~(B)) | ((V) ? B : 0))#define cpu_set_ccr_H(PROC,VAL) cpu_set_ccr_flag(PROC, M6811_H_BIT, VAL)#define cpu_set_ccr_X(PROC,VAL) cpu_set_ccr_flag(PROC, M6811_X_BIT, VAL)#define cpu_set_ccr_S(PROC,VAL) cpu_set_ccr_flag(PROC, M6811_S_BIT, VAL)#define cpu_set_ccr_N(PROC,VAL) cpu_set_ccr_flag(PROC, M6811_N_BIT, VAL)#define cpu_set_ccr_V(PROC,VAL) cpu_set_ccr_flag(PROC, M6811_V_BIT, VAL)#define cpu_set_ccr_C(PROC,VAL) cpu_set_ccr_flag(PROC, M6811_C_BIT, VAL)#define cpu_set_ccr_Z(PROC,VAL) cpu_set_ccr_flag(PROC, M6811_Z_BIT, VAL)#define cpu_set_ccr_I(PROC,VAL) cpu_set_ccr_flag(PROC, M6811_I_BIT, VAL)#undef inline#define inline static __inline__extern void cpu_memory_exception (struct _sim_cpu *proc,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -