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

Function relocate_patch_table

src/commonlib/fsp_relocate.c:418–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

416}
417
418static int relocate_patch_table(void *fsp, size_t size, size_t offset,
419 ssize_t adjustment)
420{
421 struct fsp_patch_table *table;
422 size_t num;
423 size_t num_entries;
424
425 table = relative_offset(fsp, offset);
426
427 if ((offset + sizeof(*table) > size) ||
428 (read_le16(&table->header_length) + offset) > size) {
429 printk(BIOS_ERR, "FSPP not entirely contained in region.\n");
430 return -1;
431 }
432
433 num_entries = read_le32(&table->patch_entry_num);
434 printk(FSP_DBG_LVL, "FSPP relocs: %zx\n", num_entries);
435
436 for (num = 0; num < num_entries; num++) {
437 uint32_t *reloc;
438 uint32_t reloc_val;
439
440 reloc = fspp_reloc(fsp, size,
441 read_le32(&table->patch_entries[num]));
442
443 if (reloc == NULL) {
444 printk(BIOS_ERR, "Ignoring FSPP entry: %x\n",
445 read_le32(&table->patch_entries[num]));
446 continue;
447 }
448
449 reloc_val = read_le32(reloc);
450 printk(FSP_DBG_LVL, "Adjusting %p %x -> %x\n",
451 reloc, reloc_val,
452 (unsigned int)(reloc_val + adjustment));
453
454 write_le32(reloc, reloc_val + adjustment);
455 }
456
457 return 0;
458}
459
460static ssize_t relocate_remaining_items(void *fsp, size_t size,
461 uintptr_t new_addr, size_t fih_offset)

Callers 1

relocate_remaining_itemsFunction · 0.85

Calls 6

read_le16Function · 0.85
read_le32Function · 0.85
fspp_relocFunction · 0.85
write_le32Function · 0.85
relative_offsetFunction · 0.70
printkFunction · 0.50

Tested by

no test coverage detected