aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAarya Chaumal <aarya.chaumal@gmail.com>2022-07-15 16:51:27 +0530
committerAnastasia Klimchuk <aklm@chromium.org>2023-02-13 04:54:39 +0000
commit8fbe405038cf52149902e6e148716064e25ec7b3 (patch)
tree60ab106221712e1695cf4a5f3e7d6b83c526a63f /include
parentbd90bbeccdc5d1273f239bb43d16513d57fb557a (diff)
downloadflashrom-8fbe405038cf52149902e6e148716064e25ec7b3.tar.gz
flashrom-8fbe405038cf52149902e6e148716064e25ec7b3.tar.bz2
flashrom-8fbe405038cf52149902e6e148716064e25ec7b3.zip
flashrom.c: Add functions for new erase selection algorithm
1) Add function to flatten out the addresses of the flash chip as per the different erase functions. This function will return a list of layouts which is dynamically allocated. So after use all the layouts as well as the list itself should be freed. The free_erase_layout function does that. 2) Add function to align start and end address of the region (in struct walk_info) to some erase sector boundaries and modify the region start and end addresses to match nearest erase sector boundaries. This function will be used in the new algorithm for erase function selection. 3) Add function that returns a list of sectors (as seen by the first erase function) that need erasing. 4) Add a function to call the erase algorithm. Change-Id: Ic57ca1cca3d1646543f6b5939ba9c35db8d08256 Signed-off-by: Aarya Chaumal <aarya.chaumal@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/65844 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Thomas Heijligen <src@posteo.de> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/erasure_layout.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/erasure_layout.h b/include/erasure_layout.h
new file mode 100644
index 00000000..b8b5f089
--- /dev/null
+++ b/include/erasure_layout.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * Copyright (C) 2022 Aarya Chaumal
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __ERASURE_LAYOUT_H__
+#define __ERASURE_LAYOUT_H__ 1
+
+struct eraseblock_data {
+ chipoff_t start_addr;
+ chipoff_t end_addr;
+ bool selected;
+ size_t block_num;
+ size_t first_sub_block_index;
+ size_t last_sub_block_index;
+};
+
+struct erase_layout {
+ struct eraseblock_data* layout_list;
+ size_t block_count;
+ const struct block_eraser *eraser;
+};
+
+void free_erase_layout(struct erase_layout *layout, unsigned int erasefn_count);
+int create_erase_layout(struct flashctx *const flashctx, struct erase_layout **erase_layout);
+int erase_write(struct flashctx *const flashctx, chipoff_t region_start, chipoff_t region_end,
+ uint8_t* curcontents, uint8_t* newcontents,
+ struct erase_layout *erase_layout, bool *all_skipped);
+
+#endif /* !__ERASURE_LAYOUT_H__ */