]> git.sur5r.net Git - openocd/blobdiff - src/flash/str7x.c
Eliminate MixedCaps symbol from public JTAG TAP API:
[openocd] / src / flash / str7x.c
index 797fe2bc52b38a7c898831aa54d12ec5c6df9ef9..88f4f9eb7f503a62e38a7504f4fc162b9c713b4d 100644 (file)
 #include "config.h"
 #endif
 
-#include "replacements.h"
-
 #include "str7x.h"
-#include "flash.h"
-#include "target.h"
-#include "log.h"
 #include "armv4_5.h"
-#include "algorithm.h"
 #include "binarybuffer.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
 
 str7x_mem_layout_t mem_layout_str7bank0[] = {
        {0x00000000, 0x02000, 0x01},
@@ -54,17 +45,17 @@ str7x_mem_layout_t mem_layout_str7bank1[] = {
        {0x00002000, 0x02000, 0x20000}
 };
 
-int str7x_register_commands(struct command_context_s *cmd_ctx);
-int str7x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
-int str7x_erase(struct flash_bank_s *bank, int first, int last);
-int str7x_protect(struct flash_bank_s *bank, int set, int first, int last);
-int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
-int str7x_probe(struct flash_bank_s *bank);
-int str7x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-int str7x_protect_check(struct flash_bank_s *bank);
-int str7x_info(struct flash_bank_s *bank, char *buf, int buf_size);
+static int str7x_register_commands(struct command_context_s *cmd_ctx);
+static int str7x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
+static int str7x_erase(struct flash_bank_s *bank, int first, int last);
+static int str7x_protect(struct flash_bank_s *bank, int set, int first, int last);
+static int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
+static int str7x_probe(struct flash_bank_s *bank);
+//static int str7x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+static int str7x_protect_check(struct flash_bank_s *bank);
+static int str7x_info(struct flash_bank_s *bank, char *buf, int buf_size);
 
-int str7x_handle_disable_jtag_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+static int str7x_handle_disable_jtag_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 
 flash_driver_t str7x_flash =
 {
@@ -81,7 +72,7 @@ flash_driver_t str7x_flash =
        .info = str7x_info
 };
 
-int str7x_register_commands(struct command_context_s *cmd_ctx)
+static int str7x_register_commands(struct command_context_s *cmd_ctx)
 {
        command_t *str7x_cmd = register_command(cmd_ctx, NULL, "str7x", NULL, COMMAND_ANY, NULL);
        
@@ -91,13 +82,13 @@ int str7x_register_commands(struct command_context_s *cmd_ctx)
        return ERROR_OK;
 }
 
-int str7x_get_flash_adr(struct flash_bank_s *bank, u32 reg)
+static int str7x_get_flash_adr(struct flash_bank_s *bank, u32 reg)
 {
        str7x_flash_bank_t *str7x_info = bank->driver_priv;
        return (str7x_info->register_base | reg);
 }
 
-int str7x_build_block_list(struct flash_bank_s *bank)
+static int str7x_build_block_list(struct flash_bank_s *bank)
 {
        str7x_flash_bank_t *str7x_info = bank->driver_priv;
 
@@ -155,7 +146,7 @@ int str7x_build_block_list(struct flash_bank_s *bank)
 
 /* flash bank str7x <base> <size> 0 0 <target#> <str71_variant>
  */
-int str7x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
+static int str7x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
 {
        str7x_flash_bank_t *str7x_info;
        
@@ -200,7 +191,7 @@ int str7x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char
        return ERROR_OK;
 }
 
-u32 str7x_status(struct flash_bank_s *bank)
+static u32 str7x_status(struct flash_bank_s *bank)
 {
        target_t *target = bank->target;
        u32 retval;
@@ -210,7 +201,7 @@ u32 str7x_status(struct flash_bank_s *bank)
        return retval;
 }
 
-u32 str7x_result(struct flash_bank_s *bank)
+static u32 str7x_result(struct flash_bank_s *bank)
 {
        target_t *target = bank->target;
        u32 retval;
@@ -220,7 +211,7 @@ u32 str7x_result(struct flash_bank_s *bank)
        return retval;
 }
 
-int str7x_protect_check(struct flash_bank_s *bank)
+static int str7x_protect_check(struct flash_bank_s *bank)
 {
        str7x_flash_bank_t *str7x_info = bank->driver_priv;
        target_t *target = bank->target;
@@ -247,7 +238,7 @@ int str7x_protect_check(struct flash_bank_s *bank)
        return ERROR_OK;
 }
 
-int str7x_erase(struct flash_bank_s *bank, int first, int last)
+static int str7x_erase(struct flash_bank_s *bank, int first, int last)
 {
        str7x_flash_bank_t *str7x_info = bank->driver_priv;
        target_t *target = bank->target;
@@ -283,7 +274,7 @@ int str7x_erase(struct flash_bank_s *bank, int first, int last)
        target_write_u32(target, str7x_get_flash_adr(bank, FLASH_CR0), cmd);
        
        while (((retval = str7x_status(bank)) & str7x_info->busy_bits)){
-               usleep(1000);
+               alive_sleep(1);
        }
        
        retval = str7x_result(bank);
@@ -300,7 +291,7 @@ int str7x_erase(struct flash_bank_s *bank, int first, int last)
        return ERROR_OK;
 }
 
-int str7x_protect(struct flash_bank_s *bank, int set, int first, int last)
+static int str7x_protect(struct flash_bank_s *bank, int set, int first, int last)
 {
        str7x_flash_bank_t *str7x_info = bank->driver_priv;
        target_t *target = bank->target;
@@ -339,7 +330,7 @@ int str7x_protect(struct flash_bank_s *bank, int set, int first, int last)
        target_write_u32(target, str7x_get_flash_adr(bank, FLASH_CR0), cmd);
        
        while (((retval = str7x_status(bank)) & str7x_info->busy_bits)){
-               usleep(1000);
+               alive_sleep(1);
        }
        
        retval = str7x_result(bank);
@@ -354,7 +345,7 @@ int str7x_protect(struct flash_bank_s *bank, int set, int first, int last)
        return ERROR_OK;
 }
 
-int str7x_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
+static int str7x_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
 {
        str7x_flash_bank_t *str7x_info = bank->driver_priv;
        target_t *target = bank->target;
@@ -438,7 +429,7 @@ int str7x_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 cou
                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;
@@ -469,7 +460,7 @@ int str7x_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 cou
        return retval;
 }
 
-int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
+static int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
 {
        target_t *target = bank->target;
        str7x_flash_bank_t *str7x_info = bank->driver_priv;
@@ -478,7 +469,7 @@ int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
        u32 address = bank->base + offset;
        u32 bytes_written = 0;
        u32 cmd;
-       u32 retval;
+       int retval;
        u32 check_address = offset;
        int i;
        
@@ -555,11 +546,11 @@ int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                target_write_u32(target, str7x_get_flash_adr(bank, FLASH_AR), address);
                
                /* data word 1 */
-               target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR0), 4, 1, buffer + bytes_written);
+               target_write_memory(target, str7x_get_flash_adr(bank, FLASH_DR0), 4, 1, buffer + bytes_written);
                bytes_written += 4;
                
                /* data word 2 */
-               target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR1), 4, 1, buffer + bytes_written);
+               target_write_memory(target, str7x_get_flash_adr(bank, FLASH_DR1), 4, 1, buffer + bytes_written);
                bytes_written += 4;
                
                /* start programming cycle */
@@ -568,7 +559,7 @@ int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                
                while (((retval = str7x_status(bank)) & str7x_info->busy_bits))
                {
-                       usleep(1000);
+                       alive_sleep(1);
                }
                
                retval = str7x_result(bank);
@@ -602,11 +593,11 @@ int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                target_write_u32(target, str7x_get_flash_adr(bank, FLASH_AR), address);
                
                /* data word 1 */
-               target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR0), 4, 1, last_dword);
+               target_write_memory(target, str7x_get_flash_adr(bank, FLASH_DR0), 4, 1, last_dword);
                bytes_written += 4;
                
                /* data word 2 */
-               target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR1), 4, 1, last_dword + 4);
+               target_write_memory(target, str7x_get_flash_adr(bank, FLASH_DR1), 4, 1, last_dword + 4);
                bytes_written += 4;
                
                /* start programming cycle */
@@ -615,7 +606,7 @@ int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                
                while (((retval = str7x_status(bank)) & str7x_info->busy_bits))
                {
-                       usleep(1000);
+                       alive_sleep(1);
                }
                
                retval = str7x_result(bank);
@@ -629,23 +620,25 @@ int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
        return ERROR_OK;
 }
 
-int str7x_probe(struct flash_bank_s *bank)
+static int str7x_probe(struct flash_bank_s *bank)
 {
        return ERROR_OK;
 }
 
-int str7x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+#if 0
+static int str7x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
        return ERROR_OK;
 }
+#endif
 
-int str7x_info(struct flash_bank_s *bank, char *buf, int buf_size)
+static int str7x_info(struct flash_bank_s *bank, char *buf, int buf_size)
 {
        snprintf(buf, buf_size, "str7x flash driver info" );
        return ERROR_OK;
 }
 
-int str7x_handle_disable_jtag_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+static int str7x_handle_disable_jtag_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
        flash_bank_t *bank;
        target_t *target = NULL;
@@ -717,4 +710,3 @@ int str7x_handle_disable_jtag_command(struct command_context_s *cmd_ctx, char *c
        
        return ERROR_OK;
 }
-