| 205 | } |
| 206 | |
| 207 | static 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 | ¤t_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) { |
no test coverage detected