49 #include <sys/types.h>
51 #include <netinet/in.h>
53 #include <arpa/inet.h>
66 #define ACCL_REGNUM 22
67 #define ACCH_REGNUM 23
77 unsigned int *data_count = obj;
78 if (s->flags & SEC_LOAD)
81 bfd_size_type section_size = bfd_section_size (abfd, s);
82 bfd_vma section_base = bfd_section_lma (abfd, s);
85 *data_count += section_size;
88 bfd_section_name (abfd, s),
89 (
unsigned long) section_size);
94 for (i = 0; i < section_size; i += 4)
98 bfd_get_section_contents (abfd, s, (
char *) &buffer, i, 4);
124 unsigned int data_count = 0;
125 struct timeval start_time, end_time;
128 if (filename == NULL || filename[0] == 0)
133 error (
_(
"Unable to open file %s."), filename);
135 if (bfd_check_format (abfd, bfd_object) == 0)
136 error (
_(
"File is not an object file."));
137 gettimeofday (&start_time, NULL);
139 for (s = abfd->sections; s; s = s->next)
140 if (s->flags & SEC_LOAD)
142 bfd_size_type section_size = bfd_section_size (abfd, s);
143 bfd_vma section_base = bfd_section_vma (abfd, s);
146 data_count += section_size;
149 bfd_section_name (abfd, s), section_size);
154 for (i = 0; i < section_size; i += 4)
157 bfd_get_section_contents (abfd, s, (
char *) &buffer, i, 4);
172 gettimeofday (&end_time, NULL);
174 (
unsigned long) bfd_get_start_address (abfd));
208 {
"r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
209 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
210 "psw",
"cbr",
"spi",
"spu",
"bpc",
"pc",
"accl",
"acch",
215 int regnamelen,
char *val,
int vallen)
221 for (regno = 0; regno <
num_regs; regno++)
222 if (strncmp (regname,
m32r_regnames[regno], regnamelen) == 0)
225 if (regno >= num_regs)
231 val = strchr (val,
':');
240 #if (defined SM_REGNUM || defined BSM_REGNUM || defined IE_REGNUM \
241 || defined BIE_REGNUM || defined COND_REGNUM || defined CBR_REGNUM \
242 || defined BPC_REGNUM || defined BCARRY_REGNUM)
243 unsigned long psw = strtoul (val, NULL, 16);
244 char *zero =
"00000000", *one =
"00000001";
250 (psw & 0x80) ? one : zero);
255 (psw & 0x8000) ? one : zero);
260 (psw & 0x40) ? one : zero);
265 (psw & 0x4000) ? one : zero);
270 (psw & 0x1) ? one : zero);
274 (psw & 0x1) ? one : zero);
290 stackmode = psw & 0x80;
430 struct timeval start_time, end_time;
431 int resp_len, data_count = 0;
433 struct hostent *hostent;
434 struct in_addr inet_addr;
440 if (!strchr (buf,
':'))
441 error (
_(
"No ethernet connection!"));
446 char *myIPaddress = strchr (strchr (buf,
':') + 1,
':') + 1;
451 error (
_(
"Please use 'set board-address' to "
452 "set the M32R-EVA board's IP address."));
453 if (strchr (myIPaddress,
'('))
454 *(strchr (myIPaddress,
'(')) =
'\0';
462 if (WSAStartup (MAKEWORD (1, 1), &wd))
463 error (
_(
"Couldn't initialize WINSOCK."));
467 gethostname (buf,
sizeof (buf));
470 hostent = gethostbyname (buf);
474 memcpy (&inet_addr.s_addr, hostent->h_addr,
475 sizeof (inet_addr.s_addr));
478 server_addr = (
char *) inet_ntoa (hostent->h_addr);
483 error (
_(
"Need to know gdb host computer's "
484 "IP address (use 'set server-address')"));
487 if (args == 0 || args[0] == 0)
496 error (
_(
"Need to know default download "
497 "path (use 'set download-path')"));
500 gettimeofday (&start_time, NULL);
511 if (strrchr (args,
'.') && !strcmp (strrchr (args,
'.'),
".srec"))
517 if (buf[0] == 0 || strstr (buf,
"complete") == 0)
518 error (
_(
"Upload file not found: %s.srec\n"
519 "Check IP addresses and download path."),
524 gettimeofday (&end_time, NULL);
529 if (bfd_check_format (abfd, bfd_object) == 0)
533 for (s = abfd->sections; s; s = s->next)
534 if (s->flags & SEC_LOAD)
536 bfd_size_type section_size = bfd_section_size (abfd, s);
537 bfd_vma section_base = bfd_section_lma (abfd, s);
539 data_count += section_size;
542 bfd_section_name (abfd, s),
543 (
unsigned long) section_size);
551 bfd_get_start_address (abfd));
553 (
unsigned long) bfd_get_start_address (abfd));
585 Specify the serial device it is connected to (e.g. /dev/ttya).";
598 Specify the serial device it is connected to (e.g. /dev/ttya).";
603 Set the default path for downloadable SREC files."),
_(
"\
604 Show the default path for downloadable SREC files."),
_(
"\
605 Determines the default path for downloadable SREC files."),
612 Set IP address for M32R-EVA target board."),
_(
"\
613 Show IP address for M32R-EVA target board."),
_(
"\
614 Determine the IP address for M32R-EVA target board."),
621 Set IP address for download server (GDB's host computer)."),
_(
"\
622 Show IP address for download server (GDB's host computer)."),
_(
"\
623 Determine the IP address for download server (GDB's host computer)."),
631 Upload the srec file via the monitor's Ethernet upload capability."));
struct gdbarch * target_gdbarch(void)
void add_target(struct target_ops *t)
void monitor_printf(char *pattern,...)
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
struct ui_file * gdb_stdout
int catch_errors(catch_errors_ftype *func, void *func_args, char *errstring, return_mask mask)
char * skip_spaces(char *chp)
static struct target_ops mon2000_ops
struct bfd * gdb_bfd_open(const char *name, const char *target, int fd)
void regcache_write_pc(struct regcache *regcache, CORE_ADDR pc)
static char * m32r_regnames[]
struct regcache * get_current_regcache(void)
void printf_filtered(const char *format,...)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void(* supply_register)(struct regcache *regcache, char *name, int namelen, char *val, int vallen)
struct cmd_list_element * setlist
static int m32r_load_1(void *dummy)
static void m32r_supply_register(struct regcache *regcache, char *regname, int regnamelen, char *val, int vallen)
void initialize_file_ftype(void)
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
int monitor_expect(char *string, char *buf, int buflen)
static void init_mon2000_cmds(void)
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
struct cmd_list_element * showlist
static struct monitor_ops mon2000_cmds
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
void generic_load(const char *name, int from_tty)
#define MO_CLR_BREAK_USES_ADDR
void print_transfer_performance(struct ui_file *stream, unsigned long data_count, unsigned long write_count, const struct timeval *start_time, const struct timeval *end_time)
#define MONITOR_OPS_MAGIC
void add_setshow_string_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static int startswith(const char *string, const char *pattern)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
void monitor_open(const char *args, struct monitor_ops *mon_ops, int from_tty)
struct cleanup * make_cleanup_bfd_unref(bfd *abfd)
void clear_symtab_users(int add_flags)
#define SERIAL_1_STOPBITS
static void m32r_open(const char *args, int from_tty)
void init_monitor_ops(struct target_ops *ops)
char * phex_nz(ULONGEST l, int sizeof_l)
static char * server_addr
static char * download_path
void(* to_open)(const char *, int)
char * monitor_supply_register(struct regcache *regcache, int regno, char *valstr)
struct target_ops * target
const char * to_shortname
char * get_exec_file(int err)
unsigned long long ULONGEST
static void m32r_load(char *filename, int from_tty)
static struct monitor_ops m32r_cmds
#define MO_REGISTER_VALUE_FIRST
static void m32r_load_section(bfd *abfd, asection *s, void *obj)
void gdb_flush(struct ui_file *file)
int monitor_expect_prompt(char *buf, int buflen)
static struct target_ops m32r_ops
static void m32r_load_gen(struct target_ops *self, const char *filename, int from_tty)
static char * m32r_inits[]
void error(const char *fmt,...)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc)
initialize_file_ftype _initialize_m32r_rom
static void m32r_upload_command(char *args, int from_tty)
void(* to_load)(struct target_ops *, const char *, int) TARGET_DEFAULT_NORETURN(tcomplain())
void do_cleanups(struct cleanup *old_chain)
static void init_m32r_cmds(void)
static void mon2000_open(const char *args, int from_tty)