summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2022-10-04 17:14:56 +0200
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-12-22 21:20:24 +0000
commitf6bcb51d2d26a0470d955700c9e5bf7ab0d0eeba (patch)
tree4e4493d82847ce8b3bd08d6440fb6b4a3e849f5e
parent8510a42afaaae1aece2a63fa9aad1530a64c4f78 (diff)
downloadchrome-ec-f6bcb51d2d26a0470d955700c9e5bf7ab0d0eeba.tar.gz
flash: Move printing information about regions to separate function
Printing information about sectors requires information about flash size and number of sectors (or flash_bank_array in case of different sector size) to be defined in CrosEC. When using Zephyr we should use DTS or structures defined in the Zephyr flash driver (through API). Moving code that depends on CrosEC structures/defines will make easier to enable support for variable sector sizes in CrosEC with Zephyr. BUG=b:239712345 BRANCH=none TEST=make buildall -j TEST=Compile bloonchipper firmware and flash it on dragonclaw board. Run 'flashinfo' command. Make sure that the output is correct. LOW_COVERAGE_REASON=This patch only moves prints to a separate function. Coverage is low because we are only testing a case without CONFIG_FLASH_MULTIPLE_REGION enabled. Later commits add tests which will check behaviour with this option enabled, but they will use another printing function (introduced later). I've checked this manually (see TEST above). Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I5b93a910b9c1c5906da1648a61f00f42e563bf25 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3932161 Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: Patryk Duda <patrykd@google.com> Commit-Queue: Patryk Duda <patrykd@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Bobby Casey <bobbycasey@google.com>
-rw-r--r--common/flash.c31
-rw-r--r--include/flash.h2
2 files changed, 21 insertions, 12 deletions
diff --git a/common/flash.c b/common/flash.c
index 4f3f578eed..c35eb64330 100644
--- a/common/flash.c
+++ b/common/flash.c
@@ -984,20 +984,11 @@ static void flash_erase_deferred(void)
DECLARE_DEFERRED(flash_erase_deferred);
#endif
-/*****************************************************************************/
-/* Console commands */
-
-#ifdef CONFIG_CMD_FLASHINFO
-#define BIT_TO_ON_OFF(value, mask) \
- ((((value) & (mask)) == (mask)) ? "ON" : "OFF")
-static int command_flash_info(int argc, const char **argv)
+void crec_flash_print_region_info(void)
{
- int i, flags;
-
- ccprintf("Usable: %4d KB\n", CONFIG_FLASH_SIZE_BYTES / 1024);
- ccprintf("Write: %4d B (ideal %d B)\n", CONFIG_FLASH_WRITE_SIZE,
- CONFIG_FLASH_WRITE_IDEAL_SIZE);
#ifdef CONFIG_FLASH_MULTIPLE_REGION
+ int i;
+
ccprintf("Regions:\n");
for (i = 0; i < ARRAY_SIZE(flash_bank_array); i++) {
ccprintf(" %d region%s:\n", flash_bank_array[i].count,
@@ -1013,6 +1004,22 @@ static int command_flash_info(int argc, const char **argv)
CONFIG_FLASH_ERASED_VALUE32 ? 1 : 0);
ccprintf("Protect: %4d B\n", CONFIG_FLASH_BANK_SIZE);
#endif
+}
+
+/*****************************************************************************/
+/* Console commands */
+
+#ifdef CONFIG_CMD_FLASHINFO
+#define BIT_TO_ON_OFF(value, mask) \
+ ((((value) & (mask)) == (mask)) ? "ON" : "OFF")
+static int command_flash_info(int argc, const char **argv)
+{
+ int i, flags;
+
+ ccprintf("Usable: %4d KB\n", CONFIG_FLASH_SIZE_BYTES / 1024);
+ ccprintf("Write: %4d B (ideal %d B)\n", CONFIG_FLASH_WRITE_SIZE,
+ CONFIG_FLASH_WRITE_IDEAL_SIZE);
+ crec_flash_print_region_info();
flags = crec_flash_get_protect();
ccprintf("Flags:\n");
ccprintf(" wp_gpio_asserted: %s\n",
diff --git a/include/flash.h b/include/flash.h
index 5df6afdb09..7e9cbf3f40 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -50,6 +50,8 @@ int crec_flash_bank_start_offset(int bank);
int crec_flash_bank_erase_size(int bank);
+void crec_flash_print_region_info(void);
+
/* Number of physical flash banks */
#define PHYSICAL_BANKS CONFIG_FLASH_MULTIPLE_REGION