1 /* Remote debugging interface for Am290*0 running MiniMON monitor, for GDB.
2 Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
3 Originally written by Daniel Mann at AMD.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* This is like remote.c but ecpects MiniMON to be running on the Am29000
24 file to gdb 3.95. I was unable to get this working on sun3os4
25 with termio, only with sgtty. Because we are only attempting to
26 use this module to debug our kernel, which is already loaded when
27 gdb is started up, I did not code up the file downloading facilities.
28 As a result this module has only the stubs to download files.
29 You should get tagged at compile time if you need to make any
45 /* Offset of member MEMBER in a struct of type TYPE. */
46 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
48 #define DRAIN_INPUT() (msg_recv_serial((union msg_t*)0))
50 extern int stop_soon_quietly; /* for wait_for_inferior */
52 static void mm_resume();
53 static void mm_fetch_registers ();
54 static int fetch_register ();
55 static void mm_store_registers ();
56 static int store_register ();
57 static int regnum_to_srnum();
58 static void mm_close ();
59 static char* msg_str();
60 static char* error_msg_str();
61 static int expect_msg();
62 static void init_target_mm();
63 static int mm_memory_space();
65 #define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400)
66 #define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE)
68 /* FIXME: Replace with `set remotedebug'. */
69 #define LLOG_FILE "minimon.log"
70 #if defined (LOG_FILE)
75 * Size of message buffers. I couldn't get memory reads to work when
76 * the byte_count was larger than 512 (it may be a baud rate problem).
78 #define BUFER_SIZE 512
80 * Size of data area in message buffer on the TARGET (remote system).
82 #define MAXDATA_T (target_config.max_msg_size - \
83 offsetof(struct write_r_msg_t,data[0]))
85 * Size of data area in message buffer on the HOST (gdb).
87 #define MAXDATA_H (BUFER_SIZE - offsetof(struct write_r_msg_t,data[0]))
89 * Defined as the minimum size of data areas of the two message buffers
91 #define MAXDATA (MAXDATA_H < MAXDATA_T ? MAXDATA_H : MAXDATA_T)
93 static char out_buf[BUFER_SIZE];
94 static char in_buf[BUFER_SIZE];
96 int msg_recv_serial();
97 int msg_send_serial();
99 #define MAX_RETRIES 5000
100 extern struct target_ops mm_ops; /* Forward declaration */
101 struct config_msg_t target_config; /* HIF needs this */
102 union msg_t *out_msg_buf = (union msg_t*)out_buf;
103 union msg_t *in_msg_buf = (union msg_t*)in_buf;
105 static int timeout = 5;
107 /* Descriptor for I/O to remote machine. Initialize it to -1 so that
108 mm_open knows that we don't have a file open when the program
112 /* stream which is fdopen'd from mm_desc. Only valid when
116 /* Called when SIGALRM signal sent due to alarm() timeout. */
121 # define volatile /**/
124 volatile int n_alarms;
131 printf ("mm_timer called\n");
135 #endif /* HAVE_TERMIO */
137 /* malloc'd name of the program on the remote system. */
138 static char *prog_name = NULL;
141 /* Number of SIGTRAPs we need to simulate. That is, the next
142 NEED_ARTIFICIAL_TRAP calls to mm_wait should just return
143 SIGTRAP without actually waiting for anything. */
145 /**************************************************** REMOTE_CREATE_INFERIOR */
146 /* This is called not only when we first attach, but also when the
147 user types "run" after having attached. */
149 mm_create_inferior (execfile, args, env)
154 #define MAX_TOKENS 25
155 #define BUFFER_SIZE 256
158 char *token[MAX_TOKENS];
159 char cmd_line[BUFFER_SIZE];
162 error ("Can't pass arguments to remote mm process (yet).");
164 if (execfile == 0 /* || exec_bfd == 0 */ )
165 error ("No exec file specified");
168 printf("Minimon not open yet.\n");
172 /* On ultra3 (NYU) we assume the kernel is already running so there is
174 FIXME: Fixed required here -> load your program, possibly with mm_load().
176 printf_filtered ("\n\
177 Assuming you are at NYU debuging a kernel, i.e., no need to download.\n\n");
179 /* We will get a task spawn event immediately. */
180 init_wait_for_inferior ();
181 clear_proceed_status ();
182 stop_soon_quietly = 1;
186 /**************************************************** REMOTE_MOURN_INFERIOR */
190 pop_target (); /* Pop back to no-child state */
191 generic_mourn_inferior ();
194 /********************************************************************** damn_b
196 /* Translate baud rates from integers to damn B_codes. Unix should
197 have outgrown this crap years ago, but even POSIX wouldn't buck it. */
206 static struct {int rate, damn_b;} baudtab[] = {
226 static int damn_b (rate)
231 for (i = 0; baudtab[i].rate != -1; i++)
232 if (rate == baudtab[i].rate) return baudtab[i].damn_b;
233 return B38400; /* Random */
237 /***************************************************************** REMOTE_OPEN
238 ** Open a connection to remote minimon.
239 NAME is the filename used for communication, then a space,
241 'target adapt /dev/ttya 9600 [prognam]' for example.
244 static char *dev_name;
247 mm_open (name, from_tty)
255 /* Find the first whitespace character, it separates dev_name from
258 p && *p && !isspace (*p); p++)
260 if (p == 0 || *p == '\0')
262 error ("Usage : <command> <serial-device> <baud-rate> [progname]");
263 dev_name = (char*)malloc (p - name + 1);
264 strncpy (dev_name, name, p - name);
265 dev_name[p - name] = '\0';
267 /* Skip over the whitespace after dev_name */
268 for (; isspace (*p); p++)
271 if (1 != sscanf (p, "%d ", &baudrate))
274 /* Skip the number and then the spaces */
275 for (; isdigit (*p); p++)
277 for (; isspace (*p); p++)
280 if (prog_name != NULL)
282 prog_name = savestring (p, strlen (p));
288 mm_desc = open (dev_name, O_RDWR);
290 perror_with_name (dev_name);
291 ioctl (mm_desc, TIOCGETP, &sg);
293 sg.c_cc[VMIN] = 0; /* read with timeout. */
294 sg.c_cc[VTIME] = timeout * 10;
295 sg.c_lflag &= ~(ICANON | ECHO);
296 sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate);
298 sg.sg_ispeed = damn_b (baudrate);
299 sg.sg_ospeed = damn_b (baudrate);
302 sg.sg_flags &= ~ECHO;
306 ioctl (mm_desc, TIOCSETP, &sg);
307 mm_stream = fdopen (mm_desc, "r+");
309 push_target (&mm_ops);
312 #ifndef NO_SIGINTERRUPT
313 /* Cause SIGALRM's to make reads fail with EINTR instead of resuming
315 if (siginterrupt (SIGALRM, 1) != 0)
316 perror ("mm_open: error in siginterrupt");
319 /* Set up read timeout timer. */
320 if ((void (*)) signal (SIGALRM, mm_timer) == (void (*)) -1)
321 perror ("mm_open: error in signal");
324 #if defined (LOG_FILE)
325 log_file = fopen (LOG_FILE, "w");
326 if (log_file == NULL)
327 perror_with_name (LOG_FILE);
330 ** Initialize target configuration structure (global)
333 out_msg_buf->config_req_msg.code = CONFIG_REQ;
334 out_msg_buf->config_req_msg.length = 4*0;
335 msg_send_serial(out_msg_buf); /* send config request message */
337 expect_msg(CONFIG,in_msg_buf,1);
339 a29k_get_processor_type ();
341 /* Print out some stuff, letting the user now what's going on */
342 printf_filtered("Connected to MiniMon via %s.\n", dev_name);
343 /* FIXME: can this restriction be removed? */
344 printf_filtered("Remote debugging using virtual addresses works only\n");
345 printf_filtered("\twhen virtual addresses map 1:1 to physical addresses.\n")
347 if (processor_type != a29k_freeze_mode) {
348 fprintf_filtered(stderr,
349 "Freeze-mode debugging not available, and can only be done on an A29050.\n");
352 target_config.code = CONFIG;
353 target_config.length = 0;
354 target_config.processor_id = in_msg_buf->config_msg.processor_id;
355 target_config.version = in_msg_buf->config_msg.version;
356 target_config.I_mem_start = in_msg_buf->config_msg.I_mem_start;
357 target_config.I_mem_size = in_msg_buf->config_msg.I_mem_size;
358 target_config.D_mem_start = in_msg_buf->config_msg.D_mem_start;
359 target_config.D_mem_size = in_msg_buf->config_msg.D_mem_size;
360 target_config.ROM_start = in_msg_buf->config_msg.ROM_start;
361 target_config.ROM_size = in_msg_buf->config_msg.ROM_size;
362 target_config.max_msg_size = in_msg_buf->config_msg.max_msg_size;
363 target_config.max_bkpts = in_msg_buf->config_msg.max_bkpts;
364 target_config.coprocessor = in_msg_buf->config_msg.coprocessor;
365 target_config.reserved = in_msg_buf->config_msg.reserved;
367 printf("Connected to MiniMON :\n");
368 printf(" Debugcore version %d.%d\n",
369 0x0f & (target_config.version >> 4),
370 0x0f & (target_config.version ) );
371 printf(" Configuration version %d.%d\n",
372 0x0f & (target_config.version >> 12),
373 0x0f & (target_config.version >> 8) );
374 printf(" Message system version %d.%d\n",
375 0x0f & (target_config.version >> 20),
376 0x0f & (target_config.version >> 16) );
377 printf(" Communication driver version %d.%d\n",
378 0x0f & (target_config.version >> 28),
379 0x0f & (target_config.version >> 24) );
382 /* Leave the target running...
383 * The above message stopped the target in the dbg core (MiniMon),
384 * so restart the target out of MiniMon,
386 out_msg_buf->go_msg.code = GO;
387 out_msg_buf->go_msg.length = 0;
388 msg_send_serial(out_msg_buf);
389 /* No message to expect after a GO */
392 /**************************************************************** REMOTE_CLOSE
393 ** Close the open connection to the minimon debugger.
394 Use this when you want to detach and do something else
397 mm_close (quitting) /*FIXME: how is quitting used */
401 error ("Can't close remote connection: not debugging remotely.");
403 /* We should never get here if there isn't something valid in
404 mm_desc and mm_stream.
406 Due to a bug in Unix, fclose closes not only the stdio stream,
407 but also the file descriptor. So we don't actually close
411 /* close (mm_desc); */
413 /* Do not try to close mm_desc again, later in the program. */
417 #if defined (LOG_FILE)
418 if (ferror (log_file))
419 printf ("Error writing log file.\n");
420 if (fclose (log_file) != 0)
421 printf ("Error closing log file.\n");
424 printf ("Ending remote debugging\n");
427 /************************************************************* REMOTE_ATACH */
428 /* Attach to a program that is already loaded and running
429 * Upon exiting the process's execution is stopped.
432 mm_attach (args, from_tty)
438 error ("MiniMon not opened yet, use the 'target minimon' command.\n");
441 printf ("Attaching to remote program %s...\n", prog_name);
443 /* Make sure the target is currently running, it is supposed to be. */
444 /* FIXME: is it ok to send MiniMon a BREAK if it is already stopped in
445 * the dbg core. If so, we don't need to send this GO.
447 out_msg_buf->go_msg.code = GO;
448 out_msg_buf->go_msg.length = 0;
449 msg_send_serial(out_msg_buf);
450 sleep(2); /* At the worst it will stop, receive a message, continue */
452 /* Send the mm a break. */
453 out_msg_buf->break_msg.code = BREAK;
454 out_msg_buf->break_msg.length = 0;
455 msg_send_serial(out_msg_buf);
457 /********************************************************** REMOTE_DETACH */
458 /* Terminate the open connection to the remote debugger.
459 Use this when you want to detach and do something else
460 with your gdb. Leave remote process running (with no breakpoints set). */
462 mm_detach (args,from_tty)
466 remove_breakpoints(); /* Just in case there were any left in */
467 out_msg_buf->go_msg.code = GO;
468 out_msg_buf->go_msg.length = 0;
469 msg_send_serial(out_msg_buf);
470 pop_target(); /* calls mm_close to do the real work */
474 /*************************************************************** REMOTE_RESUME
475 ** Tell the remote machine to resume. */
478 mm_resume (pid, step, sig)
482 error ("Can't send signals to a remote MiniMon system.");
485 out_msg_buf->step_msg.code= STEP;
486 out_msg_buf->step_msg.length = 1*4;
487 out_msg_buf->step_msg.count = 1; /* step 1 instruction */
488 msg_send_serial(out_msg_buf);
490 out_msg_buf->go_msg.code= GO;
491 out_msg_buf->go_msg.length = 0;
492 msg_send_serial(out_msg_buf);
496 /***************************************************************** REMOTE_WAIT
497 ** Wait until the remote machine stops, then return,
498 storing status in STATUS just as `wait' would. */
505 int old_timeout = timeout;
506 int old_immediate_quit = immediate_quit;
508 WSETEXIT ((*status), 0);
511 /* wait for message to arrive. It should be:
512 - A HIF service request.
513 - A HIF exit service request.
515 - A CHANNEL1 request.
516 - a debugcore HALT message.
517 HIF services must be responded too, and while-looping continued.
518 If the target stops executing, mm_wait() should return.
520 timeout = 0; /* Wait indefinetly for a message */
521 immediate_quit = 1; /* Helps ability to QUIT */
524 while(msg_recv_serial(in_msg_buf)) {
525 QUIT; /* Let user quit if they want */
527 switch (in_msg_buf->halt_msg.code)
530 i = in_msg_buf->hif_call_rtn_msg.service_number;
531 result=service_HIF(in_msg_buf);
532 if(i == 1) /* EXIT */
535 printf("Warning: failure during HIF service %d\n", i);
538 service_HIF(in_msg_buf);
541 i=in_msg_buf->channel1_msg.length;
542 in_msg_buf->channel1_msg.data[i] = '\0';
543 printf("%s", in_msg_buf->channel1_msg.data);
545 /* Send CHANNEL1_ACK message */
546 out_msg_buf->channel1_ack_msg.code = CHANNEL1_ACK;
547 out_msg_buf->channel1_ack_msg.length = 0;
548 result = msg_send_serial(out_msg_buf);
557 /* FIXME, these printfs should not be here. This is a source level
559 if (in_msg_buf->halt_msg.trap_number== 0)
560 { printf("Am290*0 received vector number %d (break point)\n",
561 in_msg_buf->halt_msg.trap_number);
562 WSETSTOP ((*status), SIGTRAP);
564 else if (in_msg_buf->halt_msg.trap_number== 1)
565 { printf("Am290*0 received vector number %d\n",
566 in_msg_buf->halt_msg.trap_number);
567 WSETSTOP ((*status), SIGBUS);
569 else if (in_msg_buf->halt_msg.trap_number== 3
570 || in_msg_buf->halt_msg.trap_number== 4)
571 { printf("Am290*0 received vector number %d\n",
572 in_msg_buf->halt_msg.trap_number);
573 WSETSTOP ((*status), SIGFPE);
575 else if (in_msg_buf->halt_msg.trap_number== 5)
576 { printf("Am290*0 received vector number %d\n",
577 in_msg_buf->halt_msg.trap_number);
578 WSETSTOP ((*status), SIGILL);
580 else if (in_msg_buf->halt_msg.trap_number >= 6
581 && in_msg_buf->halt_msg.trap_number <= 11)
582 { printf("Am290*0 received vector number %d\n",
583 in_msg_buf->halt_msg.trap_number);
584 WSETSTOP ((*status), SIGSEGV);
586 else if (in_msg_buf->halt_msg.trap_number== 12
587 || in_msg_buf->halt_msg.trap_number== 13)
588 { printf("Am290*0 received vector number %d\n",
589 in_msg_buf->halt_msg.trap_number);
590 WSETSTOP ((*status), SIGILL);
592 else if (in_msg_buf->halt_msg.trap_number== 14)
593 { printf("Am290*0 received vector number %d\n",
594 in_msg_buf->halt_msg.trap_number);
595 WSETSTOP ((*status), SIGALRM);
597 else if (in_msg_buf->halt_msg.trap_number== 15)
598 WSETSTOP ((*status), SIGTRAP);
599 else if (in_msg_buf->halt_msg.trap_number >= 16
600 && in_msg_buf->halt_msg.trap_number <= 21)
601 { printf("Am290*0 received vector number %d\n",
602 in_msg_buf->halt_msg.trap_number);
603 WSETSTOP ((*status), SIGINT);
605 else if (in_msg_buf->halt_msg.trap_number== 22)
606 { printf("Am290*0 received vector number %d\n",
607 in_msg_buf->halt_msg.trap_number);
608 WSETSTOP ((*status), SIGILL);
609 } /* BREAK message was sent */
610 else if (in_msg_buf->halt_msg.trap_number== 75)
611 WSETSTOP ((*status), SIGTRAP);
614 WSETEXIT ((*status), 0);
616 timeout = old_timeout; /* Restore original timeout value */
617 immediate_quit = old_immediate_quit;
621 /******************************************************* REMOTE_FETCH_REGISTERS
622 * Read a remote register 'regno'.
623 * If regno==-1 then read all the registers.
626 mm_fetch_registers (regno)
632 fetch_register(regno);
637 out_msg_buf->read_req_msg.byte_count = 4*1;
638 out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
639 out_msg_buf->read_req_msg.address = 1;
640 msg_send_serial(out_msg_buf);
641 expect_msg(READ_ACK,in_msg_buf,1);
642 data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
643 supply_register (GR1_REGNUM , data_p);
645 #if defined(GR64_REGNUM) /* Read gr64-127 */
646 /* Global Registers gr64-gr95 */
647 out_msg_buf->read_req_msg.code= READ_REQ;
648 out_msg_buf->read_req_msg.length = 4*3;
649 out_msg_buf->read_req_msg.byte_count = 4*32;
650 out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
651 out_msg_buf->read_req_msg.address = 64;
652 msg_send_serial(out_msg_buf);
653 expect_msg(READ_ACK,in_msg_buf,1);
654 data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
656 for (regno=GR64_REGNUM; regno<GR64_REGNUM+32; regno++) {
657 supply_register (regno, data_p++);
659 #endif /* GR64_REGNUM */
661 /* Global Registers gr96-gr127 */
662 out_msg_buf->read_req_msg.code= READ_REQ;
663 out_msg_buf->read_req_msg.length = 4*3;
664 out_msg_buf->read_req_msg.byte_count = 4 * 32;
665 out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
666 out_msg_buf->read_req_msg.address = 96;
667 msg_send_serial(out_msg_buf);
668 expect_msg(READ_ACK,in_msg_buf,1);
669 data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
671 for (regno=GR96_REGNUM; regno<GR96_REGNUM+32; regno++) {
672 supply_register (regno, data_p++);
675 /* Local Registers */
676 out_msg_buf->read_req_msg.byte_count = 4 * (128);
677 out_msg_buf->read_req_msg.memory_space = LOCAL_REG;
678 out_msg_buf->read_req_msg.address = 0;
679 msg_send_serial(out_msg_buf);
680 expect_msg(READ_ACK,in_msg_buf,1);
681 data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
683 for (regno=LR0_REGNUM; regno<LR0_REGNUM+128; regno++) {
684 supply_register (regno, data_p++);
687 /* Protected Special Registers */
688 out_msg_buf->read_req_msg.byte_count = 4*15;
689 out_msg_buf->read_req_msg.memory_space = SPECIAL_REG;
690 out_msg_buf->read_req_msg.address = 0;
691 msg_send_serial( out_msg_buf);
692 expect_msg(READ_ACK,in_msg_buf,1);
693 data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
695 for (regno=0; regno<=14; regno++) {
696 supply_register (SR_REGNUM(regno), data_p++);
698 if (USE_SHADOW_PC) { /* Let regno_to_srnum() handle the register number */
699 fetch_register(NPC_REGNUM);
700 fetch_register(PC_REGNUM);
701 fetch_register(PC2_REGNUM);
704 /* Unprotected Special Registers */
705 out_msg_buf->read_req_msg.byte_count = 4*8;
706 out_msg_buf->read_req_msg.memory_space = SPECIAL_REG;
707 out_msg_buf->read_req_msg.address = 128;
708 msg_send_serial( out_msg_buf);
709 expect_msg(READ_ACK,in_msg_buf,1);
710 data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
712 for (regno=128; regno<=135; regno++) {
713 supply_register (SR_REGNUM(regno), data_p++);
716 /* There doesn't seem to be any way to get these. */
719 supply_register (FPE_REGNUM, &val);
720 supply_register (INTE_REGNUM, &val);
721 supply_register (FPS_REGNUM, &val);
722 supply_register (EXO_REGNUM, &val);
727 /****************************************************** REMOTE_STORE_REGISTERS
728 * Store register regno into the target.
729 * If regno==-1 then store all the registers.
730 * Result is 0 for success, -1 for failure.
734 mm_store_registers (regno)
740 store_register(regno);
746 out_msg_buf->write_r_msg.code= WRITE_REQ;
749 out_msg_buf->write_r_msg.byte_count = 4*1;
750 out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count;
751 out_msg_buf->write_r_msg.memory_space = GLOBAL_REG;
752 out_msg_buf->write_r_msg.address = 1;
753 out_msg_buf->write_r_msg.data[0] = read_register (GR1_REGNUM);
755 msg_send_serial( out_msg_buf);
756 if (!expect_msg(WRITE_ACK,in_msg_buf,1)) {
760 #if defined(GR64_REGNUM)
761 /* Global registers gr64-gr95 */
762 out_msg_buf->write_r_msg.byte_count = 4* (32);
763 out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count;
764 out_msg_buf->write_r_msg.address = 64;
766 for (regno=GR64_REGNUM ; regno<GR64_REGNUM+32 ; regno++)
768 out_msg_buf->write_r_msg.data[regno-GR64_REGNUM] = read_register (regno);
770 msg_send_serial(out_msg_buf);
771 if (!expect_msg(WRITE_ACK,in_msg_buf,1)) {
774 #endif /* GR64_REGNUM */
776 /* Global registers gr96-gr127 */
777 out_msg_buf->write_r_msg.byte_count = 4* (32);
778 out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count;
779 out_msg_buf->write_r_msg.address = 96;
780 for (regno=GR96_REGNUM ; regno<GR96_REGNUM+32 ; regno++)
782 out_msg_buf->write_r_msg.data[regno-GR96_REGNUM] = read_register (regno);
784 msg_send_serial( out_msg_buf);
785 if (!expect_msg(WRITE_ACK,in_msg_buf,1)) {
789 /* Local Registers */
790 out_msg_buf->write_r_msg.memory_space = LOCAL_REG;
791 out_msg_buf->write_r_msg.byte_count = 4*128;
792 out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count;
793 out_msg_buf->write_r_msg.address = 0;
795 for (regno = LR0_REGNUM ; regno < LR0_REGNUM+128 ; regno++)
797 out_msg_buf->write_r_msg.data[regno-LR0_REGNUM] = read_register (regno);
799 msg_send_serial( out_msg_buf);
800 if (!expect_msg(WRITE_ACK,in_msg_buf,1)) {
804 /* Protected Special Registers */
805 /* VAB through TMR */
806 out_msg_buf->write_r_msg.memory_space = SPECIAL_REG;
807 out_msg_buf->write_r_msg.byte_count = 4* 10;
808 out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count;
809 out_msg_buf->write_r_msg.address = 0;
810 for (regno = 0 ; regno<=9 ; regno++) /* VAB through TMR */
811 out_msg_buf->write_r_msg.data[regno] = read_register (SR_REGNUM(regno));
812 msg_send_serial( out_msg_buf);
813 if (!expect_msg(WRITE_ACK,in_msg_buf,1)) {
817 /* PC0, PC1, PC2 possibly as shadow registers */
818 out_msg_buf->write_r_msg.byte_count = 4* 3;
819 out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count;
820 for (regno=10 ; regno<=12 ; regno++) /* LRU and MMU */
821 out_msg_buf->write_r_msg.data[regno-10] = read_register (SR_REGNUM(regno));
823 out_msg_buf->write_r_msg.address = 20; /* SPC0 */
825 out_msg_buf->write_r_msg.address = 10; /* PC0 */
826 msg_send_serial( out_msg_buf);
827 if (!expect_msg(WRITE_ACK,in_msg_buf,1)) {
832 out_msg_buf->write_r_msg.byte_count = 4* 2;
833 out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count;
834 out_msg_buf->write_r_msg.address = 13;
835 for (regno=13 ; regno<=14 ; regno++) /* LRU and MMU */
836 out_msg_buf->write_r_msg.data[regno-13] = read_register (SR_REGNUM(regno));
837 msg_send_serial( out_msg_buf);
838 if (!expect_msg(WRITE_ACK,in_msg_buf,1)) {
842 /* Unprotected Special Registers */
843 out_msg_buf->write_r_msg.byte_count = 4*8;
844 out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count;
845 out_msg_buf->write_r_msg.address = 128;
846 for (regno = 128 ; regno<=135 ; regno++)
847 out_msg_buf->write_r_msg.data[regno-128] = read_register(SR_REGNUM(regno));
848 msg_send_serial( out_msg_buf);
849 if (!expect_msg(WRITE_ACK,in_msg_buf,1)) {
853 registers_changed ();
856 /*************************************************** REMOTE_PREPARE_TO_STORE */
857 /* Get ready to modify the registers array. On machines which store
858 individual registers, this doesn't need to do anything. On machines
859 which store all the registers in one fell swoop, this makes sure
860 that registers contains all the registers from the program being
864 mm_prepare_to_store ()
866 /* Do nothing, since we can store individual regs */
869 /******************************************************* REMOTE_XFER_MEMORY */
874 #if defined(KERNEL_DEBUGGING)
875 /* Check for a virtual address in the kernel */
876 /* Assume physical address of ublock is in paddr_u register */
877 /* FIXME: doesn't work for user virtual addresses */
878 if (addr >= UVADDR) {
879 /* PADDR_U register holds the physical address of the ublock */
880 CORE_ADDR i = (CORE_ADDR)read_register(PADDR_U_REGNUM);
881 return(i + addr - (CORE_ADDR)UVADDR);
890 /******************************************************* REMOTE_FILES_INFO */
894 printf ("\tAttached to %s at %d baud and running program %s.\n",
895 dev_name, baudrate, prog_name);
898 /************************************************* REMOTE_INSERT_BREAKPOINT */
900 mm_insert_breakpoint (addr, contents_cache)
902 char *contents_cache;
904 out_msg_buf->bkpt_set_msg.code = BKPT_SET;
905 out_msg_buf->bkpt_set_msg.length = 4*4;
906 out_msg_buf->bkpt_set_msg.memory_space = I_MEM;
907 out_msg_buf->bkpt_set_msg.bkpt_addr = (ADDR32) addr;
908 out_msg_buf->bkpt_set_msg.pass_count = 1;
909 out_msg_buf->bkpt_set_msg.bkpt_type = -1; /* use illop for 29000 */
910 msg_send_serial( out_msg_buf);
911 if (expect_msg(BKPT_SET_ACK,in_msg_buf,1)) {
912 return 0; /* Success */
914 return 1; /* Failure */
918 /************************************************* REMOTE_DELETE_BREAKPOINT */
920 mm_remove_breakpoint (addr, contents_cache)
922 char *contents_cache;
924 out_msg_buf->bkpt_rm_msg.code = BKPT_RM;
925 out_msg_buf->bkpt_rm_msg.length = 4*3;
926 out_msg_buf->bkpt_rm_msg.memory_space = I_MEM;
927 out_msg_buf->bkpt_rm_msg.bkpt_addr = (ADDR32) addr;
928 msg_send_serial( out_msg_buf);
929 if (expect_msg(BKPT_RM_ACK,in_msg_buf,1)) {
930 return 0; /* Success */
932 return 1; /* Failure */
937 /******************************************************* REMOTE_KILL */
939 mm_kill(arg,from_tty)
945 #if defined(KERNEL_DEBUGGING)
946 /* We don't ever kill the kernel */
948 printf("Kernel not killed, but left in current state.\n");
949 printf("Use detach to leave kernel running.\n");
952 out_msg_buf->break_msg.code = BREAK;
953 out_msg_buf->bkpt_set_msg.length = 4*0;
954 expect_msg(HALT,in_msg_buf,from_tty);
956 printf("Target has been stopped.");
957 printf("Would you like to do a hardware reset (y/n) [n] ");
960 out_msg_buf->reset_msg.code = RESET;
961 out_msg_buf->bkpt_set_msg.length = 4*0;
962 expect_msg(RESET_ACK,in_msg_buf,from_tty);
963 printf("Target has been reset.");
972 /***************************************************************************/
974 * Load a program into the target.
977 mm_load(arg_string,from_tty)
983 #if defined(KERNEL_DEBUGGING)
984 printf("The kernel had better be loaded already! Loading not done.\n");
987 error ("The load command takes a file name");
989 arg_string = tilde_expand (arg_string);
990 make_cleanup (free, arg_string);
993 error("File loading is not yet supported for MiniMon.");
994 /* FIXME, code to load your file here... */
995 /* You may need to do an init_target_mm() */
996 /* init_target_mm(?,?,?,?,?,?,?,?); */
998 /* symbol_file_add (arg_string, from_tty, text_addr, 0, 0); */
1003 /************************************************ REMOTE_WRITE_INFERIOR_MEMORY
1004 ** Copy LEN bytes of data from debugger memory at MYADDR
1005 to inferior's memory at MEMADDR. Returns number of bytes written. */
1007 mm_write_inferior_memory (memaddr, myaddr, len)
1014 out_msg_buf->write_req_msg.code= WRITE_REQ;
1015 out_msg_buf->write_req_msg.memory_space = mm_memory_space(memaddr);
1018 while (nwritten < len) {
1019 int num_to_write = len - nwritten;
1020 if (num_to_write > MAXDATA) num_to_write = MAXDATA;
1021 for (i=0 ; i < num_to_write ; i++)
1022 out_msg_buf->write_req_msg.data[i] = myaddr[i+nwritten];
1023 out_msg_buf->write_req_msg.byte_count = num_to_write;
1024 out_msg_buf->write_req_msg.length = 3*4 + num_to_write;
1025 out_msg_buf->write_req_msg.address = memaddr + nwritten;
1026 msg_send_serial(out_msg_buf);
1028 if (expect_msg(WRITE_ACK,in_msg_buf,1)) {
1029 nwritten += in_msg_buf->write_ack_msg.byte_count;
1037 /************************************************* REMOTE_READ_INFERIOR_MEMORY
1038 ** Read LEN bytes from inferior memory at MEMADDR. Put the result
1039 at debugger address MYADDR. Returns number of bytes read. */
1041 mm_read_inferior_memory(memaddr, myaddr, len)
1048 out_msg_buf->read_req_msg.code= READ_REQ;
1049 out_msg_buf->read_req_msg.memory_space = mm_memory_space(memaddr);
1052 while (nread < len) {
1053 int num_to_read = (len - nread);
1054 if (num_to_read > MAXDATA) num_to_read = MAXDATA;
1055 out_msg_buf->read_req_msg.byte_count = num_to_read;
1056 out_msg_buf->read_req_msg.length = 3*4 + num_to_read;
1057 out_msg_buf->read_req_msg.address = memaddr + nread;
1058 msg_send_serial(out_msg_buf);
1060 if (expect_msg(READ_ACK,in_msg_buf,1)) {
1061 for (i=0 ; i<in_msg_buf->read_ack_msg.byte_count ; i++)
1062 myaddr[i+nread] = in_msg_buf->read_ack_msg.data[i];
1063 nread += in_msg_buf->read_ack_msg.byte_count;
1071 /* FIXME! Merge these two. */
1073 mm_xfer_inferior_memory (memaddr, myaddr, len, write)
1080 memaddr = translate_addr(memaddr);
1083 return mm_write_inferior_memory (memaddr, myaddr, len);
1085 return mm_read_inferior_memory (memaddr, myaddr, len);
1089 /********************************************************** MSG_SEND_SERIAL
1090 ** This function is used to send a message over the
1093 ** If the message is successfully sent, a zero is
1094 ** returned. If the message was not sendable, a -1
1095 ** is returned. This function blocks. That is, it
1096 ** does not return until the message is completely
1097 ** sent, or until an error is encountered.
1102 msg_send_serial(msg_ptr)
1103 union msg_t *msg_ptr;
1110 /* Send message header */
1112 message_size = msg_ptr->generic_msg.length + (2 * sizeof(INT32));
1114 c = *((char *)msg_ptr+byte_count);
1115 result = write(mm_desc, &c, 1);
1117 byte_count = byte_count + 1;
1119 } while ((byte_count < message_size) );
1122 } /* end msg_send_serial() */
1124 /********************************************************** MSG_RECV_SERIAL
1125 ** This function is used to receive a message over a
1128 ** If the message is waiting in the buffer, a zero is
1129 ** returned and the buffer pointed to by msg_ptr is filled
1130 ** in. If no message was available, a -1 is returned.
1131 ** If timeout==0, wait indefinetly for a character.
1136 msg_recv_serial(msg_ptr)
1137 union msg_t *msg_ptr;
1139 static INT32 length=0;
1140 static INT32 byte_count=0;
1143 if(msg_ptr == 0) /* re-sync request */
1147 /* The timeout here is the prevailing timeout set with VTIME */
1148 ->"timeout==0 semantics not supported"
1149 read(mm_desc, in_buf, BUFER_SIZE);
1152 read(mm_desc, in_buf, BUFER_SIZE);
1157 /* Receive message */
1159 /* Timeout==0, help support the mm_wait() routine */
1160 ->"timeout==0 semantics not supported (and its nice if they are)"
1161 result = read(mm_desc, &c, 1);
1164 result = read(mm_desc, &c, 1);
1168 if (errno == EINTR) {
1169 error ("Timeout reading from remote system.");
1171 perror_with_name ("remote");
1172 } else if (result == 1) {
1173 *((char *)msg_ptr+byte_count) = c;
1174 byte_count = byte_count + 1;
1177 /* Message header received. Save message length. */
1178 if (byte_count == (2 * sizeof(INT32)))
1179 length = msg_ptr->generic_msg.length;
1181 if (byte_count >= (length + (2 * sizeof(INT32)))) {
1182 /* Message received */
1188 } /* end msg_recv_serial() */
1190 /********************************************************************* KBD_RAW
1191 ** This function is used to put the keyboard in "raw"
1192 ** mode for BSD Unix. The original status is saved
1193 ** so that it may be restored later.
1202 /* Get keyboard termio (to save to restore original modes) */
1204 result = ioctl(0, TCGETA, &kbd_tbuf);
1206 result = ioctl(0, TIOCGETP, &kbd_tbuf);
1211 /* Get keyboard TERMINAL (for modification) */
1213 result = ioctl(0, TCGETA, &tbuf);
1215 result = ioctl(0, TIOCGETP, &tbuf);
1220 /* Set up new parameters */
1222 tbuf.c_iflag = tbuf.c_iflag &
1223 ~(INLCR | ICRNL | IUCLC | ISTRIP | IXON | BRKINT);
1224 tbuf.c_lflag = tbuf.c_lflag & ~(ICANON | ISIG | ECHO);
1225 tbuf.c_cc[4] = 0; /* MIN */
1226 tbuf.c_cc[5] = 0; /* TIME */
1228 /* FIXME: not sure if this is correct (matches HAVE_TERMIO). */
1229 tbuf.sg_flags |= RAW;
1230 tbuf.sg_flags |= ANYP;
1231 tbuf.sg_flags &= ~ECHO;
1234 /* Set keyboard termio to new mode (RAW) */
1236 result = ioctl(0, TCSETAF, &tbuf);
1238 result = ioctl(0, TIOCSETP, &tbuf);
1244 } /* end kbd_raw() */
1248 /***************************************************************** KBD_RESTORE
1249 ** This function is used to put the keyboard back in the
1250 ** mode it was in before kbk_raw was called. Note that
1251 ** kbk_raw() must have been called at least once before
1252 ** kbd_restore() is called.
1259 /* Set keyboard termio to original mode */
1261 result = ioctl(0, TCSETAF, &kbd_tbuf);
1263 result = ioctl(0, TIOCGETP, &kbd_tbuf);
1270 } /* end kbd_cooked() */
1273 /*****************************************************************************/
1274 /* Fetch a single register indicatated by 'regno'.
1275 * Returns 0/-1 on success/failure.
1278 fetch_register (regno)
1282 out_msg_buf->read_req_msg.code= READ_REQ;
1283 out_msg_buf->read_req_msg.length = 4*3;
1284 out_msg_buf->read_req_msg.byte_count = 4;
1286 if (regno == GR1_REGNUM)
1287 { out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
1288 out_msg_buf->read_req_msg.address = 1;
1290 else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
1291 { out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
1292 out_msg_buf->read_req_msg.address = (regno - GR96_REGNUM) + 96;
1294 #if defined(GR64_REGNUM)
1295 else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32 )
1296 { out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
1297 out_msg_buf->read_req_msg.address = (regno - GR64_REGNUM) + 64;
1299 #endif /* GR64_REGNUM */
1300 else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
1301 { out_msg_buf->read_req_msg.memory_space = LOCAL_REG;
1302 out_msg_buf->read_req_msg.address = (regno - LR0_REGNUM);
1304 else if (regno>=FPE_REGNUM && regno<=EXO_REGNUM)
1306 supply_register(160 + (regno - FPE_REGNUM),&val);
1307 return 0; /* Pretend Success */
1310 { out_msg_buf->read_req_msg.memory_space = SPECIAL_REG;
1311 out_msg_buf->read_req_msg.address = regnum_to_srnum(regno);
1314 msg_send_serial(out_msg_buf);
1316 if (expect_msg(READ_ACK,in_msg_buf,1)) {
1317 supply_register (regno, &(in_msg_buf->read_r_ack_msg.data[0]));
1324 /*****************************************************************************/
1325 /* Store a single register indicated by 'regno'.
1326 * Returns 0/-1 on success/failure.
1329 store_register (regno)
1334 out_msg_buf->write_req_msg.code= WRITE_REQ;
1335 out_msg_buf->write_req_msg.length = 4*4;
1336 out_msg_buf->write_req_msg.byte_count = 4;
1337 out_msg_buf->write_r_msg.data[0] = read_register (regno);
1339 if (regno == GR1_REGNUM)
1340 { out_msg_buf->write_req_msg.memory_space = GLOBAL_REG;
1341 out_msg_buf->write_req_msg.address = 1;
1342 /* Setting GR1 changes the numbers of all the locals, so invalidate the
1343 * register cache. Do this *after* calling read_register, because we want
1344 * read_register to return the value that write_register has just stuffed
1345 * into the registers array, not the value of the register fetched from
1348 registers_changed ();
1350 #if defined(GR64_REGNUM)
1351 else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32 )
1352 { out_msg_buf->write_req_msg.memory_space = GLOBAL_REG;
1353 out_msg_buf->write_req_msg.address = (regno - GR64_REGNUM) + 64;
1355 #endif /* GR64_REGNUM */
1356 else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
1357 { out_msg_buf->write_req_msg.memory_space = GLOBAL_REG;
1358 out_msg_buf->write_req_msg.address = (regno - GR96_REGNUM) + 96;
1360 else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
1361 { out_msg_buf->write_req_msg.memory_space = LOCAL_REG;
1362 out_msg_buf->write_req_msg.address = (regno - LR0_REGNUM);
1364 else if (regno>=FPE_REGNUM && regno<=EXO_REGNUM)
1366 return 0; /* Pretend Success */
1368 else /* An unprotected or protected special register */
1369 { out_msg_buf->write_req_msg.memory_space = SPECIAL_REG;
1370 out_msg_buf->write_req_msg.address = regnum_to_srnum(regno);
1373 msg_send_serial(out_msg_buf);
1375 if (expect_msg(WRITE_ACK,in_msg_buf,1)) {
1382 /****************************************************************************/
1384 * Convert a gdb special register number to a 29000 special register number.
1387 regnum_to_srnum(regno)
1391 case VAB_REGNUM: return(0);
1392 case OPS_REGNUM: return(1);
1393 case CPS_REGNUM: return(2);
1394 case CFG_REGNUM: return(3);
1395 case CHA_REGNUM: return(4);
1396 case CHD_REGNUM: return(5);
1397 case CHC_REGNUM: return(6);
1398 case RBP_REGNUM: return(7);
1399 case TMC_REGNUM: return(8);
1400 case TMR_REGNUM: return(9);
1401 case NPC_REGNUM: return(USE_SHADOW_PC ? (20) : (10));
1402 case PC_REGNUM: return(USE_SHADOW_PC ? (21) : (11));
1403 case PC2_REGNUM: return(USE_SHADOW_PC ? (22) : (12));
1404 case MMU_REGNUM: return(13);
1405 case LRU_REGNUM: return(14);
1406 case IPC_REGNUM: return(128);
1407 case IPA_REGNUM: return(129);
1408 case IPB_REGNUM: return(130);
1409 case Q_REGNUM: return(131);
1410 case ALU_REGNUM: return(132);
1411 case BP_REGNUM: return(133);
1412 case FC_REGNUM: return(134);
1413 case CR_REGNUM: return(135);
1414 case FPE_REGNUM: return(160);
1415 case INTE_REGNUM: return(161);
1416 case FPS_REGNUM: return(162);
1417 case EXO_REGNUM:return(164);
1419 return(255); /* Failure ? */
1422 /****************************************************************************/
1424 * Initialize the target debugger (minimon only).
1427 init_target_mm(tstart,tend,dstart,dend,entry,ms_size,rs_size,arg_start)
1428 ADDR32 tstart,tend,dstart,dend,entry;
1429 INT32 ms_size,rs_size;
1432 out_msg_buf->init_msg.code = INIT;
1433 out_msg_buf->init_msg.length= sizeof(struct init_msg_t)-2*sizeof(INT32);
1434 out_msg_buf->init_msg.text_start = tstart;
1435 out_msg_buf->init_msg.text_end = tend;
1436 out_msg_buf->init_msg.data_start = dstart;
1437 out_msg_buf->init_msg.data_end = dend;
1438 out_msg_buf->init_msg.entry_point = entry;
1439 out_msg_buf->init_msg.mem_stack_size = ms_size;
1440 out_msg_buf->init_msg.reg_stack_size = rs_size;
1441 out_msg_buf->init_msg.arg_start = arg_start;
1442 msg_send_serial(out_msg_buf);
1443 expect_msg(INIT_ACK,in_msg_buf,1);
1445 /****************************************************************************/
1447 * Return a pointer to a string representing the given message code.
1448 * Not all messages are represented here, only the ones that we expect
1449 * to be called with.
1455 static char cbuf[32];
1458 case BKPT_SET_ACK: sprintf(cbuf,"%s (%d)","BKPT_SET_ACK",code); break;
1459 case BKPT_RM_ACK: sprintf(cbuf,"%s (%d)","BKPT_RM_ACK",code); break;
1460 case INIT_ACK: sprintf(cbuf,"%s (%d)","INIT_ACK",code); break;
1461 case READ_ACK: sprintf(cbuf,"%s (%d)","READ_ACK",code); break;
1462 case WRITE_ACK: sprintf(cbuf,"%s (%d)","WRITE_ACK",code); break;
1463 case ERROR: sprintf(cbuf,"%s (%d)","ERROR",code); break;
1464 case HALT: sprintf(cbuf,"%s (%d)","HALT",code); break;
1465 default: sprintf(cbuf,"UNKNOWN (%d)",code); break;
1469 /****************************************************************************/
1471 * Selected (not all of them) error codes that we might get.
1477 static char cbuf[50];
1480 case EMFAIL: return("EMFAIL: unrecoverable error");
1481 case EMBADADDR: return("EMBADADDR: Illegal address");
1482 case EMBADREG: return("EMBADREG: Illegal register ");
1483 case EMACCESS: return("EMACCESS: Could not access memory");
1484 case EMBADMSG: return("EMBADMSG: Unknown message type");
1485 case EMMSG2BIG: return("EMMSG2BIG: Message to large");
1486 case EMNOSEND: return("EMNOSEND: Could not send message");
1487 case EMNORECV: return("EMNORECV: Could not recv message");
1488 case EMRESET: return("EMRESET: Could not RESET target");
1489 case EMCONFIG: return("EMCONFIG: Could not get target CONFIG");
1490 case EMSTATUS: return("EMSTATUS: Could not get target STATUS");
1491 case EMREAD: return("EMREAD: Could not READ target memory");
1492 case EMWRITE: return("EMWRITE: Could not WRITE target memory");
1493 case EMBKPTSET: return("EMBKPTSET: Could not set breakpoint");
1494 case EMBKPTRM: return("EMBKPTRM: Could not remove breakpoint");
1495 case EMBKPTSTAT:return("EMBKPTSTAT: Could not get breakpoint status");
1496 case EMBKPTNONE:return("EMBKPTNONE: All breakpoints in use");
1497 case EMBKPTUSED:return("EMBKPTUSED: Breakpoints already in use");
1498 case EMINIT: return("EMINIT: Could not init target memory");
1499 case EMGO: return("EMGO: Could not start execution");
1500 case EMSTEP: return("EMSTEP: Could not single step");
1501 case EMBREAK: return("EMBREAK: Could not BREAK");
1502 case EMCOMMERR: return("EMCOMMERR: Communication error");
1503 default: sprintf(cbuf,"error number %d",code); break;
1508 /****************************************************************************/
1510 * Receive a message and expect it to be of type msgcode.
1511 * Returns 0/1 on failure/success.
1514 expect_msg(msgcode,msg_buf,from_tty)
1515 INT32 msgcode; /* Msg code we expect */
1516 union msg_t *msg_buf; /* Where to put the message received */
1517 int from_tty; /* Print message on error if non-zero */
1520 while(msg_recv_serial(msg_buf) && (retries++<MAX_RETRIES));
1521 if (retries >= MAX_RETRIES) {
1522 printf("Expected msg %s, ",msg_str(msgcode));
1523 printf("no message received!\n");
1524 return(0); /* Failure */
1527 if (msg_buf->generic_msg.code != msgcode) {
1529 printf("Expected msg %s, ",msg_str(msgcode));
1530 printf("got msg %s\n",msg_str(msg_buf->generic_msg.code));
1531 if (msg_buf->generic_msg.code == ERROR)
1532 printf("%s\n",error_msg_str(msg_buf->error_msg.error_code));
1534 return(0); /* Failure */
1536 return(1); /* Success */
1538 /****************************************************************************/
1540 * Determine the MiniMon memory space qualifier based on the addr.
1541 * FIXME: Can't distinguis I_ROM/D_ROM.
1542 * FIXME: Doesn't know anything about I_CACHE/D_CACHE.
1545 mm_memory_space(addr)
1548 ADDR32 tstart = target_config.I_mem_start;
1549 ADDR32 tend = tstart + target_config.I_mem_size;
1550 ADDR32 dstart = target_config.D_mem_start;
1551 ADDR32 dend = tstart + target_config.D_mem_size;
1552 ADDR32 rstart = target_config.ROM_start;
1553 ADDR32 rend = tstart + target_config.ROM_size;
1555 if (((ADDR32)addr >= tstart) && ((ADDR32)addr < tend)) {
1557 } else if (((ADDR32)addr >= dstart) && ((ADDR32)addr < dend)) {
1559 } else if (((ADDR32)addr >= rstart) && ((ADDR32)addr < rend)) {
1560 /* FIXME: how do we determine between D_ROM and I_ROM */
1562 } else /* FIXME: what do me do now? */
1563 return D_MEM; /* Hmmm! */
1566 /****************************************************************************/
1568 * Define the target subroutine names
1570 struct target_ops mm_ops = {
1571 "minimon", "Remote AMD/Minimon target",
1572 "Remote debug an AMD 290*0 using the MiniMon dbg core on the target",
1574 mm_attach, mm_detach, mm_resume, mm_wait,
1575 mm_fetch_registers, mm_store_registers,
1576 mm_prepare_to_store,
1577 mm_xfer_inferior_memory,
1579 mm_insert_breakpoint, mm_remove_breakpoint, /* Breakpoints */
1580 0, 0, 0, 0, 0, /* Terminal handling */
1581 mm_kill, /* FIXME, kill */
1583 0, /* lookup_symbol */
1584 mm_create_inferior, /* create_inferior */
1585 mm_mourn, /* mourn_inferior FIXME */
1587 0, /* notice_signals */
1588 process_stratum, 0, /* next */
1589 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
1590 0,0, /* sections, sections_end */
1591 OPS_MAGIC, /* Always the last thing */
1595 _initialize_remote_mm()
1597 add_target (&mm_ops);
1600 #ifdef NO_HIF_SUPPORT
1604 return(0); /* Emulate a failure */