diff options
Diffstat (limited to 'boot_loader/uboot/utils/ccsAddGptlr.c')
-rw-r--r-- | boot_loader/uboot/utils/ccsAddGptlr.c | 160 |
1 files changed, 0 insertions, 160 deletions
diff --git a/boot_loader/uboot/utils/ccsAddGptlr.c b/boot_loader/uboot/utils/ccsAddGptlr.c deleted file mode 100644 index a63f6aa..0000000 --- a/boot_loader/uboot/utils/ccsAddGptlr.c +++ /dev/null | |||
@@ -1,160 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ | ||
4 | * | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * | ||
10 | * Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * | ||
13 | * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * | ||
18 | * Neither the name of Texas Instruments Incorporated nor the names of | ||
19 | * its contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | * | ||
34 | */ | ||
35 | /****************************************************************************** | ||
36 | * FILE PURPOSE: Add a GP Trailer to a CCS file | ||
37 | ****************************************************************************** | ||
38 | * FILE NAME: ccsAddGptlr.c | ||
39 | * | ||
40 | * DESCRIPTION: Adds the 8 byte General Purpose Trailer | ||
41 | * | ||
42 | * Usage: ccsAddGptlr [-h] [-infile infile] [-outfile outfile] | ||
43 | * | ||
44 | ******************************************************************************/ | ||
45 | #include <stdio.h> | ||
46 | #include <malloc.h> | ||
47 | #include <string.h> | ||
48 | #include "ccsutil.h" | ||
49 | |||
50 | char *infile = NULL; | ||
51 | char *outfile = NULL; | ||
52 | |||
53 | int parseit (int ac, char *av[]) | ||
54 | { | ||
55 | |||
56 | int i; | ||
57 | |||
58 | for (i = 1; i < ac; ) { | ||
59 | |||
60 | if (!strcmp (av[i], "-infile")) { | ||
61 | infile = av[i+1]; | ||
62 | i = i + 2; | ||
63 | continue; | ||
64 | } | ||
65 | |||
66 | if (!strcmp (av[i], "-outfile")) { | ||
67 | outfile = av[i+1]; | ||
68 | i = i + 2; | ||
69 | continue; | ||
70 | } | ||
71 | |||
72 | if (!strcmp (av[i], "-h")) { | ||
73 | fprintf (stderr, "usage: %s [-h] [-infile infile] [-outfile outfile]\n", av[0]); | ||
74 | return (-1); | ||
75 | } | ||
76 | |||
77 | fprintf (stderr, "%s: Unknown option %s\n", av[0], av[i]); | ||
78 | return (-1); | ||
79 | |||
80 | } | ||
81 | |||
82 | return (0); | ||
83 | |||
84 | } | ||
85 | |||
86 | |||
87 | int main (int argc, char *argv[]) | ||
88 | { | ||
89 | FILE *str; | ||
90 | unsigned int *dat; | ||
91 | int n; | ||
92 | |||
93 | if (parseit (argc, argv)) | ||
94 | return (-1); | ||
95 | |||
96 | |||
97 | if (infile != NULL) { | ||
98 | |||
99 | str = fopen (infile, "r"); | ||
100 | if (str == NULL) { | ||
101 | fprintf (stderr, "%s: Failed to open input file %s\n", argv[0], infile); | ||
102 | return (-1); | ||
103 | } | ||
104 | |||
105 | } else { | ||
106 | |||
107 | str = stdin; | ||
108 | |||
109 | } | ||
110 | |||
111 | dat = readCcsFile (str, &n); | ||
112 | |||
113 | if (dat == NULL) { | ||
114 | |||
115 | fprintf (stderr, "%s: Error reading CCS data file\n", argv[0]); | ||
116 | return (-1); | ||
117 | |||
118 | } | ||
119 | |||
120 | if (infile != NULL) | ||
121 | fclose (str); | ||
122 | |||
123 | |||
124 | dat = realloc (dat, (n+2) * sizeof(unsigned int)); | ||
125 | if (dat == NULL) { | ||
126 | fprintf (stderr, "%s: Realloc failed\n", argv[0]); | ||
127 | return (-1); | ||
128 | } | ||
129 | |||
130 | dat[n+0] = 0; | ||
131 | dat[n+1] = 0; | ||
132 | n = n + 2; | ||
133 | |||
134 | if (outfile != NULL) { | ||
135 | |||
136 | str = fopen (outfile, "w"); | ||
137 | if (str == NULL) { | ||
138 | fprintf (stderr, "%s: Failed to open output file %s\n", argv[0], outfile); | ||
139 | free (dat); | ||
140 | return (-1); | ||
141 | } | ||
142 | |||
143 | } else { | ||
144 | |||
145 | str = stdout; | ||
146 | |||
147 | } | ||
148 | |||
149 | writeCcsFile (str, dat, n); | ||
150 | |||
151 | if (outfile != NULL) | ||
152 | fclose (str); | ||
153 | |||
154 | free (dat); | ||
155 | |||
156 | return (0); | ||
157 | |||
158 | } | ||
159 | |||
160 | |||