annotate loadtools/hwparam.c @ 923:10b4bed10192

gsm-fw/L1: fix for the DSP patch corruption bug The L1 code we got from the LoCosto fw contains a feature for DSP CPU load measurement. This feature is a LoCosto-ism, i.e., not applicable to earlier DBB chips (Calypso) with their respective earlier DSP ROMs. Most of the code dealing with that feature is conditionalized as #if (DSP >= 38), but one spot was missed, and the MCU code was writing into an API word dealing with this feature. In TCS211 this DSP API word happens to be used by the DSP code patch, hence that write was corrupting the patched DSP code.
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 19 Oct 2015 17:13:56 +0000
parents 1ed2d78f150c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module contains the code that reads the hardware parameter files
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * specified with -h or -H, and sets variables for later use by other code.
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/param.h>
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <ctype.h>
21
67a39d8914a8 starting work on loadtool
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 17
diff changeset
9 #include <string.h>
17
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <strings.h>
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include <stdlib.h>
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 extern char default_helpers_dir[];
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
413
1ed2d78f150c loadtools: boot-reflash-hack hwparam setting hooked in
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 382
diff changeset
15 extern void set_boot_reflash_hack();
28
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 21
diff changeset
16 extern void set_default_exit_mode();
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
17 extern void set_flash_device();
28
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 21
diff changeset
18
17
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 char hw_init_script[128];
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 static void
382
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
22 handle_compal_stage(arg, filename_for_errs, lineno_for_errs)
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
23 char *arg;
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
24 char *filename_for_errs;
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
25 int lineno_for_errs;
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
26 {
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
27 char *cp;
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
28
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
29 while (isspace(*arg))
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
30 arg++;
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
31 if (!*arg) {
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
32 fprintf(stderr,
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
33 "%s line %d: compal-stage setting requires an argument\n",
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
34 filename_for_errs, lineno_for_errs);
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
35 exit(1);
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
36 }
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
37 for (cp = arg; *cp && !isspace(*cp); cp++)
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
38 ;
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
39 *cp = '\0';
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
40 set_compalstage_short(arg);
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
41 }
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
42
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
43 static void
17
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 handle_init_script(arg, filename_for_errs, lineno_for_errs)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 char *arg;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 char *filename_for_errs;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 int lineno_for_errs;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 char *cp;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 while (isspace(*arg))
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 arg++;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 if (!*arg) {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 fprintf(stderr,
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 "%s line %d: init-script setting requires an argument\n",
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 filename_for_errs, lineno_for_errs);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 exit(1);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 for (cp = arg; *cp && !isspace(*cp); cp++)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 ;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 *cp = '\0';
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 if (cp - arg > sizeof(hw_init_script) - 1) {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 fprintf(stderr,
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 "%s line %d: init-script argument is too long (buffer overflow)\n",
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 filename_for_errs, lineno_for_errs);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 exit(1);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 strcpy(hw_init_script, arg);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 static void
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 handle_pll_config(arg, filename_for_errs, lineno_for_errs)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 char *arg;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 char *filename_for_errs;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 int lineno_for_errs;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 int mult, div;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 while (isspace(*arg))
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 arg++;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 if (!isdigit(*arg)) {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 inv: fprintf(stderr, "%s line %d: pll-config argument must be M/N\n",
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 filename_for_errs, lineno_for_errs);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 exit(1);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 mult = atoi(arg);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 arg++;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 if (isdigit(*arg))
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 arg++;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 if (*arg++ != '/')
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 goto inv;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 if (!isdigit(*arg))
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 goto inv;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 div = atoi(arg);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 arg++;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 if (*arg && !isspace(*arg))
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 goto inv;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 if (mult < 0 || mult > 31 || div < 1 || div > 4) {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 fprintf(stderr,
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 "%s line %d: pll-config argument is out of range\n",
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 filename_for_errs, lineno_for_errs);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 exit(1);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 set_romload_pll_conf((mult << 2) | (div - 1));
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 static void
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 handle_rhea_cntl(arg, filename_for_errs, lineno_for_errs)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 char *arg;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 char *filename_for_errs;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 int lineno_for_errs;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 int byte;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 while (isspace(*arg))
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 arg++;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 if (arg[0] == '0' && (arg[1] == 'x' || arg[1] == 'X'))
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 arg += 2;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 byte = decode_hex_byte(arg);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 if (byte < 0 || arg[2] && !isspace(arg[2])) {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 fprintf(stderr,
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 "%s line %d: rhea-cntl argument must be a hex byte value\n",
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 filename_for_errs, lineno_for_errs);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 exit(1);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 set_romload_rhea_cntl(byte);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 static struct cmdtab {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 char *name;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 void (*func)();
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 } cmdtab[] = {
413
1ed2d78f150c loadtools: boot-reflash-hack hwparam setting hooked in
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 382
diff changeset
133 {"boot-reflash-hack", set_boot_reflash_hack},
382
a2210b0361c1 loadtools: implemented compal-stage setting in hw parameter files
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
134 {"compal-stage", handle_compal_stage},
28
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 21
diff changeset
135 {"exit-mode", set_default_exit_mode},
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
136 {"flash", set_flash_device},
17
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 {"init-script", handle_init_script},
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 {"pll-config", handle_pll_config},
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 {"rhea-cntl", handle_rhea_cntl},
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 {0, 0}
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 };
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 void
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 read_hwparam_file_fullpath(filename)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 char *filename;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 FILE *f;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 char linebuf[512];
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 int lineno;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 char *cp, *np;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 struct cmdtab *tp;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 f = fopen(filename, "r");
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 if (!f) {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 perror(filename);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 exit(1);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 for (lineno = 1; fgets(linebuf, sizeof linebuf, f); lineno++) {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 for (cp = linebuf; isspace(*cp); cp++)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 ;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 if (!*cp || *cp == '#')
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 continue;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 for (np = cp; *cp && !isspace(*cp); cp++)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 ;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 if (*cp)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 *cp++ = '\0';
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 for (tp = cmdtab; tp->name; tp++)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 if (!strcmp(tp->name, np))
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 break;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 if (tp->func)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 tp->func(cp, filename, lineno);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 else {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 fprintf(stderr,
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 "%s line %d: setting \"%s\" not understood\n",
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 filename, lineno, np);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176 exit(1);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 fclose(f);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 }
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 void
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 read_hwparam_file_shortname(confname)
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 char *confname;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 {
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186 char pathname[MAXPATHLEN];
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 sprintf(pathname, "%s/%s.config", default_helpers_dir, confname);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 read_hwparam_file_fullpath(pathname);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 }