annotate librftab/readtxramp.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 a0f79bba0ad8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
314
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Reading Tx ramp templates from formatted ASCII files, used for the ttw
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * command in fc-tmsh.
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <ctype.h>
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdlib.h>
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "../rvinterf/include/exitcodes.h"
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include "rdcommon.c"
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 static u_char *writeptr;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 static
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 process_txramp_number()
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 {
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 char *field;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 int rc;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 u_long number;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 rc = get_field(&field);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 if (rc < 0)
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 return(ERROR_USAGE);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (!rc) {
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 printf("error: %s is too short for a Tx ramp template\n",
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 filename);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 return(ERROR_USAGE);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 number = strtoul(field, 0, 0);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 *writeptr++ = number;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 return(0);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 static
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 read_txramp_16num()
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 {
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 int i, rc;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 for (i = 0; i < 16; i++) {
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 rc = process_txramp_number();
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (rc)
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 return(rc);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 }
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 return(0);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 read_tx_ramp_template(filename_arg, rdbuf)
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 char *filename_arg;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 u_char *rdbuf;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 {
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 char *field;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 int rc;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 filename = filename_arg;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 rdfile = fopen(filename, "r");
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 if (!rdfile) {
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 perror(filename);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 return(ERROR_UNIX);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 }
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 lineno = 0;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 line_nfields = 0;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 rc = get_field(&field);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 if (rc <= 0) {
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 not_valid_ramp_file:
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 printf("error: %s is not a valid Tx ramp template file\n",
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 filename);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 fclose(rdfile);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 return(ERROR_USAGE);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 if (strcmp(field, "ramp-up"))
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 goto not_valid_ramp_file;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 writeptr = rdbuf;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 rc = read_txramp_16num();
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 if (rc) {
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 fclose(rdfile);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 return(rc);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 rc = get_field(&field);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 if (rc <= 0)
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 goto not_valid_ramp_file;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 if (strcmp(field, "ramp-down"))
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 goto not_valid_ramp_file;
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 rc = read_txramp_16num();
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 if (rc) {
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 fclose(rdfile);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 return(rc);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 }
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 rc = get_field(&field);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 fclose(rdfile);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 if (rc < 0)
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 return(ERROR_USAGE);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 if (rc) {
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 printf("error: %s is too long for a Tx ramp template\n",
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 filename);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 return(ERROR_USAGE);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 }
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 return(0);
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 }