Commit d6fc90ced42e9fb77185cedfe45d0a2c7ac78508
1 parent
c0e032e009
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
scripts/dtc: Update to upstream version v1.4.4
This adds the following commits from upstream: 558cd81bdd43 dtc: Bump version to v1.4.4 c17a811c62eb fdtput: Remove star from value_len documentation 194d5caaefcb fdtget: Use @return to document the return value d922ecdd017b tests: Make realloc_fdt() really allocate *fdt 921cc17fec29 libfdt: overlay: Check the value of the right variable 9ffdf60bf463 dtc: Simplify asm_emit_string() implementation 881012e44386 libfdt: Change names of sparse helper macros bad5b28049e5 Fix assorted sparse warnings 672ac09ea04d Clean up gcc attributes 49300f2ade6a dtc: Don't abuse struct fdt_reserve_entry Signed-off-by: Tom Rini <trini@konsulko.com>
Showing 14 changed files with 131 additions and 155 deletions Side-by-side Diff
- scripts/dtc/checks.c
- scripts/dtc/data.c
- scripts/dtc/dtc-lexer.l
- scripts/dtc/dtc-lexer.lex.c_shipped
- scripts/dtc/dtc.c
- scripts/dtc/dtc.h
- scripts/dtc/flattree.c
- scripts/dtc/libfdt/libfdt_env.h
- scripts/dtc/livetree.c
- scripts/dtc/srcpos.h
- scripts/dtc/treesource.c
- scripts/dtc/util.c
- scripts/dtc/util.h
- scripts/dtc/version_gen.h
scripts/dtc/checks.c
... | ... | @@ -72,12 +72,8 @@ |
72 | 72 | #define CHECK(_nm, _fn, _d, ...) \ |
73 | 73 | CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__) |
74 | 74 | |
75 | -#ifdef __GNUC__ | |
76 | -static inline void check_msg(struct check *c, struct dt_info *dti, | |
77 | - const char *fmt, ...) __attribute__((format (printf, 3, 4))); | |
78 | -#endif | |
79 | -static inline void check_msg(struct check *c, struct dt_info *dti, | |
80 | - const char *fmt, ...) | |
75 | +static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti, | |
76 | + const char *fmt, ...) | |
81 | 77 | { |
82 | 78 | va_list ap; |
83 | 79 | va_start(ap, fmt); |
84 | 80 | |
... | ... | @@ -538,13 +534,13 @@ |
538 | 534 | FAIL(c, dti, "Reference to non-existent node or " |
539 | 535 | "label \"%s\"\n", m->ref); |
540 | 536 | else /* mark the entry as unresolved */ |
541 | - *((cell_t *)(prop->val.val + m->offset)) = | |
537 | + *((fdt32_t *)(prop->val.val + m->offset)) = | |
542 | 538 | cpu_to_fdt32(0xffffffff); |
543 | 539 | continue; |
544 | 540 | } |
545 | 541 | |
546 | 542 | phandle = get_node_phandle(dt, refnode); |
547 | - *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); | |
543 | + *((fdt32_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); | |
548 | 544 | } |
549 | 545 | } |
550 | 546 | } |
scripts/dtc/data.c
... | ... | @@ -171,9 +171,9 @@ |
171 | 171 | struct data data_append_integer(struct data d, uint64_t value, int bits) |
172 | 172 | { |
173 | 173 | uint8_t value_8; |
174 | - uint16_t value_16; | |
175 | - uint32_t value_32; | |
176 | - uint64_t value_64; | |
174 | + fdt16_t value_16; | |
175 | + fdt32_t value_32; | |
176 | + fdt64_t value_64; | |
177 | 177 | |
178 | 178 | switch (bits) { |
179 | 179 | case 8: |
180 | 180 | |
181 | 181 | |
182 | 182 | |
... | ... | @@ -197,14 +197,14 @@ |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | -struct data data_append_re(struct data d, const struct fdt_reserve_entry *re) | |
200 | +struct data data_append_re(struct data d, uint64_t address, uint64_t size) | |
201 | 201 | { |
202 | - struct fdt_reserve_entry bere; | |
202 | + struct fdt_reserve_entry re; | |
203 | 203 | |
204 | - bere.address = cpu_to_fdt64(re->address); | |
205 | - bere.size = cpu_to_fdt64(re->size); | |
204 | + re.address = cpu_to_fdt64(address); | |
205 | + re.size = cpu_to_fdt64(size); | |
206 | 206 | |
207 | - return data_append_data(d, &bere, sizeof(bere)); | |
207 | + return data_append_data(d, &re, sizeof(re)); | |
208 | 208 | } |
209 | 209 | |
210 | 210 | struct data data_append_cell(struct data d, cell_t word) |
scripts/dtc/dtc-lexer.l
... | ... | @@ -62,12 +62,7 @@ |
62 | 62 | |
63 | 63 | static void push_input_file(const char *filename); |
64 | 64 | static bool pop_input_file(void); |
65 | -#ifdef __GNUC__ | |
66 | -static void lexical_error(const char *fmt, ...) | |
67 | - __attribute__((format (printf, 1, 2))); | |
68 | -#else | |
69 | -static void lexical_error(const char *fmt, ...); | |
70 | -#endif | |
65 | +static void PRINTF(1, 2) lexical_error(const char *fmt, ...); | |
71 | 66 | |
72 | 67 | %} |
73 | 68 |
scripts/dtc/dtc-lexer.lex.c_shipped
... | ... | @@ -663,14 +663,9 @@ |
663 | 663 | |
664 | 664 | static void push_input_file(const char *filename); |
665 | 665 | static bool pop_input_file(void); |
666 | -#ifdef __GNUC__ | |
667 | -static void lexical_error(const char *fmt, ...) | |
668 | - __attribute__((format (printf, 1, 2))); | |
669 | -#else | |
670 | -static void lexical_error(const char *fmt, ...); | |
671 | -#endif | |
666 | +static void PRINTF(1, 2) lexical_error(const char *fmt, ...); | |
672 | 667 | |
673 | -#line 674 "dtc-lexer.lex.c" | |
668 | +#line 669 "dtc-lexer.lex.c" | |
674 | 669 | |
675 | 670 | #define INITIAL 0 |
676 | 671 | #define BYTESTRING 1 |
677 | 672 | |
... | ... | @@ -861,9 +856,9 @@ |
861 | 856 | register char *yy_cp, *yy_bp; |
862 | 857 | register int yy_act; |
863 | 858 | |
864 | -#line 74 "dtc-lexer.l" | |
859 | +#line 69 "dtc-lexer.l" | |
865 | 860 | |
866 | -#line 867 "dtc-lexer.lex.c" | |
861 | +#line 862 "dtc-lexer.lex.c" | |
867 | 862 | |
868 | 863 | if ( !(yy_init) ) |
869 | 864 | { |
... | ... | @@ -946,7 +941,7 @@ |
946 | 941 | case 1: |
947 | 942 | /* rule 1 can match eol */ |
948 | 943 | YY_RULE_SETUP |
949 | -#line 75 "dtc-lexer.l" | |
944 | +#line 70 "dtc-lexer.l" | |
950 | 945 | { |
951 | 946 | char *name = strchr(yytext, '\"') + 1; |
952 | 947 | yytext[yyleng-1] = '\0'; |
... | ... | @@ -956,7 +951,7 @@ |
956 | 951 | case 2: |
957 | 952 | /* rule 2 can match eol */ |
958 | 953 | YY_RULE_SETUP |
959 | -#line 81 "dtc-lexer.l" | |
954 | +#line 76 "dtc-lexer.l" | |
960 | 955 | { |
961 | 956 | char *line, *fnstart, *fnend; |
962 | 957 | struct data fn; |
... | ... | @@ -990,7 +985,7 @@ |
990 | 985 | case YY_STATE_EOF(BYTESTRING): |
991 | 986 | case YY_STATE_EOF(PROPNODENAME): |
992 | 987 | case YY_STATE_EOF(V1): |
993 | -#line 110 "dtc-lexer.l" | |
988 | +#line 105 "dtc-lexer.l" | |
994 | 989 | { |
995 | 990 | if (!pop_input_file()) { |
996 | 991 | yyterminate(); |
... | ... | @@ -1000,7 +995,7 @@ |
1000 | 995 | case 3: |
1001 | 996 | /* rule 3 can match eol */ |
1002 | 997 | YY_RULE_SETUP |
1003 | -#line 116 "dtc-lexer.l" | |
998 | +#line 111 "dtc-lexer.l" | |
1004 | 999 | { |
1005 | 1000 | DPRINT("String: %s\n", yytext); |
1006 | 1001 | yylval.data = data_copy_escape_string(yytext+1, |
... | ... | @@ -1010,7 +1005,7 @@ |
1010 | 1005 | YY_BREAK |
1011 | 1006 | case 4: |
1012 | 1007 | YY_RULE_SETUP |
1013 | -#line 123 "dtc-lexer.l" | |
1008 | +#line 118 "dtc-lexer.l" | |
1014 | 1009 | { |
1015 | 1010 | DPRINT("Keyword: /dts-v1/\n"); |
1016 | 1011 | dts_version = 1; |
... | ... | @@ -1020,7 +1015,7 @@ |
1020 | 1015 | YY_BREAK |
1021 | 1016 | case 5: |
1022 | 1017 | YY_RULE_SETUP |
1023 | -#line 130 "dtc-lexer.l" | |
1018 | +#line 125 "dtc-lexer.l" | |
1024 | 1019 | { |
1025 | 1020 | DPRINT("Keyword: /plugin/\n"); |
1026 | 1021 | return DT_PLUGIN; |
... | ... | @@ -1028,7 +1023,7 @@ |
1028 | 1023 | YY_BREAK |
1029 | 1024 | case 6: |
1030 | 1025 | YY_RULE_SETUP |
1031 | -#line 135 "dtc-lexer.l" | |
1026 | +#line 130 "dtc-lexer.l" | |
1032 | 1027 | { |
1033 | 1028 | DPRINT("Keyword: /memreserve/\n"); |
1034 | 1029 | BEGIN_DEFAULT(); |
... | ... | @@ -1037,7 +1032,7 @@ |
1037 | 1032 | YY_BREAK |
1038 | 1033 | case 7: |
1039 | 1034 | YY_RULE_SETUP |
1040 | -#line 141 "dtc-lexer.l" | |
1035 | +#line 136 "dtc-lexer.l" | |
1041 | 1036 | { |
1042 | 1037 | DPRINT("Keyword: /bits/\n"); |
1043 | 1038 | BEGIN_DEFAULT(); |
... | ... | @@ -1046,7 +1041,7 @@ |
1046 | 1041 | YY_BREAK |
1047 | 1042 | case 8: |
1048 | 1043 | YY_RULE_SETUP |
1049 | -#line 147 "dtc-lexer.l" | |
1044 | +#line 142 "dtc-lexer.l" | |
1050 | 1045 | { |
1051 | 1046 | DPRINT("Keyword: /delete-property/\n"); |
1052 | 1047 | DPRINT("<PROPNODENAME>\n"); |
... | ... | @@ -1056,7 +1051,7 @@ |
1056 | 1051 | YY_BREAK |
1057 | 1052 | case 9: |
1058 | 1053 | YY_RULE_SETUP |
1059 | -#line 154 "dtc-lexer.l" | |
1054 | +#line 149 "dtc-lexer.l" | |
1060 | 1055 | { |
1061 | 1056 | DPRINT("Keyword: /delete-node/\n"); |
1062 | 1057 | DPRINT("<PROPNODENAME>\n"); |
... | ... | @@ -1066,7 +1061,7 @@ |
1066 | 1061 | YY_BREAK |
1067 | 1062 | case 10: |
1068 | 1063 | YY_RULE_SETUP |
1069 | -#line 161 "dtc-lexer.l" | |
1064 | +#line 156 "dtc-lexer.l" | |
1070 | 1065 | { |
1071 | 1066 | DPRINT("Label: %s\n", yytext); |
1072 | 1067 | yylval.labelref = xstrdup(yytext); |
... | ... | @@ -1076,7 +1071,7 @@ |
1076 | 1071 | YY_BREAK |
1077 | 1072 | case 11: |
1078 | 1073 | YY_RULE_SETUP |
1079 | -#line 168 "dtc-lexer.l" | |
1074 | +#line 163 "dtc-lexer.l" | |
1080 | 1075 | { |
1081 | 1076 | char *e; |
1082 | 1077 | DPRINT("Integer Literal: '%s'\n", yytext); |
... | ... | @@ -1102,7 +1097,7 @@ |
1102 | 1097 | case 12: |
1103 | 1098 | /* rule 12 can match eol */ |
1104 | 1099 | YY_RULE_SETUP |
1105 | -#line 190 "dtc-lexer.l" | |
1100 | +#line 185 "dtc-lexer.l" | |
1106 | 1101 | { |
1107 | 1102 | struct data d; |
1108 | 1103 | DPRINT("Character literal: %s\n", yytext); |
... | ... | @@ -1126,7 +1121,7 @@ |
1126 | 1121 | YY_BREAK |
1127 | 1122 | case 13: |
1128 | 1123 | YY_RULE_SETUP |
1129 | -#line 211 "dtc-lexer.l" | |
1124 | +#line 206 "dtc-lexer.l" | |
1130 | 1125 | { /* label reference */ |
1131 | 1126 | DPRINT("Ref: %s\n", yytext+1); |
1132 | 1127 | yylval.labelref = xstrdup(yytext+1); |
... | ... | @@ -1135,7 +1130,7 @@ |
1135 | 1130 | YY_BREAK |
1136 | 1131 | case 14: |
1137 | 1132 | YY_RULE_SETUP |
1138 | -#line 217 "dtc-lexer.l" | |
1133 | +#line 212 "dtc-lexer.l" | |
1139 | 1134 | { /* new-style path reference */ |
1140 | 1135 | yytext[yyleng-1] = '\0'; |
1141 | 1136 | DPRINT("Ref: %s\n", yytext+2); |
... | ... | @@ -1145,7 +1140,7 @@ |
1145 | 1140 | YY_BREAK |
1146 | 1141 | case 15: |
1147 | 1142 | YY_RULE_SETUP |
1148 | -#line 224 "dtc-lexer.l" | |
1143 | +#line 219 "dtc-lexer.l" | |
1149 | 1144 | { |
1150 | 1145 | yylval.byte = strtol(yytext, NULL, 16); |
1151 | 1146 | DPRINT("Byte: %02x\n", (int)yylval.byte); |
... | ... | @@ -1154,7 +1149,7 @@ |
1154 | 1149 | YY_BREAK |
1155 | 1150 | case 16: |
1156 | 1151 | YY_RULE_SETUP |
1157 | -#line 230 "dtc-lexer.l" | |
1152 | +#line 225 "dtc-lexer.l" | |
1158 | 1153 | { |
1159 | 1154 | DPRINT("/BYTESTRING\n"); |
1160 | 1155 | BEGIN_DEFAULT(); |
... | ... | @@ -1163,7 +1158,7 @@ |
1163 | 1158 | YY_BREAK |
1164 | 1159 | case 17: |
1165 | 1160 | YY_RULE_SETUP |
1166 | -#line 236 "dtc-lexer.l" | |
1161 | +#line 231 "dtc-lexer.l" | |
1167 | 1162 | { |
1168 | 1163 | DPRINT("PropNodeName: %s\n", yytext); |
1169 | 1164 | yylval.propnodename = xstrdup((yytext[0] == '\\') ? |
... | ... | @@ -1174,7 +1169,7 @@ |
1174 | 1169 | YY_BREAK |
1175 | 1170 | case 18: |
1176 | 1171 | YY_RULE_SETUP |
1177 | -#line 244 "dtc-lexer.l" | |
1172 | +#line 239 "dtc-lexer.l" | |
1178 | 1173 | { |
1179 | 1174 | DPRINT("Binary Include\n"); |
1180 | 1175 | return DT_INCBIN; |
1181 | 1176 | |
1182 | 1177 | |
1183 | 1178 | |
1184 | 1179 | |
1185 | 1180 | |
1186 | 1181 | |
1187 | 1182 | |
1188 | 1183 | |
1189 | 1184 | |
1190 | 1185 | |
1191 | 1186 | |
... | ... | @@ -1183,64 +1178,64 @@ |
1183 | 1178 | case 19: |
1184 | 1179 | /* rule 19 can match eol */ |
1185 | 1180 | YY_RULE_SETUP |
1186 | -#line 249 "dtc-lexer.l" | |
1181 | +#line 244 "dtc-lexer.l" | |
1187 | 1182 | /* eat whitespace */ |
1188 | 1183 | YY_BREAK |
1189 | 1184 | case 20: |
1190 | 1185 | /* rule 20 can match eol */ |
1191 | 1186 | YY_RULE_SETUP |
1192 | -#line 250 "dtc-lexer.l" | |
1187 | +#line 245 "dtc-lexer.l" | |
1193 | 1188 | /* eat C-style comments */ |
1194 | 1189 | YY_BREAK |
1195 | 1190 | case 21: |
1196 | 1191 | /* rule 21 can match eol */ |
1197 | 1192 | YY_RULE_SETUP |
1198 | -#line 251 "dtc-lexer.l" | |
1193 | +#line 246 "dtc-lexer.l" | |
1199 | 1194 | /* eat C++-style comments */ |
1200 | 1195 | YY_BREAK |
1201 | 1196 | case 22: |
1202 | 1197 | YY_RULE_SETUP |
1203 | -#line 253 "dtc-lexer.l" | |
1198 | +#line 248 "dtc-lexer.l" | |
1204 | 1199 | { return DT_LSHIFT; }; |
1205 | 1200 | YY_BREAK |
1206 | 1201 | case 23: |
1207 | 1202 | YY_RULE_SETUP |
1208 | -#line 254 "dtc-lexer.l" | |
1203 | +#line 249 "dtc-lexer.l" | |
1209 | 1204 | { return DT_RSHIFT; }; |
1210 | 1205 | YY_BREAK |
1211 | 1206 | case 24: |
1212 | 1207 | YY_RULE_SETUP |
1213 | -#line 255 "dtc-lexer.l" | |
1208 | +#line 250 "dtc-lexer.l" | |
1214 | 1209 | { return DT_LE; }; |
1215 | 1210 | YY_BREAK |
1216 | 1211 | case 25: |
1217 | 1212 | YY_RULE_SETUP |
1218 | -#line 256 "dtc-lexer.l" | |
1213 | +#line 251 "dtc-lexer.l" | |
1219 | 1214 | { return DT_GE; }; |
1220 | 1215 | YY_BREAK |
1221 | 1216 | case 26: |
1222 | 1217 | YY_RULE_SETUP |
1223 | -#line 257 "dtc-lexer.l" | |
1218 | +#line 252 "dtc-lexer.l" | |
1224 | 1219 | { return DT_EQ; }; |
1225 | 1220 | YY_BREAK |
1226 | 1221 | case 27: |
1227 | 1222 | YY_RULE_SETUP |
1228 | -#line 258 "dtc-lexer.l" | |
1223 | +#line 253 "dtc-lexer.l" | |
1229 | 1224 | { return DT_NE; }; |
1230 | 1225 | YY_BREAK |
1231 | 1226 | case 28: |
1232 | 1227 | YY_RULE_SETUP |
1233 | -#line 259 "dtc-lexer.l" | |
1228 | +#line 254 "dtc-lexer.l" | |
1234 | 1229 | { return DT_AND; }; |
1235 | 1230 | YY_BREAK |
1236 | 1231 | case 29: |
1237 | 1232 | YY_RULE_SETUP |
1238 | -#line 260 "dtc-lexer.l" | |
1233 | +#line 255 "dtc-lexer.l" | |
1239 | 1234 | { return DT_OR; }; |
1240 | 1235 | YY_BREAK |
1241 | 1236 | case 30: |
1242 | 1237 | YY_RULE_SETUP |
1243 | -#line 262 "dtc-lexer.l" | |
1238 | +#line 257 "dtc-lexer.l" | |
1244 | 1239 | { |
1245 | 1240 | DPRINT("Char: %c (\\x%02x)\n", yytext[0], |
1246 | 1241 | (unsigned)yytext[0]); |
1247 | 1242 | |
... | ... | @@ -1258,10 +1253,10 @@ |
1258 | 1253 | YY_BREAK |
1259 | 1254 | case 31: |
1260 | 1255 | YY_RULE_SETUP |
1261 | -#line 277 "dtc-lexer.l" | |
1256 | +#line 272 "dtc-lexer.l" | |
1262 | 1257 | ECHO; |
1263 | 1258 | YY_BREAK |
1264 | -#line 1265 "dtc-lexer.lex.c" | |
1259 | +#line 1260 "dtc-lexer.lex.c" | |
1265 | 1260 | |
1266 | 1261 | case YY_END_OF_BUFFER: |
1267 | 1262 | { |
... | ... | @@ -2220,7 +2215,7 @@ |
2220 | 2215 | |
2221 | 2216 | #define YYTABLES_NAME "yytables" |
2222 | 2217 | |
2223 | -#line 277 "dtc-lexer.l" | |
2218 | +#line 272 "dtc-lexer.l" | |
2224 | 2219 | |
2225 | 2220 | |
2226 | 2221 |
scripts/dtc/dtc.c
... | ... | @@ -138,7 +138,7 @@ |
138 | 138 | static const char *guess_input_format(const char *fname, const char *fallback) |
139 | 139 | { |
140 | 140 | struct stat statbuf; |
141 | - uint32_t magic; | |
141 | + fdt32_t magic; | |
142 | 142 | FILE *f; |
143 | 143 | |
144 | 144 | if (stat(fname, &statbuf) != 0) |
... | ... | @@ -159,8 +159,7 @@ |
159 | 159 | } |
160 | 160 | fclose(f); |
161 | 161 | |
162 | - magic = fdt32_to_cpu(magic); | |
163 | - if (magic == FDT_MAGIC) | |
162 | + if (fdt32_to_cpu(magic) == FDT_MAGIC) | |
164 | 163 | return "dtb"; |
165 | 164 | |
166 | 165 | return guess_type_by_name(fname, fallback); |
scripts/dtc/dtc.h
... | ... | @@ -43,7 +43,6 @@ |
43 | 43 | #define debug(...) |
44 | 44 | #endif |
45 | 45 | |
46 | - | |
47 | 46 | #define DEFAULT_FDT_VERSION 17 |
48 | 47 | |
49 | 48 | /* |
... | ... | @@ -114,7 +113,7 @@ |
114 | 113 | struct data data_merge(struct data d1, struct data d2); |
115 | 114 | struct data data_append_cell(struct data d, cell_t word); |
116 | 115 | struct data data_append_integer(struct data d, uint64_t word, int bits); |
117 | -struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); | |
116 | +struct data data_append_re(struct data d, uint64_t address, uint64_t size); | |
118 | 117 | struct data data_append_addr(struct data d, uint64_t addr); |
119 | 118 | struct data data_append_byte(struct data d, uint8_t byte); |
120 | 119 | struct data data_append_zeroes(struct data d, int len); |
... | ... | @@ -227,7 +226,7 @@ |
227 | 226 | /* Boot info (tree plus memreserve information */ |
228 | 227 | |
229 | 228 | struct reserve_info { |
230 | - struct fdt_reserve_entry re; | |
229 | + uint64_t address, size; | |
231 | 230 | |
232 | 231 | struct reserve_info *next; |
233 | 232 |
scripts/dtc/flattree.c
... | ... | @@ -49,7 +49,7 @@ |
49 | 49 | |
50 | 50 | struct emitter { |
51 | 51 | void (*cell)(void *, cell_t); |
52 | - void (*string)(void *, char *, int); | |
52 | + void (*string)(void *, const char *, int); | |
53 | 53 | void (*align)(void *, int); |
54 | 54 | void (*data)(void *, struct data); |
55 | 55 | void (*beginnode)(void *, struct label *labels); |
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 | *dtbuf = data_append_cell(*dtbuf, val); |
65 | 65 | } |
66 | 66 | |
67 | -static void bin_emit_string(void *e, char *str, int len) | |
67 | +static void bin_emit_string(void *e, const char *str, int len) | |
68 | 68 | { |
69 | 69 | struct data *dtbuf = e; |
70 | 70 | |
71 | 71 | |
72 | 72 | |
... | ... | @@ -144,22 +144,14 @@ |
144 | 144 | (val >> 8) & 0xff, val & 0xff); |
145 | 145 | } |
146 | 146 | |
147 | -static void asm_emit_string(void *e, char *str, int len) | |
147 | +static void asm_emit_string(void *e, const char *str, int len) | |
148 | 148 | { |
149 | 149 | FILE *f = e; |
150 | - char c = 0; | |
151 | 150 | |
152 | - if (len != 0) { | |
153 | - /* XXX: ewww */ | |
154 | - c = str[len]; | |
155 | - str[len] = '\0'; | |
156 | - } | |
157 | - | |
158 | - fprintf(f, "\t.string\t\"%s\"\n", str); | |
159 | - | |
160 | - if (len != 0) { | |
161 | - str[len] = c; | |
162 | - } | |
151 | + if (len != 0) | |
152 | + fprintf(f, "\t.string\t\"%.*s\"\n", len, str); | |
153 | + else | |
154 | + fprintf(f, "\t.string\t\"%s\"\n", str); | |
163 | 155 | } |
164 | 156 | |
165 | 157 | static void asm_emit_align(void *e, int a) |
... | ... | @@ -179,7 +171,7 @@ |
179 | 171 | emit_offset_label(f, m->ref, m->offset); |
180 | 172 | |
181 | 173 | while ((d.len - off) >= sizeof(uint32_t)) { |
182 | - asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off)))); | |
174 | + asm_emit_cell(e, fdt32_to_cpu(*((fdt32_t *)(d.val+off)))); | |
183 | 175 | off += sizeof(uint32_t); |
184 | 176 | } |
185 | 177 | |
186 | 178 | |
187 | 179 | |
... | ... | @@ -318,17 +310,16 @@ |
318 | 310 | { |
319 | 311 | struct reserve_info *re; |
320 | 312 | struct data d = empty_data; |
321 | - static struct fdt_reserve_entry null_re = {0,0}; | |
322 | 313 | int j; |
323 | 314 | |
324 | 315 | for (re = reservelist; re; re = re->next) { |
325 | - d = data_append_re(d, &re->re); | |
316 | + d = data_append_re(d, re->address, re->size); | |
326 | 317 | } |
327 | 318 | /* |
328 | 319 | * Add additional reserved slots if the user asked for them. |
329 | 320 | */ |
330 | 321 | for (j = 0; j < reservenum; j++) { |
331 | - d = data_append_re(d, &null_re); | |
322 | + d = data_append_re(d, 0, 0); | |
332 | 323 | } |
333 | 324 | |
334 | 325 | return d; |
335 | 326 | |
... | ... | @@ -544,11 +535,11 @@ |
544 | 535 | fprintf(f, "\t.globl\t%s\n", l->label); |
545 | 536 | fprintf(f, "%s:\n", l->label); |
546 | 537 | } |
547 | - ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.address >> 32)); | |
538 | + ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->address >> 32)); | |
548 | 539 | ASM_EMIT_BELONG(f, "0x%08x", |
549 | - (unsigned int)(re->re.address & 0xffffffff)); | |
550 | - ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size >> 32)); | |
551 | - ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size & 0xffffffff)); | |
540 | + (unsigned int)(re->address & 0xffffffff)); | |
541 | + ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->size >> 32)); | |
542 | + ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->size & 0xffffffff)); | |
552 | 543 | } |
553 | 544 | for (i = 0; i < reservenum; i++) { |
554 | 545 | fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n"); |
... | ... | @@ -609,7 +600,7 @@ |
609 | 600 | |
610 | 601 | static uint32_t flat_read_word(struct inbuf *inb) |
611 | 602 | { |
612 | - uint32_t val; | |
603 | + fdt32_t val; | |
613 | 604 | |
614 | 605 | assert(((inb->ptr - inb->base) % sizeof(val)) == 0); |
615 | 606 | |
616 | 607 | |
617 | 608 | |
... | ... | @@ -718,13 +709,15 @@ |
718 | 709 | * First pass, count entries. |
719 | 710 | */ |
720 | 711 | while (1) { |
712 | + uint64_t address, size; | |
713 | + | |
721 | 714 | flat_read_chunk(inb, &re, sizeof(re)); |
722 | - re.address = fdt64_to_cpu(re.address); | |
723 | - re.size = fdt64_to_cpu(re.size); | |
724 | - if (re.size == 0) | |
715 | + address = fdt64_to_cpu(re.address); | |
716 | + size = fdt64_to_cpu(re.size); | |
717 | + if (size == 0) | |
725 | 718 | break; |
726 | 719 | |
727 | - new = build_reserve_entry(re.address, re.size); | |
720 | + new = build_reserve_entry(address, size); | |
728 | 721 | reservelist = add_reserve_entry(reservelist, new); |
729 | 722 | } |
730 | 723 | |
... | ... | @@ -817,6 +810,7 @@ |
817 | 810 | struct dt_info *dt_from_blob(const char *fname) |
818 | 811 | { |
819 | 812 | FILE *f; |
813 | + fdt32_t magic_buf, totalsize_buf; | |
820 | 814 | uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys; |
821 | 815 | uint32_t off_dt, off_str, off_mem_rsvmap; |
822 | 816 | int rc; |
... | ... | @@ -833,7 +827,7 @@ |
833 | 827 | |
834 | 828 | f = srcfile_relative_open(fname, NULL); |
835 | 829 | |
836 | - rc = fread(&magic, sizeof(magic), 1, f); | |
830 | + rc = fread(&magic_buf, sizeof(magic_buf), 1, f); | |
837 | 831 | if (ferror(f)) |
838 | 832 | die("Error reading DT blob magic number: %s\n", |
839 | 833 | strerror(errno)); |
840 | 834 | |
... | ... | @@ -844,11 +838,11 @@ |
844 | 838 | die("Mysterious short read reading magic number\n"); |
845 | 839 | } |
846 | 840 | |
847 | - magic = fdt32_to_cpu(magic); | |
841 | + magic = fdt32_to_cpu(magic_buf); | |
848 | 842 | if (magic != FDT_MAGIC) |
849 | 843 | die("Blob has incorrect magic number\n"); |
850 | 844 | |
851 | - rc = fread(&totalsize, sizeof(totalsize), 1, f); | |
845 | + rc = fread(&totalsize_buf, sizeof(totalsize_buf), 1, f); | |
852 | 846 | if (ferror(f)) |
853 | 847 | die("Error reading DT blob size: %s\n", strerror(errno)); |
854 | 848 | if (rc < 1) { |
... | ... | @@ -858,7 +852,7 @@ |
858 | 852 | die("Mysterious short read reading blob size\n"); |
859 | 853 | } |
860 | 854 | |
861 | - totalsize = fdt32_to_cpu(totalsize); | |
855 | + totalsize = fdt32_to_cpu(totalsize_buf); | |
862 | 856 | if (totalsize < FDT_V1_SIZE) |
863 | 857 | die("DT blob size (%d) is too small\n", totalsize); |
864 | 858 |
scripts/dtc/libfdt/libfdt_env.h
... | ... | @@ -58,16 +58,16 @@ |
58 | 58 | #include <string.h> |
59 | 59 | |
60 | 60 | #ifdef __CHECKER__ |
61 | -#define __force __attribute__((force)) | |
62 | -#define __bitwise __attribute__((bitwise)) | |
61 | +#define FDT_FORCE __attribute__((force)) | |
62 | +#define FDT_BITWISE __attribute__((bitwise)) | |
63 | 63 | #else |
64 | -#define __force | |
65 | -#define __bitwise | |
64 | +#define FDT_FORCE | |
65 | +#define FDT_BITWISE | |
66 | 66 | #endif |
67 | 67 | |
68 | -typedef uint16_t __bitwise fdt16_t; | |
69 | -typedef uint32_t __bitwise fdt32_t; | |
70 | -typedef uint64_t __bitwise fdt64_t; | |
68 | +typedef uint16_t FDT_BITWISE fdt16_t; | |
69 | +typedef uint32_t FDT_BITWISE fdt32_t; | |
70 | +typedef uint64_t FDT_BITWISE fdt64_t; | |
71 | 71 | |
72 | 72 | #define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n]) |
73 | 73 | #define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1)) |
74 | 74 | |
75 | 75 | |
76 | 76 | |
77 | 77 | |
78 | 78 | |
... | ... | @@ -80,29 +80,29 @@ |
80 | 80 | |
81 | 81 | static inline uint16_t fdt16_to_cpu(fdt16_t x) |
82 | 82 | { |
83 | - return (__force uint16_t)CPU_TO_FDT16(x); | |
83 | + return (FDT_FORCE uint16_t)CPU_TO_FDT16(x); | |
84 | 84 | } |
85 | 85 | static inline fdt16_t cpu_to_fdt16(uint16_t x) |
86 | 86 | { |
87 | - return (__force fdt16_t)CPU_TO_FDT16(x); | |
87 | + return (FDT_FORCE fdt16_t)CPU_TO_FDT16(x); | |
88 | 88 | } |
89 | 89 | |
90 | 90 | static inline uint32_t fdt32_to_cpu(fdt32_t x) |
91 | 91 | { |
92 | - return (__force uint32_t)CPU_TO_FDT32(x); | |
92 | + return (FDT_FORCE uint32_t)CPU_TO_FDT32(x); | |
93 | 93 | } |
94 | 94 | static inline fdt32_t cpu_to_fdt32(uint32_t x) |
95 | 95 | { |
96 | - return (__force fdt32_t)CPU_TO_FDT32(x); | |
96 | + return (FDT_FORCE fdt32_t)CPU_TO_FDT32(x); | |
97 | 97 | } |
98 | 98 | |
99 | 99 | static inline uint64_t fdt64_to_cpu(fdt64_t x) |
100 | 100 | { |
101 | - return (__force uint64_t)CPU_TO_FDT64(x); | |
101 | + return (FDT_FORCE uint64_t)CPU_TO_FDT64(x); | |
102 | 102 | } |
103 | 103 | static inline fdt64_t cpu_to_fdt64(uint64_t x) |
104 | 104 | { |
105 | - return (__force fdt64_t)CPU_TO_FDT64(x); | |
105 | + return (FDT_FORCE fdt64_t)CPU_TO_FDT64(x); | |
106 | 106 | } |
107 | 107 | #undef CPU_TO_FDT64 |
108 | 108 | #undef CPU_TO_FDT32 |
scripts/dtc/livetree.c
... | ... | @@ -319,8 +319,8 @@ |
319 | 319 | |
320 | 320 | memset(new, 0, sizeof(*new)); |
321 | 321 | |
322 | - new->re.address = address; | |
323 | - new->re.size = size; | |
322 | + new->address = address; | |
323 | + new->size = size; | |
324 | 324 | |
325 | 325 | return new; |
326 | 326 | } |
... | ... | @@ -393,7 +393,7 @@ |
393 | 393 | cell_t propval_cell(struct property *prop) |
394 | 394 | { |
395 | 395 | assert(prop->val.len == sizeof(cell_t)); |
396 | - return fdt32_to_cpu(*((cell_t *)prop->val.val)); | |
396 | + return fdt32_to_cpu(*((fdt32_t *)prop->val.val)); | |
397 | 397 | } |
398 | 398 | |
399 | 399 | struct property *get_property_by_label(struct node *tree, const char *label, |
400 | 400 | |
401 | 401 | |
402 | 402 | |
... | ... | @@ -599,13 +599,13 @@ |
599 | 599 | a = *((const struct reserve_info * const *)ax); |
600 | 600 | b = *((const struct reserve_info * const *)bx); |
601 | 601 | |
602 | - if (a->re.address < b->re.address) | |
602 | + if (a->address < b->address) | |
603 | 603 | return -1; |
604 | - else if (a->re.address > b->re.address) | |
604 | + else if (a->address > b->address) | |
605 | 605 | return 1; |
606 | - else if (a->re.size < b->re.size) | |
606 | + else if (a->size < b->size) | |
607 | 607 | return -1; |
608 | - else if (a->re.size > b->re.size) | |
608 | + else if (a->size > b->size) | |
609 | 609 | return 1; |
610 | 610 | else |
611 | 611 | return 0; |
... | ... | @@ -902,7 +902,7 @@ |
902 | 902 | struct node *refnode) |
903 | 903 | { |
904 | 904 | struct node *wn, *nwn; /* local fixup node, walk node, new */ |
905 | - uint32_t value_32; | |
905 | + fdt32_t value_32; | |
906 | 906 | char **compp; |
907 | 907 | int i, depth; |
908 | 908 |
scripts/dtc/srcpos.h
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 | |
23 | 23 | #include <stdio.h> |
24 | 24 | #include <stdbool.h> |
25 | +#include "util.h" | |
25 | 26 | |
26 | 27 | struct srcfile_state { |
27 | 28 | FILE *f; |
... | ... | @@ -106,12 +107,10 @@ |
106 | 107 | extern struct srcpos *srcpos_copy(struct srcpos *pos); |
107 | 108 | extern char *srcpos_string(struct srcpos *pos); |
108 | 109 | |
109 | -extern void srcpos_verror(struct srcpos *pos, const char *prefix, | |
110 | - const char *fmt, va_list va) | |
111 | - __attribute__((format(printf, 3, 0))); | |
112 | -extern void srcpos_error(struct srcpos *pos, const char *prefix, | |
113 | - const char *fmt, ...) | |
114 | - __attribute__((format(printf, 3, 4))); | |
110 | +extern void PRINTF(3, 0) srcpos_verror(struct srcpos *pos, const char *prefix, | |
111 | + const char *fmt, va_list va); | |
112 | +extern void PRINTF(3, 4) srcpos_error(struct srcpos *pos, const char *prefix, | |
113 | + const char *fmt, ...); | |
115 | 114 | |
116 | 115 | extern void srcpos_set_line(char *f, int l); |
117 | 116 |
scripts/dtc/treesource.c
... | ... | @@ -137,7 +137,7 @@ |
137 | 137 | static void write_propval_cells(FILE *f, struct data val) |
138 | 138 | { |
139 | 139 | void *propend = val.val + val.len; |
140 | - cell_t *cp = (cell_t *)val.val; | |
140 | + fdt32_t *cp = (fdt32_t *)val.val; | |
141 | 141 | struct marker *m = val.markers; |
142 | 142 | |
143 | 143 | fprintf(f, "<"); |
... | ... | @@ -275,8 +275,8 @@ |
275 | 275 | for_each_label(re->labels, l) |
276 | 276 | fprintf(f, "%s: ", l->label); |
277 | 277 | fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n", |
278 | - (unsigned long long)re->re.address, | |
279 | - (unsigned long long)re->re.size); | |
278 | + (unsigned long long)re->address, | |
279 | + (unsigned long long)re->size); | |
280 | 280 | } |
281 | 281 | |
282 | 282 | write_tree_source_node(f, dti->dt, 0); |
scripts/dtc/util.c
... | ... | @@ -396,7 +396,7 @@ |
396 | 396 | } while (s < data + len); |
397 | 397 | |
398 | 398 | } else if ((len % 4) == 0) { |
399 | - const uint32_t *cell = (const uint32_t *)data; | |
399 | + const fdt32_t *cell = (const fdt32_t *)data; | |
400 | 400 | |
401 | 401 | printf(" = <"); |
402 | 402 | for (i = 0, len /= 4; i < len; i++) |
403 | 403 | |
... | ... | @@ -412,15 +412,16 @@ |
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | -void util_version(void) | |
415 | +void NORETURN util_version(void) | |
416 | 416 | { |
417 | 417 | printf("Version: %s\n", DTC_VERSION); |
418 | 418 | exit(0); |
419 | 419 | } |
420 | 420 | |
421 | -void util_usage(const char *errmsg, const char *synopsis, | |
422 | - const char *short_opts, struct option const long_opts[], | |
423 | - const char * const opts_help[]) | |
421 | +void NORETURN util_usage(const char *errmsg, const char *synopsis, | |
422 | + const char *short_opts, | |
423 | + struct option const long_opts[], | |
424 | + const char * const opts_help[]) | |
424 | 425 | { |
425 | 426 | FILE *fp = errmsg ? stderr : stdout; |
426 | 427 | const char a_arg[] = "<arg>"; |
scripts/dtc/util.h
... | ... | @@ -25,15 +25,17 @@ |
25 | 25 | * USA |
26 | 26 | */ |
27 | 27 | |
28 | -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | |
29 | - | |
30 | 28 | #ifdef __GNUC__ |
31 | -static inline void | |
32 | -__attribute__((noreturn)) __attribute__((format (printf, 1, 2))) | |
33 | -die(const char *str, ...) | |
29 | +#define PRINTF(i, j) __attribute__((format (printf, i, j))) | |
30 | +#define NORETURN __attribute__((noreturn)) | |
34 | 31 | #else |
35 | -static inline void die(const char *str, ...) | |
32 | +#define PRINTF(i, j) | |
33 | +#define NORETURN | |
36 | 34 | #endif |
35 | + | |
36 | +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | |
37 | + | |
38 | +static inline void NORETURN PRINTF(1, 2) die(const char *str, ...) | |
37 | 39 | { |
38 | 40 | va_list ap; |
39 | 41 | |
... | ... | @@ -66,12 +68,7 @@ |
66 | 68 | |
67 | 69 | extern char *xstrdup(const char *s); |
68 | 70 | |
69 | -#ifdef __GNUC__ | |
70 | -extern int __attribute__((format (printf, 2, 3))) | |
71 | -xasprintf(char **strp, const char *fmt, ...); | |
72 | -#else | |
73 | -extern int xasprintf(char **strp, const char *fmt, ...); | |
74 | -#endif | |
71 | +extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...); | |
75 | 72 | extern char *join_path(const char *path, const char *name); |
76 | 73 | |
77 | 74 | /** |
... | ... | @@ -200,7 +197,7 @@ |
200 | 197 | /** |
201 | 198 | * Show source version and exit |
202 | 199 | */ |
203 | -void util_version(void) __attribute__((noreturn)); | |
200 | +void NORETURN util_version(void); | |
204 | 201 | |
205 | 202 | /** |
206 | 203 | * Show usage and exit |
... | ... | @@ -214,9 +211,10 @@ |
214 | 211 | * @param long_opts The structure of long options |
215 | 212 | * @param opts_help An array of help strings (should align with long_opts) |
216 | 213 | */ |
217 | -void util_usage(const char *errmsg, const char *synopsis, | |
218 | - const char *short_opts, struct option const long_opts[], | |
219 | - const char * const opts_help[]) __attribute__((noreturn)); | |
214 | +void NORETURN util_usage(const char *errmsg, const char *synopsis, | |
215 | + const char *short_opts, | |
216 | + struct option const long_opts[], | |
217 | + const char * const opts_help[]); | |
220 | 218 | |
221 | 219 | /** |
222 | 220 | * Show usage and exit |
scripts/dtc/version_gen.h