#include "image.h"
-
-#include "lpc2900.h"
+#include "flash.h"
#include "binarybuffer.h"
#include "armv4_5.h"
+#include "algorithm.h"
/* 1024 bytes */
};
-static uint32_t lpc2900_wait_status(flash_bank_t *bank, uint32_t mask, int timeout);
-static void lpc2900_setup(struct flash_bank_s *bank);
-static uint32_t lpc2900_is_ready(struct flash_bank_s *bank);
-static uint32_t lpc2900_read_security_status(struct flash_bank_s *bank);
-static uint32_t lpc2900_run_bist128(struct flash_bank_s *bank,
+static uint32_t lpc2900_wait_status(struct flash_bank *bank, uint32_t mask, int timeout);
+static void lpc2900_setup(struct flash_bank *bank);
+static uint32_t lpc2900_is_ready(struct flash_bank *bank);
+static uint32_t lpc2900_read_security_status(struct flash_bank *bank);
+static uint32_t lpc2900_run_bist128(struct flash_bank *bank,
uint32_t addr_from, uint32_t addr_to,
uint32_t (*signature)[4] );
-static uint32_t lpc2900_address2sector(struct flash_bank_s *bank, uint32_t offset);
+static uint32_t lpc2900_address2sector(struct flash_bank *bank, uint32_t offset);
static uint32_t lpc2900_calc_tr( uint32_t clock, uint32_t time );
* @param[in] mask Mask to be used for INT_STATUS
* @param[in] timeout Timeout in ms
*/
-static uint32_t lpc2900_wait_status( flash_bank_t *bank,
+static uint32_t lpc2900_wait_status( struct flash_bank *bank,
uint32_t mask,
int timeout )
{
uint32_t int_status;
- target_t *target = bank->target;
+ struct target *target = bank->target;
do
*
* @param bank Pointer to the flash bank descriptor
*/
-static void lpc2900_setup( struct flash_bank_s *bank )
+static void lpc2900_setup( struct flash_bank *bank )
{
uint32_t fcra;
struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv;
* Must have been successfully probed.
* Must be halted.
*/
-static uint32_t lpc2900_is_ready( struct flash_bank_s *bank )
+static uint32_t lpc2900_is_ready( struct flash_bank *bank )
{
struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv;
*
* @param bank Pointer to the flash bank descriptor
*/
-static uint32_t lpc2900_read_security_status( struct flash_bank_s *bank )
+static uint32_t lpc2900_read_security_status( struct flash_bank *bank )
{
uint32_t status;
if( (status = lpc2900_is_ready( bank )) != ERROR_OK )
return status;
}
- target_t *target = bank->target;
+ struct target *target = bank->target;
/* Enable ISS access */
target_write_u32(target, FCTR, FCTR_FS_CS | FCTR_FS_WEB | FCTR_FS_ISS);
* @param addr_to
* @param signature
*/
-static uint32_t lpc2900_run_bist128(struct flash_bank_s *bank,
+static uint32_t lpc2900_run_bist128(struct flash_bank *bank,
uint32_t addr_from,
uint32_t addr_to,
uint32_t (*signature)[4] )
{
- target_t *target = bank->target;
+ struct target *target = bank->target;
/* Clear END_OF_MISR interrupt status */
target_write_u32( target, INT_CLR_STATUS, INTSRC_END_OF_MISR );
* @param bank Pointer to the flash bank descriptor
* @param offset Offset address relative to bank start
*/
-static uint32_t lpc2900_address2sector( struct flash_bank_s *bank,
+static uint32_t lpc2900_address2sector( struct flash_bank *bank,
uint32_t offset )
{
uint32_t address = bank->base + offset;
* @param pagenum Page number (0...7)
* @param page Page array (FLASH_PAGE_SIZE bytes)
*/
-static int lpc2900_write_index_page( struct flash_bank_s *bank,
+static int lpc2900_write_index_page( struct flash_bank *bank,
int pagenum,
uint8_t (*page)[FLASH_PAGE_SIZE] )
{
}
/* Get target, and check if it's halted */
- target_t *target = bank->target;
+ struct target *target = bank->target;
if( target->state != TARGET_HALTED )
{
LOG_ERROR( "Target not halted" );
return ERROR_FLASH_BANK_INVALID;
}
- flash_bank_t *bank;
- int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+ struct flash_bank *bank;
+ int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval)
return retval;
return ERROR_COMMAND_SYNTAX_ERROR;
}
- flash_bank_t *bank;
- int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+ struct flash_bank *bank;
+ int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval)
return retval;
lpc2900_info->risky = 0;
/* Get target, and check if it's halted */
- target_t *target = bank->target;
+ struct target *target = bank->target;
if( target->state != TARGET_HALTED )
{
LOG_ERROR( "Target not halted" );
return ERROR_COMMAND_SYNTAX_ERROR;
}
- flash_bank_t *bank;
- int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+ struct flash_bank *bank;
+ int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval)
return retval;
return ERROR_COMMAND_SYNTAX_ERROR;
}
- flash_bank_t *bank;
- int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+ struct flash_bank *bank;
+ int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval)
return retval;
lpc2900_info->risky = 0;
/* Get target, and check if it's halted */
- target_t *target = bank->target;
+ struct target *target = bank->target;
if (target->state != TARGET_HALTED)
{
LOG_ERROR("Target not halted");
}
/* The image will always start at offset 0 */
- image_t image;
+ struct image image;
image.base_address_set = 1;
image.base_address = 0;
image.start_address_set = 0;
}
/* Get the bank descriptor */
- flash_bank_t *bank;
- int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+ struct flash_bank *bank;
+ int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval)
return retval;
}
/* Get the bank descriptor */
- flash_bank_t *bank;
- int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+ struct flash_bank *bank;
+ int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval)
return retval;
/**
* Register private command handlers.
*/
-static int lpc2900_register_commands(struct command_context_s *cmd_ctx)
+static int lpc2900_register_commands(struct command_context *cmd_ctx)
{
- command_t *lpc2900_cmd = register_command(cmd_ctx, NULL, "lpc2900",
+ struct command *lpc2900_cmd = register_command(cmd_ctx, NULL, "lpc2900",
NULL, COMMAND_ANY, NULL);
register_command(
* @param first First sector to be erased
* @param last Last sector (including) to be erased
*/
-static int lpc2900_erase(struct flash_bank_s *bank, int first, int last)
+static int lpc2900_erase(struct flash_bank *bank, int first, int last)
{
uint32_t status;
int sector;
int last_unsecured_sector;
- target_t *target = bank->target;
+ struct target *target = bank->target;
struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv;
-static int lpc2900_protect(struct flash_bank_s *bank, int set, int first, int last)
+static int lpc2900_protect(struct flash_bank *bank, int set, int first, int last)
{
/* This command is not supported.
* "Protection" in LPC2900 terms is handled transparently. Sectors will
* @param offset Start address (relative to bank start)
* @param count Number of bytes to be programmed
*/
-static int lpc2900_write(struct flash_bank_s *bank, uint8_t *buffer,
+static int lpc2900_write(struct flash_bank *bank, uint8_t *buffer,
uint32_t offset, uint32_t count)
{
uint8_t page[FLASH_PAGE_SIZE];
uint32_t status;
uint32_t num_bytes;
- target_t *target = bank->target;
+ struct target *target = bank->target;
struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv;
int sector;
int retval;
/* Try working area allocation. Start with a large buffer, and try with
reduced size if that fails. */
- working_area_t *warea;
+ struct working_area *warea;
uint32_t buffer_size = lpc2900_info->max_ram_block - 1 * KiB;
while( (retval = target_alloc_working_area(target,
buffer_size + target_code_size,
if( warea )
{
- reg_param_t reg_params[5];
- armv4_5_algorithm_t armv4_5_info;
+ struct reg_param reg_params[5];
+ struct armv4_5_algorithm armv4_5_info;
/* We can use target mode. Download the algorithm. */
retval = target_write_buffer( target,
*
* @param bank Pointer to the flash bank descriptor
*/
-static int lpc2900_probe(struct flash_bank_s *bank)
+static int lpc2900_probe(struct flash_bank *bank)
{
struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv;
- target_t *target = bank->target;
+ struct target *target = bank->target;
int i = 0;
uint32_t offset;
*
* @param bank Pointer to the flash bank descriptor
*/
-static int lpc2900_erase_check(struct flash_bank_s *bank)
+static int lpc2900_erase_check(struct flash_bank *bank)
{
uint32_t status = lpc2900_is_ready(bank);
if (status != ERROR_OK)
*
* @param bank Pointer to the flash bank descriptor
*/
-static int lpc2900_protect_check(struct flash_bank_s *bank)
+static int lpc2900_protect_check(struct flash_bank *bank)
{
return lpc2900_read_security_status(bank);
}
* @param buf Buffer to take the string
* @param buf_size Maximum number of characters that the buffer can take
*/
-static int lpc2900_info(struct flash_bank_s *bank, char *buf, int buf_size)
+static int lpc2900_info(struct flash_bank *bank, char *buf, int buf_size)
{
snprintf(buf, buf_size, "lpc2900 flash driver");