diff options
Diffstat (limited to 'fw/v1/pabinchk.c')
-rw-r--r-- | fw/v1/pabinchk.c | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/fw/v1/pabinchk.c b/fw/v1/pabinchk.c new file mode 100644 index 0000000..fe196a2 --- /dev/null +++ b/fw/v1/pabinchk.c | |||
@@ -0,0 +1,162 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <string.h> | ||
4 | #include "pa.h" | ||
5 | #include "pdsp_ver.h" | ||
6 | #include "paconst.c" | ||
7 | |||
8 | #define DEVICE_PA_NUM_PDSPS (15U) | ||
9 | #define PA_PDSP_CONST_NUM_REG (32U) | ||
10 | #define PASS_VER_STR_LEN (16U) | ||
11 | |||
12 | #include "pdsp_blob_hdr.h" | ||
13 | |||
14 | static char *versions[DEVICE_PA_NUM_PDSPS] = { | ||
15 | PASS_VERSION_STR, | ||
16 | PASS_VERSION_STR, | ||
17 | PASS_VERSION_STR, | ||
18 | PASS_VERSION_STR, | ||
19 | PASS_VERSION_STR, | ||
20 | PASS_VERSION_STR, | ||
21 | PASS_VERSION_STR, | ||
22 | PASS_VERSION_STR, | ||
23 | PASS_VERSION_STR, | ||
24 | PASS_VERSION_STR, | ||
25 | PASS_VERSION_STR, | ||
26 | PASS_VERSION_STR, | ||
27 | PASS_VERSION_STR, | ||
28 | PASS_VERSION_STR, | ||
29 | PASS_VERSION_STR | ||
30 | }; | ||
31 | static char *pdsp_in_file_names[DEVICE_PA_NUM_PDSPS] = { | ||
32 | "in0_pdsp0.bib", /* 0 */ | ||
33 | "in0_pdsp1.bib", /* 1 */ | ||
34 | "in1_pdsp0.bib", /* 2 */ | ||
35 | "in1_pdsp1.bib", /* 3 */ | ||
36 | "in2_pdsp0.bib", /* 4 */ | ||
37 | "in3_pdsp0.bib", /* 5 */ | ||
38 | "in4_pdsp0.bib", /* 6 */ | ||
39 | "in4_pdsp1.bib", /* 7 */ | ||
40 | "post_pdsp0.bib", /* 8 */ | ||
41 | "post_pdsp1.bib", /* 9 */ | ||
42 | "eg0_pdsp0.bib", /* 10 */ | ||
43 | "eg0_pdsp1.bib", /* 11 */ | ||
44 | "eg0_pdsp2.bib", /* 12 */ | ||
45 | "eg1_pdsp0.bib", /* 13 */ | ||
46 | "eg2_pdsp0.bib", /* 14 */ | ||
47 | }; | ||
48 | |||
49 | static char *pdsp_out_file_names[DEVICE_PA_NUM_PDSPS] = { | ||
50 | "ks2_pa_in0_pdsp0", /* 0 */ | ||
51 | "ks2_pa_in0_pdsp1", /* 1 */ | ||
52 | "ks2_pa_in1_pdsp0", /* 2 */ | ||
53 | "ks2_pa_in1_pdsp1", /* 3 */ | ||
54 | "ks2_pa_in2_pdsp0", /* 4 */ | ||
55 | "ks2_pa_in3_pdsp0", /* 5 */ | ||
56 | "ks2_pa_in4_pdsp0", /* 6 */ | ||
57 | "ks2_pa_in4_pdsp1", /* 7 */ | ||
58 | "ks2_pa_post_pdsp0", /* 8 */ | ||
59 | "ks2_pa_post_pdsp1", /* 9 */ | ||
60 | "ks2_pa_eg0_pdsp0", /* 10 */ | ||
61 | "ks2_pa_eg0_pdsp1", /* 11 */ | ||
62 | "ks2_pa_eg0_pdsp2", /* 12 */ | ||
63 | "ks2_pa_eg1_pdsp0", /* 13 */ | ||
64 | "ks2_pa_eg2_pdsp0", /* 14 */ | ||
65 | }; | ||
66 | |||
67 | int main(int argc, char **argv) | ||
68 | { | ||
69 | unsigned long b_sz, total = 0; | ||
70 | struct pa_pdsp_firmware pdsp; | ||
71 | char in_file_name[128]; | ||
72 | char out_file_name[128]; | ||
73 | char buf_in[1024]; | ||
74 | char buf_out[1024]; | ||
75 | char *pc; | ||
76 | FILE *outfp, *infp; | ||
77 | int j, i; | ||
78 | int size, mismatch = 0; | ||
79 | |||
80 | for (i = 0; i < DEVICE_PA_NUM_PDSPS; i++) { | ||
81 | if (!pdsp_in_file_names[i]) | ||
82 | continue; | ||
83 | bzero(in_file_name, sizeof(in_file_name)); | ||
84 | bzero(out_file_name, sizeof(out_file_name)); | ||
85 | strcpy(in_file_name, (char *)pdsp_in_file_names[i]); | ||
86 | strcpy(out_file_name, (char *)pdsp_out_file_names[i]); | ||
87 | pc = &out_file_name[strlen(out_file_name)]; | ||
88 | |||
89 | strcat(pc, ".bin"); | ||
90 | outfp=fopen(out_file_name,"rb"); | ||
91 | infp=fopen(in_file_name,"rb"); | ||
92 | |||
93 | if (!outfp) | ||
94 | { | ||
95 | printf("Unable to open output file! %s", out_file_name); | ||
96 | exit(1); | ||
97 | } | ||
98 | |||
99 | if (!infp) | ||
100 | { | ||
101 | printf("Unable to open input file! %s", in_file_name); | ||
102 | fclose(outfp); | ||
103 | exit(2); | ||
104 | } | ||
105 | |||
106 | /* Check the version */ | ||
107 | fread(&pdsp, sizeof(pdsp), 1, outfp); | ||
108 | if ( 0 != strncmp((char *)&pdsp.version[0], (char *)versions[i], PASS_VER_STR_LEN)) | ||
109 | { | ||
110 | mismatch = 1; | ||
111 | } | ||
112 | |||
113 | /* Check the constant */ | ||
114 | if ( 0 != memcmp(&pdsp.constants[0], &pap_pdsp_const_reg_map[i][0], sizeof(u32) * PA_PDSP_CONST_NUM_REG)) | ||
115 | { | ||
116 | mismatch = 2; | ||
117 | } | ||
118 | |||
119 | while(mismatch == 0) { | ||
120 | size = fread(buf_out, 1, 1024, outfp); | ||
121 | if (size <= 0) | ||
122 | break; | ||
123 | |||
124 | size = fread(buf_in, 1, 1024, infp); | ||
125 | if (size <= 0) | ||
126 | break; | ||
127 | |||
128 | if ( 0 != memcmp(buf_in, buf_out, size)) | ||
129 | { | ||
130 | mismatch = 3; | ||
131 | } | ||
132 | } | ||
133 | fclose(outfp); | ||
134 | fclose(infp); | ||
135 | |||
136 | if (mismatch != 0) | ||
137 | break; | ||
138 | } | ||
139 | |||
140 | switch (mismatch) | ||
141 | { | ||
142 | |||
143 | case 3: | ||
144 | printf ("blob mismatch noticed on writing %s.bin file \n", pdsp_out_file_names[i]); | ||
145 | printf ("firmware write failed ....recheck \n"); | ||
146 | break; | ||
147 | |||
148 | case 2: | ||
149 | printf ("constants mismatch noticed on writing %s.bin file \n", pdsp_out_file_names[i]); | ||
150 | printf ("firmware write failed ....recheck \n"); | ||
151 | break; | ||
152 | |||
153 | case 1: | ||
154 | printf ("version mismatch noticed on writing %s.bin file \n", pdsp_out_file_names[i]); | ||
155 | printf ("firmware write failed ....recheck \n"); | ||
156 | break; | ||
157 | |||
158 | default: | ||
159 | printf ("all firmware written successfully...all matched \n"); | ||
160 | break; | ||
161 | } | ||
162 | } | ||