aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor
diff options
context:
space:
mode:
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>2014-03-10 22:23:07 +0100
committerSpencer Oliver <spen@spen-soft.co.uk>2014-03-17 12:47:18 +0000
commit565f8481c7b71614a05d79ab79af8610d2535a81 (patch)
treee37bd29bd71c8c83046a4b91536405542e722d84 /src/flash/nor
parentcd091c36305d9d2de838c7ba145ee7547e4e1640 (diff)
downloadriscv-openocd-565f8481c7b71614a05d79ab79af8610d2535a81.zip
riscv-openocd-565f8481c7b71614a05d79ab79af8610d2535a81.tar.gz
riscv-openocd-565f8481c7b71614a05d79ab79af8610d2535a81.tar.bz2
flash: Constify write buffer
Change-Id: Ic812098d3ed5a2992c26bb57d08ae350e2c5d5d8 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/2040 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/flash/nor')
-rw-r--r--src/flash/nor/aduc702x.c6
-rw-r--r--src/flash/nor/at91sam3.c4
-rw-r--r--src/flash/nor/at91sam4.c4
-rw-r--r--src/flash/nor/at91sam4l.c6
-rw-r--r--src/flash/nor/at91sam7.c4
-rw-r--r--src/flash/nor/at91samd.c6
-rw-r--r--src/flash/nor/avrf.c4
-rw-r--r--src/flash/nor/cfi.c14
-rw-r--r--src/flash/nor/driver.h2
-rw-r--r--src/flash/nor/dsp5680xx_flash.c2
-rw-r--r--src/flash/nor/efm32.c6
-rw-r--r--src/flash/nor/em357.c4
-rw-r--r--src/flash/nor/faux.c2
-rw-r--r--src/flash/nor/fm3.c2
-rw-r--r--src/flash/nor/kinetis.c4
-rw-r--r--src/flash/nor/lpc2000.c6
-rw-r--r--src/flash/nor/lpc288x.c2
-rw-r--r--src/flash/nor/lpc2900.c4
-rw-r--r--src/flash/nor/lpcspifi.c2
-rw-r--r--src/flash/nor/mdr.c6
-rw-r--r--src/flash/nor/mini51.c2
-rw-r--r--src/flash/nor/nrf51.c6
-rw-r--r--src/flash/nor/nuc1x.c2
-rw-r--r--src/flash/nor/ocl.c2
-rw-r--r--src/flash/nor/pic32mx.c4
-rw-r--r--src/flash/nor/stellaris.c4
-rw-r--r--src/flash/nor/stm32f1x.c8
-rw-r--r--src/flash/nor/stm32f2x.c4
-rw-r--r--src/flash/nor/stm32lx.c4
-rw-r--r--src/flash/nor/stmsmi.c4
-rw-r--r--src/flash/nor/str7x.c4
-rw-r--r--src/flash/nor/str9x.c4
-rw-r--r--src/flash/nor/str9xpec.c2
-rw-r--r--src/flash/nor/tms470.c2
-rw-r--r--src/flash/nor/virtual.c2
35 files changed, 73 insertions, 71 deletions
diff --git a/src/flash/nor/aduc702x.c b/src/flash/nor/aduc702x.c
index 60ec7d3..8852245 100644
--- a/src/flash/nor/aduc702x.c
+++ b/src/flash/nor/aduc702x.c
@@ -144,7 +144,7 @@ static int aduc702x_protect(struct flash_bank *bank, int set, int first, int las
* Caller should not check for other return values specifically
*/
static int aduc702x_write_block(struct flash_bank *bank,
- uint8_t *buffer,
+ const uint8_t *buffer,
uint32_t offset,
uint32_t count)
{
@@ -285,7 +285,7 @@ static int aduc702x_write_block(struct flash_bank *bank,
/* All-JTAG, single-access method. Very slow. Used only if there is no
* working area available. */
static int aduc702x_write_single(struct flash_bank *bank,
- uint8_t *buffer,
+ const uint8_t *buffer,
uint32_t offset,
uint32_t count)
{
@@ -326,7 +326,7 @@ static int aduc702x_write_single(struct flash_bank *bank,
return ERROR_OK;
}
-static int aduc702x_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int aduc702x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
int retval;
diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c
index a05ab16..bbdb58c 100644
--- a/src/flash/nor/at91sam3.c
+++ b/src/flash/nor/at91sam3.c
@@ -3285,7 +3285,7 @@ static const uint8_t
0x00, 0xBE /* bkpt #0 */
};
-static int sam3_page_write(struct sam3_bank_private *pPrivate, unsigned pagenum, uint8_t *buf)
+static int sam3_page_write(struct sam3_bank_private *pPrivate, unsigned pagenum, const uint8_t *buf)
{
uint32_t adr;
uint32_t status;
@@ -3344,7 +3344,7 @@ static int sam3_page_write(struct sam3_bank_private *pPrivate, unsigned pagenum,
}
static int sam3_write(struct flash_bank *bank,
- uint8_t *buffer,
+ const uint8_t *buffer,
uint32_t offset,
uint32_t count)
{
diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c
index 84d09c2..4d5ba2e 100644
--- a/src/flash/nor/at91sam4.c
+++ b/src/flash/nor/at91sam4.c
@@ -1877,7 +1877,7 @@ static int sam4_page_read(struct sam4_bank_private *pPrivate, unsigned pagenum,
return r;
}
-static int sam4_page_write(struct sam4_bank_private *pPrivate, unsigned pagenum, uint8_t *buf)
+static int sam4_page_write(struct sam4_bank_private *pPrivate, unsigned pagenum, const uint8_t *buf)
{
uint32_t adr;
uint32_t status;
@@ -1939,7 +1939,7 @@ static int sam4_page_write(struct sam4_bank_private *pPrivate, unsigned pagenum,
}
static int sam4_write(struct flash_bank *bank,
- uint8_t *buffer,
+ const uint8_t *buffer,
uint32_t offset,
uint32_t count)
{
diff --git a/src/flash/nor/at91sam4l.c b/src/flash/nor/at91sam4l.c
index d3bdbfe..9f1319b 100644
--- a/src/flash/nor/at91sam4l.c
+++ b/src/flash/nor/at91sam4l.c
@@ -495,7 +495,7 @@ static int sam4l_erase(struct flash_bank *bank, int first, int last)
/* Write an entire page from host buffer 'buf' to page-aligned 'address' in the
* Flash. */
static int sam4l_write_page(struct sam4l_info *chip, struct target *target,
- uint32_t address, uint8_t *buf)
+ uint32_t address, const uint8_t *buf)
{
int res;
@@ -527,7 +527,7 @@ static int sam4l_write_page(struct sam4l_info *chip, struct target *target,
/* Write partial contents into page-aligned 'address' on the Flash from host
* buffer 'buf' by writing 'nb' of 'buf' at 'offset' into the Flash page. */
static int sam4l_write_page_partial(struct sam4l_info *chip,
- struct flash_bank *bank, uint32_t address, uint8_t *buf,
+ struct flash_bank *bank, uint32_t address, const uint8_t *buf,
uint32_t page_offset, uint32_t nb)
{
int res;
@@ -556,7 +556,7 @@ static int sam4l_write_page_partial(struct sam4l_info *chip,
return res;
}
-static int sam4l_write(struct flash_bank *bank, uint8_t *buffer,
+static int sam4l_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
int res;
diff --git a/src/flash/nor/at91sam7.c b/src/flash/nor/at91sam7.c
index 9cda3f2..c7334ca 100644
--- a/src/flash/nor/at91sam7.c
+++ b/src/flash/nor/at91sam7.c
@@ -98,7 +98,7 @@
#define FLASH_SIZE_2048KB 14
static int at91sam7_protect_check(struct flash_bank *bank);
-static int at91sam7_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset,
+static int at91sam7_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset,
uint32_t count);
static uint32_t at91sam7_get_flash_status(struct target *target, int bank_number);
@@ -954,7 +954,7 @@ static int at91sam7_protect(struct flash_bank *bank, int set, int first, int las
return ERROR_OK;
}
-static int at91sam7_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int at91sam7_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
int retval;
struct at91sam7_flash_bank *at91sam7_info = bank->driver_priv;
diff --git a/src/flash/nor/at91samd.c b/src/flash/nor/at91samd.c
index 8b0f14d..5af61ab 100644
--- a/src/flash/nor/at91samd.c
+++ b/src/flash/nor/at91samd.c
@@ -385,7 +385,7 @@ static int samd_erase(struct flash_bank *bank, int first, int last)
/* Write an entire row (four pages) from host buffer 'buf' to row-aligned
* 'address' in the Flash. */
static int samd_write_row(struct flash_bank *bank, uint32_t address,
- uint8_t *buf)
+ const uint8_t *buf)
{
int res;
struct samd_info *chip = (struct samd_info *)bank->driver_priv;
@@ -424,7 +424,7 @@ static int samd_write_row(struct flash_bank *bank, uint32_t address,
/* Write partial contents into row-aligned 'address' on the Flash from host
* buffer 'buf' by writing 'nb' of 'buf' at 'row_offset' into the Flash row. */
static int samd_write_row_partial(struct flash_bank *bank, uint32_t address,
- uint8_t *buf, uint32_t row_offset, uint32_t nb)
+ const uint8_t *buf, uint32_t row_offset, uint32_t nb)
{
int res;
struct samd_info *chip = (struct samd_info *)bank->driver_priv;
@@ -453,7 +453,7 @@ static int samd_write_row_partial(struct flash_bank *bank, uint32_t address,
return res;
}
-static int samd_write(struct flash_bank *bank, uint8_t *buffer,
+static int samd_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
int res;
diff --git a/src/flash/nor/avrf.c b/src/flash/nor/avrf.c
index e408282..ecc0904 100644
--- a/src/flash/nor/avrf.c
+++ b/src/flash/nor/avrf.c
@@ -142,7 +142,7 @@ static int avr_jtagprg_chiperase(struct avr_common *avr)
}
static int avr_jtagprg_writeflashpage(struct avr_common *avr,
- uint8_t *page_buf,
+ const uint8_t *page_buf,
uint32_t buf_size,
uint32_t addr,
uint32_t page_size)
@@ -239,7 +239,7 @@ static int avrf_protect(struct flash_bank *bank, int set, int first, int last)
return ERROR_OK;
}
-static int avrf_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int avrf_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
struct avr_common *avr = target->arch_info;
diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c
index 56d8e6e..97d3f19 100644
--- a/src/flash/nor/cfi.c
+++ b/src/flash/nor/cfi.c
@@ -1126,7 +1126,7 @@ static uint32_t cfi_command_val(struct flash_bank *bank, uint8_t cmd)
}
}
-static int cfi_intel_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int cfi_intel_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t address, uint32_t count)
{
struct target *target = bank->target;
@@ -1379,7 +1379,7 @@ cleanup:
return retval;
}
-static int cfi_spansion_write_block_mips(struct flash_bank *bank, uint8_t *buffer,
+static int cfi_spansion_write_block_mips(struct flash_bank *bank, const uint8_t *buffer,
uint32_t address, uint32_t count)
{
struct cfi_flash_bank *cfi_info = bank->driver_priv;
@@ -1592,7 +1592,7 @@ static int cfi_spansion_write_block_mips(struct flash_bank *bank, uint8_t *buffe
return retval;
}
-static int cfi_spansion_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int cfi_spansion_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t address, uint32_t count)
{
struct cfi_flash_bank *cfi_info = bank->driver_priv;
@@ -2002,7 +2002,7 @@ static int cfi_intel_write_word(struct flash_bank *bank, uint8_t *word, uint32_t
return ERROR_OK;
}
-static int cfi_intel_write_words(struct flash_bank *bank, uint8_t *word,
+static int cfi_intel_write_words(struct flash_bank *bank, const uint8_t *word,
uint32_t wordcount, uint32_t address)
{
int retval;
@@ -2122,7 +2122,7 @@ static int cfi_spansion_write_word(struct flash_bank *bank, uint8_t *word, uint3
return ERROR_OK;
}
-static int cfi_spansion_write_words(struct flash_bank *bank, uint8_t *word,
+static int cfi_spansion_write_words(struct flash_bank *bank, const uint8_t *word,
uint32_t wordcount, uint32_t address)
{
int retval;
@@ -2215,7 +2215,7 @@ static int cfi_write_word(struct flash_bank *bank, uint8_t *word, uint32_t addre
return ERROR_FLASH_OPERATION_FAILED;
}
-static int cfi_write_words(struct flash_bank *bank, uint8_t *word,
+static int cfi_write_words(struct flash_bank *bank, const uint8_t *word,
uint32_t wordcount, uint32_t address)
{
struct cfi_flash_bank *cfi_info = bank->driver_priv;
@@ -2312,7 +2312,7 @@ static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, u
return ERROR_OK;
}
-static int cfi_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct cfi_flash_bank *cfi_info = bank->driver_priv;
struct target *target = bank->target;
diff --git a/src/flash/nor/driver.h b/src/flash/nor/driver.h
index 4e17207..8f2e1cc 100644
--- a/src/flash/nor/driver.h
+++ b/src/flash/nor/driver.h
@@ -137,7 +137,7 @@ struct flash_driver {
* @returns ERROR_OK if successful; otherwise, an error code.
*/
int (*write)(struct flash_bank *bank,
- uint8_t *buffer, uint32_t offset, uint32_t count);
+ const uint8_t *buffer, uint32_t offset, uint32_t count);
/**
* Read data from the flash. Note CPU address will be
diff --git a/src/flash/nor/dsp5680xx_flash.c b/src/flash/nor/dsp5680xx_flash.c
index 9368d89..693ff48 100644
--- a/src/flash/nor/dsp5680xx_flash.c
+++ b/src/flash/nor/dsp5680xx_flash.c
@@ -156,7 +156,7 @@ static int dsp5680xx_flash_protect(struct flash_bank *bank, int set, int first,
*
* @return
*/
-static int dsp5680xx_flash_write(struct flash_bank *bank, uint8_t * buffer,
+static int dsp5680xx_flash_write(struct flash_bank *bank, const uint8_t* buffer,
uint32_t offset, uint32_t count)
{
int retval;
diff --git a/src/flash/nor/efm32.c b/src/flash/nor/efm32.c
index 6e2ebce..3c46c76 100644
--- a/src/flash/nor/efm32.c
+++ b/src/flash/nor/efm32.c
@@ -98,7 +98,7 @@ struct efm32_info {
uint16_t page_size;
};
-static int efm32x_write(struct flash_bank *bank, uint8_t *buffer,
+static int efm32x_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count);
static int efm32x_get_flash_size(struct flash_bank *bank, uint16_t *flash_sz)
@@ -499,7 +499,7 @@ static int efm32x_protect(struct flash_bank *bank, int set, int first, int last)
return ERROR_OK;
}
-static int efm32x_write_block(struct flash_bank *bank, uint8_t *buf,
+static int efm32x_write_block(struct flash_bank *bank, const uint8_t *buf,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -735,7 +735,7 @@ static int efm32x_write_word(struct flash_bank *bank, uint32_t addr,
return ERROR_OK;
}
-static int efm32x_write(struct flash_bank *bank, uint8_t *buffer,
+static int efm32x_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
diff --git a/src/flash/nor/em357.c b/src/flash/nor/em357.c
index 56f44b3..70a5431 100644
--- a/src/flash/nor/em357.c
+++ b/src/flash/nor/em357.c
@@ -455,7 +455,7 @@ static int em357_protect(struct flash_bank *bank, int set, int first, int last)
return em357_write_options(bank);
}
-static int em357_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int em357_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -583,7 +583,7 @@ static int em357_write_block(struct flash_bank *bank, uint8_t *buffer,
return retval;
}
-static int em357_write(struct flash_bank *bank, uint8_t *buffer,
+static int em357_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
diff --git a/src/flash/nor/faux.c b/src/flash/nor/faux.c
index 8e51b8e..1fd1da2 100644
--- a/src/flash/nor/faux.c
+++ b/src/flash/nor/faux.c
@@ -93,7 +93,7 @@ static int faux_protect(struct flash_bank *bank, int set, int first, int last)
return ERROR_OK;
}
-static int faux_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int faux_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct faux_flash_bank *info = bank->driver_priv;
memcpy(info->memory + offset, buffer, count);
diff --git a/src/flash/nor/fm3.c b/src/flash/nor/fm3.c
index 1859912..d4bd5b9 100644
--- a/src/flash/nor/fm3.c
+++ b/src/flash/nor/fm3.c
@@ -347,7 +347,7 @@ static int fm3_erase(struct flash_bank *bank, int first, int last)
return retval;
}
-static int fm3_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int fm3_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct fm3_flash_bank *fm3_info = bank->driver_priv;
diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c
index dc9208c..8678590 100644
--- a/src/flash/nor/kinetis.c
+++ b/src/flash/nor/kinetis.c
@@ -278,7 +278,7 @@ static const uint8_t kinetis_flash_write_code[] = {
};
/* Program LongWord Block Write */
-static int kinetis_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int kinetis_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t wcount)
{
struct target *target = bank->target;
@@ -586,7 +586,7 @@ static int kinetis_erase(struct flash_bank *bank, int first, int last)
return ERROR_OK;
}
-static int kinetis_write(struct flash_bank *bank, uint8_t *buffer,
+static int kinetis_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
unsigned int i, result, fallback = 0;
diff --git a/src/flash/nor/lpc2000.c b/src/flash/nor/lpc2000.c
index 259b42f..69c8b03 100644
--- a/src/flash/nor/lpc2000.c
+++ b/src/flash/nor/lpc2000.c
@@ -711,7 +711,7 @@ static int lpc2000_protect(struct flash_bank *bank, int set, int first, int last
return ERROR_OK;
}
-static int lpc2000_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int lpc2000_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -746,6 +746,7 @@ static int lpc2000_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offs
/* check if exception vectors should be flashed */
if ((offset == 0) && (count >= 0x20) && lpc2000_info->calc_checksum) {
+ assert(lpc2000_info->checksum_vector < 8);
uint32_t checksum = 0;
for (int i = 0; i < 8; i++) {
LOG_DEBUG("Vector 0x%2.2x: 0x%8.8" PRIx32, i * 4, buf_get_u32(buffer + (i * 4), 0, 32));
@@ -763,7 +764,8 @@ static int lpc2000_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offs
"checksum.");
}
- buf_set_u32(buffer + (lpc2000_info->checksum_vector * 4), 0, 32, checksum);
+ /* FIXME: WARNING! This code is broken because it modifies the callers buffer in place. */
+ buf_set_u32((uint8_t *)buffer + (lpc2000_info->checksum_vector * 4), 0, 32, checksum);
}
struct working_area *iap_working_area;
diff --git a/src/flash/nor/lpc288x.c b/src/flash/nor/lpc288x.c
index b602619..89f79e3 100644
--- a/src/flash/nor/lpc288x.c
+++ b/src/flash/nor/lpc288x.c
@@ -277,7 +277,7 @@ static int lpc288x_erase(struct flash_bank *bank, int first, int last)
return ERROR_OK;
}
-static int lpc288x_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int lpc288x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
uint8_t page_buffer[FLASH_PAGE_SIZE];
uint32_t status, source_offset, dest_offset;
diff --git a/src/flash/nor/lpc2900.c b/src/flash/nor/lpc2900.c
index 018d94a..7c3e675 100644
--- a/src/flash/nor/lpc2900.c
+++ b/src/flash/nor/lpc2900.c
@@ -1058,7 +1058,7 @@ static int lpc2900_protect(struct flash_bank *bank, int set, int first, int last
* @param offset Start address (relative to bank start)
* @param count Number of bytes to be programmed
*/
-static int lpc2900_write(struct flash_bank *bank, uint8_t *buffer,
+static int lpc2900_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
uint8_t page[FLASH_PAGE_SIZE];
@@ -1186,7 +1186,7 @@ static int lpc2900_write(struct flash_bank *bank, uint8_t *buffer,
/* Write to flash in large blocks */
while (count != 0) {
uint32_t this_npages;
- uint8_t *this_buffer;
+ const uint8_t *this_buffer;
int start_sector = lpc2900_address2sector(bank, offset);
/* First page / last page / rest */
diff --git a/src/flash/nor/lpcspifi.c b/src/flash/nor/lpcspifi.c
index 7566c27..2f4c601 100644
--- a/src/flash/nor/lpcspifi.c
+++ b/src/flash/nor/lpcspifi.c
@@ -581,7 +581,7 @@ static int lpcspifi_protect(struct flash_bank *bank, int set,
return ERROR_OK;
}
-static int lpcspifi_write(struct flash_bank *bank, uint8_t *buffer,
+static int lpcspifi_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
diff --git a/src/flash/nor/mdr.c b/src/flash/nor/mdr.c
index 650abfd..ed76aab 100644
--- a/src/flash/nor/mdr.c
+++ b/src/flash/nor/mdr.c
@@ -223,7 +223,7 @@ static int mdr_protect(struct flash_bank *bank, int set, int first, int last)
return ERROR_OK;
}
-static int mdr_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int mdr_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -314,7 +314,7 @@ static int mdr_write_block(struct flash_bank *bank, uint8_t *buffer,
return retval;
}
-static int mdr_write(struct flash_bank *bank, uint8_t *buffer,
+static int mdr_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -345,7 +345,7 @@ static int mdr_write(struct flash_bank *bank, uint8_t *buffer,
LOG_INFO("odd number of bytes to write, padding with 0xff");
buffer = memcpy(new_buffer, buffer, count);
while (rem--)
- buffer[count++] = 0xff;
+ new_buffer[count++] = 0xff;
}
uint32_t flash_cmd, cur_per_clock;
diff --git a/src/flash/nor/mini51.c b/src/flash/nor/mini51.c
index 19b1444..61aee5d 100644
--- a/src/flash/nor/mini51.c
+++ b/src/flash/nor/mini51.c
@@ -312,7 +312,7 @@ static int mini51_protect(struct flash_bank *bank, int set, int first, int last)
return ERROR_FLASH_OPERATION_FAILED;
}
-static int mini51_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int mini51_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
int status;
int timeout;
diff --git a/src/flash/nor/nrf51.c b/src/flash/nor/nrf51.c
index 4b3ab3e..444db61 100644
--- a/src/flash/nor/nrf51.c
+++ b/src/flash/nor/nrf51.c
@@ -429,7 +429,7 @@ static int nrf51_erase_page(struct nrf51_info *chip, struct flash_sector *sector
return res;
}
-static int nrf51_write_page(struct flash_bank *bank, uint32_t offset, uint8_t *buffer)
+static int nrf51_write_page(struct flash_bank *bank, uint32_t offset, const uint8_t *buffer)
{
assert(offset % 4 == 0);
@@ -484,7 +484,7 @@ static int nrf51_erase(struct flash_bank *bank, int first, int last)
return res;
}
-static int nrf51_write(struct flash_bank *bank, uint8_t *buffer,
+static int nrf51_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
int res;
@@ -502,7 +502,7 @@ static int nrf51_write(struct flash_bank *bank, uint8_t *buffer,
struct {
size_t length;
- uint8_t *buffer;
+ const uint8_t *buffer;
} start_extra, end_extra;
start_extra.length = region.start % chip->code_page_size;
diff --git a/src/flash/nor/nuc1x.c b/src/flash/nor/nuc1x.c
index 6ca858e..179302e 100644
--- a/src/flash/nor/nuc1x.c
+++ b/src/flash/nor/nuc1x.c
@@ -378,7 +378,7 @@ static int nuc1x_erase(struct flash_bank *bank, int first, int last)
}
/* The write routine stub. */
-static int nuc1x_write(struct flash_bank *bank, uint8_t *buffer,
+static int nuc1x_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
diff --git a/src/flash/nor/ocl.c b/src/flash/nor/ocl.c
index 6b297b0..c547d9a 100644
--- a/src/flash/nor/ocl.c
+++ b/src/flash/nor/ocl.c
@@ -118,7 +118,7 @@ static int ocl_protect(struct flash_bank *bank, int set, int first, int last)
return ERROR_OK;
}
-static int ocl_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int ocl_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct ocl_priv *ocl = bank->driver_priv;
int retval;
diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c
index 2b27ec5..5e82ba6 100644
--- a/src/flash/nor/pic32mx.c
+++ b/src/flash/nor/pic32mx.c
@@ -410,7 +410,7 @@ static uint32_t pic32mx_flash_write_code[] = {
0x00000000 /* nop */
};
-static int pic32mx_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int pic32mx_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -571,7 +571,7 @@ static int pic32mx_write_word(struct flash_bank *bank, uint32_t address, uint32_
return pic32mx_nvm_exec(bank, NVMCON_OP_WORD_PROG, 5);
}
-static int pic32mx_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int pic32mx_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
uint32_t words_remaining = (count / 4);
uint32_t bytes_remaining = (count & 0x00000003);
diff --git a/src/flash/nor/stellaris.c b/src/flash/nor/stellaris.c
index 8886c19..7665ab3 100644
--- a/src/flash/nor/stellaris.c
+++ b/src/flash/nor/stellaris.c
@@ -997,7 +997,7 @@ static const uint8_t stellaris_write_code[] = {
0x01, 0x00, 0x42, 0xA4 /* .word 0xA4420001 */
};
static int stellaris_write_block(struct flash_bank *bank,
- uint8_t *buffer, uint32_t offset, uint32_t wcount)
+ const uint8_t *buffer, uint32_t offset, uint32_t wcount)
{
struct target *target = bank->target;
uint32_t buffer_size = 16384;
@@ -1078,7 +1078,7 @@ static int stellaris_write_block(struct flash_bank *bank,
return retval;
}
-static int stellaris_write(struct flash_bank *bank, uint8_t *buffer,
+static int stellaris_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
diff --git a/src/flash/nor/stm32f1x.c b/src/flash/nor/stm32f1x.c
index 1b67ff0..aacf6dc 100644
--- a/src/flash/nor/stm32f1x.c
+++ b/src/flash/nor/stm32f1x.c
@@ -130,7 +130,7 @@ struct stm32x_flash_bank {
static int stm32x_mass_erase(struct flash_bank *bank);
static int stm32x_get_device_id(struct flash_bank *bank, uint32_t *device_id);
-static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count);
/* flash bank stm32x <base> <size> 0 0 <target#>
@@ -561,7 +561,7 @@ static int stm32x_protect(struct flash_bank *bank, int set, int first, int last)
return stm32x_write_options(bank);
}
-static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct stm32x_flash_bank *stm32x_info = bank->driver_priv;
@@ -692,7 +692,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
return retval;
}
-static int stm32x_write(struct flash_bank *bank, uint8_t *buffer,
+static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -720,7 +720,7 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer,
}
LOG_INFO("odd number of bytes to write, padding with 0xff");
buffer = memcpy(new_buffer, buffer, count);
- buffer[count++] = 0xff;
+ new_buffer[count++] = 0xff;
}
uint32_t words_remaining = count / 2;
diff --git a/src/flash/nor/stm32f2x.c b/src/flash/nor/stm32f2x.c
index be96d98..41973e6 100644
--- a/src/flash/nor/stm32f2x.c
+++ b/src/flash/nor/stm32f2x.c
@@ -481,7 +481,7 @@ static int stm32x_protect(struct flash_bank *bank, int set, int first, int last)
return ERROR_OK;
}
-static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -608,7 +608,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
return retval;
}
-static int stm32x_write(struct flash_bank *bank, uint8_t *buffer,
+static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c
index eb4f96d..75cecce 100644
--- a/src/flash/nor/stm32lx.c
+++ b/src/flash/nor/stm32lx.c
@@ -212,7 +212,7 @@ static int stm32lx_protect(struct flash_bank *bank, int set, int first,
return ERROR_OK;
}
-static int stm32lx_write_half_pages(struct flash_bank *bank, uint8_t *buffer,
+static int stm32lx_write_half_pages(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
@@ -403,7 +403,7 @@ static int stm32lx_write_half_pages(struct flash_bank *bank, uint8_t *buffer,
return retval;
}
-static int stm32lx_write(struct flash_bank *bank, uint8_t *buffer,
+static int stm32lx_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
diff --git a/src/flash/nor/stmsmi.c b/src/flash/nor/stmsmi.c
index eea1d9f..6f73c36 100644
--- a/src/flash/nor/stmsmi.c
+++ b/src/flash/nor/stmsmi.c
@@ -372,7 +372,7 @@ static int stmsmi_protect(struct flash_bank *bank, int set,
return ERROR_OK;
}
-static int smi_write_buffer(struct flash_bank *bank, uint8_t *buffer,
+static int smi_write_buffer(struct flash_bank *bank, const uint8_t *buffer,
uint32_t address, uint32_t len)
{
struct target *target = bank->target;
@@ -397,7 +397,7 @@ static int smi_write_buffer(struct flash_bank *bank, uint8_t *buffer,
return ERROR_OK;
}
-static int stmsmi_write(struct flash_bank *bank, uint8_t *buffer,
+static int stmsmi_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c
index 32c8ebd..515b975 100644
--- a/src/flash/nor/str7x.c
+++ b/src/flash/nor/str7x.c
@@ -442,7 +442,7 @@ static int str7x_protect(struct flash_bank *bank, int set, int first, int last)
return ERROR_OK;
}
-static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int str7x_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct str7x_flash_bank *str7x_info = bank->driver_priv;
@@ -559,7 +559,7 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer,
return retval;
}
-static int str7x_write(struct flash_bank *bank, uint8_t *buffer,
+static int str7x_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
diff --git a/src/flash/nor/str9x.c b/src/flash/nor/str9x.c
index 2158622..8b3c137 100644
--- a/src/flash/nor/str9x.c
+++ b/src/flash/nor/str9x.c
@@ -347,7 +347,7 @@ static int str9x_protect(struct flash_bank *bank,
}
static int str9x_write_block(struct flash_bank *bank,
- uint8_t *buffer, uint32_t offset, uint32_t count)
+ const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
uint32_t buffer_size = 32768;
@@ -459,7 +459,7 @@ static int str9x_write_block(struct flash_bank *bank,
}
static int str9x_write(struct flash_bank *bank,
- uint8_t *buffer, uint32_t offset, uint32_t count)
+ const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
uint32_t words_remaining = (count / 2);
diff --git a/src/flash/nor/str9xpec.c b/src/flash/nor/str9xpec.c
index e08495d..f0af53a 100644
--- a/src/flash/nor/str9xpec.c
+++ b/src/flash/nor/str9xpec.c
@@ -565,7 +565,7 @@ static int str9xpec_set_address(struct flash_bank *bank, uint8_t sector)
return ERROR_OK;
}
-static int str9xpec_write(struct flash_bank *bank, uint8_t *buffer,
+static int str9xpec_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct str9xpec_flash_controller *str9xpec_info = bank->driver_priv;
diff --git a/src/flash/nor/tms470.c b/src/flash/nor/tms470.c
index 3851504..86858a8 100644
--- a/src/flash/nor/tms470.c
+++ b/src/flash/nor/tms470.c
@@ -890,7 +890,7 @@ static int tms470_protect(struct flash_bank *bank, int set, int first, int last)
/* ---------------------------------------------------------------------- */
-static int tms470_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int tms470_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct target *target = bank->target;
uint32_t glbctrl, fmbac2, orig_fmregopt, fmbsea, fmbseb, fmmaxpp, fmmstat;
diff --git a/src/flash/nor/virtual.c b/src/flash/nor/virtual.c
index fab521d..599a9c0 100644
--- a/src/flash/nor/virtual.c
+++ b/src/flash/nor/virtual.c
@@ -119,7 +119,7 @@ static int virtual_erase(struct flash_bank *bank, int first, int last)
return ERROR_OK;
}
-static int virtual_write(struct flash_bank *bank, uint8_t *buffer,
+static int virtual_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t offset, uint32_t count)
{
struct flash_bank *master_bank = virtual_get_master_bank(bank);