diff loadtools/flash.h @ 976:ff4ce8d5ece4

fc-loadtool flash: definitions for AMD sector lock architecture
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 01 Dec 2023 06:43:21 +0000
parents 44cdfc4fed4c
children c5133c3c11b1
line wrap: on
line diff
--- a/loadtools/flash.h	Tue Nov 28 19:08:53 2023 +0000
+++ b/loadtools/flash.h	Fri Dec 01 06:43:21 2023 +0000
@@ -36,12 +36,40 @@
 	uint8_t	expect_val;
 };
 
+/*
+ * In order to examine non-volatile sector lock state of AMD-style flash
+ * chips, we need to know how their sectors are grouped for the purpose
+ * of locking: aggregation of sectors into groups that can only be locked
+ * or unlocked as a unit, and also grouping into independent-read partitions
+ * where each partition needs its own Autoselect sequence.
+ */
+
+struct lock_group_desc {
+	uint32_t	block_size;
+	unsigned	nblocks;
+	int		is_group;
+	int		part_begin;
+	int		part_end;
+};
+
+#define	MAX_AMD_LOCK_GROUPS	8
+
+struct amd_lock_info {
+	unsigned		ngroups;
+	struct lock_group_desc	groups[MAX_AMD_LOCK_GROUPS];
+	int			have_status_word_3;
+	int			have_status_word_7;
+	int			have_mode_lock_bits;
+	int			have_pln_lock_reg;
+};
+
 struct flash_device {
 	char			*name;
 	struct cfi_check	*cfi_table;
 	int			required_global_config;
 	struct flash_geom	*bank_geom[2];
 	struct flash_cmdset	*cmdset;
+	struct amd_lock_info	*lock_info[2];
 };
 
 /* the following structures describe flash banks as accessible to us */
@@ -70,6 +98,7 @@
 	struct flash_device	*device;
 	struct flash_geom	*geom;
 	struct flash_cmdset	*ops;
+	struct amd_lock_info	*amd_lock;
 	struct sector_info	*sectors;
 	int			detect_done;
 };