From b191880ebd3d0b307884f2298b0416633afef685 Mon Sep 17 00:00:00 2001 From: armink Date: Fri, 8 Feb 2019 21:32:27 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E3=80=91ef=5Fset=5F?= =?UTF-8?q?and=5Fsave=5Fenv=20=E5=8F=8A=20ef=5Fdel=5Fand=5Fsave=5Fenv=20?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=97=A7=E7=89=88=E6=9C=AC=E7=9A=84=20API?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: armink --- easyflash/src/ef_env_ng.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/easyflash/src/ef_env_ng.c b/easyflash/src/ef_env_ng.c index e8910f7..54f7aef 100644 --- a/easyflash/src/ef_env_ng.c +++ b/easyflash/src/ef_env_ng.c @@ -1035,6 +1035,19 @@ EfErrCode ef_del_env(const char *key) return result; } +/** + * The same to ef_del_env on this mode + * It's compatibility with older versions (less then V4.0). + * + * @param key ENV name + * + * @return result + */ +EfErrCode ef_del_and_save_env(const char *key) +{ + return ef_del_env(key); +} + static EfErrCode set_env(const char *key, const void *value_buf, size_t buf_len) { EfErrCode result = EF_NO_ERR; @@ -1116,6 +1129,20 @@ EfErrCode ef_set_env(const char *key, const char *value) return ef_set_env_blob(key, value, strlen(value)); } +/** + * The same to ef_set_env on this mode. + * It's compatibility with older versions (less then V4.0). + * + * @param key ENV name + * @param value ENV value + * + * @return result + */ +EfErrCode ef_set_and_save_env(const char *key, const char *value) +{ + return ef_set_env_blob(key, value, strlen(value)); +} + /** * Save ENV to flash. */ @@ -1207,7 +1234,6 @@ __reload: print_value = true; goto __reload; } else if (!value_is_str) { - //TODO 减去 GC 扇区 ef_print("blob @0x%08X %dbytes", env->addr.value, env->value_len); } ef_print("\n"); @@ -1237,7 +1263,8 @@ void ef_print_env(void) env_iterator(&env, &using_size, NULL, print_env_cb); ef_print("\nmode: next generation\n"); - ef_print("size: %lu/%lu bytes.\n", using_size + SECTOR_NUM * SECTOR_HDR_DATA_SIZE, ENV_AREA_SIZE); + ef_print("size: %lu/%lu bytes.\n", using_size + (SECTOR_NUM - EF_GC_EMPTY_SEC_THRESHOLD) * SECTOR_HDR_DATA_SIZE, + ENV_AREA_SIZE - SECTOR_SIZE * EF_GC_EMPTY_SEC_THRESHOLD); /* unlock the ENV cache */ ef_port_env_unlock();