summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2022-10-04 17:51:26 +0200
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-01-11 19:30:53 +0000
commit883caf605af66cf149e4580071962388ff922ecb (patch)
treed744b9a4a439bc8c77aab474f873bca5e5f2db2e /include
parentb5a80a5c03a1a75ed48baaf582a1567501d742f4 (diff)
downloadchrome-ec-883caf605af66cf149e4580071962388ff922ecb.tar.gz
flash: Introduce functions for filling flash regions info
EC_CMD_FLASH_INFO requires flash_bank_array to be defined if flash banks have different size. When using Zephyr the array is not available. In this case we should use the Zephyr flash API. Moving code that depends on flash_bank_array will make easier to to enable support for variable bank sizes in CrosEC with Zephyr. The change also makes existing code easier to read and understand. BUG=b:239712345 BRANCH=none TEST=make buildall -j Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I4da19c3c302a9b64cfa4c851b3bdac10b7c438d5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3932162 Reviewed-by: Bobby Casey <bobbycasey@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Patryk Duda <patrykd@google.com> Tested-by: Patryk Duda <patrykd@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/flash.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/flash.h b/include/flash.h
index 5448bc9c4b..9a498bce82 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -80,6 +80,29 @@ void crec_flash_print_region_info(void);
*/
int crec_flash_total_banks(void);
+/**
+ * Fill flash info response structure (version 2)
+ *
+ * The function is responsible for filling 'num_banks_desc', 'num_banks_total'
+ * and 'banks' fields with information about flash layout.
+ *
+ * We are passing the whole response structure because it is marked
+ * as '__ec_align4', so it's packed, and should be aligned also but on most
+ * systems it's not because CONFIG_HOSTCMD_OPTION is not enabled. It means that
+ * the structure can be placed at ANY address. Passing the response structure
+ * gives information to the compiler how members should be accessed.
+ * Passing pointer to structure member is an error, and compiler will warn
+ * about it. Taking pointer to structure member, passing it as uint8_t and
+ * casting it is dangerous because the compiler will assume that the address
+ * is aligned and you won't get any warning about it.
+ *
+ * @param pointer to flash info version 2 response structure
+ * @param size of 'banks' array inside response structure
+ * @return EC_RES_SUCCESS or other error code.
+ */
+int crec_flash_response_fill_banks(struct ec_response_flash_info_2 *r,
+ int num_banks);
+
/* Persistent protection state flash offset / size / bank */
#if defined(CONFIG_FLASH_PSTATE) && defined(CONFIG_FLASH_PSTATE_BANK)