annotate rvinterf/tmsh/oneshot.c @ 505:7bf0d909c87e

fc-loadtool flash ID check: change of reset after the check logic This change only affects those flash configurations that have ID checks enabled. The logic for resetting the flash after the ID check has been changed as follows: 1) If the check fails, we return without attempting to reset the flash. 2) If the check is successful, we reset the flash using the configured method (could be AMD or Intel or Intel W30) instead of always doing an AMD flash reset as the original code did.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 27 May 2019 19:58:01 +0000
parents 27c41e4b21ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
71
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the one-shot mode of operation for fc-tmsh.
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/errno.h>
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <unistd.h>
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "exitcodes.h"
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 extern int oneshot_nowait;
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern int sock;
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern int got_tm_response;
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 oneshot_command(argc, argv)
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char **argv;
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 {
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 fd_set fds;
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 int rc;
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (!oneshot_nowait)
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 init(); /* to catch the response properly */
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 rc = dispatch_oneshot_cmd(argc, argv);
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (rc)
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 exit(rc);
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (oneshot_nowait)
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 exit(0);
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 /* wait for response */
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 for (;;) {
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 FD_ZERO(&fds);
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 FD_SET(sock, &fds);
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 rc = select(sock+1, &fds, 0, 0, 0);
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (rc < 0) {
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 if (errno == EINTR)
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 continue;
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 perror("select");
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 exit(ERROR_UNIX);
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 }
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (FD_ISSET(sock, &fds))
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 handle_rvinterf_input();
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (got_tm_response)
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 exit(0);
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
27c41e4b21ae fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }