summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-05-27 21:23:47 +0000
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-05-27 21:23:47 +0000
commit938e01d0c3ff4fedf1629cc1c1928af1c90882e9 (patch)
treec496c2db7f863657643ff3bfb6db3a0bf7659310 /src
parent506ca886c4d89aabcffab2dfa6736dfcfc1396c5 (diff)
downloadopenocd_libswd-938e01d0c3ff4fedf1629cc1c1928af1c90882e9.tar.gz
openocd_libswd-938e01d0c3ff4fedf1629cc1c1928af1c90882e9.tar.bz2
openocd_libswd-938e01d0c3ff4fedf1629cc1c1928af1c90882e9.tar.xz
openocd_libswd-938e01d0c3ff4fedf1629cc1c1928af1c90882e9.zip
- moved flash erase_check target code to target.c
git-svn-id: svn://svn.berlios.de/openocd/trunk@694 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/flash/flash.c258
-rw-r--r--src/flash/flash.h3
-rw-r--r--src/flash/stellaris.c2
-rw-r--r--src/flash/stm32x.c2
-rw-r--r--src/target/arm720t.c1
-rw-r--r--src/target/arm7_9_common.c63
-rw-r--r--src/target/arm7_9_common.h1
-rw-r--r--src/target/arm7tdmi.c1
-rw-r--r--src/target/arm920t.c1
-rw-r--r--src/target/arm926ejs.c1
-rw-r--r--src/target/arm966e.c1
-rw-r--r--src/target/arm9tdmi.c1
-rw-r--r--src/target/armv7m.c60
-rw-r--r--src/target/armv7m.h1
-rw-r--r--src/target/cortex_m3.c1
-rw-r--r--src/target/feroceon.c1
-rw-r--r--src/target/target.c17
-rw-r--r--src/target/target.h2
-rw-r--r--src/target/xscale.c3
19 files changed, 210 insertions, 210 deletions
diff --git a/src/flash/flash.c b/src/flash/flash.c
index 1e4edd62..91a94db7 100644
--- a/src/flash/flash.c
+++ b/src/flash/flash.c
@@ -1090,11 +1090,11 @@ int flash_write(target_t *target, image_t *image, u32 *written, int erase)
return retval;
}
-int default_flash_blank_check(struct flash_bank_s *bank)
+int default_flash_mem_blank_check(struct flash_bank_s *bank)
{
target_t *target = bank->target;
u8 buffer[1024];
- int buffer_size=sizeof(buffer);
+ int buffer_size = sizeof(buffer);
int i;
int nBytes;
@@ -1103,227 +1103,73 @@ int default_flash_blank_check(struct flash_bank_s *bank)
return ERROR_TARGET_NOT_HALTED;
}
- int retval;
- int fast_check=0;
- working_area_t *erase_check_algorithm;
-#if 0
- /* FIX! doesn't work yet... */
- /*
- char test(char *a, int len, char t)
+ for (i = 0; i < bank->num_sectors; i++)
{
- int i=0;
-
- for (i=0; i<len; i++)
+ int j;
+ bank->sectors[i].is_erased = 1;
+
+ for (j = 0; j < bank->sectors[i].size; j += buffer_size)
{
- t&=a[i];
-
+ int chunk;
+ int retval;
+ chunk = buffer_size;
+ if (chunk > (j - bank->sectors[i].size))
+ {
+ chunk = (j - bank->sectors[i].size);
+ }
+
+ retval = target->type->read_memory(target, bank->base + bank->sectors[i].offset + j, 4, chunk/4, buffer);
+ if (retval != ERROR_OK)
+ return retval;
+
+ for (nBytes = 0; nBytes < chunk; nBytes++)
+ {
+ if (buffer[nBytes] != 0xFF)
+ {
+ bank->sectors[i].is_erased = 0;
+ break;
+ }
+ }
}
}
- $ arm-elf-gcc -c -mthumb -O3 test.c
-
- $ arm-elf-objdump --disassemble test.o
-
- test.o: file format elf32-littlearm
-
- Disassembly of section .text:
-
- 00000000 <test>:
- 0: b510 push {r4, lr}
- 2: 0612 lsl r2, r2, #24
- 4: 1c04 mov r4, r0 (add r4, r0, #0)
- 6: 0e10 lsr r0, r2, #24
- 8: 2200 mov r2, #0
- a: 2900 cmp r1, #0
- c: dd04 ble 18 <test+0x18>
- e: 5ca3 ldrb r3, [r4, r2]
- 10: 3201 add r2, #1
- 12: 4018 and r0, r3
- 14: 428a cmp r2, r1
- 16: dbfa blt e <test+0xe>
- 18: bd10 pop {r4, pc}
- 1a: 46c0 nop (mov r8, r8)
-
-
- */
- u16 erase_check_code[] =
- {
- 0x0612,// lsl r2, r2, #24
- 0x1c04,// mov r4, r0 (add r4, r0, #0)
- 0x0e10,// lsr r0, r2, #24
- 0x2200,// mov r2, #0
- 0x2900,// cmp r1, #0
- 0xdd04,// ble 18 <test+0x18>
- 0x5ca3,// ldrb r3, [r4, r2]
- 0x3201,// add r2, #1
- 0x4018,// and r0, r3
- 0x428a,// cmp r2, r1
- 0xdbfa,// blt e <test+0xe>
- 0x46c0,// nop (mov r8, r8)
-
- };
-
+ return ERROR_OK;
+}
+int default_flash_blank_check(struct flash_bank_s *bank)
+{
+ target_t *target = bank->target;
+ int i;
+ int retval;
+ int fast_check = 0;
+ int blank;
- /* make sure we have a working area */
- if (target_alloc_working_area(target, ((sizeof(erase_check_code)+3)/4)*4, &erase_check_algorithm) != ERROR_OK)
+ if (bank->target->state != TARGET_HALTED)
{
- erase_check_algorithm = NULL;
+ return ERROR_TARGET_NOT_HALTED;
}
-
- if (erase_check_algorithm)
- {
- u8 erase_check_code_buf[((sizeof(erase_check_code)+3)/4)*4];
- LOG_DEBUG("Running fast flash erase check");
- for (i = 0; i < sizeof(erase_check_code)/sizeof(*erase_check_code); i++)
- target_buffer_set_u16(target, erase_check_code_buf + (i*2), erase_check_code[i]);
-
- /* write algorithm code to working area */
- if ((retval=target->type->write_memory(target, erase_check_algorithm->address, 2, sizeof(erase_check_code)/sizeof(*erase_check_code), erase_check_code_buf))==ERROR_OK)
- {
- for (i = 0; i < bank->num_sectors; i++)
- {
- u32 address = bank->base + bank->sectors[i].offset;
- u32 size = bank->sectors[i].size;
-
- reg_param_t reg_params[3];
- armv7m_algorithm_t arm_info;
-
- arm_info.common_magic = ARMV7M_COMMON_MAGIC;
- arm_info.core_mode = ARMV7M_MODE_ANY;
- arm_info.core_state = ARMV7M_STATE_THUMB;
-
- init_reg_param(&reg_params[0], "r0", 32, PARAM_OUT);
- buf_set_u32(reg_params[0].value, 0, 32, address);
-
- init_reg_param(&reg_params[1], "r1", 32, PARAM_OUT);
- buf_set_u32(reg_params[1].value, 0, 32, size);
-
- init_reg_param(&reg_params[2], "r2", 32, PARAM_IN_OUT);
- buf_set_u32(reg_params[2].value, 0, 32, 0xff);
-
- if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params, erase_check_algorithm->address,
- erase_check_algorithm->address + sizeof(erase_check_code) - 2, 10000, &arm_info)) != ERROR_OK)
- break;
-
- if (buf_get_u32(reg_params[2].value, 0, 32) == 0xff)
- bank->sectors[i].is_erased = 1;
- else
- bank->sectors[i].is_erased = 0;
-
- destroy_reg_param(&reg_params[0]);
- destroy_reg_param(&reg_params[1]);
- destroy_reg_param(&reg_params[2]);
- }
- if (i == bank->num_sectors)
- {
- fast_check = 1;
- }
- }
- target_free_working_area(target, erase_check_algorithm);
- }
-#endif
- if (!fast_check)
+ for (i = 0; i < bank->num_sectors; i++)
{
- /* try ARM7 instead */
-
- u32 erase_check_code[] =
- {
- 0xe4d03001, /* ldrb r3, [r0], #1 */
- 0xe0022003, /* and r2, r2, r3 */
- 0xe2511001, /* subs r1, r1, #1 */
- 0x1afffffb, /* b -4 */
- 0xeafffffe /* b 0 */
- };
-
- /* make sure we have a working area */
- if (target_alloc_working_area(target, 20, &erase_check_algorithm) == ERROR_OK)
+ u32 address = bank->base + bank->sectors[i].offset;
+ u32 size = bank->sectors[i].size;
+
+ if ((retval = target_blank_check_memory(target, address, size, &blank)) != ERROR_OK)
{
- u8 erase_check_code_buf[5 * 4];
-
- for (i = 0; i < 5; i++)
- target_buffer_set_u32(target, erase_check_code_buf + (i*4), erase_check_code[i]);
-
- /* write algorithm code to working area */
- if ((retval=target->type->write_memory(target, erase_check_algorithm->address, 4, 5, erase_check_code_buf))==ERROR_OK)
- {
- for (i = 0; i < bank->num_sectors; i++)
- {
- u32 address = bank->base + bank->sectors[i].offset;
- u32 size = bank->sectors[i].size;
-
- reg_param_t reg_params[3];
- armv4_5_algorithm_t armv4_5_info;
-
- armv4_5_info.common_magic = ARMV4_5_COMMON_MAGIC;
- armv4_5_info.core_mode = ARMV4_5_MODE_SVC;
- armv4_5_info.core_state = ARMV4_5_STATE_ARM;
-
- init_reg_param(&reg_params[0], "r0", 32, PARAM_OUT);
- buf_set_u32(reg_params[0].value, 0, 32, address);
-
- init_reg_param(&reg_params[1], "r1", 32, PARAM_OUT);
- buf_set_u32(reg_params[1].value, 0, 32, size);
-
- init_reg_param(&reg_params[2], "r2", 32, PARAM_IN_OUT);
- buf_set_u32(reg_params[2].value, 0, 32, 0xff);
-
- if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params,
- erase_check_algorithm->address, erase_check_algorithm->address + 0x10, 10000, &armv4_5_info)) != ERROR_OK)
- break;
-
- if (buf_get_u32(reg_params[2].value, 0, 32) == 0xff)
- bank->sectors[i].is_erased = 1;
- else
- bank->sectors[i].is_erased = 0;
-
- destroy_reg_param(&reg_params[0]);
- destroy_reg_param(&reg_params[1]);
- destroy_reg_param(&reg_params[2]);
- }
- if (i == bank->num_sectors)
- {
- fast_check = 1;
- }
- }
- target_free_working_area(target, erase_check_algorithm);
+ fast_check = 0;
+ break;
}
+ if (blank == 0xFF)
+ bank->sectors[i].is_erased = 1;
+ else
+ bank->sectors[i].is_erased = 0;
+ fast_check = 1;
}
-
-
+
if (!fast_check)
{
LOG_USER("Running slow fallback erase check - add working memory");
- for (i = 0; i < bank->num_sectors; i++)
- {
- int j;
- bank->sectors[i].is_erased = 1;
-
- for (j=0; j<bank->sectors[i].size; j+=buffer_size)
- {
- int chunk;
- int retval;
- chunk=buffer_size;
- if (chunk>(j-bank->sectors[i].size))
- {
- chunk=(j-bank->sectors[i].size);
- }
-
- retval=target->type->read_memory(target, bank->base + bank->sectors[i].offset + j, 4, chunk/4, buffer);
- if (retval!=ERROR_OK)
- return retval;
-
- for (nBytes = 0; nBytes < chunk; nBytes++)
- {
- if (buffer[nBytes] != 0xFF)
- {
- bank->sectors[i].is_erased = 0;
- break;
- }
- }
- }
- }
+ return default_flash_mem_blank_check(bank);
}
return ERROR_OK;
diff --git a/src/flash/flash.h b/src/flash/flash.h
index e2f78855..e7a79f8f 100644
--- a/src/flash/flash.h
+++ b/src/flash/flash.h
@@ -78,7 +78,8 @@ extern int flash_erase_address_range(target_t *target, u32 addr, u32 length);
extern int flash_write(target_t *target, image_t *image, u32 *written, int erase);
extern void flash_set_dirty(void);
extern int flash_get_bank_count();
-int default_flash_blank_check(struct flash_bank_s *bank);
+extern int default_flash_blank_check(struct flash_bank_s *bank);
+extern int default_flash_mem_blank_check(struct flash_bank_s *bank);
extern flash_bank_t *get_flash_bank_by_num(int num);
extern flash_bank_t *get_flash_bank_by_num_noprobe(int num);
diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c
index e8c0a1c1..57049faa 100644
--- a/src/flash/stellaris.c
+++ b/src/flash/stellaris.c
@@ -70,7 +70,7 @@ flash_driver_t stellaris_flash =
.write = stellaris_write,
.probe = stellaris_probe,
.auto_probe = stellaris_auto_probe,
- .erase_check = default_flash_blank_check,
+ .erase_check = default_flash_mem_blank_check,
.protect_check = stellaris_protect_check,
.info = stellaris_info
};
diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c
index 9ce16f7d..dcd59d2d 100644
--- a/src/flash/stm32x.c
+++ b/src/flash/stm32x.c
@@ -61,7 +61,7 @@ flash_driver_t stm32x_flash =
.write = stm32x_write,
.probe = stm32x_probe,
.auto_probe = stm32x_auto_probe,
- .erase_check = default_flash_blank_check,
+ .erase_check = default_flash_mem_blank_check,
.protect_check = stm32x_protect_check,
.info = stm32x_info
};
diff --git a/src/target/arm720t.c b/src/target/arm720t.c
index 9645db85..cc45c9e6 100644
--- a/src/target/arm720t.c
+++ b/src/target/arm720t.c
@@ -70,6 +70,7 @@ target_type_t arm720t_target =
.write_memory = arm720t_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.checksum_memory = arm7_9_checksum_memory,
+ .blank_check_memory = arm7_9_blank_check_memory,
.run_algorithm = armv4_5_run_algorithm,
diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c
index 517badfd..b4ab4ef9 100644
--- a/src/target/arm7_9_common.c
+++ b/src/target/arm7_9_common.c
@@ -2305,6 +2305,69 @@ int arm7_9_checksum_memory(struct target_s *target, u32 address, u32 count, u32*
return ERROR_OK;
}
+int arm7_9_blank_check_memory(struct target_s *target, u32 address, u32 count, u32* blank)
+{
+ working_area_t *erase_check_algorithm;
+ reg_param_t reg_params[3];
+ armv4_5_algorithm_t armv4_5_info;
+ int retval;
+ int i;
+
+ u32 erase_check_code[] =
+ {
+ /* loop: */
+ 0xe4d03001, /* ldrb r3, [r0], #1 */
+ 0xe0022003, /* and r2, r2, r3 */
+ 0xe2511001, /* subs r1, r1, #1 */
+ 0x1afffffb, /* bne loop */
+ /* end: */
+ 0xeafffffe /* b end */
+ };
+
+ /* make sure we have a working area */
+ if (target_alloc_working_area(target, sizeof(erase_check_code), &erase_check_algorithm) != ERROR_OK)
+ {
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ }
+
+ /* convert flash writing code into a buffer in target endianness */
+ for (i = 0; i < (sizeof(erase_check_code)/sizeof(u32)); i++)
+ target_write_u32(target, erase_check_algorithm->address + i*sizeof(u32), erase_check_code[i]);
+
+ armv4_5_info.common_magic = ARMV4_5_COMMON_MAGIC;
+ armv4_5_info.core_mode = ARMV4_5_MODE_SVC;
+ armv4_5_info.core_state = ARMV4_5_STATE_ARM;
+
+ init_reg_param(&reg_params[0], "r0", 32, PARAM_OUT);
+ buf_set_u32(reg_params[0].value, 0, 32, address);
+
+ init_reg_param(&reg_params[1], "r1", 32, PARAM_OUT);
+ buf_set_u32(reg_params[1].value, 0, 32, count);
+
+ init_reg_param(&reg_params[2], "r2", 32, PARAM_IN_OUT);
+ buf_set_u32(reg_params[2].value, 0, 32, 0xff);
+
+ if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params,
+ erase_check_algorithm->address, erase_check_algorithm->address + (sizeof(erase_check_code) - 4), 10000, &armv4_5_info)) != ERROR_OK)
+ {
+ destroy_reg_param(&reg_params[0]);
+ destroy_reg_param(&reg_params[1]);
+ destroy_reg_param(&reg_params[2]);
+ target_free_working_area(target, erase_check_algorithm);
+ return 0;
+ }
+
+ *blank = buf_get_u32(reg_params[2].value, 0, 32);
+
+ destroy_reg_param(&reg_params[0]);
+ destroy_reg_param(&reg_params[1]);
+ destroy_reg_param(&reg_params[2]);
+
+ target_free_working_area(target, erase_check_algorithm);
+
+ return ERROR_OK;
+}
+
int arm7_9_register_commands(struct command_context_s *cmd_ctx)
{
command_t *arm7_9_cmd;
diff --git a/src/target/arm7_9_common.h b/src/target/arm7_9_common.h
index 21992faf..d6052f85 100644
--- a/src/target/arm7_9_common.h
+++ b/src/target/arm7_9_common.h
@@ -123,6 +123,7 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count
int arm7_9_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
int arm7_9_bulk_write_memory(target_t *target, u32 address, u32 count, u8 *buffer);
int arm7_9_checksum_memory(struct target_s *target, u32 address, u32 count, u32* checksum);
+int arm7_9_blank_check_memory(struct target_s *target, u32 address, u32 count, u32* blank);
int arm7_9_run_algorithm(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_prams, reg_param_t *reg_param, u32 entry_point, void *arch_info);
diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c
index 549f6a67..16d1b136 100644
--- a/src/target/arm7tdmi.c
+++ b/src/target/arm7tdmi.c
@@ -75,6 +75,7 @@ target_type_t arm7tdmi_target =
.write_memory = arm7_9_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.checksum_memory = arm7_9_checksum_memory,
+ .blank_check_memory = arm7_9_blank_check_memory,
.run_algorithm = armv4_5_run_algorithm,
diff --git a/src/target/arm920t.c b/src/target/arm920t.c
index 9e9bf1a5..3a3c2f1f 100644
--- a/src/target/arm920t.c
+++ b/src/target/arm920t.c
@@ -79,6 +79,7 @@ target_type_t arm920t_target =
.write_memory = arm920t_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.checksum_memory = arm7_9_checksum_memory,
+ .blank_check_memory = arm7_9_blank_check_memory,
.run_algorithm = armv4_5_run_algorithm,
diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c
index f46760e5..ffa2b0d6 100644
--- a/src/target/arm926ejs.c
+++ b/src/target/arm926ejs.c
@@ -79,6 +79,7 @@ target_type_t arm926ejs_target =
.write_memory = arm926ejs_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.checksum_memory = arm7_9_checksum_memory,
+ .blank_check_memory = arm7_9_blank_check_memory,
.run_algorithm = armv4_5_run_algorithm,
diff --git a/src/target/arm966e.c b/src/target/arm966e.c
index 3112e0fc..af699cfa 100644
--- a/src/target/arm966e.c
+++ b/src/target/arm966e.c
@@ -70,6 +70,7 @@ target_type_t arm966e_target =
.write_memory = arm7_9_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.checksum_memory = arm7_9_checksum_memory,
+ .blank_check_memory = arm7_9_blank_check_memory,
.run_algorithm = armv4_5_run_algorithm,
diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c
index 24f3b2eb..90fb45aa 100644
--- a/src/target/arm9tdmi.c
+++ b/src/target/arm9tdmi.c
@@ -73,6 +73,7 @@ target_type_t arm9tdmi_target =
.write_memory = arm7_9_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.checksum_memory = arm7_9_checksum_memory,
+ .blank_check_memory = arm7_9_blank_check_memory,
.run_algorithm = armv4_5_run_algorithm,
diff --git a/src/target/armv7m.c b/src/target/armv7m.c
index 950c5cda..b862cf38 100644
--- a/src/target/armv7m.c
+++ b/src/target/armv7m.c
@@ -596,4 +596,64 @@ int armv7m_checksum_memory(struct target_s *target, u32 address, u32 count, u32*
return ERROR_OK;
}
+int armv7m_blank_check_memory(struct target_s *target, u32 address, u32 count, u32* blank)
+{
+ working_area_t *erase_check_algorithm;
+ reg_param_t reg_params[3];
+ armv7m_algorithm_t armv7m_info;
+ int retval;
+ int i;
+
+ u16 erase_check_code[] =
+ {
+ /* loop: */
+ 0xF810, 0x3B01, /* ldrb r3, [r0], #1 */
+ 0xEA02, 0x0203, /* and r2, r2, r3 */
+ 0x3901, /* subs r1, r1, #1 */
+ 0xD1F9, /* bne loop */
+ /* end: */
+ 0xE7FE, /* b end */
+ };
+
+ /* make sure we have a working area */
+ if (target_alloc_working_area(target, sizeof(erase_check_code), &erase_check_algorithm) != ERROR_OK)
+ {
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ }
+
+ /* convert flash writing code into a buffer in target endianness */
+ for (i = 0; i < (sizeof(erase_check_code)/sizeof(u16)); i++)
+ target_write_u16(target, erase_check_algorithm->address + i*sizeof(u16), erase_check_code[i]);
+
+ armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
+ armv7m_info.core_mode = ARMV7M_MODE_ANY;
+
+ init_reg_param(&reg_params[0], "r0", 32, PARAM_OUT);
+ buf_set_u32(reg_params[0].value, 0, 32, address);
+
+ init_reg_param(&reg_params[1], "r1", 32, PARAM_OUT);
+ buf_set_u32(reg_params[1].value, 0, 32, count);
+
+ init_reg_param(&reg_params[2], "r2", 32, PARAM_IN_OUT);
+ buf_set_u32(reg_params[2].value, 0, 32, 0xff);
+ if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params,
+ erase_check_algorithm->address, erase_check_algorithm->address + (sizeof(erase_check_code)-2), 10000, &armv7m_info)) != ERROR_OK)
+ {
+ destroy_reg_param(&reg_params[0]);
+ destroy_reg_param(&reg_params[1]);
+ destroy_reg_param(&reg_params[2]);
+ target_free_working_area(target, erase_check_algorithm);
+ return 0;
+ }
+
+ *blank = buf_get_u32(reg_params[2].value, 0, 32);
+
+ destroy_reg_param(&reg_params[0]);
+ destroy_reg_param(&reg_params[1]);
+ destroy_reg_param(&reg_params[2]);
+
+ target_free_working_area(target, erase_check_algorithm);
+
+ return ERROR_OK;
+}
diff --git a/src/target/armv7m.h b/src/target/armv7m.h
index ebbf437f..d7d24adb 100644
--- a/src/target/armv7m.h
+++ b/src/target/armv7m.h
@@ -129,6 +129,7 @@ extern int armv7m_invalidate_core_regs(target_t *target);
extern int armv7m_restore_context(target_t *target);
extern int armv7m_checksum_memory(struct target_s *target, u32 address, u32 count, u32* checksum);
+extern int armv7m_blank_check_memory(struct target_s *target, u32 address, u32 count, u32* blank);
/* Thumb mode instructions
*/
diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c
index 58b620b5..845cca5f 100644
--- a/src/target/cortex_m3.c
+++ b/src/target/cortex_m3.c
@@ -81,6 +81,7 @@ target_type_t cortexm3_target =
.write_memory = cortex_m3_write_memory,
.bulk_write_memory = cortex_m3_bulk_write_memory,
.checksum_memory = armv7m_checksum_memory,
+ .blank_check_memory = armv7m_blank_check_memory,
.run_algorithm = armv7m_run_algorithm,
diff --git a/src/target/feroceon.c b/src/target/feroceon.c
index dc216292..a912dbd3 100644
--- a/src/target/feroceon.c
+++ b/src/target/feroceon.c
@@ -83,6 +83,7 @@ target_type_t feroceon_target =
.write_memory = arm926ejs_write_memory,
.bulk_write_memory = feroceon_bulk_write_memory,
.checksum_memory = arm7_9_checksum_memory,
+ .blank_check_memory = arm7_9_blank_check_memory,
.run_algorithm = armv4_5_run_algorithm,
diff --git a/src/target/target.c b/src/target/target.c
index 8c479189..0a44e7b3 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1136,6 +1136,23 @@ int target_checksum_memory(struct target_s *target, u32 address, u32 size, u32*
return retval;
}
+int target_blank_check_memory(struct target_s *target, u32 address, u32 size, u32* blank)
+{
+ int retval;
+ if (!target->type->examined)
+ {
+ LOG_ERROR("Target not examined yet");
+ return ERROR_FAIL;
+ }
+
+ if (target->type->blank_check_memory == 0)
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+
+ retval = target->type->blank_check_memory(target, address, size, blank);
+
+ return retval;
+}
+
int target_read_u32(struct target_s *target, u32 address, u32 *value)
{
u8 value_buf[4];
diff --git a/src/target/target.h b/src/target/target.h
index dd70170d..17ac94a5 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -159,6 +159,7 @@ typedef struct target_type_s
int (*bulk_write_memory)(struct target_s *target, u32 address, u32 count, u8 *buffer);
int (*checksum_memory)(struct target_s *target, u32 address, u32 count, u32* checksum);
+ int (*blank_check_memory)(struct target_s *target, u32 address, u32 count, u32* blank);
/* target break-/watchpoint control
* rw: 0 = write, 1 = read, 2 = access
@@ -283,6 +284,7 @@ extern target_t* get_target_by_num(int num);
extern int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer);
extern int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer);
extern int target_checksum_memory(struct target_s *target, u32 address, u32 size, u32* crc);
+extern int target_blank_check_memory(struct target_s *target, u32 address, u32 size, u32* blank);
/* DANGER!!!!!
*
diff --git a/src/target/xscale.c b/src/target/xscale.c
index 48233243..a83ab70d 100644
--- a/src/target/xscale.c
+++ b/src/target/xscale.c
@@ -111,7 +111,8 @@ target_type_t xscale_target =
.write_memory = xscale_write_memory,
.bulk_write_memory = xscale_bulk_write_memory,
.checksum_memory = xscale_checksum_memory,
-
+ .blank_check_memory = NULL,
+
.run_algorithm = armv4_5_run_algorithm,
.add_breakpoint = xscale_add_breakpoint,