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

Function read_soft_fuse

util/amdfwtool/amdfwread.c:207–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207static int read_soft_fuse(FILE *fw, const embedded_firmware *fw_header)
208{
209 psp_directory_entry *current_entries = NULL;
210 size_t num_current_entries = 0;
211
212 uint32_t psp_offset = 0;
213 /* 0xffffffff or 0x00000000 indicates that the offset is in new_psp_directory */
214 if (fw_header->psp_directory != 0xffffffff && fw_header->psp_directory != 0x00000000)
215 psp_offset = fw_header->psp_directory;
216 else
217 psp_offset = fw_header->new_psp_directory;
218
219 psp_directory_header header;
220 if (read_psp_directory(fw, psp_offset, PSP_COOKIE, &header,
221 &current_entries, &num_current_entries) != 0)
222 return 1;
223
224 while (1) {
225 uint32_t l2_dir_offset = 0;
226 uint32_t ish_dir_offset;
227 ish_directory_table ish_dir;
228
229 for (size_t i = 0; i < num_current_entries; i++) {
230 uint32_t type = current_entries[i].type;
231 uint64_t mode = current_entries[i].address_mode;
232 uint64_t addr = current_entries[i].addr;
233 uint64_t fuse;
234
235 switch (type) {
236 case AMD_FW_PSP_FUSE_CHAIN:
237 fuse = mode << 62 | addr;
238
239 printf("Soft-fuse:0x%lx\n", fuse);
240 free(current_entries);
241 return 0;
242
243 case AMD_FW_PSP_L2_PTR:
244 /* There's a second level PSP directory to read */
245 if (l2_dir_offset != 0) {
246 ERR("Duplicate PSP L2 Entry, prior offset: %08x\n",
247 l2_dir_offset);
248 free(current_entries);
249 return 1;
250 }
251
252 l2_dir_offset = relative_offset(psp_offset, addr, mode);
253 break;
254
255 case AMD_FW_PSP_RECOVERYAB_A:
256 if (l2_dir_offset != 0) {
257 ERR("Duplicate PSP L2 Entry, prior offset: %08x\n",
258 l2_dir_offset);
259 free(current_entries);
260 return 1;
261 }
262
263 ish_dir_offset = relative_offset(psp_offset, addr, AMD_ADDR_REL_BIOS);
264 if (read_ish_directory(fw, ish_dir_offset, &ish_dir) != 0) {

Callers 1

mainFunction · 0.85

Calls 5

read_psp_directoryFunction · 0.85
printfFunction · 0.85
read_ish_directoryFunction · 0.85
relative_offsetFunction · 0.70
freeFunction · 0.50

Tested by

no test coverage detected