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