]> git.sur5r.net Git - openocd/blobdiff - src/flash/ocl.c
David Brownell <david-b@pacbell.net>:
[openocd] / src / flash / ocl.c
index 4f3b506cbbb361ff48dd939fa287e3ffaf0f2369..b9028b1e8d6a1119bcdb07fb7c7ed128fd01f056 100644 (file)
 #include "config.h"
 #endif
 
-#include "replacements.h"
-
 #include "ocl.h"
-
 #include "flash.h"
-#include "target.h"
-#include "log.h"
-#include "binarybuffer.h"
-#include "types.h"
 #include "embeddedice.h"
-#include "arm7_9_common.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-int ocl_register_commands(struct command_context_s *cmd_ctx);
-int ocl_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
-int ocl_erase(struct flash_bank_s *bank, int first, int last);
-int ocl_protect(struct flash_bank_s *bank, int set, int first, int last);
-int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
-int ocl_probe(struct flash_bank_s *bank);
-int ocl_erase_check(struct flash_bank_s *bank);
-int ocl_protect_check(struct flash_bank_s *bank);
-int ocl_info(struct flash_bank_s *bank, char *buf, int buf_size);
-int ocl_auto_probe(struct flash_bank_s *bank);
+
+
+static int ocl_register_commands(struct command_context_s *cmd_ctx);
+static int ocl_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
+static int ocl_erase(struct flash_bank_s *bank, int first, int last);
+static int ocl_protect(struct flash_bank_s *bank, int set, int first, int last);
+static int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
+static int ocl_probe(struct flash_bank_s *bank);
+static int ocl_erase_check(struct flash_bank_s *bank);
+static int ocl_protect_check(struct flash_bank_s *bank);
+static int ocl_info(struct flash_bank_s *bank, char *buf, int buf_size);
+static int ocl_auto_probe(struct flash_bank_s *bank);
 
 flash_driver_t ocl_flash =
 {
@@ -63,35 +52,30 @@ flash_driver_t ocl_flash =
        .auto_probe = ocl_auto_probe
 };
 
-
 typedef struct ocl_priv_s
 {
        arm_jtag_t *jtag_info;
-       int buflen;
-       int bufalign;
+       unsigned int buflen;
+       unsigned int bufalign;
 } ocl_priv_t;
 
-
-int ocl_register_commands(struct command_context_s *cmd_ctx)
+static int ocl_register_commands(struct command_context_s *cmd_ctx)
 {
        return ERROR_OK;
 }
 
-
-int ocl_erase_check(struct flash_bank_s *bank)
+static int ocl_erase_check(struct flash_bank_s *bank)
 {
        return ERROR_OK;
 }
 
-
-int ocl_protect_check(struct flash_bank_s *bank)
+static int ocl_protect_check(struct flash_bank_s *bank)
 {
        return ERROR_OK;
 }
 
-
 /* flash_bank ocl 0 0 0 0 <target#> */
-int ocl_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
+static int ocl_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
 {
        int retval;
        armv4_5_common_t *armv4_5;
@@ -115,8 +99,7 @@ int ocl_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **
        return ERROR_OK;
 }
 
-
-int ocl_erase(struct flash_bank_s *bank, int first, int last)
+static int ocl_erase(struct flash_bank_s *bank, int first, int last)
 {
        ocl_priv_t *ocl = bank->driver_priv;
        int retval;
@@ -125,13 +108,13 @@ int ocl_erase(struct flash_bank_s *bank, int first, int last)
        /* check preconditions */
        if (bank->num_sectors == 0)
                return ERROR_FLASH_BANK_NOT_PROBED;
-               
+
        if (bank->target->state != TARGET_RUNNING)
        {
                LOG_ERROR("target has to be running to communicate with the loader");
                return ERROR_TARGET_NOT_RUNNING;
        }
-               
+
        if ((first == 0) && (last == bank->num_sectors - 1))
        {
                dcc_buffer[0] = OCL_ERASE_ALL;
@@ -162,23 +145,21 @@ int ocl_erase(struct flash_bank_s *bank, int first, int last)
        if (dcc_buffer[1] != OCL_CMD_DONE)
        {
                if (dcc_buffer[0] == OCL_ERASE_ALL)
-                       LOG_ERROR("loader response to OCL_ERASE_ALL 0x%08lX", dcc_buffer[1]);
+                       LOG_ERROR("loader response to OCL_ERASE_ALL 0x%08X", dcc_buffer[1]);
                else
-                       LOG_ERROR("loader response to OCL_ERASE_BLOCK 0x%08lX", dcc_buffer[1]);
+                       LOG_ERROR("loader response to OCL_ERASE_BLOCK 0x%08X", dcc_buffer[1]);
                return ERROR_FLASH_OPERATION_FAILED;
        }
 
        return ERROR_OK;
 }
 
-
-int ocl_protect(struct flash_bank_s *bank, int set, int first, int last)
+static int ocl_protect(struct flash_bank_s *bank, int set, int first, int last)
 {
        return ERROR_OK;
 }
 
-
-int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
+static int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
 {
        ocl_priv_t *ocl = bank->driver_priv;
        int retval;
@@ -187,7 +168,7 @@ int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
        int byteofs;
        int runlen;
        u32 chksum;
-       
+
        int i;
 
        /* check preconditions */
@@ -246,7 +227,7 @@ int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                        chksum ^= *(dcc_bufptr++);
 
                *(dcc_bufptr++) = chksum;
-               
+
                /* send the data */
                if ((retval = embeddedice_send(ocl->jtag_info, dcc_buffer, dcc_bufptr-dcc_buffer)) != ERROR_OK)
                {
@@ -272,7 +253,7 @@ int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
 
                if (dcc_buffer[0] != OCL_CMD_DONE)
                {
-                       LOG_ERROR("loader response to OCL_FLASH_BLOCK 0x%08lX", dcc_buffer[0]);
+                       LOG_ERROR("loader response to OCL_FLASH_BLOCK 0x%08X", dcc_buffer[0]);
                        free(dcc_buffer);
                        return ERROR_FLASH_OPERATION_FAILED;
                }
@@ -285,8 +266,7 @@ int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
        return ERROR_OK;
 }
 
-
-int ocl_probe(struct flash_bank_s *bank)
+static int ocl_probe(struct flash_bank_s *bank)
 {
        ocl_priv_t *ocl = bank->driver_priv;
        int retval;
@@ -312,10 +292,10 @@ int ocl_probe(struct flash_bank_s *bank)
        /* receive response */
        if ((retval = embeddedice_receive(ocl->jtag_info, dcc_buffer, 1) != ERROR_OK))
                return retval;
-               
+
        if (dcc_buffer[0] != OCL_CMD_DONE)
        {
-               LOG_ERROR("loader response to OCL_PROBE 0x%08lX", dcc_buffer[0]);
+               LOG_ERROR("loader response to OCL_PROBE 0x%08X", dcc_buffer[0]);
                return ERROR_FLASH_OPERATION_FAILED;
        }
 
@@ -384,14 +364,12 @@ int ocl_probe(struct flash_bank_s *bank)
        return ERROR_OK;
 }
 
-
-int ocl_info(struct flash_bank_s *bank, char *buf, int buf_size)
+static int ocl_info(struct flash_bank_s *bank, char *buf, int buf_size)
 {
        return ERROR_OK;
 }
 
-
-int ocl_auto_probe(struct flash_bank_s *bank)
+static int ocl_auto_probe(struct flash_bank_s *bank)
 {
        ocl_priv_t *ocl = bank->driver_priv;