Special case for ucode CBFS file, as it might contain more than one ucode */
| 492 | |
| 493 | /* Special case for ucode CBFS file, as it might contain more than one ucode */ |
| 494 | int fit_add_microcode_file(struct fit_table *fit, |
| 495 | struct cbfs_image *file_source_image, |
| 496 | const char *blob_name, |
| 497 | fit_offset_converter_t offset_helper, |
| 498 | const size_t max_fit_entries) |
| 499 | { |
| 500 | struct microcode_entry *mcus; |
| 501 | |
| 502 | size_t i; |
| 503 | size_t mcus_found; |
| 504 | |
| 505 | mcus = malloc(sizeof(*mcus) * max_fit_entries); |
| 506 | if (!mcus) { |
| 507 | ERROR("Couldn't allocate memory for microcode entries.\n"); |
| 508 | return 1; |
| 509 | } |
| 510 | |
| 511 | if (parse_microcode_blob(file_source_image, blob_name, &mcus_found, mcus, |
| 512 | max_fit_entries)) { |
| 513 | free(mcus); |
| 514 | return 1; |
| 515 | } |
| 516 | |
| 517 | for (i = 0; i < mcus_found; i++) { |
| 518 | if (fit_add_entry(fit, |
| 519 | offset_to_ptr(offset_helper, &file_source_image->buffer, |
| 520 | mcus[i].offset), |
| 521 | 0, |
| 522 | FIT_TYPE_MICROCODE, |
| 523 | max_fit_entries)) { |
| 524 | |
| 525 | free(mcus); |
| 526 | return 1; |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | free(mcus); |
| 531 | return 0; |
| 532 | } |
| 533 | |
| 534 | static uint32_t *get_fit_ptr(struct buffer *bootblock, fit_offset_converter_t offset_fn, |
| 535 | uint32_t topswap_size) |
no test coverage detected