Tidy up formatting.
[deliverable/binutils-gdb.git] / gdb / remote-es.c
CommitLineData
c906108c
SS
1/* Memory-access and commands for remote es1800 processes, for GDB.
2 Copyright (C) 1988, 1992 Free Software Foundation, Inc.
3
4 This file is added to GDB to make it possible to do debugging via an
5 ES-1800 emulator. The code was originally written by Johan Holmberg
6 TT/SJ Ericsson Telecom AB and later modified by Johan Henriksson
7 TT/SJ. It was modified for gdb 4.0 by TX/DK Jan Nordenand by TX/DKG
8 Harald Johansen.
9
c5aa993b 10 This file is part of GDB.
c906108c 11
c5aa993b
JM
12 GDB is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 1, or (at your option)
15 any later version.
c906108c 16
c5aa993b
JM
17 GDB is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
c906108c 21
c5aa993b
JM
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. */
c906108c
SS
26
27
28/* Emulator communication protocol.
29 All values are encoded in ascii hex digits.
30
c5aa993b
JM
31 Request
32 Command
33 Reply
34 read registers:
35 DR<cr>
36 - 0 - - 1 - - 2 - - 3 - - 4 - - 5 - -- 6 - - 7 -
37 D = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
38 A = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
39 PC = XXXXXX SSP = XXXXXX USP = XXXXXX SR = XXXXXXXX
40 >
41 Each byte of register data is described by two hex digits.
42
43 write regs
44 D0=XXXXXXXX<cr>
45 >D1=XXXXXXXX<cr>
46 >D2=XXXXXXXX<cr>
47 >D3=XXXXXXXX<cr>
48 >D4=XXXXXXXX<cr>
49 >D5=XXXXXXXX<cr>
50 >D6=XXXXXXXX<cr>
51 >D7=XXXXXXXX<cr>
52 >A0=XXXXXXXX<cr>
53 >A1=XXXXXXXX<cr>
54 >A2=XXXXXXXX<cr>
55 >A3=XXXXXXXX<cr>
56 >A4=XXXXXXXX<cr>
57 >A5=XXXXXXXX<cr>
58 >A6=XXXXXXXX<cr>
59 >A7=XXXXXXXX<cr>
60 >SR=XXXXXXXX<cr>
61 >PC=XXXXXX<cr>
62 >
63 Each byte of register data is described by two hex digits.
64
65 read mem
66 @.BAA..AA
67 $FFFFFFXX
68 >
69 AA..AA is address, XXXXXXX is the contents
70
71 write mem
72 @.BAA..AA=$XXXXXXXX
73 >
74 AA..AA is address, XXXXXXXX is data
75
76 cont
77 PC=$AA..AA
78 >RBK
79 R>
80 AA..AA is address to resume. If AA..AA is omitted, resume at same address.
81
82 step
83 PC=$AA..AA
84 >STP
85 R>
86 AA..AA is address to resume. If AA..AA is omitted, resume at same address.
87
88 kill req
89 STP
90 >
91 */
c906108c
SS
92
93
94#include <stdio.h>
95#include <signal.h>
96#include <sys/ioctl.h>
97#include <sys/file.h>
98#include <errno.h>
99#include <ctype.h>
100#include <setjmp.h>
101#include <fcntl.h>
102#include "defs.h"
103#include "gdb_string.h"
104#include "frame.h"
105#include "inferior.h"
106#include "target.h"
03f2053f 107#include "gdb_wait.h"
c906108c
SS
108#include "command.h"
109#include "remote-utils.h"
110#include "gdbcore.h"
111#include "serial.h"
112
113/* Prototypes for local functions */
114
a14ed312 115static void es1800_child_detach (char *, int);
c906108c 116
a14ed312 117static void es1800_child_open (char *, int);
c906108c 118
a14ed312 119static void es1800_transparent (char *, int);
c906108c 120
a14ed312 121static void es1800_create_inferior (char *, char *, char **);
c906108c 122
a14ed312 123static void es1800_load (char *, int);
c906108c 124
a14ed312 125static void es1800_kill (void);
c906108c 126
a14ed312 127static int verify_break (int);
c906108c 128
a14ed312 129static int es1800_remove_breakpoint (CORE_ADDR, char *);
c906108c 130
a14ed312 131static int es1800_insert_breakpoint (CORE_ADDR, char *);
c906108c 132
a14ed312 133static void es1800_files_info (struct target_ops *);
c906108c
SS
134
135static int
a14ed312
KB
136es1800_xfer_inferior_memory (CORE_ADDR, char *, int, int,
137 struct target_ops *);
c906108c 138
a14ed312 139static void es1800_prepare_to_store (void);
c906108c 140
a14ed312 141static int es1800_wait (int, struct target_waitstatus *);
c906108c 142
a14ed312 143static void es1800_resume (int, int, enum target_signal);
c906108c 144
a14ed312 145static void es1800_detach (char *, int);
c906108c 146
a14ed312 147static void es1800_attach (char *, int);
c906108c 148
a14ed312 149static int damn_b (char *);
c906108c 150
a14ed312 151static void es1800_open (char *, int);
c906108c 152
a14ed312 153static void es1800_timer (void);
c906108c 154
a14ed312 155static void es1800_reset (char *);
c906108c 156
a14ed312 157static void es1800_request_quit (void);
c906108c 158
a14ed312 159static int readchar (void);
c906108c 160
a14ed312 161static void expect (char *, int);
c906108c 162
a14ed312 163static void expect_prompt (void);
c906108c 164
a14ed312 165static void download (FILE *, int, int);
c906108c
SS
166
167#if 0
a14ed312 168static void bfd_copy (bfd *, bfd *);
c906108c
SS
169#endif
170
a14ed312 171static void get_break_addr (int, CORE_ADDR *);
c906108c 172
a14ed312 173static int fromhex (int);
c906108c 174
a14ed312 175static int tohex (int);
c906108c 176
a14ed312 177static void es1800_close (int);
c906108c 178
a14ed312 179static void es1800_fetch_registers (void);
c906108c 180
a14ed312 181static void es1800_fetch_register (int);
c906108c 182
a14ed312 183static void es1800_store_register (int);
c906108c 184
a14ed312 185static void es1800_read_bytes (CORE_ADDR, char *, int);
c906108c 186
a14ed312 187static void es1800_write_bytes (CORE_ADDR, char *, int);
c906108c 188
a14ed312 189static void send_with_reply (char *, char *, int);
c906108c 190
a14ed312 191static void send_command (char *);
c906108c 192
a14ed312 193static void send (char *);
c906108c 194
a14ed312 195static void getmessage (char *, int);
c906108c 196
a14ed312 197static void es1800_mourn_inferior (void);
c906108c 198
a14ed312 199static void es1800_create_break_insn (char *, int);
c906108c 200
a14ed312 201static void es1800_init_break (char *, int);
c906108c
SS
202
203/* Local variables */
204
205/* FIXME: Convert this to use "set remotedebug" instead. */
206#define LOG_FILE "es1800.log"
207#if defined (LOG_FILE)
208static FILE *log_file;
209#endif
210
c5aa993b 211extern struct target_ops es1800_ops; /* Forward decl */
c906108c
SS
212extern struct target_ops es1800_child_ops; /* Forward decl */
213
214static int kiodebug;
c5aa993b
JM
215static int timeout = 100;
216static char *savename; /* Name of i/o device used */
c906108c 217static serial_ttystate es1800_saved_ttystate;
c5aa993b 218static int es1800_fc_save; /* Save fcntl state */
c906108c
SS
219
220/* indicates that the emulator uses 32-bit data-adress (68020-mode)
221 instead of 24-bit (68000 -mode) */
222
223static int m68020;
224
225#define MODE (m68020 ? "M68020" : "M68000" )
226#define ES1800_BREAK_VEC (0xf)
227
228/* Descriptor for I/O to remote machine. Initialize it to NULL so that
229 es1800_open knows that we don't have a file open when the program
230 starts. */
231
232static serial_t es1800_desc = NULL;
233
234#define PBUFSIZ 1000
235#define HDRLEN sizeof("@.BAAAAAAAA=$VV\r")
236
237/* Maximum number of bytes to read/write at once. The value here
238 is chosen to fill up a packet. */
239
240#define MAXBUFBYTES ((PBUFSIZ-150)*16/75 )
241
242static int es1800_break_vec = 0;
243static char es1800_break_insn[2];
244static long es1800_break_address;
c5aa993b 245static void (*old_sigint) (); /* Old signal-handler for sigint */
c906108c
SS
246static jmp_buf interrupt;
247
248/* Local signalhandler to allow breaking tranfers or program run.
249 Rely on global variables: old_sigint(), interrupt */
250
251static void
252es1800_request_quit ()
253{
254 /* restore original signalhandler */
255 signal (SIGINT, old_sigint);
256 longjmp (interrupt, 1);
257}
258
259
260/* Reset emulator.
261 Sending reset character(octal 32) to emulator.
c5aa993b 262 quit - return to '(esgdb)' prompt or continue */
c906108c
SS
263
264static void
265es1800_reset (quit)
266 char *quit;
267{
268 char buf[80];
269
270 if (quit)
271 {
272 printf ("\nResetting emulator... ");
273 }
274 strcpy (buf, "\032");
275 send (buf);
276 expect_prompt ();
277 if (quit)
278 {
279 error ("done\n");
280 }
281}
282
283
284/* Open a connection to a remote debugger and push the new target
285 onto the stack. Check if the emulator is responding and find out
286 what kind of processor the emulator is connected to.
287 Initiate the breakpoint handling in the emulator.
288
289 name - the filename used for communication (ex. '/dev/tta')
290 from_tty - says whether to be verbose or not */
291
292static void
293es1800_open (name, from_tty)
294 char *name;
295 int from_tty;
296{
297 char buf[PBUFSIZ];
298 char *p;
299 int i, fcflag;
300
301 m68020 = 0;
302
c5aa993b 303 if (!name) /* no device name given in target command */
c906108c
SS
304 {
305 error_no_arg ("serial port device name");
306 }
307
308 target_preopen (from_tty);
309 es1800_close (0);
310
311 /* open the device and configure it for communication */
312
313#ifndef DEBUG_STDIN
314
315 es1800_desc = SERIAL_OPEN (name);
316 if (es1800_desc == NULL)
317 {
318 perror_with_name (name);
319 }
320 savename = savestring (name, strlen (name));
321
322 es1800_saved_ttystate = SERIAL_GET_TTY_STATE (es1800_desc);
323
c2c6d25f 324 if ((fcflag = fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_GETFL, 0)) == -1)
c906108c
SS
325 {
326 perror_with_name ("fcntl serial");
327 }
328 es1800_fc_save = fcflag;
329
c5aa993b 330 fcflag = (fcflag & (FREAD | FWRITE)); /* mask out any funny stuff */
c2c6d25f 331 if (fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, fcflag) == -1)
c906108c
SS
332 {
333 perror_with_name ("fcntl serial");
334 }
335
336 if (baud_rate != -1)
337 {
338 if (SERIAL_SETBAUDRATE (es1800_desc, baud_rate))
339 {
340 SERIAL_CLOSE (es1800_desc);
341 perror_with_name (name);
342 }
343 }
344
345 SERIAL_RAW (es1800_desc);
346
347 /* If there is something sitting in the buffer we might take it as a
348 response to a command, which would be bad. */
349 SERIAL_FLUSH_INPUT (es1800_desc);
350
c5aa993b 351#endif /* DEBUG_STDIN */
c906108c
SS
352
353 push_target (&es1800_ops); /* Switch to using remote target now */
354 if (from_tty)
355 {
356 printf ("Remote ES1800 debugging using %s\n", name);
357 }
358
359#if defined (LOG_FILE)
360
361 log_file = fopen (LOG_FILE, "w");
362 if (log_file == NULL)
363 {
364 perror_with_name (LOG_FILE);
365 }
366
c5aa993b 367#endif /* LOG_FILE */
c906108c
SS
368
369 /* Hello? Are you there?, also check mode */
370
371 /* send_with_reply( "DB 0 TO 1", buf, sizeof(buf)); */
c5aa993b 372 /* for (p = buf, i = 0; *p++ =='0';) *//* count the number of zeros */
c906108c
SS
373 /* i++; */
374
375 send ("\032");
c5aa993b 376 getmessage (buf, sizeof (buf)); /* send reset character */
c906108c
SS
377
378 if (from_tty)
379 {
380 printf ("Checking mode.... ");
381 }
c5aa993b 382 /* m68020 = (i==8); *//* if eight zeros then we are in m68020 mode */
c906108c 383
c5aa993b 384 /* What kind of processor am i talking to ? */
c906108c 385 p = buf;
c5aa993b
JM
386 while (*p++ != '\n')
387 {;
388 }
389 while (*p++ != '\n')
390 {;
391 }
392 while (*p++ != '\n')
393 {;
394 }
395 for (i = 0; i < 20; i++, p++)
396 {;
397 }
c906108c
SS
398 m68020 = !strncmp (p, "68020", 5);
399 if (from_tty)
400 {
401 printf ("You are in %s(%c%c%c%c%c)-mode\n", MODE, p[0], p[1], p[2],
402 p[3], p[4]);
403 }
404
405 /* if no init_break statement is present in .gdb file we have to check
406 whether to download a breakpoint routine or not */
407
408#if 0
409 if ((es1800_break_vec == 0) || (verify_break (es1800_break_vec) != 0)
410 && query ("No breakpoint routine in ES 1800 emulator!\nDownload a breakpoint routine to the emulator? "))
411 {
412 CORE_ADDR memaddress;
413 printf ("Give the start address of the breakpoint routine: ");
414 scanf ("%li", &memaddress);
415 es1800_init_break ((es1800_break_vec ? es1800_break_vec :
416 ES1800_BREAK_VEC), memaddress);
417 }
418#endif
419
420}
421
422/* Close out all files and local state before this target loses control.
c5aa993b 423 quitting - are we quitting gdb now? */
c906108c
SS
424
425static void
426es1800_close (quitting)
427 int quitting;
428{
429 if (es1800_desc != NULL)
430 {
431 printf ("\nClosing connection to emulator...\n");
432 if (SERIAL_SET_TTY_STATE (es1800_desc, es1800_saved_ttystate) < 0)
433 print_sys_errmsg ("warning: unable to restore tty state", errno);
c2c6d25f 434 fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, es1800_fc_save);
c906108c
SS
435 SERIAL_CLOSE (es1800_desc);
436 es1800_desc = NULL;
437 }
438 if (savename != NULL)
439 {
440 free (savename);
441 }
442 savename = NULL;
443
444#if defined (LOG_FILE)
445
446 if (log_file != NULL)
447 {
448 if (ferror (log_file))
449 {
450 printf ("Error writing log file.\n");
451 }
452 if (fclose (log_file) != 0)
453 {
454 printf ("Error closing log file.\n");
455 }
456 log_file = NULL;
457 }
458
c5aa993b 459#endif /* LOG_FILE */
c906108c
SS
460
461}
462
463/* Attaches to a process on the target side
c5aa993b
JM
464 proc_id - the id of the process to be attached.
465 from_tty - says whether to be verbose or not */
c906108c
SS
466
467static void
468es1800_attach (args, from_tty)
c5aa993b
JM
469 char *args;
470 int from_tty;
c906108c
SS
471{
472 error ("Cannot attach to pid %s, this feature is not implemented yet.",
473 args);
474}
475
476
477/* Takes a program previously attached to and detaches it.
478 We better not have left any breakpoints
479 in the program or it'll die when it hits one.
480 Close the open connection to the remote debugger.
481 Use this when you want to detach and do something else
482 with your gdb.
c5aa993b 483
c906108c
SS
484 args - arguments given to the 'detach' command
485 from_tty - says whether to be verbose or not */
486
487static void
488es1800_detach (args, from_tty)
489 char *args;
490 int from_tty;
491{
492 if (args)
493 {
494 error ("Argument given to \"detach\" when remotely debugging.");
495 }
496 pop_target ();
497 if (from_tty)
498 {
499 printf ("Ending es1800 remote debugging.\n");
500 }
501}
502
503
504/* Tell the remote machine to resume.
505 step - single-step or run free
506 siggnal - the signal value to be given to the target (0 = no signal) */
507
508static void
509es1800_resume (pid, step, siggnal)
510 int pid;
511 int step;
512 enum target_signal siggnal;
513{
514 char buf[PBUFSIZ];
515
516 if (siggnal)
517 {
518 error ("Can't send signals to a remote system.");
519 }
520 if (step)
521 {
c5aa993b 522 strcpy (buf, "STP\r");
c906108c
SS
523 send (buf);
524 }
525 else
526 {
527 send_command ("RBK");
528 }
529}
530
531/* Wait until the remote machine stops, then return,
532 storing status in STATUS just as `wait' would.
533 status - */
c5aa993b 534
c906108c
SS
535static int
536es1800_wait (pid, status)
537 int pid;
538 struct target_waitstatus *status;
539{
540 unsigned char buf[PBUFSIZ];
541 int old_timeout = timeout;
542
543 status->kind = TARGET_WAITKIND_EXITED;
544 status->value.integer = 0;
545
c5aa993b 546 timeout = 0; /* Don't time out -- user program is running. */
c906108c
SS
547 if (!setjmp (interrupt))
548 {
549 old_sigint = signal (SIGINT, es1800_request_quit);
550 while (1)
c5aa993b
JM
551 {
552 getmessage (buf, sizeof (buf));
553 if (strncmp (buf, "\r\n* BREAK *", 11) == 0)
c906108c
SS
554 {
555 status->kind = TARGET_WAITKIND_STOPPED;
556 status->value.sig = TARGET_SIGNAL_TRAP;
557 send_command ("STP"); /* Restore stack and PC and such */
558 if (m68020)
559 {
560 send_command ("STP");
561 }
562 break;
563 }
564 if (strncmp (buf, "STP\r\n ", 6) == 0)
565 {
566 status->kind = TARGET_WAITKIND_STOPPED;
567 status->value.sig = TARGET_SIGNAL_TRAP;
568 break;
569 }
570 if (buf[strlen (buf) - 2] == 'R')
571 {
572 printf ("Unexpected emulator reply: \n%s\n", buf);
573 }
574 else
575 {
576 printf ("Unexpected stop: \n%s\n", buf);
577 status->kind = TARGET_WAITKIND_STOPPED;
578 status->value.sig = TARGET_SIGNAL_QUIT;
579 break;
580 }
c5aa993b 581 }
c906108c
SS
582 }
583 else
584 {
585 fflush (stdin);
586 printf ("\nStopping emulator...");
587 if (!setjmp (interrupt))
588 {
589 old_sigint = signal (SIGINT, es1800_request_quit);
590 send_command ("STP");
591 printf (" emulator stopped\n");
592 status->kind = TARGET_WAITKIND_STOPPED;
593 status->value.sig = TARGET_SIGNAL_INT;
c5aa993b 594 }
c906108c
SS
595 else
596 {
597 fflush (stdin);
c5aa993b 598 es1800_reset ((char *) 1);
c906108c
SS
599 }
600 }
601 signal (SIGINT, old_sigint);
602 timeout = old_timeout;
603 return (0);
604}
605
606
607/* Fetch register values from remote machine.
608 regno - the register to be fetched (fetch all registers if -1) */
609
610static void
611es1800_fetch_register (regno)
612 int regno;
613{
614 char buf[PBUFSIZ];
615 int k;
616 int r;
617 char *p;
c5aa993b
JM
618 static char regtab[18][4] =
619 {
620 "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
621 "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
622 "SR ", "PC "
623 };
c906108c
SS
624
625 if ((regno < 15) || (regno == 16) || (regno == 17))
626 {
627 r = regno * 4;
628 send_with_reply (regtab[regno], buf, sizeof (buf));
629 p = buf;
630 for (k = 0; k < 4; k++)
631 {
c5aa993b 632 if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
c906108c
SS
633 {
634 error ("Emulator reply is too short: %s", buf);
635 }
c5aa993b 636 registers[r++] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
c906108c
SS
637 }
638 }
639 else
640 {
641 es1800_fetch_registers ();
642 }
643}
644
645/* Read the remote registers into REGISTERS.
646 Always fetches all registers. */
647
648static void
649es1800_fetch_registers ()
650{
651 char buf[PBUFSIZ];
652 char SR_buf[PBUFSIZ];
653 int i;
654 int k;
655 int r;
656 char *p;
657
658 send_with_reply ("DR", buf, sizeof (buf));
659
660 /* Reply is edited to a string that describes registers byte by byte,
661 each byte encoded as two hex characters. */
662
663 p = buf;
664 r = 0;
665
666 /* parsing row one - D0-D7-registers */
667
c5aa993b
JM
668 while (*p++ != '\n')
669 {;
670 }
c906108c
SS
671 for (i = 4; i < 70; i += (i == 39 ? 3 : 1))
672 {
673 for (k = 0; k < 4; k++)
674 {
c5aa993b 675 if (p[i + 0] == 0 || p[i + 1] == 0)
c906108c
SS
676 {
677 error ("Emulator reply is too short: %s", buf);
678 }
c5aa993b 679 registers[r++] = (fromhex (p[i + 0]) * 16) + fromhex (p[i + 1]);
c906108c
SS
680 i += 2;
681 }
682 }
683 p += i;
684
685 /* parsing row two - A0-A6-registers */
686
c5aa993b
JM
687 while (*p++ != '\n')
688 {;
689 }
c906108c
SS
690 for (i = 4; i < 61; i += (i == 39 ? 3 : 1))
691 {
692 for (k = 0; k < 4; k++)
693 {
c5aa993b 694 if (p[i + 0] == 0 || p[i + 1] == 0)
c906108c
SS
695 {
696 error ("Emulator reply is too short: %s", buf);
697 }
c5aa993b 698 registers[r++] = (fromhex (p[i + 0])) * 16 + fromhex (p[i + 1]);
c906108c
SS
699 i += 2;
700 }
701 }
702 p += i;
703
c5aa993b
JM
704 while (*p++ != '\n')
705 {;
706 }
c906108c
SS
707
708 /* fetch SSP-, SR- and PC-registers */
709
710 /* first - check STATUS-word and decide which stackpointer to use */
711
712 send_with_reply ("SR", SR_buf, sizeof (SR_buf));
713 p = SR_buf;
714 p += 5;
715
716 if (m68020)
717 {
c5aa993b 718 if (*p == '3') /* use masterstackpointer MSP */
c906108c
SS
719 {
720 send_with_reply ("MSP", buf, sizeof (buf));
721 }
722 else if (*p == '2') /* use interruptstackpointer ISP */
723 {
724 send_with_reply ("ISP", buf, sizeof (buf));
725 }
c5aa993b
JM
726 else
727 /* use userstackpointer USP */
c906108c 728 {
c5aa993b 729 send_with_reply ("USP", buf, sizeof (buf));
c906108c
SS
730 }
731 p = buf;
c5aa993b 732 for (k = 0; k < 4; k++)
c906108c 733 {
c5aa993b 734 if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
c906108c
SS
735 {
736 error ("Emulator reply is too short: %s", buf);
737 }
c5aa993b 738 registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
c906108c
SS
739 }
740
741 p = SR_buf;
742 for (k = 0; k < 4; k++)
743 {
c5aa993b 744 if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
c906108c
SS
745 {
746 error ("Emulator reply is too short: %s", buf);
747 }
748 registers[r++] =
c5aa993b 749 fromhex (SR_buf[k * 2 + 1]) * 16 + fromhex (SR_buf[k * 2 + 2]);
c906108c
SS
750 }
751 send_with_reply ("PC", buf, sizeof (buf));
752 p = buf;
c5aa993b 753 for (k = 0; k < 4; k++)
c906108c 754 {
c5aa993b 755 if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
c906108c
SS
756 {
757 error ("Emulator reply is too short: %s", buf);
758 }
c5aa993b 759 registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
c906108c
SS
760 }
761 }
c5aa993b
JM
762 else
763 /* 68000-mode */
764 {
765 if (*p == '2') /* use supervisorstackpointer SSP */
c906108c 766 {
c5aa993b 767 send_with_reply ("SSP", buf, sizeof (buf));
c906108c 768 }
c5aa993b
JM
769 else
770 /* use userstackpointer USP */
c906108c 771 {
c5aa993b 772 send_with_reply ("USP", buf, sizeof (buf));
c906108c
SS
773 }
774
775 /* fetch STACKPOINTER */
776
777 p = buf;
778 for (k = 0; k < 4; k++)
779 {
c5aa993b 780 if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
c906108c
SS
781 {
782 error ("Emulator reply is too short: %s", buf);
783 }
c5aa993b 784 registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
c906108c
SS
785 }
786
787 /* fetch STATUS */
788
789 p = SR_buf;
790 for (k = 0; k < 4; k++)
791 {
c5aa993b 792 if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
c906108c
SS
793 {
794 error ("Emulator reply is too short: %s", buf);
795 }
796 registers[r++] =
c5aa993b 797 fromhex (SR_buf[k * 2 + 1]) * 16 + fromhex (SR_buf[k * 2 + 2]);
c906108c
SS
798 }
799
800 /* fetch PC */
801
c5aa993b 802 send_with_reply ("PC", buf, sizeof (buf));
c906108c
SS
803 p = buf;
804 for (k = 0; k < 4; k++)
805 {
c5aa993b 806 if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
c906108c
SS
807 {
808 error ("Emulator reply is too short: %s", buf);
809 }
c5aa993b
JM
810 registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
811 }
c906108c
SS
812 }
813}
814
815/* Store register value, located in REGISTER, on the target processor.
816 regno - the register-number of the register to store
c5aa993b 817 (-1 means store them all)
c906108c
SS
818 FIXME: Return errno value. */
819
820static void
c5aa993b 821es1800_store_register (regno)
c906108c
SS
822 int regno;
823{
824
825 static char regtab[18][4] =
c5aa993b
JM
826 {
827 "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
828 "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
829 "SR ", "PC "
830 };
c906108c
SS
831
832 char buf[PBUFSIZ];
833 char SR_buf[PBUFSIZ];
834 char stack_pointer[4];
835 char *p;
836 int i;
837 int j;
838 int k;
839 unsigned char *r;
840
841 r = (unsigned char *) registers;
842
c5aa993b 843 if (regno == -1) /* write all registers */
c906108c
SS
844 {
845 j = 0;
846 k = 18;
847 }
c5aa993b
JM
848 else
849 /* write one register */
c906108c
SS
850 {
851 j = regno;
c5aa993b
JM
852 k = regno + 1;
853 r += regno * 4;
854 }
c906108c
SS
855
856 if ((regno == -1) || (regno == 15))
857 {
858 /* fetch current status */
859 send_with_reply ("SR", SR_buf, sizeof (SR_buf));
860 p = SR_buf;
861 p += 5;
862 if (m68020)
863 {
c5aa993b 864 if (*p == '3') /* use masterstackpointer MSP */
c906108c 865 {
c5aa993b 866 strcpy (stack_pointer, "MSP");
c906108c
SS
867 }
868 else
869 {
c5aa993b 870 if (*p == '2') /* use interruptstackpointer ISP */
c906108c 871 {
c5aa993b 872 strcpy (stack_pointer, "ISP");
c906108c
SS
873 }
874 else
875 {
c5aa993b 876 strcpy (stack_pointer, "USP"); /* use userstackpointer USP */
c906108c
SS
877 }
878 }
879 }
c5aa993b
JM
880 else
881 /* 68000-mode */
c906108c 882 {
c5aa993b 883 if (*p == '2') /* use supervisorstackpointer SSP */
c906108c 884 {
c5aa993b 885 strcpy (stack_pointer, "SSP");
c906108c
SS
886 }
887 else
888 {
c5aa993b 889 strcpy (stack_pointer, "USP"); /* use userstackpointer USP */
c906108c
SS
890 }
891 }
c5aa993b 892 strcpy (regtab[15], stack_pointer);
c906108c
SS
893 }
894
c5aa993b 895 for (i = j; i < k; i++)
c906108c
SS
896 {
897 buf[0] = regtab[i][0];
898 buf[1] = regtab[i][1];
899 buf[2] = regtab[i][2];
900 buf[3] = '=';
901 buf[4] = '$';
902 buf[5] = tohex ((*r >> 4) & 0x0f);
903 buf[6] = tohex (*r++ & 0x0f);
904 buf[7] = tohex ((*r >> 4) & 0x0f);
905 buf[8] = tohex (*r++ & 0x0f);
906 buf[9] = tohex ((*r >> 4) & 0x0f);
907 buf[10] = tohex (*r++ & 0x0f);
908 buf[11] = tohex ((*r >> 4) & 0x0f);
909 buf[12] = tohex (*r++ & 0x0f);
910 buf[13] = 0;
911
c5aa993b 912 send_with_reply (buf, buf, sizeof (buf)); /* FIXME, reply not used? */
c906108c
SS
913 }
914}
915
916
917/* Prepare to store registers. */
918
c5aa993b 919static void
c906108c
SS
920es1800_prepare_to_store ()
921{
922 /* Do nothing, since we can store individual regs */
923}
924
925/* Convert hex digit A to a number. */
926
927static int
928fromhex (a)
929 int a;
930{
931 if (a >= '0' && a <= '9')
932 {
933 return a - '0';
934 }
935 else if (a >= 'a' && a <= 'f')
936 {
937 return a - 'a' + 10;
938 }
939 else if (a >= 'A' && a <= 'F')
940 {
941 return a - 'A' + 10;
942 }
943 else
944 {
945 error ("Reply contains invalid hex digit");
946 }
947 return (-1);
948}
949
950
951/* Convert number NIB to a hex digit. */
952
953static int
954tohex (nib)
955 int nib;
956{
957 if (nib < 10)
958 {
959 return ('0' + nib);
960 }
961 else
962 {
963 return ('A' + nib - 10);
964 }
965}
966
967/* Read or write LEN bytes from inferior memory at MEMADDR, transferring
968 to or from debugger address MYADDR. Write to inferior if WRITE is
969 nonzero. Returns length of data written or read; 0 for error.
c5aa993b 970
c906108c
SS
971 memaddr - the target's address
972 myaddr - gdb's address
973 len - number of bytes
c5aa993b 974 write - write if != 0 otherwise read */
c906108c
SS
975
976static int
977es1800_xfer_inferior_memory (memaddr, myaddr, len, write, tops)
978 CORE_ADDR memaddr;
979 char *myaddr;
980 int len;
981 int write;
982 struct target_ops *tops; /* Unused */
983{
984 int origlen = len;
985 int xfersize;
986
987 while (len > 0)
988 {
989 xfersize = len > MAXBUFBYTES ? MAXBUFBYTES : len;
990 if (write)
991 {
992 es1800_write_bytes (memaddr, myaddr, xfersize);
993 }
994 else
995 {
996 es1800_read_bytes (memaddr, myaddr, xfersize);
997 }
998 memaddr += xfersize;
999 myaddr += xfersize;
1000 len -= xfersize;
1001 }
c5aa993b 1002 return (origlen); /* no error possible */
c906108c
SS
1003}
1004
1005
1006/* Write memory data directly to the emulator.
1007 This does not inform the data cache; the data cache uses this.
1008 MEMADDR is the address in the remote memory space.
1009 MYADDR is the address of the buffer in our space.
1010 LEN is the number of bytes.
c5aa993b 1011
c906108c
SS
1012 memaddr - the target's address
1013 myaddr - gdb's address
1014 len - number of bytes */
1015
1016static void
1017es1800_write_bytes (memaddr, myaddr, len)
1018 CORE_ADDR memaddr;
1019 char *myaddr;
1020 int len;
1021{
1022 char buf[PBUFSIZ];
1023 int i;
1024 char *p;
1025
1026 p = myaddr;
1027 for (i = 0; i < len; i++)
1028 {
c5aa993b
JM
1029 sprintf (buf, "@.B$%x=$%x", memaddr + i, (*p++) & 0xff);
1030 send_with_reply (buf, buf, sizeof (buf)); /* FIXME send_command? */
c906108c
SS
1031 }
1032}
1033
1034
1035/* Read memory data directly from the emulator.
1036 This does not use the data cache; the data cache uses this.
c5aa993b 1037
c906108c
SS
1038 memaddr - the target's address
1039 myaddr - gdb's address
1040 len - number of bytes */
1041
1042static void
1043es1800_read_bytes (memaddr, myaddr, len)
1044 CORE_ADDR memaddr;
1045 char *myaddr;
1046 int len;
1047{
c5aa993b
JM
1048 static int DB_tab[16] =
1049 {8, 11, 14, 17, 20, 23, 26, 29, 34, 37, 40, 43, 46, 49, 52, 55};
c906108c
SS
1050 char buf[PBUFSIZ];
1051 int i;
1052 int low_addr;
1053 char *p;
1054 char *b;
1055
1056 if (len > PBUFSIZ / 2 - 1)
1057 {
1058 abort ();
1059 }
1060
c5aa993b 1061 if (len == 1) /* The emulator does not like expressions like: */
c906108c 1062 {
c5aa993b 1063 len = 2; /* DB.B $20018 TO $20018 */
c906108c
SS
1064 }
1065
1066 /* Reply describes registers byte by byte, each byte encoded as two hex
1067 characters. */
1068
c5aa993b 1069 sprintf (buf, "DB.B $%x TO $%x", memaddr, memaddr + len - 1);
c906108c
SS
1070 send_with_reply (buf, buf, sizeof (buf));
1071 b = buf;
c5aa993b 1072 low_addr = memaddr & 0x0f;
c906108c
SS
1073 for (i = low_addr; i < low_addr + len; i++)
1074 {
1075 if ((!(i % 16)) && i)
c5aa993b
JM
1076 { /* if (i = 16,32,48) */
1077 while (*p++ != '\n')
1078 {;
1079 }
c906108c
SS
1080 b = p;
1081 }
c5aa993b 1082 p = b + DB_tab[i % 16] + (m68020 ? 2 : 0);
c906108c
SS
1083 if (p[0] == 32 || p[1] == 32)
1084 {
1085 error ("Emulator reply is too short: %s", buf);
1086 }
c5aa993b 1087 myaddr[i - low_addr] = fromhex (p[0]) * 16 + fromhex (p[1]);
c906108c
SS
1088 }
1089}
1090
1091/* Information about the current target */
1092
1093static void
1094es1800_files_info (tops)
1095 struct target_ops *tops; /* Unused */
1096{
1097 printf ("ES1800 Attached to %s at %d baud in %s mode\n", savename, 19200,
1098 MODE);
1099}
1100
1101
1102/* We read the contents of the target location and stash it,
1103 then overwrite it with a breakpoint instruction.
c5aa993b 1104
c906108c
SS
1105 addr - is the target location in the target machine.
1106 contents_cache - is a pointer to memory allocated for saving the target contents.
c5aa993b
JM
1107 It is guaranteed by the caller to be long enough to save sizeof
1108 BREAKPOINT bytes.
1109
c906108c
SS
1110 FIXME: This size is target_arch dependent and should be available in
1111 the target_arch transfer vector, if we ever have one... */
1112
1113static int
1114es1800_insert_breakpoint (addr, contents_cache)
1115 CORE_ADDR addr;
1116 char *contents_cache;
1117{
c5aa993b 1118 int val;
c906108c
SS
1119
1120 val = target_read_memory (addr, contents_cache, sizeof (es1800_break_insn));
1121
1122 if (val == 0)
1123 {
1124 val = target_write_memory (addr, es1800_break_insn,
1125 sizeof (es1800_break_insn));
1126 }
1127
1128 return (val);
1129}
1130
1131
1132/* Write back the stashed instruction
c5aa993b 1133
c906108c
SS
1134 addr - is the target location in the target machine.
1135 contents_cache - is a pointer to memory allocated for saving the target contents.
c5aa993b
JM
1136 It is guaranteed by the caller to be long enough to save sizeof
1137 BREAKPOINT bytes. */
1138
c906108c
SS
1139static int
1140es1800_remove_breakpoint (addr, contents_cache)
1141 CORE_ADDR addr;
1142 char *contents_cache;
1143{
1144
1145 return (target_write_memory (addr, contents_cache,
1146 sizeof (es1800_break_insn)));
1147}
1148
1149/* create_break_insn ()
1150 Primitive datastructures containing the es1800 breakpoint instruction */
1151
1152static void
1153es1800_create_break_insn (ins, vec)
1154 char *ins;
1155 int vec;
1156{
1157 if (vec == 15)
1158 {
1159 ins[0] = 0x4e;
1160 ins[1] = 0x4f;
1161 }
1162}
1163
1164
1165/* verify_break ()
1166 Seach for breakpoint routine in emulator memory.
1167 returns non-zero on failure
1168 vec - trap vector used for breakpoints */
1169
1170static int
1171verify_break (vec)
1172 int vec;
1173{
1174 CORE_ADDR memaddress;
1175 char buf[8];
c5aa993b 1176 char *instr = "NqNqNqNs"; /* breakpoint routine */
c906108c
SS
1177 int status;
1178
1179 get_break_addr (vec, &memaddress);
1180
1181 if (memaddress)
1182 {
c5aa993b 1183 status = target_read_memory (memaddress, buf, 8);
c906108c
SS
1184 if (status != 0)
1185 {
1186 memory_error (status, memaddress);
1187 }
1188 return (STRCMP (instr, buf));
1189 }
c5aa993b 1190 return (-1);
c906108c
SS
1191}
1192
1193
1194/* get_break_addr ()
1195 find address of breakpint routine
1196 vec - trap vector used for breakpoints
c5aa993b 1197 addrp - store the address here */
c906108c
SS
1198
1199static void
1200get_break_addr (vec, addrp)
1201 int vec;
1202 CORE_ADDR *addrp;
1203{
1204 CORE_ADDR memaddress = 0;
1205 int status;
1206 int k;
1207 char buf[PBUFSIZ];
1208 char base_addr[4];
1209 char *p;
1210
1211 if (m68020)
1212 {
1213 send_with_reply ("VBR ", buf, sizeof (buf));
1214 p = buf;
1215 for (k = 0; k < 4; k++)
1216 {
c5aa993b 1217 if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
c906108c
SS
1218 {
1219 error ("Emulator reply is too short: %s", buf);
1220 }
c5aa993b 1221 base_addr[k] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
c906108c
SS
1222 }
1223 /* base addr of exception vector table */
1224 memaddress = *((CORE_ADDR *) base_addr);
1225 }
1226
c5aa993b
JM
1227 memaddress += (vec + 32) * 4; /* address of trap vector */
1228 status = target_read_memory (memaddress, (char *) addrp, 4);
1229 if (status != 0)
1230 {
1231 memory_error (status, memaddress);
1232 }
c906108c
SS
1233}
1234
1235
1236/* Kill an inferior process */
1237
1238static void
1239es1800_kill ()
1240{
1241 if (inferior_pid != 0)
1242 {
1243 inferior_pid = 0;
1244 es1800_mourn_inferior ();
1245 }
1246}
1247
1248
1249/* Load a file to the ES1800 emulator.
1250 Converts the file from a.out format into Extended Tekhex format
1251 before the file is loaded.
1252 Also loads the trap routine, and sets the ES1800 breakpoint on it
1253 filename - the a.out to be loaded
1254 from_tty - says whether to be verbose or not
c5aa993b
JM
1255 FIXME Uses emulator overlay memory for trap routine */
1256
c906108c
SS
1257static void
1258es1800_load (filename, from_tty)
1259 char *filename;
1260 int from_tty;
1261{
1262
1263 FILE *instream;
1264 char loadname[15];
1265 char buf[160];
1266 struct cleanup *old_chain;
1267 int es1800_load_format = 5;
1268
c5aa993b 1269 if (es1800_desc == NULL)
c906108c
SS
1270 {
1271 printf ("No emulator attached, type emulator-command first\n");
1272 return;
1273 }
1274
1275 filename = tilde_expand (filename);
1276 make_cleanup (free, filename);
1277
1278 switch (es1800_load_format)
1279 {
c5aa993b
JM
1280 case 2: /* Extended Tekhex */
1281 if (from_tty)
1282 {
1283 printf ("Converting \"%s\" to Extended Tekhex Format\n", filename);
1284 }
1285 sprintf (buf, "tekhex %s", filename);
1286 system (buf);
1287 sprintf (loadname, "out.hex");
1288 break;
1289
1290 case 5: /* Motorola S-rec */
1291 if (from_tty)
1292 {
1293 printf ("Converting \"%s\" to Motorola S-record format\n",
1294 filename);
1295 }
1296 /* in the future the source code in copy (part of binutils-1.93) will
1297 be included in this file */
1298 sprintf (buf,
1299 "copy -s \"a.out-sunos-big\" -d \"srec\" %s /tmp/out.hex",
1300 filename);
1301 system (buf);
1302 sprintf (loadname, "/tmp/out.hex");
1303 break;
1304
1305 default:
1306 error ("Downloading format not defined\n");
1307 }
1308
c906108c
SS
1309 breakpoint_init_inferior ();
1310 inferior_pid = 0;
1311 if (from_tty)
1312 {
c5aa993b 1313 printf ("Downloading \"%s\" to the ES 1800\n", filename);
c906108c
SS
1314 }
1315 if ((instream = fopen (loadname, "r")) == NULL)
1316 {
1317 perror_with_name ("fopen:");
1318 }
1319
1320 old_chain = make_cleanup (fclose, instream);
1321 immediate_quit++;
1322
1323 es1800_reset (0);
1324
1325 download (instream, from_tty, es1800_load_format);
1326
1327 /* if breakpoint routine is not present anymore we have to check
1328 whether to download a new breakpoint routine or not */
1329
1330 if ((verify_break (es1800_break_vec) != 0)
1331 && query ("No breakpoint routine in ES 1800 emulator!\nDownload a breakpoint routine to the emulator? "))
1332 {
1333 char buf[128];
1334 printf ("Using break vector 0x%x\n", es1800_break_vec);
1335 sprintf (buf, "0x%x ", es1800_break_vec);
1336 printf ("Give the start address of the breakpoint routine: ");
1337 fgets (buf + strlen (buf), sizeof (buf) - strlen (buf), stdin);
1338 es1800_init_break (buf, 0);
1339 }
1340
1341 do_cleanups (old_chain);
1342 expect_prompt ();
c5aa993b 1343 readchar (); /* FIXME I am getting a ^G = 7 after the prompt */
c906108c
SS
1344 printf ("\n");
1345
1346 if (fclose (instream) == EOF)
1347 {
1348 ;
1349 }
1350
1351 if (es1800_load_format != 2)
1352 {
1353 sprintf (buf, "/usr/bin/rm %s", loadname);
1354 system (buf);
1355 }
1356
c5aa993b 1357 symbol_file_command (filename, from_tty); /* reading symbol table */
c906108c
SS
1358 immediate_quit--;
1359}
1360
1361#if 0
1362
1363#define NUMCPYBYTES 20
1364
1365static void
1366bfd_copy (from_bfd, to_bfd)
1367 bfd *from_bfd;
1368 bfd *to_bfd;
1369{
1370 asection *p, *new;
1371 int i;
1372 char buf[NUMCPYBYTES];
1373
1374 for (p = from_bfd->sections; p != NULL; p = p->next)
1375 {
1376 printf (" Copying section %s. Size = %x.\n", p->name, p->_cooked_size);
1377 printf (" vma = %x, offset = %x, output_sec = %x\n",
1378 p->vma, p->output_offset, p->output_section);
1379 new = bfd_make_section (to_bfd, p->name);
1380 if (p->_cooked_size &&
1381 !bfd_set_section_size (to_bfd, new, p->_cooked_size))
1382 {
1383 error ("Wrong BFD size!\n");
1384 }
1385 if (!bfd_set_section_flags (to_bfd, new, p->flags))
1386 {
1387 error ("bfd_set_section_flags");
1388 }
1389 new->vma = p->vma;
c5aa993b
JM
1390
1391 for (i = 0; (i + NUMCPYBYTES) < p->_cooked_size; i += NUMCPYBYTES)
c906108c
SS
1392 {
1393 if (!bfd_get_section_contents (from_bfd, p, (PTR) buf, (file_ptr) i,
c5aa993b 1394 (bfd_size_type) NUMCPYBYTES))
c906108c
SS
1395 {
1396 error ("bfd_get_section_contents\n");
1397 }
c5aa993b
JM
1398 if (!bfd_set_section_contents (to_bfd, new, (PTR) buf, (file_ptr) i,
1399 (bfd_size_type) NUMCPYBYTES))
1400 {
1401 error ("bfd_set_section_contents\n");
1402 }
1403 }
c906108c
SS
1404 bfd_get_section_contents (from_bfd, p, (PTR) buf, (file_ptr) i,
1405 (bfd_size_type) (p->_cooked_size - i));
c5aa993b 1406 bfd_set_section_contents (to_bfd, new, (PTR) buf, (file_ptr) i,
c906108c
SS
1407 (bfd_size_type) (p->_cooked_size - i));
1408 }
1409}
1410
1411#endif
1412
1413/* Start an process on the es1800 and set inferior_pid to the new
1414 process' pid.
1415 execfile - the file to run
1416 args - arguments passed to the program
c5aa993b 1417 env - the environment vector to pass */
c906108c
SS
1418
1419static void
1420es1800_create_inferior (execfile, args, env)
1421 char *execfile;
1422 char *args;
1423 char **env;
1424{
1425 int entry_pt;
1426 int pid;
1427#if 0
1428 struct expression *expr;
1429 register struct cleanup *old_chain = 0;
1430 register value val;
1431#endif
1432
1433 if (args && *args)
1434 {
1435 error ("Can't pass arguments to remote ES1800 process");
1436 }
1437
1438#if 0
1439 if (query ("Use 'start' as entry point? "))
1440 {
1441 expr = parse_c_expression ("start");
1442 old_chain = make_cleanup (free_current_contents, &expr);
1443 val = evaluate_expression (expr);
1444 entry_pt = (val->location).address;
1445 }
1446 else
1447 {
1448 printf ("Enter the program's entry point (in hexadecimal): ");
1449 scanf ("%x", &entry_pt);
1450 }
1451#endif
1452
1453 if (execfile == 0 || exec_bfd == 0)
1454 {
1455 error ("No executable file specified");
1456 }
1457
1458 entry_pt = (int) bfd_get_start_address (exec_bfd);
1459
1460 pid = 42;
1461
1462 /* Now that we have a child process, make it our target. */
1463
1464 push_target (&es1800_child_ops);
1465
1466 /* The "process" (board) is already stopped awaiting our commands, and
1467 the program is already downloaded. We just set its PC and go. */
1468
1469 inferior_pid = pid; /* Needed for wait_for_inferior below */
1470
1471 clear_proceed_status ();
1472
1473 /* Tell wait_for_inferior that we've started a new process. */
1474
1475 init_wait_for_inferior ();
1476
1477 /* Set up the "saved terminal modes" of the inferior
1478 based on what modes we are starting it with. */
1479
1480 target_terminal_init ();
1481
1482 /* Install inferior's terminal modes. */
1483
1484 target_terminal_inferior ();
1485
1486 /* remote_start (args); */
1487 /* trap_expected = 0; */
1488 /* insert_step_breakpoint (); FIXME, do we need this? */
1489
1490 /* Let 'er rip... */
1491 proceed ((CORE_ADDR) entry_pt, TARGET_SIGNAL_DEFAULT, 0);
1492
1493}
1494
1495
1496/* The process has died, clean up. */
1497
1498static void
1499es1800_mourn_inferior ()
1500{
1501 remove_breakpoints ();
1502 unpush_target (&es1800_child_ops);
1503 generic_mourn_inferior (); /* Do all the proper things now */
1504}
1505
1506/* ES1800-protocol specific routines */
1507
1508/* Keep discarding input from the remote system, until STRING is found.
1509 Let the user break out immediately.
1510 string - the string to expect
1511 nowait - break out if string not the emulator's first respond otherwise
c5aa993b
JM
1512 read until string is found (== 0) */
1513
c906108c
SS
1514static void
1515expect (string, nowait)
1516 char *string;
c5aa993b 1517 int nowait;
c906108c
SS
1518{
1519 char c;
1520 char *p = string;
1521
1522 immediate_quit++;
1523 while (1)
1524 {
1525 c = readchar ();
1526 if (isalpha (c))
1527 {
1528 c = toupper (c);
1529 }
1530 if (c == toupper (*p))
1531 {
1532 p++;
1533 if (*p == '\0')
1534 {
1535 immediate_quit--;
1536 return;
1537 }
1538 }
1539 else if (!nowait)
1540 {
1541 p = string;
1542 }
1543 else
1544 {
c5aa993b 1545 printf ("\'%s\' expected\n", string);
c906108c 1546 printf ("char %d is %d", p - string, c);
c5aa993b 1547 error ("\n");
c906108c
SS
1548 }
1549 }
1550}
1551
1552/* Keep discarding input until we see the prompt. */
1553
1554static void
1555expect_prompt ()
1556{
1557 expect (">", 0);
1558}
1559
1560
1561/* Read one character */
1562
1563#ifdef DEBUG_STDIN
1564
1565/* read from stdin */
1566
1567static int
1568readchar ()
1569{
1570 char buf[1];
1571
1572 buf[0] = '\0';
1573 printf ("readchar, give one character\n");
1574 read (0, buf, 1);
1575
1576#if defined (LOG_FILE)
1577 putc (buf[0] & 0x7f, log_file);
1578#endif
1579
1580 return (buf[0] & 0x7f);
1581}
1582
c5aa993b 1583#else /* !DEBUG_STDIN */
c906108c
SS
1584
1585/* Read a character from the remote system, doing all the fancy
1586 timeout stuff. */
1587
1588static int
1589readchar ()
1590{
1591 int ch;
1592
1593 ch = SERIAL_READCHAR (es1800_desc, timeout);
1594
1595 /* FIXME: doing an error() here will probably cause trouble, at least if from
1596 es1800_wait. */
1597 if (ch == SERIAL_TIMEOUT)
1598 error ("Timeout reading from remote system.");
1599 else if (ch == SERIAL_ERROR)
1600 perror_with_name ("remote read");
1601
1602#if defined (LOG_FILE)
1603 putc (ch & 0x7f, log_file);
1604 fflush (log_file);
1605#endif
1606
1607 return (ch);
1608}
1609
c5aa993b 1610#endif /* DEBUG_STDIN */
c906108c
SS
1611
1612
1613/* Send a command to the emulator and save the reply.
1614 Report an error if we get an error reply.
1615 string - the es1800 command
1616 buf - containing the emulator reply on return
1617 len - size of buf */
1618
1619static void
1620send_with_reply (string, buf, len)
c5aa993b
JM
1621 char *string, *buf;
1622 int len;
c906108c
SS
1623{
1624 send (string);
1625 SERIAL_WRITE (es1800_desc, "\r", 1);
1626
1627#ifndef DEBUG_STDIN
1628 expect (string, 1);
1629 expect ("\r\n", 0);
1630#endif
1631
1632 getmessage (buf, len);
1633}
1634
1635
1636/* Send the command in STR to the emulator adding \r. check
1637 the echo for consistency.
1638 string - the es1800 command */
c5aa993b 1639
c906108c
SS
1640static void
1641send_command (string)
1642 char *string;
1643{
1644 send (string);
1645 SERIAL_WRITE (es1800_desc, "\r", 1);
1646
1647#ifndef DEBUG_STDIN
1648 expect (string, 0);
1649 expect_prompt ();
1650#endif
1651
1652}
1653
1654/* Send a string
1655 string - the es1800 command */
1656
1657static void
1658send (string)
1659 char *string;
1660{
c5aa993b 1661 if (kiodebug)
c906108c
SS
1662 {
1663 fprintf (stderr, "Sending: %s\n", string);
1664 }
1665 SERIAL_WRITE (es1800_desc, string, strlen (string));
1666}
1667
1668
1669/* Read a message from the emulator and store it in BUF.
1670 buf - containing the emulator reply on return
1671 len - size of buf */
c5aa993b 1672
c906108c
SS
1673static void
1674getmessage (buf, len)
1675 char *buf;
1676 int len;
1677{
1678 char *bp;
1679 int c;
1680 int prompt_found = 0;
1681 extern kiodebug;
1682
1683#if defined (LOG_FILE)
1684 /* This is a convenient place to do this. The idea is to do it often
1685 enough that we never lose much data if we terminate abnormally. */
1686 fflush (log_file);
1687#endif
1688
1689 bp = buf;
1690 c = readchar ();
1691 do
1692 {
c5aa993b 1693 if (c)
c906108c 1694 {
c5aa993b 1695 if (len-- < 2) /* char and terminaling NULL */
c906108c
SS
1696 {
1697 error ("input buffer overrun\n");
1698 }
1699 *bp++ = c;
1700 }
1701 c = readchar ();
1702 if ((c == '>') && (*(bp - 1) == ' '))
1703 {
1704 prompt_found = 1;
1705 }
1706 }
1707 while (!prompt_found);
1708 *bp = 0;
c5aa993b 1709
c906108c
SS
1710 if (kiodebug)
1711 {
c5aa993b 1712 fprintf (stderr, "message received :%s\n", buf);
c906108c
SS
1713 }
1714}
1715
1716static void
1717download (instream, from_tty, format)
c5aa993b 1718 FILE *instream;
c906108c
SS
1719 int from_tty;
1720 int format;
1721{
1722 char c;
1723 char buf[160];
1724 int i = 0;
1725
c5aa993b
JM
1726 send_command ("SET #2,$1A"); /* reset char = ^Z */
1727 send_command ("SET #3,$11,$13"); /* XON XOFF */
c906108c
SS
1728 if (format == 2)
1729 {
1730 send_command ("SET #26,#2");
1731 }
1732 else
1733 {
c5aa993b 1734 send_command ("SET #26,#5"); /* Format=Extended Tekhex */
c906108c
SS
1735 }
1736 send_command ("DFB = $10");
1737 send_command ("PUR");
1738 send_command ("CES");
1739 send ("DNL\r");
1740 expect ("DNL", 1);
1741 if (from_tty)
1742 {
1743 printf (" 0 records loaded...\r");
1744 }
1745 while (fgets (buf, 160, instream))
c5aa993b
JM
1746 {
1747 send (buf);
1748 if (from_tty)
1749 {
1750 printf ("%5d\b\b\b\b\b", ++i);
1751 fflush (stdout);
1752 }
1753 if ((c = readchar ()) != 006)
1754 {
1755 error ("expected ACK");
1756 }
1757 }
c906108c
SS
1758 if (from_tty)
1759 {
1760 printf ("- All");
1761 }
1762}
1763
1764/* Additional commands */
1765
1766#if defined (TIOCGETP) && defined (FNDELAY) && defined (EWOULDBLOCK)
1767#define PROVIDE_TRANSPARENT
1768#endif
1769
1770#ifdef PROVIDE_TRANSPARENT
1771/* Talk directly to the emulator
1772 FIXME, uses busy wait, and is SUNOS (or at least BSD) specific */
1773
c5aa993b
JM
1774/*ARGSUSED */
1775static void
c906108c
SS
1776es1800_transparent (args, from_tty)
1777 char *args;
1778 int from_tty;
1779{
1780 int console;
1781 struct sgttyb modebl;
1782 int fcflag;
1783 int cc;
1784 struct sgttyb console_mode_save;
1785 int console_fc_save;
1786 int es1800_fc_save;
1787 int inputcnt = 80;
1788 char inputbuf[80];
1789 int consolecnt = 0;
1790 char consolebuf[80];
1791 int es1800_cnt = 0;
1792 char es1800_buf[80];
1793 int i;
1794
1795 dont_repeat ();
c5aa993b 1796 if (es1800_desc == NULL)
c906108c
SS
1797 {
1798 printf ("No emulator attached, type emulator-command first\n");
1799 return;
1800 }
1801
1802 printf ("\n");
1803 printf ("You are now communicating directly with the ES 1800 emulator.\n");
1804 printf ("To leave this mode (transparent mode), press ^E.\n");
1805 printf ("\n");
1806 printf (" >");
1807 fflush (stdout);
1808
c5aa993b 1809 if ((console = open ("/dev/tty", O_RDWR)) == -1)
c906108c
SS
1810 {
1811 perror_with_name ("/dev/tty:");
1812 }
1813
1814 if ((fcflag = fcntl (console, F_GETFL, 0)) == -1)
1815 {
1816 perror_with_name ("fcntl console");
1817 }
1818
1819 console_fc_save = fcflag;
1820 fcflag = fcflag | FNDELAY;
1821
1822 if (fcntl (console, F_SETFL, fcflag) == -1)
1823 {
1824 perror_with_name ("fcntl console");
1825 }
1826
1827 if (ioctl (console, TIOCGETP, &modebl))
1828 {
1829 perror_with_name ("ioctl console");
1830 }
1831
1832 console_mode_save = modebl;
c5aa993b 1833 modebl.sg_flags = RAW;
c906108c
SS
1834
1835 if (ioctl (console, TIOCSETP, &modebl))
1836 {
1837 perror_with_name ("ioctl console");
1838 }
1839
c2c6d25f 1840 if ((fcflag = fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_GETFL, 0)) == -1)
c906108c
SS
1841 {
1842 perror_with_name ("fcntl serial");
1843 }
1844
1845 es1800_fc_save = fcflag;
1846 fcflag = fcflag | FNDELAY;
1847
c2c6d25f 1848 if (fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, fcflag) == -1)
c906108c
SS
1849 {
1850 perror_with_name ("fcntl serial");
1851 }
1852
1853 while (1)
c5aa993b 1854 {
c906108c
SS
1855 cc = read (console, inputbuf, inputcnt);
1856 if (cc != -1)
1857 {
1858 if ((*inputbuf & 0x7f) == 0x05)
1859 {
1860 break;
1861 }
c5aa993b 1862 for (i = 0; i < cc;)
c906108c
SS
1863 {
1864 es1800_buf[es1800_cnt++] = inputbuf[i++];
1865 }
1866 if ((cc = SERIAL_WRITE (es1800_desc, es1800_buf, es1800_cnt)) == -1)
1867 {
1868 perror_with_name ("FEL! write:");
1869 }
1870 es1800_cnt -= cc;
c5aa993b 1871 if (es1800_cnt && cc)
c906108c
SS
1872 {
1873 for (i = 0; i < es1800_cnt; i++)
1874 {
c5aa993b 1875 es1800_buf[i] = es1800_buf[cc + i];
c906108c
SS
1876 }
1877 }
1878 }
1879 else if (errno != EWOULDBLOCK)
1880 {
1881 perror_with_name ("FEL! read:");
1882 }
c5aa993b 1883
c2c6d25f 1884 cc = read (DEPRECATED_SERIAL_FD (es1800_desc), inputbuf, inputcnt);
c906108c
SS
1885 if (cc != -1)
1886 {
c5aa993b 1887 for (i = 0; i < cc;)
c906108c
SS
1888 {
1889 consolebuf[consolecnt++] = inputbuf[i++];
1890 }
c5aa993b 1891 if ((cc = write (console, consolebuf, consolecnt)) == -1)
c906108c
SS
1892 {
1893 perror_with_name ("FEL! write:");
1894 }
1895 consolecnt -= cc;
c5aa993b 1896 if (consolecnt && cc)
c906108c
SS
1897 {
1898 for (i = 0; i < consolecnt; i++)
1899 {
c5aa993b 1900 consolebuf[i] = consolebuf[cc + i];
c906108c
SS
1901 }
1902 }
1903 }
1904 else if (errno != EWOULDBLOCK)
1905 {
1906 perror_with_name ("FEL! read:");
1907 }
1908 }
1909
1910 console_fc_save = console_fc_save & !FNDELAY;
1911 if (fcntl (console, F_SETFL, console_fc_save) == -1)
1912 {
1913 perror_with_name ("FEL! fcntl");
1914 }
1915
1916 if (ioctl (console, TIOCSETP, &console_mode_save))
1917 {
1918 perror_with_name ("FEL! ioctl");
1919 }
1920
1921 close (console);
1922
c2c6d25f 1923 if (fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, es1800_fc_save) == -1)
c906108c
SS
1924 {
1925 perror_with_name ("FEL! fcntl");
1926 }
1927
1928 printf ("\n");
1929
1930}
1931#endif /* PROVIDE_TRANSPARENT */
1932
1933static void
1934es1800_init_break (args, from_tty)
1935 char *args;
1936 int from_tty;
1937{
1938 CORE_ADDR memaddress = 0;
1939 char buf[PBUFSIZ];
1940 char base_addr[4];
1941 char *space_index;
1942 char *p;
1943 int k;
1944
1945 if (args == NULL)
1946 {
1947 error_no_arg ("a trap vector");
1948 }
1949
1950 if (!(space_index = strchr (args, ' ')))
1951 {
1952 error ("Two arguments needed (trap vector and address of break routine).\n");
1953 }
1954
1955 *space_index = '\0';
1956
1957 es1800_break_vec = strtol (args, (char **) NULL, 0);
1958 es1800_break_address = parse_and_eval_address (space_index + 1);
1959
1960 es1800_create_break_insn (es1800_break_insn, es1800_break_vec);
1961
1962 if (m68020)
1963 {
1964 send_with_reply ("VBR ", buf, sizeof (buf));
1965 p = buf;
1966 for (k = 0; k < 4; k++)
1967 {
c5aa993b 1968 if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
c906108c
SS
1969 {
1970 error ("Emulator reply is too short: %s", buf);
1971 }
c5aa993b 1972 base_addr[k] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
c906108c
SS
1973 }
1974 /* base addr of exception vector table */
c5aa993b 1975 memaddress = *((CORE_ADDR *) base_addr);
c906108c
SS
1976 }
1977
c5aa993b 1978 memaddress += (es1800_break_vec + 32) * 4; /* address of trap vector */
c906108c
SS
1979
1980 sprintf (buf, "@.L%lx=$%lx", memaddress, es1800_break_address);
c5aa993b
JM
1981 send_command (buf); /* set the address of the break routine in the */
1982 /* trap vector */
1983
1984 sprintf (buf, "@.L%lx=$4E714E71", es1800_break_address); /* NOP; NOP */
c906108c 1985 send_command (buf);
c5aa993b 1986 sprintf (buf, "@.L%lx=$4E714E73", es1800_break_address + 4); /* NOP; RTE */
c906108c 1987 send_command (buf);
c5aa993b 1988
c906108c
SS
1989 sprintf (buf, "AC2=$%lx", es1800_break_address + 4);
1990 /* breakpoint at es1800-break_address */
1991 send_command (buf);
c5aa993b 1992 send_command ("WHEN AC2 THEN BRK"); /* ie in exception routine */
c906108c
SS
1993
1994 if (from_tty)
1995 {
1996 printf ("Breakpoint (trap $%x) routine at address: %lx\n",
1997 es1800_break_vec, es1800_break_address);
1998 }
c5aa993b 1999}
c906108c
SS
2000
2001static void
2002es1800_child_open (arg, from_tty)
2003 char *arg;
2004 int from_tty;
2005{
2006 error ("Use the \"run\" command to start a child process.");
2007}
2008
2009static void
2010es1800_child_detach (args, from_tty)
2011 char *args;
2012 int from_tty;
2013{
2014 if (args)
2015 {
2016 error ("Argument given to \"detach\" when remotely debugging.");
2017 }
c5aa993b 2018
c906108c
SS
2019 pop_target ();
2020 if (from_tty)
2021 {
2022 printf ("Ending debugging the process %d.\n", inferior_pid);
2023 }
2024}
2025
2026
2027/* Define the target subroutine names */
2028
c5aa993b 2029struct target_ops es1800_ops;
c906108c 2030
c5aa993b
JM
2031static void
2032init_es1800_ops (void)
c906108c 2033{
c5aa993b
JM
2034 es1800_ops.to_shortname = "es1800";
2035 es1800_ops.to_longname = "Remote serial target in ES1800-emulator protocol";
2036 es1800_ops.to_doc = "Remote debugging on the es1800 emulator via a serial line.\n\
2037Specify the serial device it is connected to (e.g. /dev/ttya).";
2038 es1800_ops.to_open = es1800_open;
2039 es1800_ops.to_close = es1800_close;
2040 es1800_ops.to_attach = es1800_attach;
2041 es1800_ops.to_post_attach = NULL;
c906108c 2042 es1800_ops.to_require_attach = NULL;
c5aa993b 2043 es1800_ops.to_detach = es1800_detach;
c906108c 2044 es1800_ops.to_require_detach = NULL;
c5aa993b
JM
2045 es1800_ops.to_resume = es1800_resume;
2046 es1800_ops.to_wait = NULL;
2047 es1800_ops.to_post_wait = NULL;
2048 es1800_ops.to_fetch_registers = NULL;
2049 es1800_ops.to_store_registers = NULL;
2050 es1800_ops.to_prepare_to_store = es1800_prepare_to_store;
2051 es1800_ops.to_xfer_memory = es1800_xfer_inferior_memory;
2052 es1800_ops.to_files_info = es1800_files_info;
2053 es1800_ops.to_insert_breakpoint = es1800_insert_breakpoint;
2054 es1800_ops.to_remove_breakpoint = es1800_remove_breakpoint;
2055 es1800_ops.to_terminal_init = NULL;
2056 es1800_ops.to_terminal_inferior = NULL;
2057 es1800_ops.to_terminal_ours_for_output = NULL;
2058 es1800_ops.to_terminal_ours = NULL;
2059 es1800_ops.to_terminal_info = NULL;
2060 es1800_ops.to_kill = NULL;
2061 es1800_ops.to_load = es1800_load;
2062 es1800_ops.to_lookup_symbol = NULL;
2063 es1800_ops.to_create_inferior = es1800_create_inferior;
c906108c
SS
2064 es1800_ops.to_post_startup_inferior = NULL;
2065 es1800_ops.to_acknowledge_created_inferior = NULL;
c5aa993b 2066 es1800_ops.to_clone_and_follow_inferior = NULL;
c906108c
SS
2067 es1800_ops.to_post_follow_inferior_by_clone = NULL;
2068 es1800_ops.to_insert_fork_catchpoint = NULL;
2069 es1800_ops.to_remove_fork_catchpoint = NULL;
2070 es1800_ops.to_insert_vfork_catchpoint = NULL;
c5aa993b 2071 es1800_ops.to_remove_vfork_catchpoint = NULL;
c906108c 2072 es1800_ops.to_has_forked = NULL;
c5aa993b
JM
2073 es1800_ops.to_has_vforked = NULL;
2074 es1800_ops.to_can_follow_vfork_prior_to_exec = NULL;
c906108c
SS
2075 es1800_ops.to_post_follow_vfork = NULL;
2076 es1800_ops.to_insert_exec_catchpoint = NULL;
2077 es1800_ops.to_remove_exec_catchpoint = NULL;
2078 es1800_ops.to_has_execd = NULL;
2079 es1800_ops.to_reported_exec_events_per_exec_call = NULL;
2080 es1800_ops.to_has_exited = NULL;
c5aa993b
JM
2081 es1800_ops.to_mourn_inferior = NULL;
2082 es1800_ops.to_can_run = 0;
2083 es1800_ops.to_notice_signals = 0;
2084 es1800_ops.to_thread_alive = 0;
2085 es1800_ops.to_stop = 0;
c906108c 2086 es1800_ops.to_pid_to_exec_file = NULL;
c5aa993b
JM
2087 es1800_ops.to_core_file_to_sym_file = NULL;
2088 es1800_ops.to_stratum = core_stratum;
2089 es1800_ops.DONT_USE = 0;
2090 es1800_ops.to_has_all_memory = 0;
2091 es1800_ops.to_has_memory = 1;
2092 es1800_ops.to_has_stack = 0;
2093 es1800_ops.to_has_registers = 0;
2094 es1800_ops.to_has_execution = 0;
2095 es1800_ops.to_sections = NULL;
2096 es1800_ops.to_sections_end = NULL;
2097 es1800_ops.to_magic = OPS_MAGIC;
c906108c
SS
2098}
2099
2100/* Define the target subroutine names */
2101
c5aa993b 2102struct target_ops es1800_child_ops;
c906108c 2103
c5aa993b
JM
2104static void
2105init_es1800_child_ops (void)
c906108c 2106{
c5aa993b
JM
2107 es1800_child_ops.to_shortname = "es1800_process";
2108 es1800_child_ops.to_longname = "Remote serial target in ES1800-emulator protocol";
2109 es1800_child_ops.to_doc = "Remote debugging on the es1800 emulator via a serial line.\n\
c906108c 2110Specify the serial device it is connected to (e.g. /dev/ttya).";
c5aa993b
JM
2111 es1800_child_ops.to_open = es1800_child_open;
2112 es1800_child_ops.to_close = NULL;
2113 es1800_child_ops.to_attach = es1800_attach;
c906108c 2114 es1800_child_ops.to_post_attach = NULL;
c5aa993b
JM
2115 es1800_child_ops.to_require_attach = NULL;
2116 es1800_child_ops.to_detach = es1800_child_detach;
2117 es1800_child_ops.to_require_detach = NULL;
2118 es1800_child_ops.to_resume = es1800_resume;
2119 es1800_child_ops.to_wait = es1800_wait;
2120 es1800_child_ops.to_post_wait = NULL;
2121 es1800_child_ops.to_fetch_registers = es1800_fetch_register;
2122 es1800_child_ops.to_store_registers = es1800_store_register;
2123 es1800_child_ops.to_prepare_to_store = es1800_prepare_to_store;
2124 es1800_child_ops.to_xfer_memory = es1800_xfer_inferior_memory;
2125 es1800_child_ops.to_files_info = es1800_files_info;
2126 es1800_child_ops.to_insert_breakpoint = es1800_insert_breakpoint;
2127 es1800_child_ops.to_remove_breakpoint = es1800_remove_breakpoint;
2128 es1800_child_ops.to_terminal_init = NULL;
2129 es1800_child_ops.to_terminal_inferior = NULL;
2130 es1800_child_ops.to_terminal_ours_for_output = NULL;
2131 es1800_child_ops.to_terminal_ours = NULL;
2132 es1800_child_ops.to_terminal_info = NULL;
2133 es1800_child_ops.to_kill = es1800_kill;
2134 es1800_child_ops.to_load = es1800_load;
2135 es1800_child_ops.to_lookup_symbol = NULL;
2136 es1800_child_ops.to_create_inferior = es1800_create_inferior;
c906108c
SS
2137 es1800_child_ops.to_post_startup_inferior = NULL;
2138 es1800_child_ops.to_acknowledge_created_inferior = NULL;
2139 es1800_child_ops.to_clone_and_follow_inferior = NULL;
2140 es1800_child_ops.to_post_follow_inferior_by_clone = NULL;
2141 es1800_child_ops.to_insert_fork_catchpoint = NULL;
2142 es1800_child_ops.to_remove_fork_catchpoint = NULL;
2143 es1800_child_ops.to_insert_vfork_catchpoint = NULL;
c5aa993b 2144 es1800_child_ops.to_remove_vfork_catchpoint = NULL;
c906108c 2145 es1800_child_ops.to_has_forked = NULL;
c5aa993b 2146 es1800_child_ops.to_has_vforked = NULL;
c906108c
SS
2147 es1800_child_ops.to_can_follow_vfork_prior_to_exec = NULL;
2148 es1800_child_ops.to_post_follow_vfork = NULL;
2149 es1800_child_ops.to_insert_exec_catchpoint = NULL;
2150 es1800_child_ops.to_remove_exec_catchpoint = NULL;
2151 es1800_child_ops.to_has_execd = NULL;
2152 es1800_child_ops.to_reported_exec_events_per_exec_call = NULL;
2153 es1800_child_ops.to_has_exited = NULL;
c5aa993b
JM
2154 es1800_child_ops.to_mourn_inferior = es1800_mourn_inferior;
2155 es1800_child_ops.to_can_run = 0;
2156 es1800_child_ops.to_notice_signals = 0;
2157 es1800_child_ops.to_thread_alive = 0;
2158 es1800_child_ops.to_stop = 0;
c906108c
SS
2159 es1800_child_ops.to_pid_to_exec_file = NULL;
2160 es1800_child_ops.to_core_file_to_sym_file = NULL;
c5aa993b
JM
2161 es1800_child_ops.to_stratum = process_stratum;
2162 es1800_child_ops.DONT_USE = 0;
2163 es1800_child_ops.to_has_all_memory = 1;
2164 es1800_child_ops.to_has_memory = 1;
2165 es1800_child_ops.to_has_stack = 1;
2166 es1800_child_ops.to_has_registers = 1;
2167 es1800_child_ops.to_has_execution = 1;
2168 es1800_child_ops.to_sections = NULL;
2169 es1800_child_ops.to_sections_end = NULL;
2170 es1800_child_ops.to_magic = OPS_MAGIC;
c906108c
SS
2171}
2172
2173void
2174_initialize_es1800 ()
2175{
c5aa993b
JM
2176 init_es1800_ops ();
2177 init_es1800_child_ops ();
c906108c
SS
2178 add_target (&es1800_ops);
2179 add_target (&es1800_child_ops);
2180#ifdef PROVIDE_TRANSPARENT
2181 add_com ("transparent", class_support, es1800_transparent,
2182 "Start transparent communication with the ES 1800 emulator.");
2183#endif /* PROVIDE_TRANSPARENT */
2184 add_com ("init_break", class_support, es1800_init_break,
c5aa993b 2185 "Download break routine and initialize break facility on ES 1800");
c906108c 2186}
This page took 0.175067 seconds and 4 git commands to generate.