summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-12-14 22:25:15 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-12-14 22:25:15 +0000
commit63fd9026f1e82b67a65072fda862ba7af35839e1 (patch)
tree7d9ffba077715cf9e75c9f4a36d0d7f11a3181f6
parent83c92e983aaf11fb6f5bafb6744275c50add193c (diff)
downloadflashrom-63fd9026f1e82b67a65072fda862ba7af35839e1.tar.gz
flashrom-63fd9026f1e82b67a65072fda862ba7af35839e1.tar.bz2
flashrom-63fd9026f1e82b67a65072fda862ba7af35839e1.zip
Use struct flashctx instead of struct flashchip for flash chip access
Struct flashchip is used only for the flashchips array and for operations which do not access hardware, e.g. printing a list of supported flash chips. struct flashctx (flash context) contains all data available in struct flashchip, but it also contains runtime information like mapping addresses. struct flashctx is expected to grow additional members over time, a prime candidate being programmer info. struct flashctx contains all of struct flashchip with identical member layout, but struct flashctx has additional members at the end. The separation between struct flashchip/flashctx shrinks the memory requirement of the big flashchips array and allows future extension of flashctx without having to worry about bloat. Corresponding to flashrom svn r1473. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
-rw-r--r--82802ab.c14
-rw-r--r--a25.c8
-rw-r--r--at25.c22
-rw-r--r--chipdrivers.h168
-rw-r--r--cli_classic.c5
-rw-r--r--dediprog.c6
-rw-r--r--dummyflasher.c4
-rw-r--r--flash.h56
-rw-r--r--flashrom.c47
-rw-r--r--ichspi.c8
-rw-r--r--it87spi.c10
-rw-r--r--jedec.c32
-rw-r--r--layout.c2
-rw-r--r--linux_spi.c8
-rw-r--r--m29f400bt.c10
-rw-r--r--opaque.c8
-rw-r--r--pm49fl00x.c4
-rw-r--r--programmer.h20
-rw-r--r--serprog.c4
-rw-r--r--sharplhf00l04.c2
-rw-r--r--spi.c8
-rw-r--r--spi25.c48
-rw-r--r--sst28sf040.c12
-rw-r--r--sst49lfxxxc.c8
-rw-r--r--sst_fwhub.c8
-rw-r--r--stm50flw0x0x.c6
-rw-r--r--w29ee011.c2
-rw-r--r--w39.c36
-rw-r--r--wbsio_spi.c4
29 files changed, 301 insertions, 269 deletions
diff --git a/82802ab.c b/82802ab.c
index 8f671c985..228d071f2 100644
--- a/82802ab.c
+++ b/82802ab.c
@@ -40,7 +40,7 @@ void print_status_82802ab(uint8_t status)
msg_cdbg("%s", status & 0x2 ? "WP|TBL#|WP#,ABORT:" : "UNLOCK:");
}
-int probe_82802ab(struct flashchip *flash)
+int probe_82802ab(struct flashctx *flash)
{
chipaddr bios = flash->virtual_memory;
uint8_t id1, id2, flashcontent1, flashcontent2;
@@ -89,7 +89,7 @@ int probe_82802ab(struct flashchip *flash)
return 1;
}
-uint8_t wait_82802ab(struct flashchip *flash)
+uint8_t wait_82802ab(struct flashctx *flash)
{
uint8_t status;
chipaddr bios = flash->virtual_memory;
@@ -107,7 +107,7 @@ uint8_t wait_82802ab(struct flashchip *flash)
return status;
}
-int unlock_82802ab(struct flashchip *flash)
+int unlock_82802ab(struct flashctx *flash)
{
int i;
//chipaddr wrprotect = flash->virtual_registers + page + 2;
@@ -118,7 +118,7 @@ int unlock_82802ab(struct flashchip *flash)
return 0;
}
-int erase_block_82802ab(struct flashchip *flash, unsigned int page,
+int erase_block_82802ab(struct flashctx *flash, unsigned int page,
unsigned int pagesize)
{
chipaddr bios = flash->virtual_memory;
@@ -141,7 +141,7 @@ int erase_block_82802ab(struct flashchip *flash, unsigned int page,
}
/* chunksize is 1 */
-int write_82802ab(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
+int write_82802ab(struct flashctx *flash, uint8_t *src, unsigned int start, unsigned int len)
{
int i;
chipaddr dst = flash->virtual_memory + start;
@@ -157,7 +157,7 @@ int write_82802ab(struct flashchip *flash, uint8_t *src, unsigned int start, uns
return 0;
}
-int unlock_28f004s5(struct flashchip *flash)
+int unlock_28f004s5(struct flashctx *flash)
{
chipaddr bios = flash->virtual_memory;
uint8_t mcfg, bcfg, need_unlock = 0, can_unlock = 0;
@@ -209,7 +209,7 @@ int unlock_28f004s5(struct flashchip *flash)
return 0;
}
-int unlock_lh28f008bjt(struct flashchip *flash)
+int unlock_lh28f008bjt(struct flashctx *flash)
{
chipaddr bios = flash->virtual_memory;
uint8_t mcfg, bcfg;
diff --git a/a25.c b/a25.c
index 5791c4607..f7641cb80 100644
--- a/a25.c
+++ b/a25.c
@@ -29,7 +29,7 @@ static void spi_prettyprint_status_register_amic_a25_srwd(uint8_t status)
"(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not ");
}
-int spi_prettyprint_status_register_amic_a25l05p(struct flashchip *flash)
+int spi_prettyprint_status_register_amic_a25l05p(struct flashctx *flash)
{
uint8_t status;
@@ -45,7 +45,7 @@ int spi_prettyprint_status_register_amic_a25l05p(struct flashchip *flash)
return 0;
}
-int spi_prettyprint_status_register_amic_a25l40p(struct flashchip *flash)
+int spi_prettyprint_status_register_amic_a25l40p(struct flashctx *flash)
{
uint8_t status;
@@ -60,7 +60,7 @@ int spi_prettyprint_status_register_amic_a25l40p(struct flashchip *flash)
return 0;
}
-int spi_prettyprint_status_register_amic_a25l032(struct flashchip *flash)
+int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash)
{
uint8_t status;
@@ -78,7 +78,7 @@ int spi_prettyprint_status_register_amic_a25l032(struct flashchip *flash)
return 0;
}
-int spi_prettyprint_status_register_amic_a25lq032(struct flashchip *flash)
+int spi_prettyprint_status_register_amic_a25lq032(struct flashctx *flash)
{
uint8_t status;
diff --git a/at25.c b/at25.c
index e55b007e8..eccf4c899 100644
--- a/at25.c
+++ b/at25.c
@@ -57,7 +57,7 @@ static void spi_prettyprint_status_register_atmel_at25_swp(uint8_t status)
}
}
-int spi_prettyprint_status_register_at25df(struct flashchip *flash)
+int spi_prettyprint_status_register_at25df(struct flashctx *flash)
{
uint8_t status;
@@ -72,7 +72,7 @@ int spi_prettyprint_status_register_at25df(struct flashchip *flash)
return 0;
}
-int spi_prettyprint_status_register_at25df_sec(struct flashchip *flash)
+int spi_prettyprint_status_register_at25df_sec(struct flashctx *flash)
{
/* FIXME: We should check the security lockdown. */
msg_cdbg("Ignoring security lockdown (if present)\n");
@@ -80,7 +80,7 @@ int spi_prettyprint_status_register_at25df_sec(struct flashchip *flash)
return spi_prettyprint_status_register_at25df(flash);
}
-int spi_prettyprint_status_register_at25f(struct flashchip *flash)
+int spi_prettyprint_status_register_at25f(struct flashctx *flash)
{
uint8_t status;
@@ -99,7 +99,7 @@ int spi_prettyprint_status_register_at25f(struct flashchip *flash)
return 0;
}
-int spi_prettyprint_status_register_at25fs010(struct flashchip *flash)
+int spi_prettyprint_status_register_at25fs010(struct flashctx *flash)
{
uint8_t status;
@@ -123,7 +123,7 @@ int spi_prettyprint_status_register_at25fs010(struct flashchip *flash)
return 0;
}
-int spi_prettyprint_status_register_at25fs040(struct flashchip *flash)
+int spi_prettyprint_status_register_at25fs040(struct flashctx *flash)
{
uint8_t status;
@@ -147,7 +147,7 @@ int spi_prettyprint_status_register_at25fs040(struct flashchip *flash)
return 0;
}
-int spi_prettyprint_status_register_atmel_at26df081a(struct flashchip *flash)
+int spi_prettyprint_status_register_atmel_at26df081a(struct flashctx *flash)
{
uint8_t status;
@@ -163,7 +163,7 @@ int spi_prettyprint_status_register_atmel_at26df081a(struct flashchip *flash)
return 0;
}
-int spi_disable_blockprotect_at25df(struct flashchip *flash)
+int spi_disable_blockprotect_at25df(struct flashctx *flash)
{
uint8_t status;
int result;
@@ -203,14 +203,14 @@ int spi_disable_blockprotect_at25df(struct flashchip *flash)
return 0;
}
-int spi_disable_blockprotect_at25df_sec(struct flashchip *flash)
+int spi_disable_blockprotect_at25df_sec(struct flashctx *flash)
{
/* FIXME: We should check the security lockdown. */
msg_cinfo("Ignoring security lockdown (if present)\n");
return spi_disable_blockprotect_at25df(flash);
}
-int spi_disable_blockprotect_at25f(struct flashchip *flash)
+int spi_disable_blockprotect_at25f(struct flashctx *flash)
{
/* spi_disable_blockprotect_at25df is not really the right way to do
* this, but the side effects of said function work here as well.
@@ -218,7 +218,7 @@ int spi_disable_blockprotect_at25f(struct flashchip *flash)
return spi_disable_blockprotect_at25df(flash);
}
-int spi_disable_blockprotect_at25fs010(struct flashchip *flash)
+int spi_disable_blockprotect_at25fs010(struct flashctx *flash)
{
uint8_t status;
int result;
@@ -252,7 +252,7 @@ int spi_disable_blockprotect_at25fs010(struct flashchip *flash)
return 0;
}
-int spi_disable_blockprotect_at25fs040(struct flashchip *flash)
+int spi_disable_blockprotect_at25fs040(struct flashctx *flash)
{
uint8_t status;
int result;
diff --git a/chipdrivers.h b/chipdrivers.h
index d2886c401..ce0f9acd6 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -19,79 +19,79 @@
*
* Header file for flash chip drivers. Included from flash.h.
* As a general rule, every function listed here should take a pointer to
- * struct flashchip as first parameter.
+ * struct flashctx as first parameter.
*/
#ifndef __CHIPDRIVERS_H__
#define __CHIPDRIVERS_H__ 1
-#include "flash.h" /* for chipaddr and flashchip */
+#include "flash.h" /* for chipaddr and flashctx */
/* spi.c, should probably be in spi_chip.c */
-int probe_spi_rdid(struct flashchip *flash);
-int probe_spi_rdid4(struct flashchip *flash);
-int probe_spi_rems(struct flashchip *flash);
-int probe_spi_res1(struct flashchip *flash);
-int probe_spi_res2(struct flashchip *flash);
+int probe_spi_rdid(struct flashctx *flash);
+int probe_spi_rdid4(struct flashctx *flash);
+int probe_spi_rems(struct flashctx *flash);
+int probe_spi_res1(struct flashctx *flash);
+int probe_spi_res2(struct flashctx *flash);
int spi_write_enable(void);
int spi_write_disable(void);
-int spi_block_erase_20(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
-int spi_block_erase_52(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
-int spi_block_erase_d7(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
-int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
-int spi_block_erase_60(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
-int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
-int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
-int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
-int spi_chip_read(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len);
+int spi_block_erase_20(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
+int spi_block_erase_52(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
+int spi_block_erase_d7(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
+int spi_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
+int spi_block_erase_60(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
+int spi_block_erase_c7(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
+int spi_chip_write_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int spi_chip_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len);
uint8_t spi_read_status_register(void);
-int spi_write_status_register(struct flashchip *flash, int status);
+int spi_write_status_register(struct flashctx *flash, int status);
void spi_prettyprint_status_register_bit(uint8_t status, int bit);
void spi_prettyprint_status_register_bp3210(uint8_t status, int bp);
void spi_prettyprint_status_register_welwip(uint8_t status);
-int spi_prettyprint_status_register(struct flashchip *flash);
-int spi_disable_blockprotect(struct flashchip *flash);
+int spi_prettyprint_status_register(struct flashctx *flash);
+int spi_disable_blockprotect(struct flashctx *flash);
int spi_byte_program(unsigned int addr, uint8_t databyte);
int spi_nbyte_program(unsigned int addr, uint8_t *bytes, unsigned int len);
int spi_nbyte_read(unsigned int addr, uint8_t *bytes, unsigned int len);
-int spi_read_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
-int spi_write_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
-int spi_aai_write(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
+int spi_write_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
+int spi_aai_write(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
/* opaque.c */
-int probe_opaque(struct flashchip *flash);
-int read_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
-int write_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
-int erase_opaque(struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);
+int probe_opaque(struct flashctx *flash);
+int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int write_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
/* a25.c */
-int spi_prettyprint_status_register_amic_a25l05p(struct flashchip *flash);
-int spi_prettyprint_status_register_amic_a25l40p(struct flashchip *flash);
-int spi_prettyprint_status_register_amic_a25l032(struct flashchip *flash);
-int spi_prettyprint_status_register_amic_a25lq032(struct flashchip *flash);
+int spi_prettyprint_status_register_amic_a25l05p(struct flashctx *flash);
+int spi_prettyprint_status_register_amic_a25l40p(struct flashctx *flash);
+int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash);
+int spi_prettyprint_status_register_amic_a25lq032(struct flashctx *flash);
/* at25.c */
-int spi_prettyprint_status_register_at25df(struct flashchip *flash);
-int spi_prettyprint_status_register_at25df_sec(struct flashchip *flash);
-int spi_prettyprint_status_register_at25f(struct flashchip *flash);
-int spi_prettyprint_status_register_at25fs010(struct flashchip *flash);
-int spi_prettyprint_status_register_at25fs040(struct flashchip *flash);
-int spi_prettyprint_status_register_atmel_at26df081a(struct flashchip *flash);
-int spi_disable_blockprotect_at25df(struct flashchip *flash);
-int spi_disable_blockprotect_at25df_sec(struct flashchip *flash);
-int spi_disable_blockprotect_at25f(struct flashchip *flash);
-int spi_disable_blockprotect_at25fs010(struct flashchip *flash);
-int spi_disable_blockprotect_at25fs040(struct flashchip *flash);
+int spi_prettyprint_status_register_at25df(struct flashctx *flash);
+int spi_prettyprint_status_register_at25df_sec(struct flashctx *flash);
+int spi_prettyprint_status_register_at25f(struct flashctx *flash);
+int spi_prettyprint_status_register_at25fs010(struct flashctx *flash);
+int spi_prettyprint_status_register_at25fs040(struct flashctx *flash);
+int spi_prettyprint_status_register_atmel_at26df081a(struct flashctx *flash);
+int spi_disable_blockprotect_at25df(struct flashctx *flash);
+int spi_disable_blockprotect_at25df_sec(struct flashctx *flash);
+int spi_disable_blockprotect_at25f(struct flashctx *flash);
+int spi_disable_blockprotect_at25fs010(struct flashctx *flash);
+int spi_disable_blockprotect_at25fs040(struct flashctx *flash);
/* 82802ab.c */
-uint8_t wait_82802ab(struct flashchip *flash);
-int probe_82802ab(struct flashchip *flash);
-int erase_block_82802ab(struct flashchip *flash, unsigned int page, unsigned int pagesize);
-int write_82802ab(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
+uint8_t wait_82802ab(struct flashctx *flash);
+int probe_82802ab(struct flashctx *flash);
+int erase_block_82802ab(struct flashctx *flash, unsigned int page, unsigned int pagesize);
+int write_82802ab(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
void print_status_82802ab(uint8_t status);
-int unlock_82802ab(struct flashchip *flash);
-int unlock_28f004s5(struct flashchip *flash);
-int unlock_lh28f008bjt(struct flashchip *flash);
+int unlock_82802ab(struct flashctx *flash);
+int unlock_28f004s5(struct flashctx *flash);
+int unlock_lh28f008bjt(struct flashctx *flash);
/* jedec.c */
uint8_t oddparity(uint8_t val);
@@ -99,58 +99,58 @@ void toggle_ready_jedec(chipaddr dst);
void data_polling_jedec(chipaddr dst, uint8_t data);
int write_byte_program_jedec(chipaddr bios, uint8_t *src,
chipaddr dst);
-int probe_jedec(struct flashchip *flash);
-int write_jedec(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
-int write_jedec_1(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
-int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize);
-int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
-int erase_chip_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
+int probe_jedec(struct flashctx *flash);
+int write_jedec(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int write_jedec_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int erase_sector_jedec(struct flashctx *flash, unsigned int page, unsigned int pagesize);
+int erase_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize);
+int erase_chip_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize);
/* m29f400bt.c */
-int probe_m29f400bt(struct flashchip *flash);
-int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
-int block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
-int write_m29f400bt(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int probe_m29f400bt(struct flashctx *flash);
+int block_erase_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len);
+int block_erase_chip_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len);
+int write_m29f400bt(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
void protect_m29f400bt(chipaddr bios);
/* pm49fl00x.c */
-int unlock_49fl00x(struct flashchip *flash);
-int lock_49fl00x(struct flashchip *flash);
+int unlock_49fl00x(struct flashctx *flash);
+int lock_49fl00x(struct flashctx *flash);
/* sst28sf040.c */
-int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
-int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size);
-int write_28sf040(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
-int unprotect_28sf040(struct flashchip *flash);
-int protect_28sf040(struct flashchip *flash);
+int erase_chip_28sf040(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
+int erase_sector_28sf040(struct flashctx *flash, unsigned int address, unsigned int sector_size);
+int write_28sf040(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int unprotect_28sf040(struct flashctx *flash);
+int protect_28sf040(struct flashctx *flash);
/* sst49lfxxxc.c */
-int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size);
-int unlock_49lfxxxc(struct flashchip *flash);
+int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size);
+int unlock_49lfxxxc(struct flashctx *flash);
/* sst_fwhub.c */
-int printlock_sst_fwhub(struct flashchip *flash);
-int unlock_sst_fwhub(struct flashchip *flash);
+int printlock_sst_fwhub(struct flashctx *flash);
+int unlock_sst_fwhub(struct flashctx *flash);
/* w39.c */
-int printlock_w39l040(struct flashchip * flash);
-int printlock_w39v040a(struct flashchip *flash);
-int printlock_w39v040b(struct flashchip *flash);
-int printlock_w39v040c(struct flashchip *flash);
-int printlock_w39v040fa(struct flashchip *flash);
-int printlock_w39v040fb(struct flashchip *flash);
-int printlock_w39v040fc(struct flashchip *flash);
-int printlock_w39v080a(struct flashchip *flash);
-int printlock_w39v080fa(struct flashchip *flash);
-int printlock_w39v080fa_dual(struct flashchip *flash);
-int unlock_w39v040fb(struct flashchip *flash);
-int unlock_w39v080fa(struct flashchip *flash);
+int printlock_w39l040(struct flashctx * flash);
+int printlock_w39v040a(struct flashctx *flash);
+int printlock_w39v040b(struct flashctx *flash);
+int printlock_w39v040c(struct flashctx *flash);
+int printlock_w39v040fa(struct flashctx *flash);
+int printlock_w39v040fb(struct flashctx *flash);
+int printlock_w39v040fc(struct flashctx *flash);
+int printlock_w39v080a(struct flashctx *flash);
+int printlock_w39v080fa(struct flashctx *flash);
+int printlock_w39v080fa_dual(struct flashctx *flash);
+int unlock_w39v040fb(struct flashctx *flash);
+int unlock_w39v080fa(struct flashctx *flash);
/* w29ee011.c */
-int probe_w29ee011(struct flashchip *flash);
+int probe_w29ee011(struct flashctx *flash);
/* stm50flw0x0x.c */
-int erase_sector_stm50flw0x0x(struct flashchip *flash, unsigned int block, unsigned int blocksize);
-int unlock_stm50flw0x0x(struct flashchip *flash);
+int erase_sector_stm50flw0x0x(struct flashctx *flash, unsigned int block, unsigned int blocksize);
+int unlock_stm50flw0x0x(struct flashctx *flash);
#endif /* !__CHIPDRIVERS_H__ */
diff --git a/cli_classic.c b/cli_classic.c
index 49bc8a800..bb8c29f8d 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -169,8 +169,8 @@ int main(int argc, char *argv[])
unsigned long size;
/* Probe for up to three flash chips. */
const struct flashchip *flash;
- struct flashchip flashes[3];
- struct flashchip *fill_flash;
+ struct flashctx flashes[3];
+ struct flashctx *fill_flash;
const char *name;
int namelen, opt, i;
int startchip = 0, chipcount = 0, option_index = 0, force = 0;
@@ -409,6 +409,7 @@ int main(int argc, char *argv[])
}
#endif
+ /* Does a chip with the requested name exist in the flashchips array? */
if (chip_to_probe) {
for (flash = flashchips; flash && flash->name; flash++)
if (!strcmp(flash->name, chip_to_probe))
diff --git a/dediprog.c b/dediprog.c
index ca2d3e024..4161f62f3 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -205,7 +205,7 @@ static int dediprog_set_spi_speed(uint16_t speed)
* @len length
* @return 0 on success, 1 on failure
*/
-static int dediprog_spi_bulk_read(struct flashchip *flash, uint8_t *buf,
+static int dediprog_spi_bulk_read(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len)
{
int ret;
@@ -253,7 +253,7 @@ static int dediprog_spi_bulk_read(struct flashchip *flash, uint8_t *buf,
return 0;
}
-static int dediprog_spi_read(struct flashchip *flash, uint8_t *buf,
+static int dediprog_spi_read(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len)
{
int ret;
@@ -299,7 +299,7 @@ static int dediprog_spi_read(struct flashchip *flash, uint8_t *buf,
return 0;
}
-static int dediprog_spi_write_256(struct flashchip *flash, uint8_t *buf,
+static int dediprog_spi_write_256(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len)
{
int ret;
diff --git a/dummyflasher.c b/dummyflasher.c
index 8437c58b3..cb975b46e 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -62,7 +62,7 @@ static unsigned int spi_write_256_chunksize = 256;
static int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
-static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf,
+static int dummy_spi_write_256(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len);
static const struct spi_programmer spi_programmer_dummyflasher = {
@@ -548,7 +548,7 @@ static int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
return 0;
}
-static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf,
+static int dummy_spi_write_256(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len)
{
return spi_write_chunked(flash, buf, start, len,
diff --git a/flash.h b/flash.h
index 543b70c71..b1cd28079 100644
--- a/flash.h
+++ b/flash.h
@@ -93,6 +93,8 @@ enum chipbustype {
#define FEATURE_WRSR_WREN (1 << 7)
#define FEATURE_WRSR_EITHER (FEATURE_WRSR_EWSR | FEATURE_WRSR_WREN)
+struct flashctx;
+
struct flashchip {
const char *vendor;
const char *name;
@@ -119,7 +121,7 @@ struct flashchip {
*/
uint32_t tested;
- int (*probe) (struct flashchip *flash);
+ int (*probe) (struct flashctx *flash);
/* Delay after "enter/exit ID mode" commands in microseconds.
* NB: negative values have special meanings, see TIMING_* below.
@@ -140,20 +142,42 @@ struct flashchip {
} eraseblocks[NUM_ERASEREGIONS];
/* a block_erase function should try to erase one block of size
* 'blocklen' at address 'blockaddr' and return 0 on success. */
- int (*block_erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);
+ int (*block_erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
} block_erasers[NUM_ERASEFUNCTIONS];
- int (*printlock) (struct flashchip *flash);
- int (*unlock) (struct flashchip *flash);
- int (*write) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
- int (*read) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
- struct {
+ int (*printlock) (struct flashctx *flash);
+ int (*unlock) (struct flashctx *flash);
+ int (*write) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+ int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+ struct voltage {
uint16_t min;
uint16_t max;
} voltage;
+};
- /* Some flash devices have an additional register space. */
+/* struct flashctx must always contain struct flashchip at the beginning. */
+struct flashctx {
+ const char *vendor;
+ const char *name;
+ enum chipbustype bustype;
+ uint32_t manufacture_id;
+ uint32_t model_id;
+ int total_size;
+ int page_size;
+ int feature_bits;
+ uint32_t tested;
+ int (*probe) (struct flashctx *flash);
+ int probe_timing;
+ struct block_eraser block_erasers[NUM_ERASEFUNCTIONS];
+ int (*printlock) (struct flashctx *flash);
+ int (*unlock) (struct flashctx *flash);
+ int (*write) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+ int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+ struct voltage voltage;
+ /* struct flashchip ends here. */
+
chipaddr virtual_memory;
+ /* Some flash devices have an additional register space. */
chipaddr virtual_registers;
};
@@ -203,23 +227,23 @@ extern enum chipbustype buses_supported;
extern int verbose;
extern const char flashrom_version[];
extern char *chip_to_probe;
-void map_flash_registers(struct flashchip *flash);
-int read_memmapped(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
-int erase_flash(struct flashchip *flash);
-int probe_flash(int startchip, struct flashchip *fill_flash, int force);
-int read_flash_to_file(struct flashchip *flash, const char *filename);
+void map_flash_registers(struct flashctx *flash);
+int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int erase_flash(struct flashctx *flash);
+int probe_flash(int startchip, struct flashctx *fill_flash, int force);
+int read_flash_to_file(struct flashctx *flash, const char *filename);
int min(int a, int b);
int max(int a, int b);
void tolower_string(char *str);
char *extract_param(char **haystack, const char *needle, const char *delim);
-int verify_range(struct flashchip *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len, const char *message);
+int verify_range(struct flashctx *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len, const char *message);
int need_erase(uint8_t *have, uint8_t *want, unsigned int len, enum write_granularity gran);
char *strcat_realloc(char *dest, const char *src);
void print_version(void);
void print_banner(void);
void list_programmers_linebreak(int startcol, int cols, int paren);
int selfcheck(void);
-int doit(struct flashchip *flash, int force, const char *filename, int read_it, int write_it, int erase_it, int verify_it);
+int doit(struct flashctx *flash, int force, const char *filename, int read_it, int write_it, int erase_it, int verify_it);
int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename);
int write_buf_to_file(unsigned char *buf, unsigned long size, const char *filename);
@@ -259,7 +283,7 @@ int print(int type, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
/* layout.c */
int read_romlayout(char *name);
int find_romentry(char *name);
-int handle_romentries(struct flashchip *flash, uint8_t *oldcontents, uint8_t *newcontents);
+int handle_romentries(struct flashctx *flash, uint8_t *oldcontents, uint8_t *newcontents);
/* spi.c */
struct spi_command {
diff --git a/flashrom.c b/flashrom.c
index fadd09830..6cba06c5d 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -268,7 +268,7 @@ struct shutdown_func_data {
*/
static int may_register_shutdown = 0;
-static int check_block_eraser(const struct flashchip *flash, int k, int log);
+static int check_block_eraser(const struct flashctx *flash, int k, int log);
/* Register a function to be executed on programmer shutdown.
* The advantage over atexit() is that you can supply a void pointer which will
@@ -404,7 +404,7 @@ void programmer_delay(int usecs)
programmer_table[programmer].delay(usecs);
}
-void map_flash_registers(struct flashchip *flash)
+void map_flash_registers(struct flashctx *flash)
{
size_t size = flash->total_size * 1024;
/* Flash registers live 4 MByte below the flash. */
@@ -412,7 +412,7 @@ void map_flash_registers(struct flashchip *flash)
flash->virtual_registers = (chipaddr)programmer_map_flash_region("flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size);
}
-int read_memmapped(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len)
+int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len)
{
chip_readn(buf, flash->virtual_memory + start, len);
@@ -523,7 +523,7 @@ char *extract_programmer_param(const char *param_name)
}
/* Returns the number of well-defined erasers for a chip. */
-static unsigned int count_usable_erasers(const struct flashchip *flash)
+static unsigned int count_usable_erasers(const struct flashctx *flash)
{
unsigned int usable_erasefunctions = 0;
int k;
@@ -535,7 +535,7 @@ static unsigned int count_usable_erasers(const struct flashchip *flash)
}
/* start is an offset to the base address of the flash chip */
-int check_erased_range(struct flashchip *flash, unsigned int start, unsigned int len)
+int check_erased_range(struct flashctx *flash, unsigned int start, unsigned int len)
{
int ret;
uint8_t *cmpbuf = malloc(len);
@@ -558,7 +558,7 @@ int check_erased_range(struct flashchip *flash, unsigned int start, unsigned int
* @message string to print in the "FAILED" message
* @return 0 for success, -1 for failure
*/
-int verify_range(struct flashchip *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len,
+int verify_range(struct flashctx *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len,
const char *message)
{
unsigned int i;
@@ -938,7 +938,7 @@ int check_max_decode(enum chipbustype buses, uint32_t size)
return 1;
}
-int probe_flash(int startchip, struct flashchip *fill_flash, int force)
+int probe_flash(int startchip, struct flashctx *fill_flash, int force)
{
const struct flashchip *flash;
unsigned long base = 0;
@@ -976,7 +976,7 @@ int probe_flash(int startchip, struct flashchip *fill_flash, int force)
check_max_decode(buses_common, size);
/* Start filling in the dynamic data. */
- *fill_flash = *flash;
+ memcpy(fill_flash, flash, sizeof(struct flashchip));
base = flashbase ? flashbase : (0xffffffff - size + 1);
fill_flash->virtual_memory = (chipaddr)programmer_map_flash_region("flash chip", base, size);
@@ -1029,7 +1029,7 @@ notfound:
return flash - flashchips;
}
-int verify_flash(struct flashchip *flash, uint8_t *buf)
+int verify_flash(struct flashctx *flash, uint8_t *buf)
{
int ret;
unsigned int total_size = flash->total_size * 1024;
@@ -1103,7 +1103,7 @@ int write_buf_to_file(unsigned char *buf, unsigned long size,
return 0;
}
-int read_flash_to_file(struct flashchip *flash, const char *filename)
+int read_flash_to_file(struct flashctx *flash, const char *filename)
{
unsigned long size = flash->total_size * 1024;
unsigned char *buf = calloc(size, sizeof(char));
@@ -1202,11 +1202,11 @@ static int selfcheck_eraseblocks(const struct flashchip *flash)
return ret;
}
-static int erase_and_write_block_helper(struct flashchip *flash,
+static int erase_and_write_block_helper(struct flashctx *flash,
unsigned int start, unsigned int len,
uint8_t *curcontents,
uint8_t *newcontents,
- int (*erasefn) (struct flashchip *flash,
+ int (*erasefn) (struct flashctx *flash,
unsigned int addr,
unsigned int len))
{
@@ -1253,14 +1253,14 @@ static int erase_and_write_block_helper(struct flashchip *flash,
return ret;
}
-static int walk_eraseregions(struct flashchip *flash, int erasefunction,
- int (*do_something) (struct flashchip *flash,
+static int walk_eraseregions(struct flashctx *flash, int erasefunction,
+ int (*do_something) (struct flashctx *flash,
unsigned int addr,
unsigned int len,
uint8_t *param1,
uint8_t *param2,
int (*erasefn) (
- struct flashchip *flash,
+ struct flashctx *flash,
unsigned int addr,
unsigned int len)),
void *param1, void *param2)
@@ -1292,7 +1292,7 @@ static int walk_eraseregions(struct flashchip *flash, int erasefunction,
return 0;
}
-static int check_block_eraser(const struct flashchip *flash, int k, int log)
+static int check_block_eraser(const struct flashctx *flash, int k, int log)
{
struct block_eraser eraser = flash->block_erasers[k];
@@ -1316,7 +1316,7 @@ static int check_block_eraser(const struct flashchip *flash, int k, int log)
return 0;
}
-int erase_and_write_flash(struct flashchip *flash, uint8_t *oldcontents,
+int erase_and_write_flash(struct flashctx *flash, uint8_t *oldcontents,
uint8_t *newcontents)
{
int k, ret = 1;
@@ -1534,6 +1534,13 @@ int selfcheck(void)
msg_gerr("Flashchips table miscompilation!\n");
ret = 1;
}
+ /* Check that virtual_memory in struct flashctx is placed directly
+ * after the members copied from struct flashchip.
+ */
+ if (sizeof(struct flashchip) != offsetof(struct flashctx, virtual_memory)) {
+ msg_gerr("struct flashctx broken!\n");
+ ret = 1;
+ }
for (flash = flashchips; flash && flash->name; flash++)
if (selfcheck_eraseblocks(flash))
ret = 1;
@@ -1559,7 +1566,7 @@ int selfcheck(void)
return ret;
}
-void check_chip_supported(const struct flashchip *flash)
+void check_chip_supported(const struct flashctx *flash)
{
if (TEST_OK_MASK != (flash->tested & TEST_OK_MASK)) {
msg_cinfo("===\n");
@@ -1611,7 +1618,7 @@ void check_chip_supported(const struct flashchip *flash)
/* FIXME: This function signature needs to be improved once doit() has a better
* function signature.
*/
-int chip_safety_check(struct flashchip *flash, int force, int read_it, int write_it, int erase_it, int verify_it)
+int chip_safety_check(struct flashctx *flash, int force, int read_it, int write_it, int erase_it, int verify_it)
{
if (!programmer_may_write && (write_it || erase_it)) {
msg_perr("Write/erase is not working yet on your programmer in "
@@ -1672,7 +1679,7 @@ int chip_safety_check(struct flashchip *flash, int force, int read_it, int write
* but right now it allows us to split off the CLI code.
* Besides that, the function itself is a textbook example of abysmal code flow.
*/
-int doit(struct flashchip *flash, int force, const char *filename, int read_it, int write_it, int erase_it, int verify_it)
+int doit(struct flashctx *flash, int force, const char *filename, int read_it, int write_it, int erase_it, int verify_it)
{
uint8_t *oldcontents;
uint8_t *newcontents;
diff --git a/ichspi.c b/ichspi.c
index 78cdb3be4..1c6698672 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1175,7 +1175,7 @@ static int ich_hwseq_wait_for_cycle_complete(unsigned int timeout,
return 0;
}
-int ich_hwseq_probe(struct flashchip *flash)
+int ich_hwseq_probe(struct flashctx *flash)
{
uint32_t total_size, boundary;
uint32_t erase_size_low, size_low, erase_size_high, size_high;
@@ -1228,7 +1228,7 @@ int ich_hwseq_probe(struct flashchip *flash)
return 1;
}
-int ich_hwseq_block_erase(struct flashchip *flash,
+int ich_hwseq_block_erase(struct flashctx *flash,
unsigned int addr,
unsigned int len)
{
@@ -1278,7 +1278,7 @@ int ich_hwseq_block_erase(struct flashchip *flash,
return 0;
}
-int ich_hwseq_read(struct flashchip *flash, uint8_t *buf, unsigned int addr,
+int ich_hwseq_read(struct flashctx *flash, uint8_t *buf, unsigned int addr,
unsigned int len)
{
uint16_t hsfc;
@@ -1316,7 +1316,7 @@ int ich_hwseq_read(struct flashchip *flash, uint8_t *buf, unsigned int addr,
return 0;
}
-int ich_hwseq_write(struct flashchip *flash, uint8_t *buf, unsigned int addr,
+int ich_hwseq_write(struct flashctx *flash, uint8_t *buf, unsigned int addr,
unsigned int len)
{
uint16_t hsfc;
diff --git a/it87spi.c b/it87spi.c
index 481025224..5a7e6ecac 100644
--- a/it87spi.c
+++ b/it87spi.c
@@ -105,9 +105,9 @@ void probe_superio_ite(void)
static int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
-static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf,
+static int it8716f_spi_chip_read(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len);
-static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
+static int it8716f_spi_chip_write_256(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len);
static const struct spi_programmer spi_programmer_it87xx = {
@@ -312,7 +312,7 @@ static int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
}
/* Page size is usually 256 bytes */
-static int it8716f_spi_page_program(struct flashchip *flash, uint8_t *buf,
+static int it8716f_spi_page_program(struct flashctx *flash, uint8_t *buf,
unsigned int start)
{
unsigned int i;
@@ -340,7 +340,7 @@ static int it8716f_spi_page_program(struct flashchip *flash, uint8_t *buf,
* IT8716F only allows maximum of 512 kb SPI mapped to LPC memory cycles
* Need to read this big flash using firmware cycles 3 byte at a time.
*/
-static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf,
+static int it8716f_spi_chip_read(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len)
{
fast_spi = 0;
@@ -358,7 +358,7 @@ static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf,
return 0;
}
-static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
+static int it8716f_spi_chip_write_256(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len)
{
/*
diff --git a/jedec.c b/jedec.c
index 8004863fc..97621d9a9 100644
--- a/jedec.c
+++ b/jedec.c
@@ -91,7 +91,7 @@ void data_polling_jedec(chipaddr dst, uint8_t data)
msg_cdbg("%s: excessive loops, i=0x%x\n", __func__, i);
}
-static unsigned int getaddrmask(struct flashchip *flash)
+static unsigned int getaddrmask(struct flashctx *flash)
{
switch (flash->feature_bits & FEATURE_ADDR_MASK) {
case FEATURE_ADDR_FULL:
@@ -110,7 +110,7 @@ static unsigned int getaddrmask(struct flashchip *flash)
}
}
-static void start_program_jedec_common(struct flashchip *flash, unsigned int mask)
+static void start_program_jedec_common(struct flashctx *flash, unsigned int mask)
{
chipaddr bios = flash->virtual_memory;
chip_writeb(0xAA, bios + (0x5555 & mask));
@@ -118,7 +118,7 @@ static void start_program_jedec_common(struct flashchip *flash, unsigned int mas
chip_writeb(0xA0, bios + (0x5555 & mask));
}
-static int probe_jedec_common(struct flashchip *flash, unsigned int mask)
+static int probe_jedec_common(struct flashctx *flash, unsigned int mask)
{
chipaddr bios = flash->virtual_memory;
uint8_t id1, id2;
@@ -237,7 +237,7 @@ static int probe_jedec_common(struct flashchip *flash, unsigned int mask)
return 1;
}
-static int erase_sector_jedec_common(struct flashchip *flash, unsigned int page,
+static int erase_sector_jedec_common(struct flashctx *flash, unsigned int page,
unsigned int pagesize, unsigned int mask)
{
chipaddr bios = flash->virtual_memory;
@@ -267,7 +267,7 @@ static int erase_sector_jedec_common(struct flashchip *flash, unsigned int page,
return 0;
}
-static int erase_block_jedec_common(struct flashchip *flash, unsigned int block,
+static int erase_block_jedec_common(struct flashctx *flash, unsigned int block,
unsigned int blocksize, unsigned int mask)
{
chipaddr bios = flash->virtual_memory;
@@ -297,7 +297,7 @@ static int erase_block_jedec_common(struct flashchip *flash, unsigned int block,
return 0;
}
-static int erase_chip_jedec_common(struct flashchip *flash, unsigned int mask)
+static int erase_chip_jedec_common(struct flashctx *flash, unsigned int mask)
{
chipaddr bios = flash->virtual_memory;
int delay_us = 0;
@@ -325,7 +325,7 @@ static int erase_chip_jedec_common(struct flashchip *flash, unsigned int mask)
return 0;
}
-static int write_byte_program_jedec_common(struct flashchip *flash, uint8_t *src,
+static int write_byte_program_jedec_common(struct flashctx *flash, uint8_t *src,
chipaddr dst, unsigned int mask)
{
int tried = 0, failed = 0;
@@ -355,7 +355,7 @@ retry:
}
/* chunksize is 1 */
-int write_jedec_1(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
+int write_jedec_1(struct flashctx *flash, uint8_t *src, unsigned int start, unsigned int len)
{
int i, failed = 0;
chipaddr dst = flash->virtual_memory + start;
@@ -376,7 +376,7 @@ int write_jedec_1(struct flashchip *flash, uint8_t *src, unsigned int start, uns
return failed;
}
-int write_page_write_jedec_common(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int page_size)
+int write_page_write_jedec_common(struct flashctx *flash, uint8_t *src, unsigned int start, unsigned int page_size)
{
int i, tried = 0, failed;
uint8_t *s = src;
@@ -424,11 +424,11 @@ retry:
* This function is a slightly modified copy of spi_write_chunked.
* Each page is written separately in chunks with a maximum size of chunksize.
*/
-int write_jedec(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len)
+int write_jedec(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len)
{
unsigned int i, starthere, lenhere;
/* FIXME: page_size is the wrong variable. We need max_writechunk_size
- * in struct flashchip to do this properly. All chips using
+ * in struct flashctx to do this properly. All chips using
* write_jedec have page_size set to max_writechunk_size, so
* we're OK for now.
*/
@@ -458,7 +458,7 @@ int write_jedec(struct flashchip *flash, uint8_t *buf, unsigned int start, int u
}
/* erase chip with block_erase() prototype */
-int erase_chip_block_jedec(struct flashchip *flash, unsigned int addr,
+int erase_chip_block_jedec(struct flashctx *flash, unsigned int addr,
unsigned int blocksize)
{
unsigned int mask;
@@ -472,7 +472,7 @@ int erase_chip_block_jedec(struct flashchip *flash, unsigned int addr,
return erase_chip_jedec_common(flash, mask);
}
-int probe_jedec(struct flashchip *flash)
+int probe_jedec(struct flashctx *flash)
{
unsigned int mask;
@@ -480,7 +480,7 @@ int probe_jedec(struct flashchip *flash)
return probe_jedec_common(flash, mask);
}
-int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int size)
+int erase_sector_jedec(struct flashctx *flash, unsigned int page, unsigned int size)
{
unsigned int mask;
@@ -488,7 +488,7 @@ int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int
return erase_sector_jedec_common(flash, page, size, mask);
}
-int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int size)
+int erase_block_jedec(struct flashctx *flash, unsigned int page, unsigned int size)
{
unsigned int mask;
@@ -496,7 +496,7 @@ int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int s
return erase_block_jedec_common(flash, page, size, mask);
}
-int erase_chip_jedec(struct flashchip *flash)
+int erase_chip_jedec(struct flashctx *flash)
{
unsigned int mask;
diff --git a/layout.c b/layout.c
index d719a051b..530ebd546 100644
--- a/layout.c
+++ b/layout.c
@@ -240,7 +240,7 @@ int find_next_included_romentry(unsigned int start)
return best_entry;
}
-int handle_romentries(struct flashchip *flash, uint8_t *oldcontents, uint8_t *newcontents)
+int handle_romentries(struct flashctx *flash, uint8_t *oldcontents, uint8_t *newcontents)
{
unsigned int start = 0;
int entry;
diff --git a/linux_spi.c b/linux_spi.c
index 44a2fcd6d..372082300 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -36,9 +36,9 @@ static int fd = -1;
static int linux_spi_shutdown(void *data);
static int linux_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *txbuf, unsigned char *rxbuf);
-static int linux_spi_read(struct flashchip *flash, uint8_t *buf,
+static int linux_spi_read(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len);
-static int linux_spi_write_256(struct flashchip *flash, uint8_t *buf,
+static int linux_spi_write_256(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len);
static const struct spi_programmer spi_programmer_linux = {
@@ -131,13 +131,13 @@ static int linux_spi_send_command(unsigned int writecnt, unsigned int readcnt,
return 0;
}
-static int linux_spi_read(struct flashchip *flash, uint8_t *buf,
+static int linux_spi_read(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len)
{
return spi_read_chunked(flash, buf, start, len, (unsigned)getpagesize());
}
-static int linux_spi_write_256(struct flashchip *flash, uint8_t *buf,
+static int linux_spi_write_256(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len)
{
return spi_write_chunked(flash, buf, start, len, ((unsigned)getpagesize()) - 4);
diff --git a/m29f400bt.c b/m29f400bt.c
index 61bfa2e4a..f664b476c 100644
--- a/m29f400bt.c
+++ b/m29f400bt.c
@@ -28,7 +28,7 @@
functions. */
/* chunksize is 1 */
-int write_m29f400bt(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
+int write_m29f400bt(struct flashctx *flash, uint8_t *src, unsigned int start, unsigned int len)
{
int i;
chipaddr bios = flash->virtual_memory;
@@ -55,7 +55,7 @@ int write_m29f400bt(struct flashchip *flash, uint8_t *src, unsigned int start, u
return 0;
}
-int probe_m29f400bt(struct flashchip *flash)
+int probe_m29f400bt(struct flashctx *flash)
{
chipaddr bios = flash->virtual_memory;
uint8_t id1, id2;
@@ -86,7 +86,7 @@ int probe_m29f400bt(struct flashchip *flash)
return 0;
}
-int erase_m29f400bt(struct flashchip *flash)
+int erase_m29f400bt(struct flashctx *flash)
{
chipaddr bios = flash->virtual_memory;
@@ -105,7 +105,7 @@ int erase_m29f400bt(struct flashchip *flash)
return 0;
}
-int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len)
+int block_erase_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len)
{
chipaddr bios = flash->virtual_memory;
chipaddr dst = bios + start;
@@ -125,7 +125,7 @@ int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned
return 0;
}
-int block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int address, unsigned int blocklen)
+int block_erase_chip_m29f400bt(struct flashctx *flash, unsigned int address, unsigned int blocklen)
{
if ((address != 0) || (blocklen != flash->total_size * 1024)) {
msg_cerr("%s called with incorrect arguments\n",
diff --git a/opaque.c b/opaque.c
index 1c3161294..43ddb07ef 100644
--- a/opaque.c
+++ b/opaque.c
@@ -41,7 +41,7 @@ const struct opaque_programmer opaque_programmer_none = {
const struct opaque_programmer *opaque_programmer = &opaque_programmer_none;
-int probe_opaque(struct flashchip *flash)
+int probe_opaque(struct flashctx *flash)
{
if (!opaque_programmer->probe) {
msg_perr("%s called before register_opaque_programmer. "
@@ -53,7 +53,7 @@ int probe_opaque(struct flashchip *flash)
return opaque_programmer->probe(flash);
}
-int read_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
if (!opaque_programmer->read) {
msg_perr("%s called before register_opaque_programmer. "
@@ -64,7 +64,7 @@ int read_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsig
return opaque_programmer->read(flash, buf, start, len);
}
-int write_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int write_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
if (!opaque_programmer->write) {
msg_perr("%s called before register_opaque_programmer. "
@@ -75,7 +75,7 @@ int write_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsi
return opaque_programmer->write(flash, buf, start, len);
}
-int erase_opaque(struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen)
+int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen)
{
if (!opaque_programmer->erase) {
msg_perr("%s called before register_opaque_programmer. "
diff --git a/pm49fl00x.c b/pm49fl00x.c
index 13992a38a..3f7475897 100644
--- a/pm49fl00x.c
+++ b/pm49fl00x.c
@@ -36,13 +36,13 @@ static void write_lockbits_49fl00x(chipaddr bios, unsigned int size,
}
}
-int unlock_49fl00x(struct flashchip *flash)
+int unlock_49fl00x(struct flashctx *flash)
{
write_lockbits_49fl00x(flash->virtual_registers, flash->total_size * 1024, 0, flash->page_size);
return 0;
}
-int lock_49fl00x(struct flashchip *flash)
+int lock_49fl00x(struct flashctx *flash)
{
write_lockbits_49fl00x(flash->virtual_registers, flash->total_size * 1024, 1, flash->page_size);
return 0;
diff --git a/programmer.h b/programmer.h
index 8f5591240..c80b85106 100644
--- a/programmer.h
+++ b/programmer.h
@@ -24,7 +24,7 @@
#ifndef __PROGRAMMER_H__
#define __PROGRAMMER_H__ 1
-#include "flash.h" /* for chipaddr and flashchip */
+#include "flash.h" /* for chipaddr and flashctx */
enum programmer {
#if CONFIG_INTERNAL == 1
@@ -513,7 +513,7 @@ struct decode_sizes {
extern struct decode_sizes max_rom_decode;
extern int programmer_may_write;
extern unsigned long flashbase;
-void check_chip_supported(const struct flashchip *flash);
+void check_chip_supported(const struct flashctx *flash);
int check_max_decode(enum chipbustype buses, uint32_t size);
char *extract_programmer_param(const char *param_name);
@@ -570,16 +570,16 @@ struct spi_programmer {
int (*multicommand)(struct spi_command *cmds);
/* Optimized functions for this programmer */
- int (*read)(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
- int (*write_256)(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
+ int (*read)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+ int (*write_256)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
};
extern const struct spi_programmer *spi_programmer;
int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
int default_spi_send_multicommand(struct spi_command *cmds);
-int default_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
-int default_spi_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int default_spi_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
void register_spi_programmer(const struct spi_programmer *programmer);
/* ichspi.c */
@@ -624,10 +624,10 @@ struct opaque_programmer {
int max_data_read;
int max_data_write;
/* Specific functions for this programmer */
- int (*probe) (struct flashchip *flash);
- int (*read) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
- int (*write) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
- int (*erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);
+ int (*probe) (struct flashctx *flash);
+ int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+ int (*write) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+ int (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
};
extern const struct opaque_programmer *opaque_programmer;
void register_opaque_programmer(const struct opaque_programmer *pgm);
diff --git a/serprog.c b/serprog.c
index 7925cee65..539e4887e 100644
--- a/serprog.c
+++ b/serprog.c
@@ -302,7 +302,7 @@ static int sp_stream_buffer_op(uint8_t cmd, uint32_t parmlen, uint8_t * parms)
static int serprog_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr,
unsigned char *readarr);
-static int serprog_spi_read(struct flashchip *flash, uint8_t *buf,
+static int serprog_spi_read(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len);
static struct spi_programmer spi_programmer_serprog = {
.type = SPI_CONTROLLER_SERPROG,
@@ -822,7 +822,7 @@ static int serprog_spi_send_command(unsigned int writecnt, unsigned int readcnt,
* the advantage that it is much faster for most chips, but breaks those with
* non-contiguous address space (like AT45DB161D). When spi_read_chunked is
* fixed this method can be removed. */
-static int serprog_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+static int serprog_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
unsigned int i, cur_len;
const unsigned int max_read = spi_programmer_serprog.max_data_read;
diff --git a/sharplhf00l04.c b/sharplhf00l04.c
index 4865fc277..d572e962d 100644
--- a/sharplhf00l04.c
+++ b/sharplhf00l04.c
@@ -26,7 +26,7 @@
* FIXME: This file is unused.
*/
-int erase_lhf00l04_block(struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen)
+int erase_lhf00l04_block(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen)
{
chipaddr bios = flash->virtual_memory + blockaddr;
chipaddr wrprotect = flash->virtual_registers + blockaddr + 2;
diff --git a/spi.c b/spi.c
index 60f77b092..2eeb1af3d 100644
--- a/spi.c
+++ b/spi.c
@@ -97,7 +97,7 @@ int default_spi_send_multicommand(struct spi_command *cmds)
return result;
}
-int default_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
unsigned int max_data = spi_programmer->max_data_read;
if (max_data == MAX_DATA_UNSPECIFIED) {
@@ -109,7 +109,7 @@ int default_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start,
return spi_read_chunked(flash, buf, start, len, max_data);
}
-int default_spi_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int default_spi_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
unsigned int max_data = spi_programmer->max_data_write;
if (max_data == MAX_DATA_UNSPECIFIED) {
@@ -121,7 +121,7 @@ int default_spi_write_256(struct flashchip *flash, uint8_t *buf, unsigned int st
return spi_write_chunked(flash, buf, start, len, max_data);
}
-int spi_chip_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
unsigned int addrbase = 0;
if (!spi_programmer->read) {
@@ -160,7 +160,7 @@ int spi_chip_read(struct flashchip *flash, uint8_t *buf, unsigned int start, uns
* .write_256 = spi_chip_write_1
*/
/* real chunksize is up to 256, logical chunksize is 256 */
-int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int spi_chip_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
if (!spi_programmer->write_256) {
msg_perr("%s called, but SPI page write is unsupported on this "
diff --git a/spi25.c b/spi25.c
index 60eb644a0..abcf6d071 100644
--- a/spi25.c
+++ b/spi25.c
@@ -113,7 +113,7 @@ int spi_write_disable(void)
return spi_send_command(sizeof(cmd), 0, cmd, NULL);
}
-static int probe_spi_rdid_generic(struct flashchip *flash, int bytes)
+static int probe_spi_rdid_generic(struct flashctx *flash, int bytes)
{
unsigned char readarr[4];
uint32_t id1;
@@ -167,12 +167,12 @@ static int probe_spi_rdid_generic(struct flashchip *flash, int bytes)
return 0;
}
-int probe_spi_rdid(struct flashchip *flash)
+int probe_spi_rdid(struct flashctx *flash)
{
return probe_spi_rdid_generic(flash, 3);
}
-int probe_spi_rdid4(struct flashchip *flash)
+int probe_spi_rdid4(struct flashctx *flash)
{
/* Some SPI controllers do not support commands with writecnt=1 and
* readcnt=4.
@@ -194,7 +194,7 @@ int probe_spi_rdid4(struct flashchip *flash)
return 0;
}
-int probe_spi_rems(struct flashchip *flash)
+int probe_spi_rems(struct flashctx *flash)
{
unsigned char readarr[JEDEC_REMS_INSIZE];
uint32_t id1, id2;
@@ -230,7 +230,7 @@ int probe_spi_rems(struct flashchip *flash)
return 0;
}
-int probe_spi_res1(struct flashchip *flash)
+int probe_spi_res1(struct flashctx *flash)
{
static const unsigned char allff[] = {0xff, 0xff, 0xff};
static const unsigned char all00[] = {0x00, 0x00, 0x00};
@@ -274,7 +274,7 @@ int probe_spi_res1(struct flashchip *flash)
return 1;
}
-int probe_spi_res2(struct flashchip *flash)
+int probe_spi_res2(struct flashctx *flash)
{
unsigned char readarr[2];
uint32_t id1, id2;
@@ -410,7 +410,7 @@ void spi_prettyprint_status_register_sst25vf040b(uint8_t status)
bpt[(status & 0x1c) >> 2]);
}
-int spi_prettyprint_status_register(struct flashchip *flash)
+int spi_prettyprint_status_register(struct flashctx *flash)
{
uint8_t status;
@@ -444,7 +444,7 @@ int spi_prettyprint_status_register(struct flashchip *flash)
return 0;
}
-int spi_chip_erase_60(struct flashchip *flash)
+int spi_chip_erase_60(struct flashctx *flash)
{
int result;
struct spi_command cmds[] = {
@@ -481,7 +481,7 @@ int spi_chip_erase_60(struct flashchip *flash)
return 0;
}
-int spi_chip_erase_c7(struct flashchip *flash)
+int spi_chip_erase_c7(struct flashctx *flash)
{
int result;
struct spi_command cmds[] = {
@@ -517,7 +517,7 @@ int spi_chip_erase_c7(struct flashchip *flash)
return 0;
}
-int spi_block_erase_52(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_52(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
{
int result;
struct spi_command cmds[] = {
@@ -563,7 +563,7 @@ int spi_block_erase_52(struct flashchip *flash, unsigned int addr, unsigned int
* 32k for SST
* 4-32k non-uniform for EON
*/
-int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
{
int result;
struct spi_command cmds[] = {
@@ -607,7 +607,7 @@ int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int
/* Block size is usually
* 4k for PMC
*/
-int spi_block_erase_d7(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_d7(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
{
int result;
struct spi_command cmds[] = {
@@ -649,7 +649,7 @@ int spi_block_erase_d7(struct flashchip *flash, unsigned int addr, unsigned int
}
/* Sector size is usually 4k, though Macronix eliteflash has 64k */
-int spi_block_erase_20(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_20(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
{
int result;
struct spi_command cmds[] = {
@@ -690,7 +690,7 @@ int spi_block_erase_20(struct flashchip *flash, unsigned int addr, unsigned int
return 0;
}
-int spi_block_erase_60(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_60(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
{
if ((addr != 0) || (blocklen != flash->total_size * 1024)) {
msg_cerr("%s called with incorrect arguments\n",
@@ -700,7 +700,7 @@ int spi_block_erase_60(struct flashchip *flash, unsigned int addr, unsigned int
return spi_chip_erase_60(flash);
}
-int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_c7(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
{
if ((addr != 0) || (blocklen != flash->total_size * 1024)) {
msg_cerr("%s called with incorrect arguments\n",
@@ -728,7 +728,7 @@ int spi_write_status_enable(void)
* This is according the SST25VF016 datasheet, who knows it is more
* generic that this...
*/
-static int spi_write_status_register_ewsr(struct flashchip *flash, int status)
+static int spi_write_status_register_ewsr(struct flashctx *flash, int status)
{
int result;
int i = 0;
@@ -776,7 +776,7 @@ static int spi_write_status_register_ewsr(struct flashchip *flash, int status)
return 0;
}
-static int spi_write_status_register_wren(struct flashchip *flash, int status)
+static int spi_write_status_register_wren(struct flashctx *flash, int status)
{
int result;
int i = 0;
@@ -824,7 +824,7 @@ static int spi_write_status_register_wren(struct flashchip *flash, int status)
return 0;
}
-int spi_write_status_register(struct flashchip *flash, int status)
+int spi_write_status_register(struct flashctx *flash, int status)
{
int ret = 1;
@@ -926,7 +926,7 @@ int spi_nbyte_program(unsigned int addr, uint8_t *bytes, unsigned int len)
* Write 0x00 to the status register. Check if any locks are still set (that
* part is chip specific). Repeat once.
*/
-int spi_disable_blockprotect(struct flashchip *flash)
+int spi_disable_blockprotect(struct flashctx *flash)
{
uint8_t status;
int result;
@@ -968,7 +968,7 @@ int spi_nbyte_read(unsigned int address, uint8_t *bytes, unsigned int len)
* FIXME: Use the chunk code from Michael Karcher instead.
* Each page is read separately in chunks with a maximum size of chunksize.
*/
-int spi_read_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
+int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
{
int rc = 0;
unsigned int i, j, starthere, lenhere, toread;
@@ -1007,12 +1007,12 @@ int spi_read_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start,
* FIXME: Use the chunk code from Michael Karcher instead.
* Each page is written separately in chunks with a maximum size of chunksize.
*/
-int spi_write_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
+int spi_write_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
{
int rc = 0;
unsigned int i, j, starthere, lenhere, towrite;
/* FIXME: page_size is the wrong variable. We need max_writechunk_size
- * in struct flashchip to do this properly. All chips using
+ * in struct flashctx to do this properly. All chips using
* spi_chip_write_256 have page_size set to max_writechunk_size, so
* we're OK for now.
*/
@@ -1055,7 +1055,7 @@ int spi_write_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start,
* (e.g. due to size constraints in IT87* for over 512 kB)
*/
/* real chunksize is 1, logical chunksize is 1 */
-int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int spi_chip_write_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
unsigned int i;
int result = 0;
@@ -1071,7 +1071,7 @@ int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, unsigned int start,
return 0;
}
-int spi_aai_write(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int spi_aai_write(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
uint32_t pos = start;
int result;
diff --git a/sst28sf040.c b/sst28sf040.c
index 2038d537d..ca401648d 100644
--- a/sst28sf040.c
+++ b/sst28sf040.c
@@ -30,7 +30,7 @@
#define RESET 0xFF
#define READ_ID 0x90
-int protect_28sf040(struct flashchip *flash)
+int protect_28sf040(struct flashctx *flash)
{
chipaddr bios = flash->virtual_memory;
@@ -45,7 +45,7 @@ int protect_28sf040(struct flashchip *flash)
return 0;
}
-int unprotect_28sf040(struct flashchip *flash)
+int unprotect_28sf040(struct flashctx *flash)
{
chipaddr bios = flash->virtual_memory;
@@ -60,7 +60,7 @@ int unprotect_28sf040(struct flashchip *flash)
return 0;
}
-int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size)
+int erase_sector_28sf040(struct flashctx *flash, unsigned int address, unsigned int sector_size)
{
chipaddr bios = flash->virtual_memory;
@@ -76,7 +76,7 @@ int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned
}
/* chunksize is 1 */
-int write_28sf040(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
+int write_28sf040(struct flashctx *flash, uint8_t *src, unsigned int start, unsigned int len)
{
int i;
chipaddr bios = flash->virtual_memory;
@@ -100,7 +100,7 @@ int write_28sf040(struct flashchip *flash, uint8_t *src, unsigned int start, uns
return 0;
}
-static int erase_28sf040(struct flashchip *flash)
+static int erase_28sf040(struct flashctx *flash)
{
chipaddr bios = flash->virtual_memory;
@@ -114,7 +114,7 @@ static int erase_28sf040(struct flashchip *flash)
return 0;
}
-int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int erase_chip_28sf040(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
{
if ((addr != 0) || (blocklen != flash->total_size * 1024)) {
msg_cerr("%s called with incorrect arguments\n",
diff --git a/sst49lfxxxc.c b/sst49lfxxxc.c
index c3ef823c4..bcfb0433e 100644
--- a/sst49lfxxxc.c
+++ b/sst49lfxxxc.c
@@ -23,7 +23,7 @@
#include "flash.h"
#include "chipdrivers.h"
-static int write_lockbits_block_49lfxxxc(struct flashchip *flash, unsigned long address, unsigned char bits)
+static int write_lockbits_block_49lfxxxc(struct flashctx *flash, unsigned long address, unsigned char bits)
{
unsigned long lock = flash->virtual_registers + address + 2;
msg_cdbg("lockbits at address=0x%08lx is 0x%01x\n", lock, chip_readb(lock));
@@ -32,7 +32,7 @@ static int write_lockbits_block_49lfxxxc(struct flashchip *flash, unsigned long
return 0;
}
-static int write_lockbits_49lfxxxc(struct flashchip *flash, unsigned char bits)
+static int write_lockbits_49lfxxxc(struct flashctx *flash, unsigned char bits)
{
chipaddr registers = flash->virtual_registers;
unsigned int i, left = flash->total_size * 1024;
@@ -54,12 +54,12 @@ static int write_lockbits_49lfxxxc(struct flashchip *flash, unsigned char bits)
return 0;
}
-int unlock_49lfxxxc(struct flashchip *flash)
+int unlock_49lfxxxc(struct flashctx *flash)
{
return write_lockbits_49lfxxxc(flash, 0);
}
-int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size)
+int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size)
{
uint8_t status;
chipaddr bios = flash->virtual_memory;
diff --git a/sst_fwhub.c b/sst_fwhub.c
index a11cccb9e..3656c8107 100644
--- a/sst_fwhub.c
+++ b/sst_fwhub.c
@@ -24,7 +24,7 @@
#include "flash.h"
-static int check_sst_fwhub_block_lock(struct flashchip *flash, int offset)
+static int check_sst_fwhub_block_lock(struct flashctx *flash, int offset)
{
chipaddr registers = flash->virtual_registers;
uint8_t blockstatus;
@@ -50,7 +50,7 @@ static int check_sst_fwhub_block_lock(struct flashchip *flash, int offset)
return blockstatus & 0x1;
}
-static int clear_sst_fwhub_block_lock(struct flashchip *flash, int offset)
+static int clear_sst_fwhub_block_lock(struct flashctx *flash, int offset)
{
chipaddr registers = flash->virtual_registers;
uint8_t blockstatus;
@@ -68,7 +68,7 @@ static int clear_sst_fwhub_block_lock(struct flashchip *flash, int offset)
return blockstatus;
}
-int printlock_sst_fwhub(struct flashchip *flash)
+int printlock_sst_fwhub(struct flashctx *flash)
{
int i;
@@ -78,7 +78,7 @@ int printlock_sst_fwhub(struct flashchip *flash)
return 0;
}
-int unlock_sst_fwhub(struct flashchip *flash)
+int unlock_sst_fwhub(struct flashctx *flash)
{
int i, ret=0;
diff --git a/stm50flw0x0x.c b/stm50flw0x0x.c
index f3fc4d8fe..65d520d9b 100644
--- a/stm50flw0x0x.c
+++ b/stm50flw0x0x.c
@@ -36,7 +36,7 @@
* The ST M50FLW080B and STM50FLW080B chips have to be unlocked,
* before you can erase them or write to them.
*/
-static int unlock_block_stm50flw0x0x(struct flashchip *flash, int offset)
+static int unlock_block_stm50flw0x0x(struct flashctx *flash, int offset)
{
chipaddr wrprotect = flash->virtual_registers + 2;
static const uint8_t unlock_sector = 0x00;
@@ -79,7 +79,7 @@ static int unlock_block_stm50flw0x0x(struct flashchip *flash, int offset)
return 0;
}
-int unlock_stm50flw0x0x(struct flashchip *flash)
+int unlock_stm50flw0x0x(struct flashctx *flash)
{
int i;
@@ -94,7 +94,7 @@ int unlock_stm50flw0x0x(struct flashchip *flash)
}
/* This function is unused. */
-int erase_sector_stm50flw0x0x(struct flashchip *flash, unsigned int sector, unsigned int sectorsize)
+int erase_sector_stm50flw0x0x(struct flashctx *flash, unsigned int sector, unsigned int sectorsize)
{
chipaddr bios = flash->virtual_memory + sector;
diff --git a/w29ee011.c b/w29ee011.c
index ee5aa44d5..e86c2f4bc 100644
--- a/w29ee011.c
+++ b/w29ee011.c
@@ -24,7 +24,7 @@
/* According to the Winbond W29EE011, W29EE012, W29C010M, W29C011A
* datasheets this is the only valid probe function for those chips.
*/
-int probe_w29ee011(struct flashchip *flash)
+int probe_w29ee011(struct flashctx *flash)
{
chipaddr bios = flash->virtual_memory;
uint8_t id1, id2;
diff --git a/w39.c b/w39.c
index a2c101427..6af50b870 100644
--- a/w39.c
+++ b/w39.c
@@ -21,7 +21,7 @@
#include "flash.h"
-static int printlock_w39_fwh_block(struct flashchip *flash, unsigned int offset)
+static int printlock_w39_fwh_block(struct flashctx *flash, unsigned int offset)
{
chipaddr wrprotect = flash->virtual_registers + offset + 2;
uint8_t locking;
@@ -59,7 +59,7 @@ static int printlock_w39_fwh_block(struct flashchip *flash, unsigned int offset)
return (locking & ((1 << 2) | (1 << 0))) ? -1 : 0;
}
-static int unlock_w39_fwh_block(struct flashchip *flash, unsigned int offset)
+static int unlock_w39_fwh_block(struct flashctx *flash, unsigned int offset)
{
chipaddr wrprotect = flash->virtual_registers + offset + 2;
uint8_t locking;
@@ -80,7 +80,7 @@ static int unlock_w39_fwh_block(struct flashchip *flash, unsigned int offset)
return 0;
}
-static uint8_t w39_idmode_readb(struct flashchip *flash, unsigned int offset)
+static uint8_t w39_idmode_readb(struct flashctx *flash, unsigned int offset)
{
chipaddr bios = flash->virtual_memory;
uint8_t val;
@@ -127,7 +127,7 @@ static int printlock_w39_bootblock_64k16k(uint8_t lock)
return 0;
}
-static int printlock_w39_common(struct flashchip *flash, unsigned int offset)
+static int printlock_w39_common(struct flashctx *flash, unsigned int offset)
{
uint8_t lock;
@@ -136,7 +136,7 @@ static int printlock_w39_common(struct flashchip *flash, unsigned int offset)
return printlock_w39_tblwp(lock);
}
-static int printlock_w39_fwh(struct flashchip *flash)
+static int printlock_w39_fwh(struct flashctx *flash)
{
unsigned int i, total_size = flash->total_size * 1024;
int ret = 0;
@@ -148,7 +148,7 @@ static int printlock_w39_fwh(struct flashchip *flash)
return ret;
}
-static int unlock_w39_fwh(struct flashchip *flash)
+static int unlock_w39_fwh(struct flashctx *flash)
{
unsigned int i, total_size = flash->total_size * 1024;
@@ -160,7 +160,7 @@ static int unlock_w39_fwh(struct flashchip *flash)
return 0;
}
-int printlock_w39l040(struct flashchip * flash)
+int printlock_w39l040(struct flashctx * flash)
{
uint8_t lock;
int ret;
@@ -176,7 +176,7 @@ int printlock_w39l040(struct flashchip * flash)
return ret;
}
-int printlock_w39v040a(struct flashchip *flash)
+int printlock_w39v040a(struct flashctx *flash)
{
uint8_t lock;
int ret = 0;
@@ -194,18 +194,18 @@ int printlock_w39v040a(struct flashchip *flash)
return ret;
}
-int printlock_w39v040b(struct flashchip *flash)
+int printlock_w39v040b(struct flashctx *flash)
{
return printlock_w39_common(flash, 0x7fff2);
}
-int printlock_w39v040c(struct flashchip *flash)
+int printlock_w39v040c(struct flashctx *flash)
{
/* Typo in the datasheet? The other chips use 0x7fff2. */
return printlock_w39_common(flash, 0xfff2);
}
-int printlock_w39v040fa(struct flashchip *flash)
+int printlock_w39v040fa(struct flashctx *flash)
{
int ret = 0;
@@ -215,7 +215,7 @@ int printlock_w39v040fa(struct flashchip *flash)
return ret;
}
-int printlock_w39v040fb(struct flashchip *flash)
+int printlock_w39v040fb(struct flashctx *flash)
{
int ret = 0;
@@ -225,7 +225,7 @@ int printlock_w39v040fb(struct flashchip *flash)
return ret;
}
-int printlock_w39v040fc(struct flashchip *flash)
+int printlock_w39v040fc(struct flashctx *flash)
{
int ret = 0;
@@ -236,12 +236,12 @@ int printlock_w39v040fc(struct flashchip *flash)
return ret;
}
-int printlock_w39v080a(struct flashchip *flash)
+int printlock_w39v080a(struct flashctx *flash)
{
return printlock_w39_common(flash, 0xffff2);
}
-int printlock_w39v080fa(struct flashchip *flash)
+int printlock_w39v080fa(struct flashctx *flash)
{
int ret = 0;
@@ -251,7 +251,7 @@ int printlock_w39v080fa(struct flashchip *flash)
return ret;
}
-int printlock_w39v080fa_dual(struct flashchip *flash)
+int printlock_w39v080fa_dual(struct flashctx *flash)
{
msg_cinfo("Block locking for W39V080FA in dual mode is "
"undocumented.\n");
@@ -259,7 +259,7 @@ int printlock_w39v080fa_dual(struct flashchip *flash)
return -1;
}
-int unlock_w39v040fb(struct flashchip *flash)
+int unlock_w39v040fb(struct flashctx *flash)
{
if (unlock_w39_fwh(flash))
return -1;
@@ -269,7 +269,7 @@ int unlock_w39v040fb(struct flashchip *flash)
return 0;
}
-int unlock_w39v080fa(struct flashchip *flash)
+int unlock_w39v080fa(struct flashctx *flash)
{
if (unlock_w39_fwh(flash))
return -1;
diff --git a/wbsio_spi.c b/wbsio_spi.c
index dbc772960..50ea1aa1f 100644
--- a/wbsio_spi.c
+++ b/wbsio_spi.c
@@ -62,7 +62,7 @@ done:
static int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
-static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
+static int wbsio_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
static const struct spi_programmer spi_programmer_wbsio = {
.type = SPI_CONTROLLER_WBSIO,
@@ -194,7 +194,7 @@ static int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
return 0;
}
-static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+static int wbsio_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
return read_memmapped(flash, buf, start, len);
}