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

Function relative_offset

util/amdfwtool/amdfwread.c:69–96  ·  view source on GitHub ↗

Converts addresses to be relative to the start of the file */

Source from the content-addressed store, hash-verified

67
68/* Converts addresses to be relative to the start of the file */
69static uint64_t relative_offset(uint32_t header_offset, uint64_t addr, uint64_t mode)
70{
71 switch (mode) {
72 /* Since this utility operates on the BIOS file, physical address is converted
73 relative to the start of the BIOS file. */
74 case AMD_ADDR_PHYSICAL:
75 if (addr < MAX(SPI_ROM_BASE, 0xffffffff - rom_size + 1) ||
76 addr > 0xffffffff) {
77 ERR("Invalid address(%lx) or mode(%lx)\n", addr, mode);
78 exit(1);
79 }
80 return file_rel_mask(addr);
81
82 case AMD_ADDR_REL_BIOS:
83 if (addr >= rom_size) {
84 ERR("Invalid address(%lx) or mode(%lx)\n", addr, mode);
85 exit(1);
86 }
87 return file_rel_mask(addr);
88
89 case AMD_ADDR_REL_TAB:
90 return addr + header_offset;
91
92 default:
93 ERR("Unsupported mode %lu\n", mode);
94 exit(1);
95 }
96}
97
98static int read_header(FILE *fw, uint32_t offset, void *header, size_t header_size)
99{

Callers 3

read_soft_fuseFunction · 0.70
amdfw_bios_dir_walkFunction · 0.70
amdfw_psp_dir_walkFunction · 0.70

Calls 2

exitFunction · 0.85
file_rel_maskFunction · 0.85

Tested by

no test coverage detected