mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 14:11:15 +02:00
cli_classic.c: implement set_wp_region operation
set_wp_region allows to set the wp_range based on a layout region. Signed-off-by: Daniel Campello <campello@chromium.org> Change-Id: Ibad68a038ab38b9986b0d8b5f5eb6c73b20ef381 Reviewed-on: https://review.coreboot.org/c/flashrom/+/52531 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:

committed by
Edward O'Callaghan

parent
6509912a1d
commit
7367f77aa4
@ -65,6 +65,7 @@ static void cli_classic_usage(const char *name)
|
||||
" --wp-list list write protect range\n"
|
||||
" --wp-status show write protect status\n"
|
||||
" --wp-range=<start>,<len> set write protect range\n"
|
||||
" --wp-region <region> set write protect region\n"
|
||||
" --flash-name read out the detected flash name\n"
|
||||
" --flash-size read out the detected flash size\n"
|
||||
" --fmap read ROM layout from fmap embedded in ROM\n"
|
||||
@ -236,6 +237,7 @@ int main(int argc, char *argv[])
|
||||
char *pparam = NULL;
|
||||
struct layout_include_args *include_args = NULL;
|
||||
char *wp_mode_opt = NULL;
|
||||
char *wp_region = NULL;
|
||||
|
||||
/*
|
||||
* Safety-guard against a user who has (mistakenly) closed
|
||||
@ -462,6 +464,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#endif /* STANDALONE */
|
||||
break;
|
||||
case OPTION_WP_SET_REGION:
|
||||
set_wp_region = 1;
|
||||
wp_region = strdup(optarg);
|
||||
break;
|
||||
default:
|
||||
cli_classic_abort_usage(NULL);
|
||||
break;
|
||||
@ -772,6 +778,15 @@ int main(int argc, char *argv[])
|
||||
ret |= wp->set_range(fill_flash, wp_start, wp_len);
|
||||
}
|
||||
|
||||
if (set_wp_region && wp_region) {
|
||||
if (get_region_range(layout, wp_region, &wp_start, &wp_len)) {
|
||||
ret = 1;
|
||||
goto out_release;
|
||||
}
|
||||
ret |= wp->set_range(fill_flash, wp_start, wp_len);
|
||||
free(wp_region);
|
||||
}
|
||||
|
||||
if (!ret && set_wp_enable) {
|
||||
enum wp_mode wp_mode;
|
||||
|
||||
|
Reference in New Issue
Block a user