mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
Unsignify lengths and addresses in chip functions and structs
Push those changes forward where needed to prevent new sign conversion warnings where possible. Corresponding to flashrom svn r1470. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
parent
8ca4255d79
commit
c69c9c84e0
@ -141,7 +141,7 @@ int erase_block_82802ab(struct flashchip *flash, unsigned int page,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* chunksize is 1 */
|
/* chunksize is 1 */
|
||||||
int write_82802ab(struct flashchip *flash, uint8_t *src, int start, int len)
|
int write_82802ab(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
chipaddr dst = flash->virtual_memory + start;
|
chipaddr dst = flash->virtual_memory + start;
|
||||||
|
@ -295,7 +295,8 @@ static int buspirate_spi_send_command(unsigned int writecnt, unsigned int readcn
|
|||||||
const unsigned char *writearr, unsigned char *readarr)
|
const unsigned char *writearr, unsigned char *readarr)
|
||||||
{
|
{
|
||||||
static unsigned char *buf = NULL;
|
static unsigned char *buf = NULL;
|
||||||
int i = 0, ret = 0;
|
unsigned int i = 0;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (writecnt > 16 || readcnt > 16 || (readcnt + writecnt) > 16)
|
if (writecnt > 16 || readcnt > 16 || (readcnt + writecnt) > 16)
|
||||||
return SPI_INVALID_LENGTH;
|
return SPI_INVALID_LENGTH;
|
||||||
|
@ -41,9 +41,9 @@ int spi_block_erase_d7(struct flashchip *flash, unsigned int addr, unsigned int
|
|||||||
int spi_block_erase_d8(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_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_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
|
||||||
int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, int start, int len);
|
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, int start, 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, int start, int len);
|
int spi_chip_read(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len);
|
||||||
uint8_t spi_read_status_register(void);
|
uint8_t spi_read_status_register(void);
|
||||||
int spi_write_status_register(struct flashchip *flash, int status);
|
int spi_write_status_register(struct flashchip *flash, int status);
|
||||||
void spi_prettyprint_status_register_bit(uint8_t status, int bit);
|
void spi_prettyprint_status_register_bit(uint8_t status, int bit);
|
||||||
@ -51,17 +51,17 @@ void spi_prettyprint_status_register_bp3210(uint8_t status, int bp);
|
|||||||
void spi_prettyprint_status_register_welwip(uint8_t status);
|
void spi_prettyprint_status_register_welwip(uint8_t status);
|
||||||
int spi_prettyprint_status_register(struct flashchip *flash);
|
int spi_prettyprint_status_register(struct flashchip *flash);
|
||||||
int spi_disable_blockprotect(struct flashchip *flash);
|
int spi_disable_blockprotect(struct flashchip *flash);
|
||||||
int spi_byte_program(int addr, uint8_t databyte);
|
int spi_byte_program(unsigned int addr, uint8_t databyte);
|
||||||
int spi_nbyte_program(int addr, uint8_t *bytes, int len);
|
int spi_nbyte_program(unsigned int addr, uint8_t *bytes, unsigned int len);
|
||||||
int spi_nbyte_read(int addr, uint8_t *bytes, 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, int start, int len, int chunksize);
|
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, int start, int len, 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, int start, int len);
|
int spi_aai_write(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
|
|
||||||
/* opaque.c */
|
/* opaque.c */
|
||||||
int probe_opaque(struct flashchip *flash);
|
int probe_opaque(struct flashchip *flash);
|
||||||
int read_opaque(struct flashchip *flash, uint8_t *buf, int start, int len);
|
int read_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
int write_opaque(struct flashchip *flash, uint8_t *buf, int start, 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 erase_opaque(struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);
|
||||||
|
|
||||||
/* a25.c */
|
/* a25.c */
|
||||||
@ -87,7 +87,7 @@ int spi_disable_blockprotect_at25fs040(struct flashchip *flash);
|
|||||||
uint8_t wait_82802ab(struct flashchip *flash);
|
uint8_t wait_82802ab(struct flashchip *flash);
|
||||||
int probe_82802ab(struct flashchip *flash);
|
int probe_82802ab(struct flashchip *flash);
|
||||||
int erase_block_82802ab(struct flashchip *flash, unsigned int page, unsigned int pagesize);
|
int erase_block_82802ab(struct flashchip *flash, unsigned int page, unsigned int pagesize);
|
||||||
int write_82802ab(struct flashchip *flash, uint8_t *buf, int start, int len);
|
int write_82802ab(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
void print_status_82802ab(uint8_t status);
|
void print_status_82802ab(uint8_t status);
|
||||||
int unlock_82802ab(struct flashchip *flash);
|
int unlock_82802ab(struct flashchip *flash);
|
||||||
int unlock_28f004s5(struct flashchip *flash);
|
int unlock_28f004s5(struct flashchip *flash);
|
||||||
@ -100,8 +100,8 @@ void data_polling_jedec(chipaddr dst, uint8_t data);
|
|||||||
int write_byte_program_jedec(chipaddr bios, uint8_t *src,
|
int write_byte_program_jedec(chipaddr bios, uint8_t *src,
|
||||||
chipaddr dst);
|
chipaddr dst);
|
||||||
int probe_jedec(struct flashchip *flash);
|
int probe_jedec(struct flashchip *flash);
|
||||||
int write_jedec(struct flashchip *flash, uint8_t *buf, int start, int len);
|
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, int start, 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_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_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 erase_chip_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
|
||||||
@ -110,7 +110,7 @@ int erase_chip_block_jedec(struct flashchip *flash, unsigned int page, unsigned
|
|||||||
int probe_m29f400bt(struct flashchip *flash);
|
int probe_m29f400bt(struct flashchip *flash);
|
||||||
int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
|
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 block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
|
||||||
int write_m29f400bt(struct flashchip *flash, uint8_t *buf, int start, int len);
|
int write_m29f400bt(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
void protect_m29f400bt(chipaddr bios);
|
void protect_m29f400bt(chipaddr bios);
|
||||||
|
|
||||||
/* pm49fl00x.c */
|
/* pm49fl00x.c */
|
||||||
@ -120,7 +120,7 @@ int lock_49fl00x(struct flashchip *flash);
|
|||||||
/* sst28sf040.c */
|
/* sst28sf040.c */
|
||||||
int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
|
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 erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size);
|
||||||
int write_28sf040(struct flashchip *flash, uint8_t *buf, int start, int len);
|
int write_28sf040(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
int unprotect_28sf040(struct flashchip *flash);
|
int unprotect_28sf040(struct flashchip *flash);
|
||||||
int protect_28sf040(struct flashchip *flash);
|
int protect_28sf040(struct flashchip *flash);
|
||||||
|
|
||||||
|
20
dediprog.c
20
dediprog.c
@ -206,13 +206,13 @@ static int dediprog_set_spi_speed(uint16_t speed)
|
|||||||
* @return 0 on success, 1 on failure
|
* @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 flashchip *flash, uint8_t *buf,
|
||||||
int start, int len)
|
unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
unsigned int i;
|
||||||
/* chunksize must be 512, other sizes will NOT work at all. */
|
/* chunksize must be 512, other sizes will NOT work at all. */
|
||||||
const int chunksize = 0x200;
|
const unsigned int chunksize = 0x200;
|
||||||
const int count = len / chunksize;
|
const unsigned int count = len / chunksize;
|
||||||
const char count_and_chunk[] = {count & 0xff,
|
const char count_and_chunk[] = {count & 0xff,
|
||||||
(count >> 8) & 0xff,
|
(count >> 8) & 0xff,
|
||||||
chunksize & 0xff,
|
chunksize & 0xff,
|
||||||
@ -253,14 +253,14 @@ static int dediprog_spi_bulk_read(struct flashchip *flash, uint8_t *buf,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start,
|
static int dediprog_spi_read(struct flashchip *flash, uint8_t *buf,
|
||||||
int len)
|
unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
/* chunksize must be 512, other sizes will NOT work at all. */
|
/* chunksize must be 512, other sizes will NOT work at all. */
|
||||||
const int chunksize = 0x200;
|
const unsigned int chunksize = 0x200;
|
||||||
int residue = start % chunksize ? chunksize - start % chunksize : 0;
|
unsigned int residue = start % chunksize ? chunksize - start % chunksize : 0;
|
||||||
int bulklen;
|
unsigned int bulklen;
|
||||||
|
|
||||||
dediprog_set_leds(PASS_OFF|BUSY_ON|ERROR_OFF);
|
dediprog_set_leds(PASS_OFF|BUSY_ON|ERROR_OFF);
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ static int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int dediprog_spi_write_256(struct flashchip *flash, uint8_t *buf,
|
static int dediprog_spi_write_256(struct flashchip *flash, uint8_t *buf,
|
||||||
int start, int len)
|
unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -46,24 +46,24 @@ enum emu_chip {
|
|||||||
};
|
};
|
||||||
static enum emu_chip emu_chip = EMULATE_NONE;
|
static enum emu_chip emu_chip = EMULATE_NONE;
|
||||||
static char *emu_persistent_image = NULL;
|
static char *emu_persistent_image = NULL;
|
||||||
static int emu_chip_size = 0;
|
static unsigned int emu_chip_size = 0;
|
||||||
#if EMULATE_SPI_CHIP
|
#if EMULATE_SPI_CHIP
|
||||||
static int emu_max_byteprogram_size = 0;
|
static unsigned int emu_max_byteprogram_size = 0;
|
||||||
static int emu_max_aai_size = 0;
|
static unsigned int emu_max_aai_size = 0;
|
||||||
static int emu_jedec_se_size = 0;
|
static unsigned int emu_jedec_se_size = 0;
|
||||||
static int emu_jedec_be_52_size = 0;
|
static unsigned int emu_jedec_be_52_size = 0;
|
||||||
static int emu_jedec_be_d8_size = 0;
|
static unsigned int emu_jedec_be_d8_size = 0;
|
||||||
static int emu_jedec_ce_60_size = 0;
|
static unsigned int emu_jedec_ce_60_size = 0;
|
||||||
static int emu_jedec_ce_c7_size = 0;
|
static unsigned int emu_jedec_ce_c7_size = 0;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int spi_write_256_chunksize = 256;
|
static unsigned int spi_write_256_chunksize = 256;
|
||||||
|
|
||||||
static int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
static int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
||||||
const unsigned char *writearr, unsigned char *readarr);
|
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 flashchip *flash, uint8_t *buf,
|
||||||
int start, int len);
|
unsigned int start, unsigned int len);
|
||||||
|
|
||||||
static const struct spi_programmer spi_programmer_dummyflasher = {
|
static const struct spi_programmer spi_programmer_dummyflasher = {
|
||||||
.type = SPI_CONTROLLER_DUMMY,
|
.type = SPI_CONTROLLER_DUMMY,
|
||||||
@ -320,8 +320,8 @@ void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len)
|
|||||||
static int emulate_spi_chip_response(unsigned int writecnt, unsigned int readcnt,
|
static int emulate_spi_chip_response(unsigned int writecnt, unsigned int readcnt,
|
||||||
const unsigned char *writearr, unsigned char *readarr)
|
const unsigned char *writearr, unsigned char *readarr)
|
||||||
{
|
{
|
||||||
int offs;
|
unsigned int offs;
|
||||||
static int aai_offs;
|
static int unsigned aai_offs;
|
||||||
static int aai_active = 0;
|
static int aai_active = 0;
|
||||||
|
|
||||||
if (writecnt == 0) {
|
if (writecnt == 0) {
|
||||||
@ -549,7 +549,7 @@ static int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf,
|
static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf,
|
||||||
int start, int len)
|
unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
return spi_write_chunked(flash, buf, start, len,
|
return spi_write_chunked(flash, buf, start, len,
|
||||||
spi_write_256_chunksize);
|
spi_write_256_chunksize);
|
||||||
|
20
flash.h
20
flash.h
@ -108,9 +108,9 @@ struct flashchip {
|
|||||||
uint32_t model_id;
|
uint32_t model_id;
|
||||||
|
|
||||||
/* Total chip size in kilobytes */
|
/* Total chip size in kilobytes */
|
||||||
int total_size;
|
unsigned int total_size;
|
||||||
/* Chip page size in bytes */
|
/* Chip page size in bytes */
|
||||||
int page_size;
|
unsigned int page_size;
|
||||||
int feature_bits;
|
int feature_bits;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -121,8 +121,10 @@ struct flashchip {
|
|||||||
|
|
||||||
int (*probe) (struct flashchip *flash);
|
int (*probe) (struct flashchip *flash);
|
||||||
|
|
||||||
/* Delay after "enter/exit ID mode" commands in microseconds. */
|
/* Delay after "enter/exit ID mode" commands in microseconds.
|
||||||
int probe_timing;
|
* NB: negative values have special meanings, see TIMING_* below.
|
||||||
|
*/
|
||||||
|
signed int probe_timing;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Erase blocks and associated erase function. Any chip erase function
|
* Erase blocks and associated erase function. Any chip erase function
|
||||||
@ -143,8 +145,8 @@ struct flashchip {
|
|||||||
|
|
||||||
int (*printlock) (struct flashchip *flash);
|
int (*printlock) (struct flashchip *flash);
|
||||||
int (*unlock) (struct flashchip *flash);
|
int (*unlock) (struct flashchip *flash);
|
||||||
int (*write) (struct flashchip *flash, uint8_t *buf, int start, int len);
|
int (*write) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len);
|
int (*read) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
struct {
|
struct {
|
||||||
uint16_t min;
|
uint16_t min;
|
||||||
uint16_t max;
|
uint16_t max;
|
||||||
@ -202,7 +204,7 @@ extern int verbose;
|
|||||||
extern const char flashrom_version[];
|
extern const char flashrom_version[];
|
||||||
extern char *chip_to_probe;
|
extern char *chip_to_probe;
|
||||||
void map_flash_registers(struct flashchip *flash);
|
void map_flash_registers(struct flashchip *flash);
|
||||||
int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len);
|
int read_memmapped(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
int erase_flash(struct flashchip *flash);
|
int erase_flash(struct flashchip *flash);
|
||||||
int probe_flash(int startchip, struct flashchip *fill_flash, int force);
|
int probe_flash(int startchip, struct flashchip *fill_flash, int force);
|
||||||
int read_flash_to_file(struct flashchip *flash, const char *filename);
|
int read_flash_to_file(struct flashchip *flash, const char *filename);
|
||||||
@ -210,8 +212,8 @@ int min(int a, int b);
|
|||||||
int max(int a, int b);
|
int max(int a, int b);
|
||||||
void tolower_string(char *str);
|
void tolower_string(char *str);
|
||||||
char *extract_param(char **haystack, const char *needle, const char *delim);
|
char *extract_param(char **haystack, const char *needle, const char *delim);
|
||||||
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, const char *message);
|
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len, const char *message);
|
||||||
int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran);
|
int need_erase(uint8_t *have, uint8_t *want, unsigned int len, enum write_granularity gran);
|
||||||
char *strcat_realloc(char *dest, const char *src);
|
char *strcat_realloc(char *dest, const char *src);
|
||||||
void print_version(void);
|
void print_version(void);
|
||||||
void print_banner(void);
|
void print_banner(void);
|
||||||
|
27
flashrom.c
27
flashrom.c
@ -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);
|
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, int start, int len)
|
int read_memmapped(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len)
|
||||||
{
|
{
|
||||||
chip_readn(buf, flash->virtual_memory + start, len);
|
chip_readn(buf, flash->virtual_memory + start, len);
|
||||||
|
|
||||||
@ -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 */
|
/* start is an offset to the base address of the flash chip */
|
||||||
int check_erased_range(struct flashchip *flash, int start, int len)
|
int check_erased_range(struct flashchip *flash, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
uint8_t *cmpbuf = malloc(len);
|
uint8_t *cmpbuf = malloc(len);
|
||||||
@ -558,10 +558,10 @@ int check_erased_range(struct flashchip *flash, int start, int len)
|
|||||||
* @message string to print in the "FAILED" message
|
* @message string to print in the "FAILED" message
|
||||||
* @return 0 for success, -1 for failure
|
* @return 0 for success, -1 for failure
|
||||||
*/
|
*/
|
||||||
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len,
|
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len,
|
||||||
const char *message)
|
const char *message)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
uint8_t *readbuf = malloc(len);
|
uint8_t *readbuf = malloc(len);
|
||||||
int ret = 0, failcount = 0;
|
int ret = 0, failcount = 0;
|
||||||
|
|
||||||
@ -639,10 +639,10 @@ out_free:
|
|||||||
* @gran write granularity (enum, not count)
|
* @gran write granularity (enum, not count)
|
||||||
* @return 0 if no erase is needed, 1 otherwise
|
* @return 0 if no erase is needed, 1 otherwise
|
||||||
*/
|
*/
|
||||||
int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran)
|
int need_erase(uint8_t *have, uint8_t *want, unsigned int len, enum write_granularity gran)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
int i, j, limit;
|
unsigned int i, j, limit;
|
||||||
|
|
||||||
switch (gran) {
|
switch (gran) {
|
||||||
case write_gran_1bit:
|
case write_gran_1bit:
|
||||||
@ -705,11 +705,13 @@ int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gra
|
|||||||
* in relation to the max write length of the programmer and the max write
|
* in relation to the max write length of the programmer and the max write
|
||||||
* length of the chip.
|
* length of the chip.
|
||||||
*/
|
*/
|
||||||
static int get_next_write(uint8_t *have, uint8_t *want, int len,
|
static unsigned int get_next_write(uint8_t *have, uint8_t *want, unsigned int len,
|
||||||
int *first_start, enum write_granularity gran)
|
unsigned int *first_start,
|
||||||
|
enum write_granularity gran)
|
||||||
{
|
{
|
||||||
int need_write = 0, rel_start = 0, first_len = 0;
|
int need_write = 0;
|
||||||
int i, limit, stride;
|
unsigned int rel_start = 0, first_len = 0;
|
||||||
|
unsigned int i, limit, stride;
|
||||||
|
|
||||||
switch (gran) {
|
switch (gran) {
|
||||||
case write_gran_1bit:
|
case write_gran_1bit:
|
||||||
@ -1030,7 +1032,7 @@ notfound:
|
|||||||
int verify_flash(struct flashchip *flash, uint8_t *buf)
|
int verify_flash(struct flashchip *flash, uint8_t *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int total_size = flash->total_size * 1024;
|
unsigned int total_size = flash->total_size * 1024;
|
||||||
|
|
||||||
msg_cinfo("Verifying flash... ");
|
msg_cinfo("Verifying flash... ");
|
||||||
|
|
||||||
@ -1208,7 +1210,8 @@ static int erase_and_write_block_helper(struct flashchip *flash,
|
|||||||
unsigned int addr,
|
unsigned int addr,
|
||||||
unsigned int len))
|
unsigned int len))
|
||||||
{
|
{
|
||||||
int starthere = 0, lenhere = 0, ret = 0, skip = 1, writecount = 0;
|
unsigned int starthere = 0, lenhere = 0;
|
||||||
|
int ret = 0, skip = 1, writecount = 0;
|
||||||
enum write_granularity gran = write_gran_256bytes; /* FIXME */
|
enum write_granularity gran = write_gran_256bytes; /* FIXME */
|
||||||
|
|
||||||
/* curcontents and newcontents are opaque to walk_eraseregions, and
|
/* curcontents and newcontents are opaque to walk_eraseregions, and
|
||||||
|
6
ichspi.c
6
ichspi.c
@ -1278,7 +1278,8 @@ int ich_hwseq_block_erase(struct flashchip *flash,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ich_hwseq_read(struct flashchip *flash, uint8_t *buf, int addr, int len)
|
int ich_hwseq_read(struct flashchip *flash, uint8_t *buf, unsigned int addr,
|
||||||
|
unsigned int len)
|
||||||
{
|
{
|
||||||
uint16_t hsfc;
|
uint16_t hsfc;
|
||||||
uint16_t timeout = 100 * 60;
|
uint16_t timeout = 100 * 60;
|
||||||
@ -1315,7 +1316,8 @@ int ich_hwseq_read(struct flashchip *flash, uint8_t *buf, int addr, int len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ich_hwseq_write(struct flashchip *flash, uint8_t *buf, int addr, int len)
|
int ich_hwseq_write(struct flashchip *flash, uint8_t *buf, unsigned int addr,
|
||||||
|
unsigned int len)
|
||||||
{
|
{
|
||||||
uint16_t hsfc;
|
uint16_t hsfc;
|
||||||
uint16_t timeout = 100 * 60;
|
uint16_t timeout = 100 * 60;
|
||||||
|
15
it87spi.c
15
it87spi.c
@ -106,9 +106,9 @@ void probe_superio_ite(void)
|
|||||||
static int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
static int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
||||||
const unsigned char *writearr, unsigned char *readarr);
|
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 flashchip *flash, uint8_t *buf,
|
||||||
int start, int len);
|
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 flashchip *flash, uint8_t *buf,
|
||||||
int start, int len);
|
unsigned int start, unsigned int len);
|
||||||
|
|
||||||
static const struct spi_programmer spi_programmer_it87xx = {
|
static const struct spi_programmer spi_programmer_it87xx = {
|
||||||
.type = SPI_CONTROLLER_IT87XX,
|
.type = SPI_CONTROLLER_IT87XX,
|
||||||
@ -313,9 +313,10 @@ static int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
|||||||
|
|
||||||
/* Page size is usually 256 bytes */
|
/* 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 flashchip *flash, uint8_t *buf,
|
||||||
int start)
|
unsigned int start)
|
||||||
{
|
{
|
||||||
int i, result;
|
unsigned int i;
|
||||||
|
int result;
|
||||||
chipaddr bios = flash->virtual_memory;
|
chipaddr bios = flash->virtual_memory;
|
||||||
|
|
||||||
result = spi_write_enable();
|
result = spi_write_enable();
|
||||||
@ -340,7 +341,7 @@ static int it8716f_spi_page_program(struct flashchip *flash, uint8_t *buf,
|
|||||||
* Need to read this big flash using firmware cycles 3 byte at a time.
|
* 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 flashchip *flash, uint8_t *buf,
|
||||||
int start, int len)
|
unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
fast_spi = 0;
|
fast_spi = 0;
|
||||||
|
|
||||||
@ -358,7 +359,7 @@ static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
|
static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
|
||||||
int start, int len)
|
unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* IT8716F only allows maximum of 512 kb SPI chip size for memory
|
* IT8716F only allows maximum of 512 kb SPI chip size for memory
|
||||||
@ -374,7 +375,7 @@ static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
|
|||||||
(flash->page_size > 256)) {
|
(flash->page_size > 256)) {
|
||||||
spi_chip_write_1(flash, buf, start, len);
|
spi_chip_write_1(flash, buf, start, len);
|
||||||
} else {
|
} else {
|
||||||
int lenhere;
|
unsigned int lenhere;
|
||||||
|
|
||||||
if (start % flash->page_size) {
|
if (start % flash->page_size) {
|
||||||
/* start to the end of the page or to start + len,
|
/* start to the end of the page or to start + len,
|
||||||
|
26
jedec.c
26
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);
|
msg_cdbg("%s: excessive loops, i=0x%x\n", __func__, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getaddrmask(struct flashchip *flash)
|
static unsigned int getaddrmask(struct flashchip *flash)
|
||||||
{
|
{
|
||||||
switch (flash->feature_bits & FEATURE_ADDR_MASK) {
|
switch (flash->feature_bits & FEATURE_ADDR_MASK) {
|
||||||
case FEATURE_ADDR_FULL:
|
case FEATURE_ADDR_FULL:
|
||||||
@ -355,12 +355,12 @@ retry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* chunksize is 1 */
|
/* chunksize is 1 */
|
||||||
int write_jedec_1(struct flashchip *flash, uint8_t *src, int start, int len)
|
int write_jedec_1(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int i, failed = 0;
|
int i, failed = 0;
|
||||||
chipaddr dst = flash->virtual_memory + start;
|
chipaddr dst = flash->virtual_memory + start;
|
||||||
chipaddr olddst;
|
chipaddr olddst;
|
||||||
int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
mask = getaddrmask(flash);
|
mask = getaddrmask(flash);
|
||||||
|
|
||||||
@ -376,14 +376,14 @@ int write_jedec_1(struct flashchip *flash, uint8_t *src, int start, int len)
|
|||||||
return failed;
|
return failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_page_write_jedec_common(struct flashchip *flash, uint8_t *src, int start, int page_size)
|
int write_page_write_jedec_common(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int page_size)
|
||||||
{
|
{
|
||||||
int i, tried = 0, failed;
|
int i, tried = 0, failed;
|
||||||
uint8_t *s = src;
|
uint8_t *s = src;
|
||||||
chipaddr bios = flash->virtual_memory;
|
chipaddr bios = flash->virtual_memory;
|
||||||
chipaddr dst = bios + start;
|
chipaddr dst = bios + start;
|
||||||
chipaddr d = dst;
|
chipaddr d = dst;
|
||||||
int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
mask = getaddrmask(flash);
|
mask = getaddrmask(flash);
|
||||||
|
|
||||||
@ -424,15 +424,15 @@ retry:
|
|||||||
* This function is a slightly modified copy of spi_write_chunked.
|
* This function is a slightly modified copy of spi_write_chunked.
|
||||||
* Each page is written separately in chunks with a maximum size of chunksize.
|
* Each page is written separately in chunks with a maximum size of chunksize.
|
||||||
*/
|
*/
|
||||||
int write_jedec(struct flashchip *flash, uint8_t *buf, int start, int len)
|
int write_jedec(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len)
|
||||||
{
|
{
|
||||||
int i, starthere, lenhere;
|
unsigned int i, starthere, lenhere;
|
||||||
/* FIXME: page_size is the wrong variable. We need max_writechunk_size
|
/* FIXME: page_size is the wrong variable. We need max_writechunk_size
|
||||||
* in struct flashchip to do this properly. All chips using
|
* in struct flashchip to do this properly. All chips using
|
||||||
* write_jedec have page_size set to max_writechunk_size, so
|
* write_jedec have page_size set to max_writechunk_size, so
|
||||||
* we're OK for now.
|
* we're OK for now.
|
||||||
*/
|
*/
|
||||||
int page_size = flash->page_size;
|
unsigned int page_size = flash->page_size;
|
||||||
|
|
||||||
/* Warning: This loop has a very unusual condition and body.
|
/* Warning: This loop has a very unusual condition and body.
|
||||||
* The loop needs to go through each page with at least one affected
|
* The loop needs to go through each page with at least one affected
|
||||||
@ -461,7 +461,7 @@ int write_jedec(struct flashchip *flash, uint8_t *buf, int start, int len)
|
|||||||
int erase_chip_block_jedec(struct flashchip *flash, unsigned int addr,
|
int erase_chip_block_jedec(struct flashchip *flash, unsigned int addr,
|
||||||
unsigned int blocksize)
|
unsigned int blocksize)
|
||||||
{
|
{
|
||||||
int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
mask = getaddrmask(flash);
|
mask = getaddrmask(flash);
|
||||||
if ((addr != 0) || (blocksize != flash->total_size * 1024)) {
|
if ((addr != 0) || (blocksize != flash->total_size * 1024)) {
|
||||||
@ -474,7 +474,7 @@ int erase_chip_block_jedec(struct flashchip *flash, unsigned int addr,
|
|||||||
|
|
||||||
int probe_jedec(struct flashchip *flash)
|
int probe_jedec(struct flashchip *flash)
|
||||||
{
|
{
|
||||||
int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
mask = getaddrmask(flash);
|
mask = getaddrmask(flash);
|
||||||
return probe_jedec_common(flash, mask);
|
return probe_jedec_common(flash, mask);
|
||||||
@ -482,7 +482,7 @@ int probe_jedec(struct flashchip *flash)
|
|||||||
|
|
||||||
int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int size)
|
int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int size)
|
||||||
{
|
{
|
||||||
int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
mask = getaddrmask(flash);
|
mask = getaddrmask(flash);
|
||||||
return erase_sector_jedec_common(flash, page, size, mask);
|
return erase_sector_jedec_common(flash, page, size, mask);
|
||||||
@ -490,7 +490,7 @@ int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int
|
|||||||
|
|
||||||
int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int size)
|
int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int size)
|
||||||
{
|
{
|
||||||
int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
mask = getaddrmask(flash);
|
mask = getaddrmask(flash);
|
||||||
return erase_block_jedec_common(flash, page, size, mask);
|
return erase_block_jedec_common(flash, page, size, mask);
|
||||||
@ -498,7 +498,7 @@ int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int s
|
|||||||
|
|
||||||
int erase_chip_jedec(struct flashchip *flash)
|
int erase_chip_jedec(struct flashchip *flash)
|
||||||
{
|
{
|
||||||
int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
mask = getaddrmask(flash);
|
mask = getaddrmask(flash);
|
||||||
return erase_chip_jedec_common(flash, mask);
|
return erase_chip_jedec_common(flash, mask);
|
||||||
|
16
linux_spi.c
16
linux_spi.c
@ -36,10 +36,10 @@ static int fd = -1;
|
|||||||
static int linux_spi_shutdown(void *data);
|
static int linux_spi_shutdown(void *data);
|
||||||
static int linux_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
static int linux_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
||||||
const unsigned char *txbuf, unsigned char *rxbuf);
|
const unsigned char *txbuf, unsigned char *rxbuf);
|
||||||
static int linux_spi_read(struct flashchip *flash, uint8_t *buf, int start,
|
static int linux_spi_read(struct flashchip *flash, uint8_t *buf,
|
||||||
int len);
|
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 flashchip *flash, uint8_t *buf,
|
||||||
int start, int len);
|
unsigned int start, unsigned int len);
|
||||||
|
|
||||||
static const struct spi_programmer spi_programmer_linux = {
|
static const struct spi_programmer spi_programmer_linux = {
|
||||||
.type = SPI_CONTROLLER_LINUX,
|
.type = SPI_CONTROLLER_LINUX,
|
||||||
@ -131,14 +131,14 @@ static int linux_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int linux_spi_read(struct flashchip *flash, uint8_t *buf, int start,
|
static int linux_spi_read(struct flashchip *flash, uint8_t *buf,
|
||||||
int len)
|
unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
return spi_read_chunked(flash, buf, start, len, getpagesize());
|
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 flashchip *flash, uint8_t *buf,
|
||||||
int start, int len)
|
unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
return spi_write_chunked(flash, buf, start, len, getpagesize() - 4);
|
return spi_write_chunked(flash, buf, start, len, ((unsigned)getpagesize()) - 4);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
functions. */
|
functions. */
|
||||||
|
|
||||||
/* chunksize is 1 */
|
/* chunksize is 1 */
|
||||||
int write_m29f400bt(struct flashchip *flash, uint8_t *src, int start, int len)
|
int write_m29f400bt(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
chipaddr bios = flash->virtual_memory;
|
chipaddr bios = flash->virtual_memory;
|
||||||
|
4
opaque.c
4
opaque.c
@ -53,7 +53,7 @@ int probe_opaque(struct flashchip *flash)
|
|||||||
return opaque_programmer->probe(flash);
|
return opaque_programmer->probe(flash);
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_opaque(struct flashchip *flash, uint8_t *buf, int start, int len)
|
int read_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
if (!opaque_programmer->read) {
|
if (!opaque_programmer->read) {
|
||||||
msg_perr("%s called before register_opaque_programmer. "
|
msg_perr("%s called before register_opaque_programmer. "
|
||||||
@ -64,7 +64,7 @@ int read_opaque(struct flashchip *flash, uint8_t *buf, int start, int len)
|
|||||||
return opaque_programmer->read(flash, buf, start, len);
|
return opaque_programmer->read(flash, buf, start, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_opaque(struct flashchip *flash, uint8_t *buf, int start, int len)
|
int write_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
if (!opaque_programmer->write) {
|
if (!opaque_programmer->write) {
|
||||||
msg_perr("%s called before register_opaque_programmer. "
|
msg_perr("%s called before register_opaque_programmer. "
|
||||||
|
@ -22,10 +22,10 @@
|
|||||||
|
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
|
||||||
static void write_lockbits_49fl00x(chipaddr bios, int size,
|
static void write_lockbits_49fl00x(chipaddr bios, unsigned int size,
|
||||||
unsigned char bits, int block_size)
|
unsigned char bits, unsigned int block_size)
|
||||||
{
|
{
|
||||||
int i, left = size;
|
unsigned int i, left = size;
|
||||||
|
|
||||||
for (i = 0; left >= block_size; i++, left -= block_size) {
|
for (i = 0; left >= block_size; i++, left -= block_size) {
|
||||||
/* pm49fl002 */
|
/* pm49fl002 */
|
||||||
|
16
programmer.h
16
programmer.h
@ -563,23 +563,23 @@ extern const int spi_programmer_count;
|
|||||||
#define MAX_DATA_WRITE_UNLIMITED 256
|
#define MAX_DATA_WRITE_UNLIMITED 256
|
||||||
struct spi_programmer {
|
struct spi_programmer {
|
||||||
enum spi_controller type;
|
enum spi_controller type;
|
||||||
int max_data_read;
|
unsigned int max_data_read;
|
||||||
int max_data_write;
|
unsigned int max_data_write;
|
||||||
int (*command)(unsigned int writecnt, unsigned int readcnt,
|
int (*command)(unsigned int writecnt, unsigned int readcnt,
|
||||||
const unsigned char *writearr, unsigned char *readarr);
|
const unsigned char *writearr, unsigned char *readarr);
|
||||||
int (*multicommand)(struct spi_command *cmds);
|
int (*multicommand)(struct spi_command *cmds);
|
||||||
|
|
||||||
/* Optimized functions for this programmer */
|
/* Optimized functions for this programmer */
|
||||||
int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len);
|
int (*read)(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
int (*write_256)(struct flashchip *flash, uint8_t *buf, int start, int len);
|
int (*write_256)(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct spi_programmer *spi_programmer;
|
extern const struct spi_programmer *spi_programmer;
|
||||||
int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
||||||
const unsigned char *writearr, unsigned char *readarr);
|
const unsigned char *writearr, unsigned char *readarr);
|
||||||
int default_spi_send_multicommand(struct spi_command *cmds);
|
int default_spi_send_multicommand(struct spi_command *cmds);
|
||||||
int default_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
|
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, int start, int len);
|
int default_spi_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
void register_spi_programmer(const struct spi_programmer *programmer);
|
void register_spi_programmer(const struct spi_programmer *programmer);
|
||||||
|
|
||||||
/* ichspi.c */
|
/* ichspi.c */
|
||||||
@ -625,8 +625,8 @@ struct opaque_programmer {
|
|||||||
int max_data_write;
|
int max_data_write;
|
||||||
/* Specific functions for this programmer */
|
/* Specific functions for this programmer */
|
||||||
int (*probe) (struct flashchip *flash);
|
int (*probe) (struct flashchip *flash);
|
||||||
int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len);
|
int (*read) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
int (*write) (struct flashchip *flash, uint8_t *buf, int start, 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 (*erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);
|
||||||
};
|
};
|
||||||
extern const struct opaque_programmer *opaque_programmer;
|
extern const struct opaque_programmer *opaque_programmer;
|
||||||
|
11
serprog.c
11
serprog.c
@ -302,8 +302,8 @@ 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,
|
static int serprog_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
||||||
const unsigned char *writearr,
|
const unsigned char *writearr,
|
||||||
unsigned char *readarr);
|
unsigned char *readarr);
|
||||||
static int serprog_spi_read(struct flashchip *flash, uint8_t *buf, int start,
|
static int serprog_spi_read(struct flashchip *flash, uint8_t *buf,
|
||||||
int len);
|
unsigned int start, unsigned int len);
|
||||||
static struct spi_programmer spi_programmer_serprog = {
|
static struct spi_programmer spi_programmer_serprog = {
|
||||||
.type = SPI_CONTROLLER_SERPROG,
|
.type = SPI_CONTROLLER_SERPROG,
|
||||||
.max_data_read = MAX_DATA_READ_UNLIMITED,
|
.max_data_read = MAX_DATA_READ_UNLIMITED,
|
||||||
@ -822,11 +822,10 @@ 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
|
* 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
|
* non-contiguous address space (like AT45DB161D). When spi_read_chunked is
|
||||||
* fixed this method can be removed. */
|
* fixed this method can be removed. */
|
||||||
static int serprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
|
static int serprog_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i, cur_len;
|
||||||
int cur_len;
|
const unsigned int max_read = spi_programmer_serprog.max_data_read;
|
||||||
const int max_read = spi_programmer_serprog.max_data_read;
|
|
||||||
for (i = 0; i < len; i += cur_len) {
|
for (i = 0; i < len; i += cur_len) {
|
||||||
int ret;
|
int ret;
|
||||||
cur_len = min(max_read, (len - i));
|
cur_len = min(max_read, (len - i));
|
||||||
|
14
spi.c
14
spi.c
@ -97,9 +97,9 @@ int default_spi_send_multicommand(struct spi_command *cmds)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int default_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
|
int default_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int max_data = spi_programmer->max_data_read;
|
unsigned int max_data = spi_programmer->max_data_read;
|
||||||
if (max_data == MAX_DATA_UNSPECIFIED) {
|
if (max_data == MAX_DATA_UNSPECIFIED) {
|
||||||
msg_perr("%s called, but SPI read chunk size not defined "
|
msg_perr("%s called, but SPI read chunk size not defined "
|
||||||
"on this hardware. Please report a bug at "
|
"on this hardware. Please report a bug at "
|
||||||
@ -109,9 +109,9 @@ int default_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
|
|||||||
return spi_read_chunked(flash, buf, start, len, max_data);
|
return spi_read_chunked(flash, buf, start, len, max_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int default_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len)
|
int default_spi_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int max_data = spi_programmer->max_data_write;
|
unsigned int max_data = spi_programmer->max_data_write;
|
||||||
if (max_data == MAX_DATA_UNSPECIFIED) {
|
if (max_data == MAX_DATA_UNSPECIFIED) {
|
||||||
msg_perr("%s called, but SPI write chunk size not defined "
|
msg_perr("%s called, but SPI write chunk size not defined "
|
||||||
"on this hardware. Please report a bug at "
|
"on this hardware. Please report a bug at "
|
||||||
@ -121,9 +121,9 @@ int default_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int
|
|||||||
return spi_write_chunked(flash, buf, start, len, max_data);
|
return spi_write_chunked(flash, buf, start, len, max_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len)
|
int spi_chip_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int addrbase = 0;
|
unsigned int addrbase = 0;
|
||||||
if (!spi_programmer->read) {
|
if (!spi_programmer->read) {
|
||||||
msg_perr("%s called, but SPI read is unsupported on this "
|
msg_perr("%s called, but SPI read is unsupported on this "
|
||||||
"hardware. Please report a bug at "
|
"hardware. Please report a bug at "
|
||||||
@ -160,7 +160,7 @@ int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len)
|
|||||||
* .write_256 = spi_chip_write_1
|
* .write_256 = spi_chip_write_1
|
||||||
*/
|
*/
|
||||||
/* real chunksize is up to 256, logical chunksize is 256 */
|
/* real chunksize is up to 256, logical chunksize is 256 */
|
||||||
int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len)
|
int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
if (!spi_programmer->write_256) {
|
if (!spi_programmer->write_256) {
|
||||||
msg_perr("%s called, but SPI page write is unsupported on this "
|
msg_perr("%s called, but SPI page write is unsupported on this "
|
||||||
|
27
spi25.c
27
spi25.c
@ -840,7 +840,7 @@ int spi_write_status_register(struct flashchip *flash, int status)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_byte_program(int addr, uint8_t databyte)
|
int spi_byte_program(unsigned int addr, uint8_t databyte)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
struct spi_command cmds[] = {
|
struct spi_command cmds[] = {
|
||||||
@ -875,7 +875,7 @@ int spi_byte_program(int addr, uint8_t databyte)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_nbyte_program(int addr, uint8_t *bytes, int len)
|
int spi_nbyte_program(unsigned int addr, uint8_t *bytes, unsigned int len)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
/* FIXME: Switch to malloc based on len unless that kills speed. */
|
/* FIXME: Switch to malloc based on len unless that kills speed. */
|
||||||
@ -950,7 +950,7 @@ int spi_disable_blockprotect(struct flashchip *flash)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_nbyte_read(int address, uint8_t *bytes, int len)
|
int spi_nbyte_read(unsigned int address, uint8_t *bytes, unsigned int len)
|
||||||
{
|
{
|
||||||
const unsigned char cmd[JEDEC_READ_OUTSIZE] = {
|
const unsigned char cmd[JEDEC_READ_OUTSIZE] = {
|
||||||
JEDEC_READ,
|
JEDEC_READ,
|
||||||
@ -968,12 +968,11 @@ int spi_nbyte_read(int address, uint8_t *bytes, int len)
|
|||||||
* FIXME: Use the chunk code from Michael Karcher instead.
|
* FIXME: Use the chunk code from Michael Karcher instead.
|
||||||
* Each page is read separately in chunks with a maximum size of chunksize.
|
* Each page is read separately in chunks with a maximum size of chunksize.
|
||||||
*/
|
*/
|
||||||
int spi_read_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize)
|
int spi_read_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int i, j, starthere, lenhere;
|
unsigned int i, j, starthere, lenhere, toread;
|
||||||
int page_size = flash->page_size;
|
unsigned int page_size = flash->page_size;
|
||||||
int toread;
|
|
||||||
|
|
||||||
/* Warning: This loop has a very unusual condition and body.
|
/* Warning: This loop has a very unusual condition and body.
|
||||||
* The loop needs to go through each page with at least one affected
|
* The loop needs to go through each page with at least one affected
|
||||||
@ -1008,17 +1007,16 @@ int spi_read_chunked(struct flashchip *flash, uint8_t *buf, int start, int len,
|
|||||||
* FIXME: Use the chunk code from Michael Karcher instead.
|
* FIXME: Use the chunk code from Michael Karcher instead.
|
||||||
* Each page is written separately in chunks with a maximum size of chunksize.
|
* Each page is written separately in chunks with a maximum size of chunksize.
|
||||||
*/
|
*/
|
||||||
int spi_write_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize)
|
int spi_write_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int i, j, starthere, lenhere;
|
unsigned int i, j, starthere, lenhere, towrite;
|
||||||
/* FIXME: page_size is the wrong variable. We need max_writechunk_size
|
/* FIXME: page_size is the wrong variable. We need max_writechunk_size
|
||||||
* in struct flashchip to do this properly. All chips using
|
* in struct flashchip to do this properly. All chips using
|
||||||
* spi_chip_write_256 have page_size set to max_writechunk_size, so
|
* spi_chip_write_256 have page_size set to max_writechunk_size, so
|
||||||
* we're OK for now.
|
* we're OK for now.
|
||||||
*/
|
*/
|
||||||
int page_size = flash->page_size;
|
unsigned int page_size = flash->page_size;
|
||||||
int towrite;
|
|
||||||
|
|
||||||
/* Warning: This loop has a very unusual condition and body.
|
/* Warning: This loop has a very unusual condition and body.
|
||||||
* The loop needs to go through each page with at least one affected
|
* The loop needs to go through each page with at least one affected
|
||||||
@ -1057,9 +1055,10 @@ int spi_write_chunked(struct flashchip *flash, uint8_t *buf, int start, int len,
|
|||||||
* (e.g. due to size constraints in IT87* for over 512 kB)
|
* (e.g. due to size constraints in IT87* for over 512 kB)
|
||||||
*/
|
*/
|
||||||
/* real chunksize is 1, logical chunksize is 1 */
|
/* real chunksize is 1, logical chunksize is 1 */
|
||||||
int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, int start, int len)
|
int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int i, result = 0;
|
unsigned int i;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
for (i = start; i < start + len; i++) {
|
for (i = start; i < start + len; i++) {
|
||||||
result = spi_byte_program(i, buf[i - start]);
|
result = spi_byte_program(i, buf[i - start]);
|
||||||
@ -1072,7 +1071,7 @@ int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, int start, int len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_aai_write(struct flashchip *flash, uint8_t *buf, int start, int len)
|
int spi_aai_write(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
uint32_t pos = start;
|
uint32_t pos = start;
|
||||||
int result;
|
int result;
|
||||||
|
@ -76,7 +76,7 @@ int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* chunksize is 1 */
|
/* chunksize is 1 */
|
||||||
int write_28sf040(struct flashchip *flash, uint8_t *src, int start, int len)
|
int write_28sf040(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
chipaddr bios = flash->virtual_memory;
|
chipaddr bios = flash->virtual_memory;
|
||||||
|
@ -35,7 +35,7 @@ static int write_lockbits_block_49lfxxxc(struct flashchip *flash, unsigned long
|
|||||||
static int write_lockbits_49lfxxxc(struct flashchip *flash, unsigned char bits)
|
static int write_lockbits_49lfxxxc(struct flashchip *flash, unsigned char bits)
|
||||||
{
|
{
|
||||||
chipaddr registers = flash->virtual_registers;
|
chipaddr registers = flash->virtual_registers;
|
||||||
int i, left = flash->total_size * 1024;
|
unsigned int i, left = flash->total_size * 1024;
|
||||||
unsigned long address;
|
unsigned long address;
|
||||||
|
|
||||||
msg_cdbg("\nbios=0x%08lx\n", registers);
|
msg_cdbg("\nbios=0x%08lx\n", registers);
|
||||||
|
12
w39.c
12
w39.c
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
|
||||||
static int printlock_w39_fwh_block(struct flashchip *flash, int offset)
|
static int printlock_w39_fwh_block(struct flashchip *flash, unsigned int offset)
|
||||||
{
|
{
|
||||||
chipaddr wrprotect = flash->virtual_registers + offset + 2;
|
chipaddr wrprotect = flash->virtual_registers + offset + 2;
|
||||||
uint8_t locking;
|
uint8_t locking;
|
||||||
@ -59,7 +59,7 @@ static int printlock_w39_fwh_block(struct flashchip *flash, int offset)
|
|||||||
return (locking & ((1 << 2) | (1 << 0))) ? -1 : 0;
|
return (locking & ((1 << 2) | (1 << 0))) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unlock_w39_fwh_block(struct flashchip *flash, int offset)
|
static int unlock_w39_fwh_block(struct flashchip *flash, unsigned int offset)
|
||||||
{
|
{
|
||||||
chipaddr wrprotect = flash->virtual_registers + offset + 2;
|
chipaddr wrprotect = flash->virtual_registers + offset + 2;
|
||||||
uint8_t locking;
|
uint8_t locking;
|
||||||
@ -80,7 +80,7 @@ static int unlock_w39_fwh_block(struct flashchip *flash, int offset)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t w39_idmode_readb(struct flashchip *flash, int offset)
|
static uint8_t w39_idmode_readb(struct flashchip *flash, unsigned int offset)
|
||||||
{
|
{
|
||||||
chipaddr bios = flash->virtual_memory;
|
chipaddr bios = flash->virtual_memory;
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
@ -127,7 +127,7 @@ static int printlock_w39_bootblock_64k16k(uint8_t lock)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int printlock_w39_common(struct flashchip *flash, int offset)
|
static int printlock_w39_common(struct flashchip *flash, unsigned int offset)
|
||||||
{
|
{
|
||||||
uint8_t lock;
|
uint8_t lock;
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ static int printlock_w39_common(struct flashchip *flash, int offset)
|
|||||||
|
|
||||||
static int printlock_w39_fwh(struct flashchip *flash)
|
static int printlock_w39_fwh(struct flashchip *flash)
|
||||||
{
|
{
|
||||||
int i, total_size = flash->total_size * 1024;
|
unsigned int i, total_size = flash->total_size * 1024;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* Print lock status of the complete chip */
|
/* Print lock status of the complete chip */
|
||||||
@ -150,7 +150,7 @@ static int printlock_w39_fwh(struct flashchip *flash)
|
|||||||
|
|
||||||
static int unlock_w39_fwh(struct flashchip *flash)
|
static int unlock_w39_fwh(struct flashchip *flash)
|
||||||
{
|
{
|
||||||
int i, total_size = flash->total_size * 1024;
|
unsigned int i, total_size = flash->total_size * 1024;
|
||||||
|
|
||||||
/* Unlock the complete chip */
|
/* Unlock the complete chip */
|
||||||
for (i = 0; i < total_size; i += flash->page_size)
|
for (i = 0; i < total_size; i += flash->page_size)
|
||||||
|
@ -62,7 +62,7 @@ done:
|
|||||||
|
|
||||||
static int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
static int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
||||||
const unsigned char *writearr, unsigned char *readarr);
|
const unsigned char *writearr, unsigned char *readarr);
|
||||||
static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
|
static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||||
|
|
||||||
static const struct spi_programmer spi_programmer_wbsio = {
|
static const struct spi_programmer spi_programmer_wbsio = {
|
||||||
.type = SPI_CONTROLLER_WBSIO,
|
.type = SPI_CONTROLLER_WBSIO,
|
||||||
@ -194,7 +194,7 @@ static int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
|
static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
|
||||||
{
|
{
|
||||||
return read_memmapped(flash, buf, start, len);
|
return read_memmapped(flash, buf, start, len);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user