33 #include "gdb/sim-bfin.h"
44 #define P_LINKAGE 0xE800
45 #define P_MINUS_SP1 0x0140
46 #define P_MINUS_SP2 0x05C0
47 #define P_MINUS_SP3 0x0540
48 #define P_MINUS_SP4 0x04C0
49 #define P_SP_PLUS 0x6C06
50 #define P_P2_LOW 0xE10A
51 #define P_P2_HIGH 0XE14A
52 #define P_SP_EQ_SP_PLUS_P2 0X5BB2
53 #define P_SP_EQ_P2_PLUS_SP 0x5B96
54 #define P_MINUS_MINUS_SP_EQ_RETS 0x0167
58 #define P_16_BIT_INSR_MAX 0xBFFF
60 #define P_32_BIT_INSR_MIN 0xC000
62 #define P_32_BIT_INSR_MAX 0xE801
64 #define P_JUMP_PREG_MIN 0x0050
66 #define P_JUMP_PREG_MAX 0x0057
68 #define P_JUMP_PC_PLUS_PREG_MIN 0x0080
70 #define P_JUMP_PC_PLUS_PREG_MAX 0x0087
72 #define P_JUMP_S_MIN 0x2000
74 #define P_JUMP_S_MAX 0x2FFF
76 #define P_JUMP_L_MIN 0xE200
78 #define P_JUMP_L_MAX 0xE2FF
80 #define P_IF_CC_JUMP_MIN 0x1800
82 #define P_IF_CC_JUMP_MAX 0x1BFF
84 #define P_IF_CC_JUMP_BP_MIN 0x1C00
86 #define P_IF_CC_JUMP_BP_MAX 0x1FFF
88 #define P_IF_NOT_CC_JUMP_MIN 0x1000
90 #define P_IF_NOT_CC_JUMP_MAX 0x13FF
92 #define P_IF_NOT_CC_JUMP_BP_MIN 0x1400
94 #define P_IF_NOT_CC_JUMP_BP_MAX 0x17FF
96 #define P_CALL_PREG_MIN 0x0060
98 #define P_CALL_PREG_MAX 0x0067
100 #define P_CALL_PC_PLUS_PREG_MIN 0x0070
102 #define P_CALL_PC_PLUS_PREG_MAX 0x0077
104 #define P_CALL_MIN 0xE300
106 #define P_CALL_MAX 0xE3FF
110 #define P_MNOP 0xC803
112 #define P_EXCPT_MIN 0x00A0
114 #define P_EXCPT_MAX 0x00AF
116 #define P_BIT_MULTI_INS_1 0xC000
118 #define P_BIT_MULTI_INS_2 0x0800
121 #define UPPER_LIMIT 40
124 #define ASTAT_CC_POS 5
125 #define ASTAT_CC (1 << ASTAT_CC_POS)
131 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
132 "p0",
"p1",
"p2",
"p3",
"p4",
"p5",
"sp",
"fp",
133 "i0",
"i1",
"i2",
"i3",
"m0",
"m1",
"m2",
"m3",
134 "b0",
"b1",
"b2",
"b3",
"l0",
"l1",
"l2",
"l3",
135 "a0x",
"a0w",
"a1x",
"a1w",
"astat",
"rets",
136 "lc0",
"lt0",
"lb0",
"lc1",
"lt1",
"lb1",
"cycles",
"cycles2",
137 "usp",
"seqstat",
"syscfg",
"reti",
"retx",
"retn",
"rete",
141 #define NUM_BFIN_REGNAMES ARRAY_SIZE (bfin_register_name_strings)
301 if (cache->
base == 0)
348 if (cache->
base == 0)
355 static struct value *
366 if (regnum < BFIN_NUM_REGS && cache->
saved_regs[regnum] != -1)
438 else if (op ==
P_RTS)
451 warning (
_(
"Function Prologue not recognised; "
452 "pc will point to ENTRY_POINT of the function"));
493 struct value *
function,
506 long reg_r0, reg_r1, reg_r2;
511 for (i = nargs - 1; i >= 0; i--)
523 sp -= 12 - total_len;
527 for (i = nargs - 1; i >= 0; i--)
531 int container_len = (
TYPE_LENGTH (value_type) + 3) & ~3;
581 static const unsigned char *
587 static unsigned char bfin_breakpoint[] = {0xa1, 0x00, 0x00, 0x00};
588 static unsigned char bfin_sim_breakpoint[] = {0x25, 0x00, 0x00, 0x00};
592 if ((iw & 0xf000) >= 0xc000)
599 return bfin_sim_breakpoint;
601 return bfin_breakpoint;
611 bfd_byte *valbuf = dst;
635 const bfd_byte *valbuf = src;
662 struct value *
function,
697 _(
"invalid register number %d"), regnum);
703 buffer[1] = buffer[2] = buffer[3] = 0;
717 _(
"invalid register number %d"), regnum);
738 return cache->
base - 4;
746 return cache->
base + 8;
776 return (address & ~0x3);
792 static struct gdbarch *
796 struct gdbarch *gdbarch;
801 if (info.
abfd && bfd_get_flavour (info.
abfd) == bfd_target_elf_flavour)
802 elf_flags = elf_elfheader (info.
abfd)->e_flags;
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype frame_align)
static int bfin_reg_to_regnum(struct gdbarch *gdbarch, int reg)
void set_gdbarch_ps_regnum(struct gdbarch *gdbarch, int ps_regnum)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
struct type * builtin_func_ptr
CORE_ADDR get_frame_pc(struct frame_info *frame)
static CORE_ADDR bfin_frame_args_address(struct frame_info *this_frame, void **this_cache)
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
static void bfin_store_return_value(struct type *type, struct regcache *regs, const gdb_byte *src)
static void bfin_extract_return_value(struct type *type, struct regcache *regs, gdb_byte *dst)
static const char * bfin_register_name(struct gdbarch *gdbarch, int i)
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
struct value * frame_unwind_got_memory(struct frame_info *frame, int regnum, CORE_ADDR addr)
void warning(const char *fmt,...)
static CORE_ADDR bfin_frame_align(struct gdbarch *gdbarch, CORE_ADDR address)
static CORE_ADDR bfin_push_dummy_call(struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr)
ULONGEST frame_unwind_register_unsigned(struct frame_info *frame, int regnum)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void internal_error(const char *file, int line, const char *fmt,...)
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
static int is_minus_minus_sp(int op)
struct gdbarch_list * next
static struct gdbarch * bfin_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
void set_gdbarch_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, gdbarch_dwarf2_reg_to_regnum_ftype dwarf2_reg_to_regnum)
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
struct type * builtin_int32
CORE_ADDR saved_regs[BFIN_NUM_REGS]
#define FRAME_OBSTACK_ZALLOC(TYPE)
void store_unsigned_integer(gdb_byte *, int, enum bfd_endian, ULONGEST)
struct value * frame_unwind_got_constant(struct frame_info *frame, int regnum, ULONGEST val)
enum bfin_abi bfin_abi(struct gdbarch *gdbarch)
static CORE_ADDR bfin_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
void set_gdbarch_pseudo_register_write(struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype pseudo_register_write)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
struct type * check_typedef(struct type *type)
static struct bfin_frame_cache * bfin_frame_cache(struct frame_info *this_frame, void **this_cache)
LONGEST read_memory_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
void initialize_file_ftype(void)
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
void set_gdbarch_sp_regnum(struct gdbarch *gdbarch, int sp_regnum)
void set_gdbarch_decr_pc_after_break(struct gdbarch *gdbarch, CORE_ADDR decr_pc_after_break)
static enum register_status bfin_pseudo_register_read(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, gdb_byte *buffer)
void set_gdbarch_dummy_id(struct gdbarch *gdbarch, gdbarch_dummy_id_ftype dummy_id)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
static const int map_gcc_gdb[]
static void bfin_frame_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
void set_gdbarch_believe_pcc_promotion(struct gdbarch *gdbarch, int believe_pcc_promotion)
initialize_file_ftype _initialize_bfin_tdep
static CORE_ADDR bfin_frame_base_address(struct frame_info *this_frame, void **this_cache)
struct type * value_enclosing_type(struct value *value)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void set_gdbarch_unwind_pc(struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype unwind_pc)
void set_gdbarch_breakpoint_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_from_pc_ftype breakpoint_from_pc)
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
gdb_byte * value_contents_writeable(struct value *value)
static struct type * bfin_register_type(struct gdbarch *gdbarch, int regnum)
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
void set_gdbarch_frame_args_skip(struct gdbarch *gdbarch, CORE_ADDR frame_args_skip)
#define P_JUMP_PC_PLUS_PREG_MIN
static enum return_value_convention bfin_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
static struct value * bfin_frame_prev_register(struct frame_info *this_frame, void **this_cache, int regnum)
static CORE_ADDR bfin_frame_local_address(struct frame_info *this_frame, void **this_cache)
void set_gdbarch_pseudo_register_read(struct gdbarch *gdbarch, gdbarch_pseudo_register_read_ftype pseudo_register_read)
static void bfin_pseudo_register_write(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buffer)
#define P_JUMP_PC_PLUS_PREG_MAX
#define P_MINUS_MINUS_SP_EQ_RETS
enum register_status regcache_raw_read(struct regcache *regcache, int regnum, gdb_byte *buf)
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
struct value * frame_unwind_got_register(struct frame_info *frame, int regnum, int new_regnum)
CORE_ADDR find_function_addr(struct value *function, struct type **retval_type)
struct type * builtin_data_ptr
static const char *const bfin_register_name_strings[]
void set_gdbarch_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
static struct bfin_frame_cache * bfin_alloc_frame_cache(void)
unsigned long long ULONGEST
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
static struct frame_id bfin_dummy_id(struct gdbarch *gdbarch, struct frame_info *this_frame)
struct type * value_type(const struct value *value)
#define BFIN_NUM_PSEUDO_REGS
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value)
static CORE_ADDR bfin_unwind_pc(struct gdbarch *gdbarch, struct frame_info *next_frame)
#define TYPE_LENGTH(thistype)
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype push_dummy_call)
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
void register_gdbarch_init(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init)
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype skip_prologue)
enum bfd_endian byte_order
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype register_name)
CORE_ADDR get_frame_func(struct frame_info *this_frame)
struct gdbarch * gdbarch_alloc(const struct gdbarch_info *info, struct gdbarch_tdep *tdep)
void set_gdbarch_inner_than(struct gdbarch *gdbarch, gdbarch_inner_than_ftype inner_than)
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
static const struct frame_unwind bfin_frame_unwind
void regcache_cooked_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
void set_gdbarch_print_insn(struct gdbarch *gdbarch, gdbarch_print_insn_ftype print_insn)
void regcache_raw_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
const ULONGEST const LONGEST len
static const unsigned char * bfin_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)