summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2023-02-10 15:51:10 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-29 08:19:21 +0000
commit191299368add277f84a0e20200140c2e13720971 (patch)
tree1e2e5e72cb385fe06d5ccfb69c6baaf8f05452c2
parent80d0bff778e80900eb2e4a9279e54b91bcaab5c3 (diff)
downloadvboot-191299368add277f84a0e20200140c2e13720971.tar.gz
futility: updater: refactor: always pass updater config to DUT APIs
To support local and remote DUTs, we need to always pass the updater configuration (including flash programmer information) for DUT related calls. No functional changes but this is required for DUT detection in the future. BUG=b:247428499,b:255617349 TEST=make; run test BRANCH=None Change-Id: I91bdc95f3073d1e94030246790db83645fbd63ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4235306 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4380982 Auto-Submit: Phoebe Wang <phoebewang@chromium.org> Tested-by: Phoebe Wang <phoebewang@chromium.org> Reviewed-by: Cheng Yueh <cyueh@chromium.org> Commit-Queue: Cheng Yueh <cyueh@chromium.org>
-rw-r--r--futility/updater.c8
-rw-r--r--futility/updater.h3
-rw-r--r--futility/updater_dut.c22
-rw-r--r--futility/updater_manifest.c5
-rw-r--r--futility/updater_quirks.c11
-rw-r--r--futility/updater_utils.h13
6 files changed, 36 insertions, 26 deletions
diff --git a/futility/updater.c b/futility/updater.c
index 6515402b..d4d44f9d 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -274,17 +274,17 @@ static int set_try_cookies(struct updater_config *cfg, const char *target,
return 0;
}
- if (dut_set_property_string("fw_try_next", slot)) {
+ if (dut_set_property_string("fw_try_next", slot, cfg)) {
ERROR("Failed to set fw_try_next to %s.\n", slot);
return -1;
}
if (!has_update &&
- dut_set_property_string("fw_result", "success")) {
+ dut_set_property_string("fw_result", "success", cfg)) {
ERROR("Failed to set fw_result to success.\n");
return -1;
}
- if (dut_set_property_int("fw_try_count", tries)) {
+ if (dut_set_property_int("fw_try_count", tries, cfg)) {
ERROR("Failed to set fw_try_count to %d.\n", tries);
return -1;
}
@@ -1369,7 +1369,7 @@ static int updater_setup_archive(
if (cfg->detect_model)
model = manifest_detect_model_from_frid(cfg, manifest);
else
- model = manifest_find_model(manifest, arg->model);
+ model = manifest_find_model(cfg, manifest, arg->model);
if (!model)
return ++errorcnt;
diff --git a/futility/updater.h b/futility/updater.h
index a8bbfe31..4382217d 100644
--- a/futility/updater.h
+++ b/futility/updater.h
@@ -342,7 +342,8 @@ int patch_image_by_model(
* system (as defined by model_name).
* Returns a model_config from manifest, or NULL if not found.
*/
-const struct model_config *manifest_find_model(const struct manifest *manifest,
+const struct model_config *manifest_find_model(struct updater_config *cfg,
+ const struct manifest *manifest,
const char *model_name);
/*
diff --git a/futility/updater_dut.c b/futility/updater_dut.c
index f152a45e..7062a614 100644
--- a/futility/updater_dut.c
+++ b/futility/updater_dut.c
@@ -22,7 +22,7 @@
* device data
* - >=0 (the matched device index) success
*/
-int dut_get_manifest_key(char **manifest_key_out)
+int dut_get_manifest_key(char **manifest_key_out, struct updater_config *cfg)
{
#ifdef HAVE_CROSID
return crosid_get_firmware_manifest_key(manifest_key_out);
@@ -36,22 +36,26 @@ int dut_get_manifest_key(char **manifest_key_out)
#endif
}
-int dut_set_property_string(const char *key, const char *value)
+int dut_set_property_string(const char *key, const char *value,
+ struct updater_config *cfg)
+
{
return VbSetSystemPropertyString(key, value);
}
-const char *dut_get_property_string(const char *key, char *dest, size_t size)
+const char *dut_get_property_string(const char *key, char *dest, size_t size,
+ struct updater_config *cfg)
{
return VbGetSystemPropertyString(key, dest, size);
}
-int dut_set_property_int(const char *key, const int value)
+int dut_set_property_int(const char *key, const int value,
+ struct updater_config *cfg)
{
return VbSetSystemPropertyInt(key, value);
}
-int dut_get_property_int(const char *key)
+int dut_get_property_int(const char *key, struct updater_config *cfg)
{
return VbGetSystemPropertyInt(key);
}
@@ -61,7 +65,7 @@ static int dut_get_mainfw_act(struct updater_config *cfg)
{
char buf[VB_MAX_STRING_PROPERTY];
- if (!dut_get_property_string("mainfw_act", buf, sizeof(buf)))
+ if (!dut_get_property_string("mainfw_act", buf, sizeof(buf), cfg))
return SLOT_UNKNOWN;
if (strcmp(buf, FWACT_A) == 0)
@@ -75,19 +79,19 @@ static int dut_get_mainfw_act(struct updater_config *cfg)
/* A helper function to return the "tpm_fwver" system property. */
static int dut_get_tpm_fwver(struct updater_config *cfg)
{
- return dut_get_property_int("tpm_fwver");
+ return dut_get_property_int("tpm_fwver", cfg);
}
/* A helper function to return the "hardware write protection" status. */
static int dut_get_wp_hw(struct updater_config *cfg)
{
/* wpsw refers to write protection 'switch', not 'software'. */
- return dut_get_property_int("wpsw_cur") ? WP_ENABLED : WP_DISABLED;
+ return dut_get_property_int("wpsw_cur", cfg) ? WP_ENABLED : WP_DISABLED;
}
static int dut_get_platform_version(struct updater_config *cfg)
{
- return dut_get_property_int("board_id");
+ return dut_get_property_int("board_id", cfg);
}
/* Helper function to return host software write protection status. */
diff --git a/futility/updater_manifest.c b/futility/updater_manifest.c
index 6d7d9d41..96faa6c4 100644
--- a/futility/updater_manifest.c
+++ b/futility/updater_manifest.c
@@ -620,7 +620,8 @@ static int manifest_from_simple_folder(struct manifest *manifest)
* system (as defined by model_name).
* Returns a model_config from manifest, or NULL if not found.
*/
-const struct model_config *manifest_find_model(const struct manifest *manifest,
+const struct model_config *manifest_find_model(struct updater_config *cfg,
+ const struct manifest *manifest,
const char *model_name)
{
char *manifest_key = NULL;
@@ -637,7 +638,7 @@ const struct model_config *manifest_find_model(const struct manifest *manifest,
return &manifest->models[0];
if (!model_name) {
- matched_index = dut_get_manifest_key(&manifest_key);
+ matched_index = dut_get_manifest_key(&manifest_key, cfg);
if (matched_index < 0) {
ERROR("Failed to get device identity. "
"Run \"crosid -v\" for explanation.\n");
diff --git a/futility/updater_quirks.c b/futility/updater_quirks.c
index eb4d7e87..31b376c5 100644
--- a/futility/updater_quirks.c
+++ b/futility/updater_quirks.c
@@ -77,7 +77,8 @@ static int is_ec_software_sync_enabled(struct updater_config *cfg)
const struct vb2_gbb_header *gbb;
/* Check if current system has disabled software sync or no support. */
- if (!(dut_get_property_int("vdat_flags") & VBSD_EC_SOFTWARE_SYNC)) {
+ if (!(dut_get_property_int("vdat_flags", cfg) & VBSD_EC_SOFTWARE_SYNC))
+ {
INFO("EC Software Sync is not available.\n");
return 0;
}
@@ -142,17 +143,17 @@ static int ec_ro_software_sync(struct updater_config *cfg)
"update by EC RO software sync.\n");
return 1;
}
- dut_set_property_int("try_ro_sync", 1);
+ dut_set_property_int("try_ro_sync", 1, cfg);
return 0;
}
/*
* Returns True if EC is running in RW.
*/
-static int is_ec_in_rw(void)
+static int is_ec_in_rw(struct updater_config *cfg)
{
char buf[VB_MAX_STRING_PROPERTY];
- return (dut_get_property_string("ecfw_act", buf, sizeof(buf)) &&
+ return (dut_get_property_string("ecfw_act", buf, sizeof(buf), cfg) &&
strcasecmp(buf, "RW") == 0);
}
@@ -358,7 +359,7 @@ static int quirk_ec_partial_recovery(struct updater_config *cfg)
/* Need full update. */
} else if (!is_ec_software_sync_enabled(cfg)) {
/* Message already printed, need full update. */
- } else if (is_ec_in_rw()) {
+ } else if (is_ec_in_rw(cfg)) {
WARN("EC Software Sync detected, will only update EC RO. "
"The contents in EC RW will be updated after reboot.\n");
return EC_RECOVERY_RO;
diff --git a/futility/updater_utils.h b/futility/updater_utils.h
index bdb0c49b..27c3f57d 100644
--- a/futility/updater_utils.h
+++ b/futility/updater_utils.h
@@ -252,12 +252,15 @@ void dut_init_properties(struct dut_property *props, int num);
int dut_get_property(enum dut_property_type property_type,
struct updater_config *cfg);
-int dut_set_property_string(const char *key, const char *value);
-const char *dut_get_property_string(const char *key, char *dest, size_t size);
-int dut_set_property_int(const char *key, const int value);
-int dut_get_property_int(const char *key);
+int dut_set_property_string(const char *key, const char *value,
+ struct updater_config *cfg);
+const char *dut_get_property_string(const char *key, char *dest, size_t size,
+ struct updater_config *cfg);
+int dut_set_property_int(const char *key, const int value,
+ struct updater_config *cfg);
+int dut_get_property_int(const char *key, struct updater_config *cfg);
/* Gets the 'firmware manifest key' on the DUT. */
-int dut_get_manifest_key(char **manifest_key_out);
+int dut_get_manifest_key(char **manifest_key_out, struct updater_config *cfg);
#endif /* VBOOT_REFERENCE_FUTILITY_UPDATER_UTILS_H_ */