Tyler Wang 559ad55a94 util/ifdtool: Add support for checking GPR0 status
This patch adds support for the new command-line option `-c` to
the ifdtool, which is able to check GPR0 (Global Protected Range)
status.

This patch also add helper function get_enabled_gprd() to get enabled
GPR0 settings. It used in enable_gpr0() and is_gpr0_protected().

Developers can use ifdtool with '-c' option to check whether GPR0 is
set to enabled or disabled in the binary file.

BUG=none
TEST=(1) > ifdtool -p mtl -E image-unlocked.bin -O image-lock.bin
         ...
         Value at GPRD offset (64) is 0x83220004
         --------- GPR0 Protected Range --------------
         Start address = 0x00004000
         End address = 0x00322fff
         ...
         GPR0 protection is now enabled

     (2) > ifdtool -p mtl -c image-unlocked.bin
         GPR0 status: Disabled

         Value at GPRD offset (64) is 0x00000000
         --------- GPR0 Protected Range --------------
         Start address = 0x00000000
         End address = 0x00000fff

     (3) > ifdtool -p mtl -c image-lock.bin
         GPR0 status: Enabled

         Value at GPRD offset (64) is 0x83220004
         --------- GPR0 Protected Range --------------
         Start address = 0x00004000
         End address = 0x00322fff

Change-Id: I6b3af973be784200b965a68e5f6b7737cba03ed7
Signed-off-by: Tyler Wang <tyler.wang@quanta.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/81928
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Reka Norman <rekanorman@chromium.org>
2024-04-25 15:37:37 +00:00
..