Add target_run_algorithm wrapper:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sun, 31 May 2009 09:38:20 +0000 (09:38 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sun, 31 May 2009 09:38:20 +0000 (09:38 +0000)
- replaces all calls to target->type->run_algorithm.
- add documentation in target_s to warn not to invoke callback directly.

git-svn-id: svn://svn.berlios.de/openocd/trunk@1961 b42882b7-edfa-0310-969c-e2dbd0fdcd60

14 files changed:
src/flash/aduc702x.c
src/flash/cfi.c
src/flash/ecos.c
src/flash/lpc2000.c
src/flash/orion_nand.c
src/flash/pic32mx.c
src/flash/stellaris.c
src/flash/stm32x.c
src/flash/str7x.c
src/flash/str9x.c
src/target/arm7_9_common.c
src/target/armv7m.c
src/target/target.c
src/target/target.h

index 2a9c1c266ebcc60dd89fb9b19a8ad0a88cc132ee..6268b1cde83977e2faa8d5604fc241ddfed03026 100644 (file)
@@ -288,7 +288,7 @@ static int aduc702x_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offse
                buf_set_u32(reg_params[2].value, 0, 32, address);
                buf_set_u32(reg_params[4].value, 0, 32, 0xFFFFF800);
 
-               if ((retval = target->type->run_algorithm(target, 0, NULL, 5, 
+               if ((retval = target_run_algorithm(target, 0, NULL, 5, 
                         reg_params, aduc702x_info->write_algorithm->address, 
                         aduc702x_info->write_algorithm->address + sizeof(aduc702x_flash_write_code) - 4, 
                         10000, &armv4_5_info)) != ERROR_OK)
index ba6c7a8079431062a3219dc013624961058a8df6..432c8cc4b2118a023cf1d88179d438c33e41cd35 100644 (file)
@@ -1227,7 +1227,7 @@ static int cfi_intel_write_block(struct flash_bank_s *bank, u8 *buffer, u32 addr
                LOG_INFO("Write 0x%04x bytes to flash at 0x%08x", thisrun_count, address );
 
                /* Execute algorithm, assume breakpoint for last instruction */
-               retval = target->type->run_algorithm(target, 0, NULL, 7, reg_params,
+               retval = target_run_algorithm(target, 0, NULL, 7, reg_params,
                        cfi_info->write_algorithm->address,
                        cfi_info->write_algorithm->address + target_code_size - sizeof(u32),
                        10000, /* 10s should be enough for max. 32k of data */
@@ -1510,7 +1510,7 @@ static int cfi_spansion_write_block(struct flash_bank_s *bank, u8 *buffer, u32 a
                buf_set_u32(reg_params[8].value, 0, 32, flash_address(bank, 0, pri_ext->_unlock2));
                buf_set_u32(reg_params[9].value, 0, 32, 0x55555555);
 
-               retval = target->type->run_algorithm(target, 0, NULL, 10, reg_params,
+               retval = target_run_algorithm(target, 0, NULL, 10, reg_params,
                                                     cfi_info->write_algorithm->address,
                                                     cfi_info->write_algorithm->address + ((24 * 4) - 4),
                                                     10000, &armv4_5_info);
index e1fa2d66c7a712092604c5121a4b63dacae4334b..2d03edb9dfa666a9b183a79ca25dff9351708cab 100644 (file)
@@ -245,7 +245,7 @@ static int runCode(ecosflash_flash_bank_t *info,
        buf_set_u32(reg_params[2].value, 0, 32, r2);
 
        int retval;
-       if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params,
+       if ((retval = target_run_algorithm(target, 0, NULL, 3, reg_params,
                        codeStart,
                        codeStop, timeout,
                        &armv4_5_info)) != ERROR_OK)
index dbbc37484f59e9705dc44712fe6a759122db5335..c3299bcd01e02a0e2ab1a74adcaf9321f7258fc7 100644 (file)
@@ -298,7 +298,7 @@ static int lpc2000_iap_call(flash_bank_t *bank, int code, u32 param_table[5], u3
        init_reg_param(&reg_params[4], "lr_svc", 32, PARAM_OUT);
        buf_set_u32(reg_params[4].value, 0, 32, lpc2000_info->iap_working_area->address + 0x4);
 
-       target->type->run_algorithm(target, 2, mem_params, 5, reg_params, lpc2000_info->iap_working_area->address, lpc2000_info->iap_working_area->address + 0x4, 10000, &armv4_5_info);
+       target_run_algorithm(target, 2, mem_params, 5, reg_params, lpc2000_info->iap_working_area->address, lpc2000_info->iap_working_area->address + 0x4, 10000, &armv4_5_info);
 
        status_code = buf_get_u32(mem_params[1].value, 0, 32);
        result_table[0] = target_buffer_get_u32(target, mem_params[1].value);
index cf26568d03d2ff3673319bd5969bcf20ea997b02..5ec1c25cde5c41b6d9941c300cf0fae94a53841e 100644 (file)
@@ -162,7 +162,7 @@ static int orion_nand_fast_block_write(struct nand_device_s *device, u8 *data, i
        buf_set_u32(reg_params[1].value, 0, 32, target_buf);
        buf_set_u32(reg_params[2].value, 0, 32, size);
 
-       retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params,
+       retval = target_run_algorithm(target, 0, NULL, 3, reg_params,
                                        hw->copy_area->address,
                                        hw->copy_area->address + code_size - 4,
                                        1000, &algo);
index 2a5ce64186a2ce2e512236d73868288b8d5ce20d..b45902cd5b49f0b902d7897f002f42037cc7d0f8 100644 (file)
@@ -419,7 +419,7 @@ static int pic32mx_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset
                buf_set_u32(reg_params[1].value, 0, 32, address);
                buf_set_u32(reg_params[2].value, 0, 32, buffer_size/4);
 
-               if ((retval = target->type->run_algorithm(target, 0, NULL, 4, reg_params, pic32mx_info->write_algorithm->address, \
+               if ((retval = target_run_algorithm(target, 0, NULL, 4, reg_params, pic32mx_info->write_algorithm->address, \
                                pic32mx_info->write_algorithm->address + (sizeof(pic32mx_flash_write_code) - 10), 10000, &armv7m_info)) != ERROR_OK)
                {
                        LOG_ERROR("error executing pic32mx flash write algorithm");
index 38ded4f1ae4bebaee3ec91f25616dc268719cffc..001b0176cd8e4a6119b77af85b761b8e04c4df88 100644 (file)
@@ -779,7 +779,7 @@ static int stellaris_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offs
                buf_set_u32(reg_params[2].value, 0, 32, 4*thisrun_count);
                LOG_INFO("Algorithm flash write %i words to 0x%x, %i remaining", thisrun_count, address, wcount);
                LOG_DEBUG("Algorithm flash write %i words to 0x%x, %i remaining", thisrun_count, address, wcount);
-               if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params, write_algorithm->address, write_algorithm->address + sizeof(stellaris_write_code)-10, 10000, &armv7m_info)) != ERROR_OK)
+               if ((retval = target_run_algorithm(target, 0, NULL, 3, reg_params, write_algorithm->address, write_algorithm->address + sizeof(stellaris_write_code)-10, 10000, &armv7m_info)) != ERROR_OK)
                {
                        LOG_ERROR("error executing stellaris flash write algorithm");
                        retval = ERROR_FLASH_OPERATION_FAILED;
index 2a3b764ca3d053055bbca1bcde6ba703b809d297..1f3460b1c9ffbedeba32891196cce82b1da2109a 100644 (file)
@@ -554,7 +554,7 @@ static int stm32x_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset,
                buf_set_u32(reg_params[1].value, 0, 32, address);
                buf_set_u32(reg_params[2].value, 0, 32, thisrun_count);
                
-               if ((retval = target->type->run_algorithm(target, 0, NULL, 4, reg_params, stm32x_info->write_algorithm->address, \
+               if ((retval = target_run_algorithm(target, 0, NULL, 4, reg_params, stm32x_info->write_algorithm->address, \
                                stm32x_info->write_algorithm->address + (sizeof(stm32x_flash_write_code) - 10), 10000, &armv7m_info)) != ERROR_OK)
                {
                        LOG_ERROR("error executing stm32x flash write algorithm");
index a1cb963695a19f00e97fc3250798b9dcf14536f3..88f4f9eb7f503a62e38a7504f4fc162b9c713b4d 100644 (file)
@@ -429,7 +429,7 @@ static int str7x_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset,
                buf_set_u32(reg_params[3].value, 0, 32, thisrun_count);
                buf_set_u32(reg_params[5].value, 0, 32, str7x_info->busy_bits);
        
-               if ((retval = target->type->run_algorithm(target, 0, NULL, 6, reg_params, str7x_info->write_algorithm->address, str7x_info->write_algorithm->address + (19 * 4), 10000, &armv4_5_info)) != ERROR_OK)
+               if ((retval = target_run_algorithm(target, 0, NULL, 6, reg_params, str7x_info->write_algorithm->address, str7x_info->write_algorithm->address + (19 * 4), 10000, &armv4_5_info)) != ERROR_OK)
                {
                        LOG_ERROR("error executing str7x flash write algorithm");
                        retval = ERROR_FLASH_OPERATION_FAILED;
index 7de98b12309fac092c48110b0d672ced7b4df85b..3566bf9c61b05c2ede3c7a6202d85fb0a1335ca4 100644 (file)
@@ -463,7 +463,7 @@ static int str9x_write_block(struct flash_bank_s *bank,
                buf_set_u32(reg_params[1].value, 0, 32, address);
                buf_set_u32(reg_params[2].value, 0, 32, thisrun_count);
 
-               if ((retval = target->type->run_algorithm(target, 0, NULL, 4, reg_params, str9x_info->write_algorithm->address, str9x_info->write_algorithm->address + (18 * 4), 10000, &armv4_5_info)) != ERROR_OK)
+               if ((retval = target_run_algorithm(target, 0, NULL, 4, reg_params, str9x_info->write_algorithm->address, str9x_info->write_algorithm->address + (18 * 4), 10000, &armv4_5_info)) != ERROR_OK)
                {
                        LOG_ERROR("error executing str9x flash write algorithm");
                        retval = ERROR_FLASH_OPERATION_FAILED;
index 4db26e92a35461aafd3d7dc2a55914a622559b54..0d202d1ae46124bcb46e0599582f18389149c819 100644 (file)
@@ -2747,7 +2747,7 @@ int arm7_9_checksum_memory(struct target_s *target, u32 address, u32 count, u32*
        buf_set_u32(reg_params[0].value, 0, 32, address);
        buf_set_u32(reg_params[1].value, 0, 32, count);
 
-       if ((retval = target->type->run_algorithm(target, 0, NULL, 2, reg_params,
+       if ((retval = target_run_algorithm(target, 0, NULL, 2, reg_params,
                crc_algorithm->address, crc_algorithm->address + (sizeof(arm7_9_crc_code) - 8), 20000, &armv4_5_info)) != ERROR_OK)
        {
                LOG_ERROR("error executing arm7_9 crc algorithm");
@@ -2812,7 +2812,7 @@ int arm7_9_blank_check_memory(struct target_s *target, u32 address, u32 count, u
        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,
+       if ((retval = target_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]);
index a73e60eaea975ff2839a85477c428246b428beae..629ac463bfdb016602c1ba9a742a6b1790f8fd04 100644 (file)
@@ -613,7 +613,7 @@ int armv7m_checksum_memory(struct target_s *target, u32 address, u32 count, u32*
        buf_set_u32(reg_params[0].value, 0, 32, address);
        buf_set_u32(reg_params[1].value, 0, 32, count);
 
-       if ((retval = target->type->run_algorithm(target, 0, NULL, 2, reg_params,
+       if ((retval = target_run_algorithm(target, 0, NULL, 2, reg_params,
                crc_algorithm->address, crc_algorithm->address + (sizeof(cortex_m3_crc_code)-6), 20000, &armv7m_info)) != ERROR_OK)
        {
                LOG_ERROR("error executing cortex_m3 crc algorithm");
@@ -674,7 +674,7 @@ int armv7m_blank_check_memory(struct target_s *target, u32 address, u32 count, u
        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,
+       if ((retval = target_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]);
index d5a40195af2eb9247c8b5dc199ce84e9d81f5088..71eb9d2b104f4c67348f4daea369df7cb9c333ba 100644 (file)
@@ -537,6 +537,17 @@ int target_write_memory(struct target_s *target,
        return target->type->write_memory(target, address, size, count, buffer);
 }
 
+int target_run_algorithm(struct target_s *target,
+               int num_mem_params, mem_param_t *mem_params,
+               int num_reg_params, reg_param_t *reg_param,
+               u32 entry_point, u32 exit_point,
+               int timeout_ms, void *arch_info)
+{
+       return target->type->run_algorithm(target,
+                       num_mem_params, mem_params, num_reg_params, reg_param,
+                       entry_point, exit_point, timeout_ms, arch_info);
+}
+
 
 int target_init(struct command_context_s *cmd_ctx)
 {
index 2214c06e65e1c656f6942194fb8aae0573620774..c319a25b2ea728a3656378918af7cba28be82e32 100644 (file)
@@ -204,6 +204,10 @@ typedef struct target_type_s
 
        /* target algorithm support */
        int (*run_algorithm_imp)(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info);
+       /**
+        * Target algorithm support.  Do @b not call this method directly,
+        * use target_run_algorithm() instead.
+        */
        int (*run_algorithm)(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info);
 
        int (*register_commands)(struct command_context_s *cmd_ctx);
@@ -379,6 +383,17 @@ extern target_t* get_current_target(struct command_context_s *cmd_ctx);
 extern int get_num_by_target(target_t *query_target);
 extern target_t *get_target(const char *id);
 
+/**
+ * Run an algorithm on the @a target given.
+ *
+ * This routine is a wrapper for target->type->run_algorithm.
+ */
+extern int target_run_algorithm(struct target_s *target,
+               int num_mem_params, mem_param_t *mem_params,
+               int num_reg_params, reg_param_t *reg_param,
+               u32 entry_point, u32 exit_point,
+               int timeout_ms, void *arch_info);
+
 /**
  * Read @count items of @a size bytes from the memory of @a target at
  * the @a address given.

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)