annotate loadtools/ltexit.c @ 1016:a6ca9ee289f7

gsm-fw feature tch-reroute: uplink substitution implemented
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 21 Mar 2016 02:27:51 +0000
parents 134c047c1269
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module implements the loadtool exit command, along with its
392
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
3 * options for jump-reboot and Iota power-off.
27
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <string.h>
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <strings.h>
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <stdlib.h>
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 static void
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 exit_bare()
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 {
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 exit(0);
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 }
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 static void
85
6f8d3771aa6c loadtools for GTA0x AP: GTA02 modem power-off implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
18 exit_gta02_cutpwr()
6f8d3771aa6c loadtools for GTA0x AP: GTA02 modem power-off implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
19 {
6f8d3771aa6c loadtools for GTA0x AP: GTA02 modem power-off implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
20 #ifdef GTA0x_AP_BUILD
6f8d3771aa6c loadtools for GTA0x AP: GTA02 modem power-off implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
21 set_gta_modem_power_ctrl(0);
6f8d3771aa6c loadtools for GTA0x AP: GTA02 modem power-off implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
22 #endif
6f8d3771aa6c loadtools for GTA0x AP: GTA02 modem power-off implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
23 exit(0);
6f8d3771aa6c loadtools for GTA0x AP: GTA02 modem power-off implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
24 }
6f8d3771aa6c loadtools for GTA0x AP: GTA02 modem power-off implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
25
6f8d3771aa6c loadtools for GTA0x AP: GTA02 modem power-off implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
26 static void
392
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
27 exit_iotaoff()
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
28 {
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
29 static char *poweroff_argv[2] = {"poweroff", 0};
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
30
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
31 tpinterf_make_cmd(poweroff_argv);
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
32 tpinterf_send_cmd();
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
33 exit(0);
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
34 }
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
35
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
36 static void
27
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 exit_jump0()
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 {
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 static char *jump0_argv[3] = {"jump", "0", 0};
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 tpinterf_make_cmd(jump0_argv);
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 tpinterf_send_cmd();
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 exit(0);
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 }
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 void (*default_exit)() = exit_bare;
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 static struct kwtab {
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 char *kw;
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 void (*func)();
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 } exit_modes[] = {
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 {"bare", exit_bare},
85
6f8d3771aa6c loadtools for GTA0x AP: GTA02 modem power-off implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
53 {"gta02-cutpwr", exit_gta02_cutpwr},
392
134c047c1269 loadtools: Iota poweroff on Compal targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 85
diff changeset
54 {"iota-off", exit_iotaoff},
27
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 {"jump0", exit_jump0},
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 {0, 0}
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 };
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 cmd_exit(argc, argv)
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 char **argv;
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 {
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 struct kwtab *tp;
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 if (argc < 2)
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 default_exit();
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 for (tp = exit_modes; tp->kw; tp++)
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 if (!strcmp(tp->kw, argv[1]))
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 break;
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 if (!tp->func) {
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 fprintf(stderr,
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 "error: \"%s\" is not an understood exit mode\n",
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 argv[1]);
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 return(-1);
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 }
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 tp->func();
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 }
28
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
77
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
78 /* called from hwparam.c config file parser */
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
79 void
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
80 set_default_exit_mode(arg, filename_for_errs, lineno_for_errs)
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
81 char *arg;
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
82 char *filename_for_errs;
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
83 int lineno_for_errs;
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
84 {
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
85 char *cp;
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
86 struct kwtab *tp;
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
87
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
88 while (isspace(*arg))
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
89 arg++;
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
90 if (!*arg) {
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
91 fprintf(stderr,
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
92 "%s line %d: exit-mode setting requires an argument\n",
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
93 filename_for_errs, lineno_for_errs);
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
94 exit(1);
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
95 }
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
96 for (cp = arg; *cp && !isspace(*cp); cp++)
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
97 ;
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
98 *cp = '\0';
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
99 for (tp = exit_modes; tp->kw; tp++)
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
100 if (!strcmp(tp->kw, arg))
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
101 break;
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
102 if (!tp->func) {
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
103 fprintf(stderr,
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
104 "%s line %d: \"%s\" is not an understood exit mode\n",
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
105 filename_for_errs, lineno_for_errs, arg);
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
106 exit(1);
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
107 }
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
108 default_exit = tp->func;
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
109 }