changeset 28:768a3d012931

loadtool: default exit mode setting implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 04 May 2013 06:39:05 +0000
parents ae6294b8a015
children dacf45e3d20f
files loadtools/hwparam.c loadtools/ltexit.c loadtools/scripts/pirelli.config loadtools/sertool.c
diffstat 4 files changed, 51 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/hwparam.c	Sat May 04 06:22:09 2013 +0000
+++ b/loadtools/hwparam.c	Sat May 04 06:39:05 2013 +0000
@@ -12,6 +12,8 @@
 
 extern char default_helpers_dir[];
 
+extern void set_default_exit_mode();
+
 char hw_init_script[128];
 
 static void
@@ -104,6 +106,7 @@
 	char *name;
 	void (*func)();
 } cmdtab[] = {
+	{"exit-mode", set_default_exit_mode},
 	{"init-script", handle_init_script},
 	{"pll-config", handle_pll_config},
 	{"rhea-cntl", handle_rhea_cntl},
--- a/loadtools/ltexit.c	Sat May 04 06:22:09 2013 +0000
+++ b/loadtools/ltexit.c	Sat May 04 06:39:05 2013 +0000
@@ -53,3 +53,36 @@
 	}
 	tp->func();
 }
+
+/* called from hwparam.c config file parser */
+void
+set_default_exit_mode(arg, filename_for_errs, lineno_for_errs)
+	char *arg;
+	char *filename_for_errs;
+	int lineno_for_errs;
+{
+	char *cp;
+	struct kwtab *tp;
+
+	while (isspace(*arg))
+		arg++;
+	if (!*arg) {
+		fprintf(stderr,
+		"%s line %d: exit-mode setting requires an argument\n",
+			filename_for_errs, lineno_for_errs);
+		exit(1);
+	}
+	for (cp = arg; *cp && !isspace(*cp); cp++)
+		;
+	*cp = '\0';
+	for (tp = exit_modes; tp->kw; tp++)
+		if (!strcmp(tp->kw, arg))
+			break;
+	if (!tp->func) {
+		fprintf(stderr,
+			"%s line %d: \"%s\" is not an understood exit mode\n",
+			filename_for_errs, lineno_for_errs, arg);
+		exit(1);
+	}
+	default_exit = tp->func;
+}
--- a/loadtools/scripts/pirelli.config	Sat May 04 06:22:09 2013 +0000
+++ b/loadtools/scripts/pirelli.config	Sat May 04 06:39:05 2013 +0000
@@ -5,3 +5,11 @@
 
 # The remaining settings are carried out via loadagent commands
 init-script pirelli.init
+
+# On this phone the current best exit strategy is jump0.
+# A Iota power-off, even if we implement one, won't be any different:
+# having the serial connection implies a USB connection, that in turn
+# implies having VBUS, and thus a Iota power-off will immediately
+# result in another power-on for charger-insert.
+
+exit-mode jump0
--- a/loadtools/sertool.c	Sat May 04 06:22:09 2013 +0000
+++ b/loadtools/sertool.c	Sat May 04 06:39:05 2013 +0000
@@ -49,3 +49,10 @@
 	tty_passthru();
 	exit(0);
 }
+
+/* called from hwparam.c config file parser */
+/* stub needed for fc-sertool to link */
+void
+set_default_exit_mode()
+{
+}