| 1681 | } |
| 1682 | |
| 1683 | static void disable_gpr0(const char *filename, char *image, int size) |
| 1684 | { |
| 1685 | struct fpsba *fpsba = find_fpsba(image, size); |
| 1686 | if (!fpsba) |
| 1687 | exit(EXIT_FAILURE); |
| 1688 | |
| 1689 | uint32_t gpr0_offset = get_gpr0_offset(); |
| 1690 | if (gpr0_offset == 0xffffffff) { |
| 1691 | fprintf(stderr, "Disabling GPR0 not supported on this platform\n"); |
| 1692 | exit(EXIT_FAILURE); |
| 1693 | } |
| 1694 | |
| 1695 | union gprd reg; |
| 1696 | /* If bit 31 is set then GPR0 protection is enable */ |
| 1697 | reg.value = fpsba->pchstrp[gpr0_offset]; |
| 1698 | if (!reg.data.write_protect_en) { |
| 1699 | printf("GPR0 protection is already disabled\n"); |
| 1700 | return; |
| 1701 | } |
| 1702 | |
| 1703 | printf("Value at GPRD offset (%d) is 0x%08x\n", gpr0_offset, reg.value); |
| 1704 | print_gpr0_range(reg); |
| 1705 | /* 0 means GPR0 protection is disabled */ |
| 1706 | fpsba->pchstrp[gpr0_offset] = 0; |
| 1707 | write_image(filename, image, size); |
| 1708 | printf("GPR0 protection is now disabled\n"); |
| 1709 | } |
| 1710 | |
| 1711 | /* |
| 1712 | * Helper function to parse the FPT to retrieve the FITC start offset and size. |
no test coverage detected