| 1294 | } |
| 1295 | |
| 1296 | static int cbfstool_convert_mkpayload(struct buffer *buffer, |
| 1297 | unused uint32_t *offset, struct cbfs_file *header) |
| 1298 | { |
| 1299 | struct buffer output; |
| 1300 | int ret; |
| 1301 | /* Per default, try and see if payload is an ELF binary */ |
| 1302 | ret = parse_elf_to_payload(buffer, &output, param.compression); |
| 1303 | |
| 1304 | /* If it's not an ELF, see if it's a FIT */ |
| 1305 | if (ret != 0) { |
| 1306 | ret = parse_fit_to_payload(buffer, &output, param.compression); |
| 1307 | if (ret == 0) |
| 1308 | header->type = htobe32(CBFS_TYPE_FIT_PAYLOAD); |
| 1309 | } |
| 1310 | |
| 1311 | /* If it's not an FIT, see if it's a UEFI FV */ |
| 1312 | if (ret != 0) |
| 1313 | ret = parse_fv_to_payload(buffer, &output, param.compression); |
| 1314 | |
| 1315 | /* If it's neither ELF nor UEFI Fv, try bzImage */ |
| 1316 | if (ret != 0) |
| 1317 | ret = parse_bzImage_to_payload(buffer, &output, |
| 1318 | param.initrd, param.cmdline, param.compression); |
| 1319 | |
| 1320 | /* Not a supported payload type */ |
| 1321 | if (ret != 0) { |
| 1322 | ERROR("Not a supported payload type (ELF / FV).\n"); |
| 1323 | buffer_delete(buffer); |
| 1324 | return -1; |
| 1325 | } |
| 1326 | |
| 1327 | buffer_delete(buffer); |
| 1328 | // Direct assign, no dupe. |
| 1329 | memcpy(buffer, &output, sizeof(*buffer)); |
| 1330 | header->len = htobe32(output.size); |
| 1331 | return 0; |
| 1332 | } |
| 1333 | |
| 1334 | static int cbfstool_convert_mkflatpayload(struct buffer *buffer, |
| 1335 | unused uint32_t *offset, struct cbfs_file *header) |
nothing calls this directly
no test coverage detected