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

Function read_bios_directory

util/amdfwtool/amdfwread.c:174–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174static int read_bios_directory(FILE *fw, uint32_t offset, uint32_t expected_cookie,
175 bios_directory_hdr *header, bios_directory_entry **entries,
176 size_t *num_entries)
177{
178 offset = file_rel_mask(offset);
179
180 if (read_header(fw, offset, header, sizeof(bios_directory_hdr))) {
181 ERR("Failed to read BIOS header\n");
182 return 1;
183 }
184
185 /* Ensure that we have a BIOS directory */
186 if (header->cookie != expected_cookie) {
187 ERR("Invalid BIOS header cookie value found: 0x%x, expected: 0x%x\n",
188 header->cookie, expected_cookie);
189 return 1;
190 }
191
192 if (!entries || !num_entries)
193 return 0;
194
195 /* Read the entries */
196 *num_entries = header->num_entries;
197 *entries = malloc(sizeof(bios_directory_entry) * header->num_entries);
198 if (fread(*entries, sizeof(bios_directory_entry), header->num_entries, fw)
199 != header->num_entries) {
200 ERR("Failed to read %d BIOS entries\n", header->num_entries);
201 return 1;
202 }
203
204 return 0;
205}
206
207static int read_soft_fuse(FILE *fw, const embedded_firmware *fw_header)
208{

Callers 2

amdfw_bios_dir_walkFunction · 0.85
amdfw_bios_dir_sizeFunction · 0.85

Calls 4

file_rel_maskFunction · 0.85
read_headerFunction · 0.85
freadFunction · 0.85
mallocFunction · 0.50

Tested by

no test coverage detected