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