Author: stefanct Date: Fri May 9 23:16:21 2014 New Revision: 1789 URL: http://flashrom.org/trac/flashrom/changeset/1789
Log: Add 'const' keyword to chip write and other function prototypes.
Inspired by and mostly based on a patch Signed-off-by: Mark Marshall mark.marshall@omicron.at
Signed-off-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at Acked-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at
Modified: trunk/82802ab.c trunk/at45db.c trunk/chipdrivers.h trunk/dummyflasher.c trunk/en29lv640b.c trunk/flash.h trunk/flashrom.c trunk/ichspi.c trunk/it87spi.c trunk/layout.c trunk/linux_spi.c trunk/m29f400bt.c trunk/opaque.c trunk/programmer.c trunk/programmer.h trunk/serial.c trunk/spi.c trunk/spi25.c trunk/sst28sf040.c
Modified: trunk/82802ab.c ============================================================================== --- trunk/82802ab.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/82802ab.c Fri May 9 23:16:21 2014 (r1789) @@ -142,8 +142,7 @@ }
/* chunksize is 1 */ -int write_82802ab(struct flashctx *flash, uint8_t *src, unsigned int start, - unsigned int len) +int write_82802ab(struct flashctx *flash, const uint8_t *src, unsigned int start, unsigned int len) { int i; chipaddr dst = flash->virtual_memory + start;
Modified: trunk/at45db.c ============================================================================== --- trunk/at45db.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/at45db.c Fri May 9 23:16:21 2014 (r1789) @@ -460,7 +460,7 @@ return at45db_erase(flash, opcode, at45db_convert_addr(addr, page_size), 200000, 100); }
-static int at45db_fill_buffer1(struct flashctx *flash, uint8_t *bytes, unsigned int off, unsigned int len) +static int at45db_fill_buffer1(struct flashctx *flash, const uint8_t *bytes, unsigned int off, unsigned int len) { const unsigned int page_size = flash->chip->page_size; if ((off + len) > page_size) { @@ -518,7 +518,7 @@ return 0; }
-static int at45db_program_page(struct flashctx *flash, uint8_t *buf, unsigned int at45db_addr) +static int at45db_program_page(struct flashctx *flash, const uint8_t *buf, unsigned int at45db_addr) { int ret = at45db_fill_buffer1(flash, buf, 0, flash->chip->page_size); if (ret != 0) { @@ -535,7 +535,7 @@ return 0; }
-int spi_write_at45db(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len) +int spi_write_at45db(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { const unsigned int page_size = flash->chip->page_size; const unsigned int total_size = flash->chip->total_size;
Modified: trunk/chipdrivers.h ============================================================================== --- trunk/chipdrivers.h Thu May 8 00:07:23 2014 (r1788) +++ trunk/chipdrivers.h Fri May 9 23:16:21 2014 (r1789) @@ -28,8 +28,8 @@ #include "flash.h" /* for chipaddr and flashctx */
/* spi.c */ -int spi_aai_write(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_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); +int spi_chip_write_256(struct flashctx *flash, const 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);
/* spi25.c */ @@ -54,12 +54,12 @@ int spi_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen); int spi_block_erase_db(struct flashctx *flash, unsigned int addr, unsigned int blocklen); erasefunc_t *spi_get_erasefn_from_opcode(uint8_t opcode); -int spi_chip_write_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); +int spi_chip_write_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); int spi_byte_program(struct flashctx *flash, unsigned int addr, uint8_t databyte); -int spi_nbyte_program(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len); +int spi_nbyte_program(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len); int spi_nbyte_read(struct flashctx *flash, unsigned int addr, uint8_t *bytes, 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_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
/* spi25_statusreg.c */ uint8_t spi_read_status_register(struct flashctx *flash); @@ -107,7 +107,7 @@ /* opaque.c */ 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 write_opaque(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
/* at45db.c */ @@ -116,7 +116,7 @@ int spi_disable_blockprotect_at45db(struct flashctx *flash); int spi_read_at45db(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); int spi_read_at45db_e8(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); -int spi_write_at45db(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); +int spi_write_at45db(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); int spi_erase_at45db_page(struct flashctx *flash, unsigned int addr, unsigned int blocklen); int spi_erase_at45db_block(struct flashctx *flash, unsigned int addr, unsigned int blocklen); int spi_erase_at45db_sector(struct flashctx *flash, unsigned int addr, unsigned int blocklen); @@ -127,7 +127,7 @@ 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); +int write_82802ab(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); void print_status_82802ab(uint8_t status); int unlock_82802ab(struct flashctx *flash); int unlock_28f004s5(struct flashctx *flash); @@ -140,8 +140,8 @@ int write_byte_program_jedec(struct flashctx *flash, chipaddr bios, uint8_t *src, chipaddr dst); 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 write_jedec(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); +int write_jedec_1(struct flashctx *flash, const 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); @@ -150,7 +150,7 @@ 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); +int write_m29f400bt(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); void protect_m29f400bt(struct flashctx *flash, chipaddr bios);
/* pm49fl00x.c */ @@ -160,7 +160,7 @@ /* sst28sf040.c */ 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 write_28sf040(struct flashctx *flash, const uint8_t *buf,unsigned int start, unsigned int len); int unprotect_28sf040(struct flashctx *flash); int protect_28sf040(struct flashctx *flash);
@@ -202,6 +202,6 @@ int probe_en29lv640b(struct flashctx *flash); int block_erase_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len); int block_erase_chip_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len); -int write_en29lv640b(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); +int write_en29lv640b(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
#endif /* !__CHIPDRIVERS_H__ */
Modified: trunk/dummyflasher.c ============================================================================== --- trunk/dummyflasher.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/dummyflasher.c Fri May 9 23:16:21 2014 (r1789) @@ -96,28 +96,18 @@
static unsigned int spi_write_256_chunksize = 256;
-static int dummy_spi_send_command(struct flashctx *flash, unsigned int writecnt, - unsigned int readcnt, - const unsigned char *writearr, - unsigned char *readarr); -static int dummy_spi_write_256(struct flashctx *flash, uint8_t *buf, +static int dummy_spi_send_command(struct flashctx *flash, unsigned int writecnt, unsigned int readcnt, + const unsigned char *writearr, unsigned char *readarr); +static int dummy_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); -static void dummy_chip_writeb(const struct flashctx *flash, uint8_t val, - chipaddr addr); -static void dummy_chip_writew(const struct flashctx *flash, uint16_t val, - chipaddr addr); -static void dummy_chip_writel(const struct flashctx *flash, uint32_t val, - chipaddr addr); -static void dummy_chip_writen(const struct flashctx *flash, uint8_t *buf, - chipaddr addr, size_t len); -static uint8_t dummy_chip_readb(const struct flashctx *flash, - const chipaddr addr); -static uint16_t dummy_chip_readw(const struct flashctx *flash, - const chipaddr addr); -static uint32_t dummy_chip_readl(const struct flashctx *flash, - const chipaddr addr); -static void dummy_chip_readn(const struct flashctx *flash, uint8_t *buf, - const chipaddr addr, size_t len); +static void dummy_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr); +static void dummy_chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr); +static void dummy_chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr); +static void dummy_chip_writen(const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len); +static uint8_t dummy_chip_readb(const struct flashctx *flash, const chipaddr addr); +static uint16_t dummy_chip_readw(const struct flashctx *flash, const chipaddr addr); +static uint32_t dummy_chip_readl(const struct flashctx *flash, const chipaddr addr); +static void dummy_chip_readn(const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len);
static const struct spi_programmer spi_programmer_dummyflasher = { .type = SPI_CONTROLLER_DUMMY, @@ -427,26 +417,22 @@ msg_pspew("%s: Unmapping 0x%zx bytes at %p\n", __func__, len, virt_addr); }
-static void dummy_chip_writeb(const struct flashctx *flash, uint8_t val, - chipaddr addr) +static void dummy_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr) { msg_pspew("%s: addr=0x%" PRIxPTR ", val=0x%02x\n", __func__, addr, val); }
-static void dummy_chip_writew(const struct flashctx *flash, uint16_t val, - chipaddr addr) +static void dummy_chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr) { msg_pspew("%s: addr=0x%" PRIxPTR ", val=0x%04x\n", __func__, addr, val); }
-static void dummy_chip_writel(const struct flashctx *flash, uint32_t val, - chipaddr addr) +static void dummy_chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr) { msg_pspew("%s: addr=0x%" PRIxPTR ", val=0x%08x\n", __func__, addr, val); }
-static void dummy_chip_writen(const struct flashctx *flash, uint8_t *buf, - chipaddr addr, size_t len) +static void dummy_chip_writen(const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len) { size_t i; msg_pspew("%s: addr=0x%" PRIxPTR ", len=0x%zx, writing data (hex):", __func__, addr, len); @@ -457,29 +443,25 @@ } }
-static uint8_t dummy_chip_readb(const struct flashctx *flash, - const chipaddr addr) +static uint8_t dummy_chip_readb(const struct flashctx *flash, const chipaddr addr) { msg_pspew("%s: addr=0x%" PRIxPTR ", returning 0xff\n", __func__, addr); return 0xff; }
-static uint16_t dummy_chip_readw(const struct flashctx *flash, - const chipaddr addr) +static uint16_t dummy_chip_readw(const struct flashctx *flash, const chipaddr addr) { msg_pspew("%s: addr=0x%" PRIxPTR ", returning 0xffff\n", __func__, addr); return 0xffff; }
-static uint32_t dummy_chip_readl(const struct flashctx *flash, - const chipaddr addr) +static uint32_t dummy_chip_readl(const struct flashctx *flash, const chipaddr addr) { msg_pspew("%s: addr=0x%" PRIxPTR ", returning 0xffffffff\n", __func__, addr); return 0xffffffff; }
-static void dummy_chip_readn(const struct flashctx *flash, uint8_t *buf, - const chipaddr addr, size_t len) +static void dummy_chip_readn(const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len) { msg_pspew("%s: addr=0x%" PRIxPTR ", len=0x%zx, returning array of 0xff\n", __func__, addr, len); memset(buf, 0xff, len); @@ -846,8 +828,7 @@ return 0; }
-static int dummy_spi_write_256(struct flashctx *flash, uint8_t *buf, - unsigned int start, unsigned int len) +static int dummy_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { return spi_write_chunked(flash, buf, start, len, spi_write_256_chunksize);
Modified: trunk/en29lv640b.c ============================================================================== --- trunk/en29lv640b.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/en29lv640b.c Fri May 9 23:16:21 2014 (r1789) @@ -31,8 +31,7 @@ */
/* chunksize is 1 */ -int write_en29lv640b(struct flashctx *flash, uint8_t *src, unsigned int start, - unsigned int len) +int write_en29lv640b(struct flashctx *flash, const uint8_t *src, unsigned int start, unsigned int len) { int i; chipaddr bios = flash->virtual_memory;
Modified: trunk/flash.h ============================================================================== --- trunk/flash.h Thu May 8 00:07:23 2014 (r1788) +++ trunk/flash.h Fri May 9 23:16:21 2014 (r1789) @@ -175,7 +175,7 @@
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 (*write) (struct flashctx *flash, const 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; @@ -228,7 +228,7 @@ void chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr); void chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr); void chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr); -void chip_writen(const struct flashctx *flash, uint8_t *buf, chipaddr addr, size_t len); +void chip_writen(const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len); uint8_t chip_readb(const struct flashctx *flash, const chipaddr addr); uint16_t chip_readw(const struct flashctx *flash, const chipaddr addr); uint32_t chip_readl(const struct flashctx *flash, const chipaddr addr); @@ -253,8 +253,8 @@ int max(int a, int b); void tolower_string(char *str); char *extract_param(const char *const *haystack, const char *needle, const char *delim); -int verify_range(struct flashctx *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len); -int need_erase(uint8_t *have, uint8_t *want, unsigned int len, enum write_granularity gran); +int verify_range(struct flashctx *flash, const uint8_t *cmpbuf, unsigned int start, unsigned int len); +int need_erase(const uint8_t *have, const uint8_t *want, unsigned int len, enum write_granularity gran); char *strcat_realloc(char *dest, const char *src); void print_version(void); void print_buildinfo(void); @@ -263,7 +263,7 @@ int selfcheck(void); 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); +int write_buf_to_file(const unsigned char *buf, unsigned long size, const char *filename);
enum test_state { OK = 0, @@ -327,7 +327,7 @@ /* layout.c */ int register_include_arg(char *name); int process_include_args(void); -int read_romlayout(char *name); +int read_romlayout(const char *name); int normalize_romentries(const struct flashctx *flash); int build_new_image(const struct flashctx *flash, uint8_t *oldcontents, uint8_t *newcontents); void layout_cleanup(void);
Modified: trunk/flashrom.c ============================================================================== --- trunk/flashrom.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/flashrom.c Fri May 9 23:16:21 2014 (r1789) @@ -463,8 +463,7 @@ flash->pgm->par.chip_writel(flash, val, addr); }
-void chip_writen(const struct flashctx *flash, uint8_t *buf, chipaddr addr, - size_t len) +void chip_writen(const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len) { flash->pgm->par.chip_writen(flash, buf, addr, len); } @@ -627,7 +626,7 @@ return usable_erasefunctions; }
-int compare_range(uint8_t *wantbuf, uint8_t *havebuf, unsigned int start, unsigned int len) +static int compare_range(const uint8_t *wantbuf, const uint8_t *havebuf, unsigned int start, unsigned int len) { int ret = 0, failcount = 0; unsigned int i; @@ -671,7 +670,7 @@ * @len length of the verified area * @return 0 for success, -1 for failure */ -int verify_range(struct flashctx *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len) +int verify_range(struct flashctx *flash, const uint8_t *cmpbuf, unsigned int start, unsigned int len) { uint8_t *readbuf = malloc(len); int ret = 0; @@ -710,7 +709,7 @@ }
/* Helper function for need_erase() that focuses on granularities of gran bytes. */ -static int need_erase_gran_bytes(uint8_t *have, uint8_t *want, unsigned int len, unsigned int gran) +static int need_erase_gran_bytes(const uint8_t *have, const uint8_t *want, unsigned int len, unsigned int gran) { unsigned int i, j, limit; for (j = 0; j < len / gran; j++) { @@ -740,7 +739,7 @@ * @gran write granularity (enum, not count) * @return 0 if no erase is needed, 1 otherwise */ -int need_erase(uint8_t *have, uint8_t *want, unsigned int len, enum write_granularity gran) +int need_erase(const uint8_t *have, const uint8_t *want, unsigned int len, enum write_granularity gran) { int result = 0; unsigned int i; @@ -808,7 +807,7 @@ * in relation to the max write length of the programmer and the max write * length of the chip. */ -static unsigned int get_next_write(uint8_t *have, uint8_t *want, unsigned int len, +static unsigned int get_next_write(const uint8_t *have, const uint8_t *want, unsigned int len, unsigned int *first_start, enum write_granularity gran) { @@ -1211,8 +1210,7 @@ #endif }
-int write_buf_to_file(unsigned char *buf, unsigned long size, - const char *filename) +int write_buf_to_file(const unsigned char *buf, unsigned long size, const char *filename) { #ifdef __LIBPAYLOAD__ msg_gerr("Error: No file I/O support in libpayload\n"); @@ -1456,8 +1454,7 @@ return 0; }
-int erase_and_write_flash(struct flashctx *flash, uint8_t *oldcontents, - uint8_t *newcontents) +int erase_and_write_flash(struct flashctx *flash, uint8_t *oldcontents, uint8_t *newcontents) { int k, ret = 1; uint8_t *curcontents;
Modified: trunk/ichspi.c ============================================================================== --- trunk/ichspi.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/ichspi.c Fri May 9 23:16:21 2014 (r1789) @@ -1327,8 +1327,7 @@ return 0; }
-static int ich_hwseq_write(struct flashctx *flash, uint8_t *buf, - unsigned int addr, unsigned int len) +static int ich_hwseq_write(struct flashctx *flash, const uint8_t *buf, unsigned int addr, unsigned int len) { uint16_t hsfc; uint16_t timeout = 100 * 60;
Modified: trunk/it87spi.c ============================================================================== --- trunk/it87spi.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/it87spi.c Fri May 9 23:16:21 2014 (r1789) @@ -108,7 +108,7 @@ unsigned char *readarr); 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 flashctx *flash, uint8_t *buf, +static int it8716f_spi_chip_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
static const struct spi_programmer spi_programmer_it87xx = { @@ -347,8 +347,7 @@ }
/* Page size is usually 256 bytes */ -static int it8716f_spi_page_program(struct flashctx *flash, uint8_t *buf, - unsigned int start) +static int it8716f_spi_page_program(struct flashctx *flash, const uint8_t *buf, unsigned int start) { unsigned int i; int result; @@ -393,7 +392,7 @@ return 0; }
-static int it8716f_spi_chip_write_256(struct flashctx *flash, uint8_t *buf, +static int it8716f_spi_chip_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { const struct flashchip *chip = flash->chip;
Modified: trunk/layout.c ============================================================================== --- trunk/layout.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/layout.c Fri May 9 23:16:21 2014 (r1789) @@ -45,7 +45,7 @@ static int num_include_args = 0; /* the number of valid include_args. */
#ifndef __LIBPAYLOAD__ -int read_romlayout(char *name) +int read_romlayout(const char *name) { FILE *romlayout; char tempstr[256]; @@ -102,7 +102,7 @@ #endif
/* returns the index of the entry (or a negative value if it is not found) */ -int find_include_arg(const char *const name) +static int find_include_arg(const char *const name) { unsigned int i; for (i = 0; i < num_include_args; i++) {
Modified: trunk/linux_spi.c ============================================================================== --- trunk/linux_spi.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/linux_spi.c Fri May 9 23:16:21 2014 (r1789) @@ -43,7 +43,7 @@ unsigned char *rxbuf); static int linux_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); -static int linux_spi_write_256(struct flashctx *flash, uint8_t *buf, +static int linux_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
static const struct spi_programmer spi_programmer_linux = { @@ -179,8 +179,7 @@ (unsigned int)getpagesize()); }
-static int linux_spi_write_256(struct flashctx *flash, uint8_t *buf, - unsigned int start, unsigned int len) +static int linux_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { return spi_write_chunked(flash, buf, start, len, ((unsigned int)getpagesize()) - 4);
Modified: trunk/m29f400bt.c ============================================================================== --- trunk/m29f400bt.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/m29f400bt.c Fri May 9 23:16:21 2014 (r1789) @@ -28,8 +28,7 @@ functions. */
/* chunksize is 1 */ -int write_m29f400bt(struct flashctx *flash, uint8_t *src, unsigned int start, - unsigned int len) +int write_m29f400bt(struct flashctx *flash, const uint8_t *src, unsigned int start, unsigned int len) { int i; chipaddr bios = flash->virtual_memory;
Modified: trunk/opaque.c ============================================================================== --- trunk/opaque.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/opaque.c Fri May 9 23:16:21 2014 (r1789) @@ -40,7 +40,7 @@ return flash->pgm->opaque.read(flash, buf, start, len); }
-int write_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len) +int write_opaque(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { return flash->pgm->opaque.write(flash, buf, start, len); }
Modified: trunk/programmer.c ============================================================================== --- trunk/programmer.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/programmer.c Fri May 9 23:16:21 2014 (r1789) @@ -78,8 +78,7 @@ return val; }
-void fallback_chip_writen(const struct flashctx *flash, uint8_t *buf, - chipaddr addr, size_t len) +void fallback_chip_writen(const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len) { size_t i; for (i = 0; i < len; i++)
Modified: trunk/programmer.h ============================================================================== --- trunk/programmer.h Thu May 8 00:07:23 2014 (r1788) +++ trunk/programmer.h Fri May 9 23:16:21 2014 (r1789) @@ -542,8 +542,8 @@
/* Optimized functions for this programmer */ 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); - int (*write_aai)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); + int (*write_256)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); + int (*write_aai)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); const void *data; };
@@ -551,8 +551,8 @@ const unsigned char *writearr, unsigned char *readarr); int default_spi_send_multicommand(struct flashctx *flash, struct spi_command *cmds); 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); -int default_spi_write_aai(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); +int default_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); +int default_spi_write_aai(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); int register_spi_programmer(const struct spi_programmer *programmer);
/* The following enum is needed by ich_descriptor_tool and ich* code as well as in chipset_enable.c. */ @@ -611,7 +611,7 @@ /* Specific functions for this programmer */ 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 (*write) (struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); int (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen); const void *data; }; @@ -624,7 +624,7 @@ void noop_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr); void fallback_chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr); void fallback_chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr); -void fallback_chip_writen(const struct flashctx *flash, uint8_t *buf, chipaddr addr, size_t len); +void fallback_chip_writen(const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len); uint16_t fallback_chip_readw(const struct flashctx *flash, const chipaddr addr); uint32_t fallback_chip_readl(const struct flashctx *flash, const chipaddr addr); void fallback_chip_readn(const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len); @@ -632,7 +632,7 @@ void (*chip_writeb) (const struct flashctx *flash, uint8_t val, chipaddr addr); void (*chip_writew) (const struct flashctx *flash, uint16_t val, chipaddr addr); void (*chip_writel) (const struct flashctx *flash, uint32_t val, chipaddr addr); - void (*chip_writen) (const struct flashctx *flash, uint8_t *buf, chipaddr addr, size_t len); + void (*chip_writen) (const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len); uint8_t (*chip_readb) (const struct flashctx *flash, const chipaddr addr); uint16_t (*chip_readw) (const struct flashctx *flash, const chipaddr addr); uint32_t (*chip_readl) (const struct flashctx *flash, const chipaddr addr); @@ -673,8 +673,8 @@ extern fdtype sp_fd; /* expose serialport_shutdown as it's currently used by buspirate */ int serialport_shutdown(void *data); -int serialport_write(unsigned char *buf, unsigned int writecnt); -int serialport_write_nonblock(unsigned char *buf, unsigned int writecnt, unsigned int timeout, unsigned int *really_wrote); +int serialport_write(const unsigned char *buf, unsigned int writecnt); +int serialport_write_nonblock(const unsigned char *buf, unsigned int writecnt, unsigned int timeout, unsigned int *really_wrote); int serialport_read(unsigned char *buf, unsigned int readcnt); int serialport_read_nonblock(unsigned char *c, unsigned int readcnt, unsigned int timeout, unsigned int *really_read);
Modified: trunk/serial.c ============================================================================== --- trunk/serial.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/serial.c Fri May 9 23:16:21 2014 (r1789) @@ -335,7 +335,7 @@ return 0; }
-int serialport_write(unsigned char *buf, unsigned int writecnt) +int serialport_write(const unsigned char *buf, unsigned int writecnt) { #ifdef _WIN32 DWORD tmp = 0; @@ -470,7 +470,7 @@ /* Tries up to timeout ms to write writecnt characters from the array starting at buf. Returns * 0 on success, positive values on temporary errors (e.g. timeouts) and negative ones on permanent errors. * If really_wrote is not NULL, this function sets its contents to the number of bytes written successfully. */ -int serialport_write_nonblock(unsigned char *buf, unsigned int writecnt, unsigned int timeout, unsigned int *really_wrote) +int serialport_write_nonblock(const unsigned char *buf, unsigned int writecnt, unsigned int timeout, unsigned int *really_wrote) { int ret = 1; /* disable blocked i/o and declare platform-specific variables */
Modified: trunk/spi.c ============================================================================== --- trunk/spi.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/spi.c Fri May 9 23:16:21 2014 (r1789) @@ -88,8 +88,7 @@ return spi_read_chunked(flash, buf, start, len, max_data); }
-int default_spi_write_256(struct flashctx *flash, uint8_t *buf, - unsigned int start, unsigned int len) +int default_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { unsigned int max_data = flash->pgm->spi.max_data_write; if (max_data == MAX_DATA_UNSPECIFIED) { @@ -135,8 +134,7 @@ * .write_256 = spi_chip_write_1 */ /* real chunksize is up to 256, logical chunksize is 256 */ -int spi_chip_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, - unsigned int len) +int spi_chip_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { return flash->pgm->spi.write_256(flash, buf, start, len); } @@ -162,8 +160,7 @@ } }
-int spi_aai_write(struct flashctx *flash, uint8_t *buf, - unsigned int start, unsigned int len) +int spi_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { return flash->pgm->spi.write_aai(flash, buf, start, len); }
Modified: trunk/spi25.c ============================================================================== --- trunk/spi25.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/spi25.c Fri May 9 23:16:21 2014 (r1789) @@ -876,8 +876,7 @@ return result; }
-int spi_nbyte_program(struct flashctx *flash, unsigned int addr, uint8_t *bytes, - unsigned int len) +int spi_nbyte_program(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len) { int result; /* FIXME: Switch to malloc based on len unless that kills speed. */ @@ -983,7 +982,7 @@ * 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 flashctx *flash, uint8_t *buf, unsigned int start, +int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize) { int rc = 0; @@ -1032,8 +1031,7 @@ * (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 flashctx *flash, uint8_t *buf, unsigned int start, - unsigned int len) +int spi_chip_write_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { unsigned int i; int result = 0; @@ -1049,7 +1047,7 @@ return 0; }
-int default_spi_write_aai(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len) +int default_spi_write_aai(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { uint32_t pos = start; int result;
Modified: trunk/sst28sf040.c ============================================================================== --- trunk/sst28sf040.c Thu May 8 00:07:23 2014 (r1788) +++ trunk/sst28sf040.c Fri May 9 23:16:21 2014 (r1789) @@ -77,8 +77,7 @@ }
/* chunksize is 1 */ -int write_28sf040(struct flashctx *flash, uint8_t *src, unsigned int start, - unsigned int len) +int write_28sf040(struct flashctx *flash, const uint8_t *src, unsigned int start, unsigned int len) { int i; chipaddr bios = flash->virtual_memory;