diff options
-rw-r--r-- | futility/cmd_update.c | 36 | ||||
-rwxr-xr-x | tests/futility/test_update.sh | 2 |
2 files changed, 36 insertions, 2 deletions
diff --git a/futility/cmd_update.c b/futility/cmd_update.c index 97d63aad..c319275a 100644 --- a/futility/cmd_update.c +++ b/futility/cmd_update.c @@ -12,6 +12,7 @@ #include <stdio.h> #include <stdlib.h> +#include "crossystem.h" #include "fmap.h" #include "futility.h" #include "host_misc.h" @@ -29,6 +30,10 @@ static const char * const FMAP_RO_FRID = "RO_FRID", * const FMAP_RW_SHARED = "RW_SHARED", * const FMAP_RW_LEGACY = "RW_LEGACY"; +/* System environment values. */ +static CONST_STRING FWACT_A = "A", + FWACT_B = "B"; + /* flashrom programmers. */ static const char * const PROG_HOST = "host", * const PROG_EMULATE = "dummy:emulate", @@ -40,6 +45,17 @@ enum wp_state { WP_ENABLED, }; +enum target_type { + TARGET_SELF, + TARGET_UPDATE, +}; + +enum active_slot { + SLOT_UNKNOWN = -1, + SLOT_A = 0, + SLOT_B, +}; + enum flashrom_ops { FLASHROM_READ, FLASHROM_WRITE, @@ -67,8 +83,7 @@ struct system_property { }; enum system_property_type { - /* TODO(hungte) Remove SYS_PROP_TEST* when we have more properties. */ - SYS_PROP_TEST1, + SYS_PROP_MAINFW_ACT, SYS_PROP_WP_HW, SYS_PROP_WP_SW, SYS_PROP_MAX @@ -81,6 +96,22 @@ struct updater_config { struct system_property system_properties[SYS_PROP_MAX]; }; +/* An helper function to return "mainfw_act" system property. */ +static int host_get_mainfw_act() +{ + char buf[VB_MAX_STRING_PROPERTY]; + + if (!VbGetSystemPropertyString("mainfw_act", buf, sizeof(buf))) + return SLOT_UNKNOWN; + + if (strcmp(buf, FWACT_A) == 0) + return SLOT_A; + else if (strcmp(buf, FWACT_B) == 0) + return SLOT_B; + + return SLOT_UNKNOWN; +} + /* A helper function to return the "hardware write protection" status. */ static int host_get_wp_hw() { @@ -719,6 +750,7 @@ static int do_update(int argc, char *argv[]) .pd_image = { .programmer = PROG_PD, }, .emulate = 0, .system_properties = { + [SYS_PROP_MAINFW_ACT] = {.getter = host_get_mainfw_act}, [SYS_PROP_WP_HW] = {.getter = host_get_wp_hw}, [SYS_PROP_WP_SW] = {.getter = host_get_wp_sw}, }, diff --git a/tests/futility/test_update.sh b/tests/futility/test_update.sh index e06bbc59..873a6f56 100755 --- a/tests/futility/test_update.sh +++ b/tests/futility/test_update.sh @@ -67,6 +67,8 @@ test_update() { cmp "${TMP}.emu" "${expected}" } +# --sys_props: mainfw_act, [wp_hw, wp_sw] + # Test Full update. test_update "Full update" \ "${FROM_IMAGE}" "${TMP}.expected.full" \ |