MCPcopy Create free account
hub / github.com/coreboot/coreboot / fit_add_microcode_file

Function fit_add_microcode_file

util/cbfstool/fit.c:494–532  ·  view source on GitHub ↗

Special case for ucode CBFS file, as it might contain more than one ucode */

Source from the content-addressed store, hash-verified

492
493/* Special case for ucode CBFS file, as it might contain more than one ucode */
494int 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
534static uint32_t *get_fit_ptr(struct buffer *bootblock, fit_offset_converter_t offset_fn,
535 uint32_t topswap_size)

Callers 1

mainFunction · 0.85

Calls 5

parse_microcode_blobFunction · 0.85
fit_add_entryFunction · 0.85
offset_to_ptrFunction · 0.70
mallocFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected