xref: /openbmc/u-boot/tools/gdb/gdbcont.c (revision 23ff8633)
1 /*
2  * (C) Copyright 2000
3  * Murray Jensen <Murray.Jensen@csiro.au>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <unistd.h>
12 #include "serial.h"
13 #include "error.h"
14 #include "remote.h"
15 
16 char *serialdev = "/dev/term/b";
17 speed_t speed = B230400;
18 int verbose = 0;
19 
20 int
21 main(int ac, char **av)
22 {
23     int c, sfd;
24 
25     if ((pname = strrchr(av[0], '/')) == NULL)
26 	pname = av[0];
27     else
28 	pname++;
29 
30     while ((c = getopt(ac, av, "b:p:v")) != EOF)
31 	switch (c) {
32 
33 	case 'b':
34 	    if ((speed = cvtspeed(optarg)) == B0)
35 		Error("can't decode baud rate specified in -b option");
36 	    break;
37 
38 	case 'p':
39 	    serialdev = optarg;
40 	    break;
41 
42 	case 'v':
43 	    verbose = 1;
44 	    break;
45 
46 	default:
47 	usage:
48 	    fprintf(stderr, "Usage: %s [-b bps] [-p dev] [-v]\n", pname);
49 	    exit(1);
50 	}
51     if (optind != ac)
52 	goto usage;
53 
54     if (verbose)
55 	fprintf(stderr, "Opening serial port and sending continue...\n");
56 
57     if ((sfd = serialopen(serialdev, speed)) < 0)
58 	Perror("open of serial device '%s' failed", serialdev);
59 
60     remote_desc = sfd;
61     remote_reset();
62     remote_continue();
63 
64     if (serialclose(sfd) < 0)
65 	Perror("close of serial device '%s' failed", serialdev);
66 
67     if (verbose)
68 	fprintf(stderr, "Done.\n");
69 
70     return (0);
71 }
72