- Replace ')\(=\)\(\w\)' with ') \1 \2'. - Replace '\(\w\)\(=\)(' with '\1 \2 ('. - Replace '\(\w\)\(=\)\(\w\)' with '\1 \2 \3'. git-svn-id: svn://svn.berlios.de/openocd/trunk@2372 b42882b7-edfa-0310-969c-e2dbd0fdcd60tags/v0.2.0
@@ -975,13 +975,13 @@ int main(int argc, char *argv[]) | |||
} | |||
mkdir(zylin_config_dir, 0777); | |||
char *dirname=alloc_printf("%s/target", zylin_config_dir); | |||
char *dirname = alloc_printf("%s/target", zylin_config_dir); | |||
mkdir(dirname, 0777); | |||
free(dirname); | |||
dirname=alloc_printf("%s/board", zylin_config_dir); | |||
dirname = alloc_printf("%s/board", zylin_config_dir); | |||
mkdir(dirname, 0777); | |||
free(dirname); | |||
dirname=alloc_printf("%s/event", zylin_config_dir); | |||
dirname = alloc_printf("%s/event", zylin_config_dir); | |||
mkdir(dirname, 0777); | |||
free(dirname); | |||
@@ -1036,7 +1036,7 @@ int main(int argc, char *argv[]) | |||
if (logAllToSerial) | |||
{ | |||
diag_printf( | |||
"%s/logserial=1 => sending log output to serial port using \"debug_level 3\" as default.\n", zylin_config_dir); | |||
"%s/logserial = 1 => sending log output to serial port using \"debug_level 3\" as default.\n", zylin_config_dir); | |||
command_run_line(cmd_ctx, "debug_level 3"); | |||
} | |||
@@ -232,10 +232,10 @@ static void at91sam7_set_flash_mode(flash_bank_t *bank, int mode) | |||
if (fmcn > 0xFF) | |||
fmcn = 0xFF; | |||
/* Only allow fmcn=0 if clock period is > 30 us = 33kHz. */ | |||
/* Only allow fmcn = 0 if clock period is > 30 us = 33kHz. */ | |||
if (at91sam7_info->mck_freq <= 33333ul) | |||
fmcn = 0; | |||
/* Only allow fws=0 if clock frequency is < 30 MHz. */ | |||
/* Only allow fws = 0 if clock frequency is < 30 MHz. */ | |||
if (at91sam7_info->mck_freq > 30000000ul) | |||
fws = 1; | |||
@@ -550,7 +550,7 @@ static int at91sam7_read_part_info(struct flash_bank_s *bank) | |||
/* calculate bank size */ | |||
bank_size = sectors_num * pages_per_sector * page_size; | |||
for (bnk=0; bnk<banks_num; bnk++) | |||
for (bnk = 0; bnk<banks_num; bnk++) | |||
{ | |||
if (bnk > 0) | |||
{ | |||
@@ -575,7 +575,7 @@ static int at91sam7_read_part_info(struct flash_bank_s *bank) | |||
/* allocate sectors */ | |||
t_bank->sectors = malloc(sectors_num * sizeof(flash_sector_t)); | |||
for (sec=0; sec<sectors_num; sec++) | |||
for (sec = 0; sec<sectors_num; sec++) | |||
{ | |||
t_bank->sectors[sec].offset = sec * pages_per_sector * page_size; | |||
t_bank->sectors[sec].size = pages_per_sector * page_size; | |||
@@ -639,7 +639,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank) | |||
at91sam7_set_flash_mode(bank, FMR_TIMING_FLASH); | |||
fast_check = 1; | |||
for (nSector=0; nSector<bank->num_sectors; nSector++) | |||
for (nSector = 0; nSector<bank->num_sectors; nSector++) | |||
{ | |||
retval = target_blank_check_memory(target, bank->base+bank->sectors[nSector].offset, | |||
bank->sectors[nSector].size, &blank); | |||
@@ -662,7 +662,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank) | |||
LOG_USER("Running slow fallback erase check - add working memory"); | |||
buffer = malloc(bank->sectors[0].size); | |||
for (nSector=0; nSector<bank->num_sectors; nSector++) | |||
for (nSector = 0; nSector<bank->num_sectors; nSector++) | |||
{ | |||
bank->sectors[nSector].is_erased = 1; | |||
retval = target_read_memory(target, bank->base+bank->sectors[nSector].offset, 4, | |||
@@ -670,7 +670,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank) | |||
if (retval != ERROR_OK) | |||
return retval; | |||
for (nByte=0; nByte<bank->sectors[nSector].size; nByte++) | |||
for (nByte = 0; nByte<bank->sectors[nSector].size; nByte++) | |||
{ | |||
if (buffer[nByte] != 0xFF) | |||
{ | |||
@@ -705,7 +705,7 @@ static int at91sam7_protect_check(struct flash_bank_s *bank) | |||
at91sam7_info->lockbits = (status >> 16); | |||
at91sam7_info->num_lockbits_on = 0; | |||
for (lock_pos=0; lock_pos<bank->num_sectors; lock_pos++) | |||
for (lock_pos = 0; lock_pos<bank->num_sectors; lock_pos++) | |||
{ | |||
if ( ((status >> (16+lock_pos))&(0x0001)) == 1) | |||
{ | |||
@@ -723,7 +723,7 @@ static int at91sam7_protect_check(struct flash_bank_s *bank) | |||
at91sam7_info->nvmbits = (status >> 8)&0xFF; | |||
at91sam7_info->num_nvmbits_on = 0; | |||
for (gpnvm_pos=0; gpnvm_pos<at91sam7_info->num_nvmbits; gpnvm_pos++) | |||
for (gpnvm_pos = 0; gpnvm_pos<at91sam7_info->num_nvmbits; gpnvm_pos++) | |||
{ | |||
if ( ((status >> (8+gpnvm_pos))&(0x01)) == 1) | |||
{ | |||
@@ -809,7 +809,7 @@ static int at91sam7_flash_bank_command(struct command_context_s *cmd_ctx, char * | |||
/* calculate bank size */ | |||
bank_size = num_sectors * pages_per_sector * page_size; | |||
for (bnk=0; bnk<banks_num; bnk++) | |||
for (bnk = 0; bnk<banks_num; bnk++) | |||
{ | |||
if (bnk > 0) | |||
{ | |||
@@ -834,7 +834,7 @@ static int at91sam7_flash_bank_command(struct command_context_s *cmd_ctx, char * | |||
/* allocate sectors */ | |||
t_bank->sectors = malloc(num_sectors * sizeof(flash_sector_t)); | |||
for (sec=0; sec<num_sectors; sec++) | |||
for (sec = 0; sec<num_sectors; sec++) | |||
{ | |||
t_bank->sectors[sec].offset = sec * pages_per_sector * page_size; | |||
t_bank->sectors[sec].size = pages_per_sector * page_size; | |||
@@ -902,7 +902,7 @@ static int at91sam7_erase(struct flash_bank_s *bank, int first, int last) | |||
/* allocate and clean buffer */ | |||
nbytes = (last - first + 1) * bank->sectors[first].size; | |||
buffer = malloc(nbytes * sizeof(uint8_t)); | |||
for (pos=0; pos<nbytes; pos++) | |||
for (pos = 0; pos<nbytes; pos++) | |||
{ | |||
buffer[pos] = 0xFF; | |||
} | |||
@@ -916,7 +916,7 @@ static int at91sam7_erase(struct flash_bank_s *bank, int first, int last) | |||
} | |||
/* mark erased sectors */ | |||
for (sec=first; sec <= last; sec++) | |||
for (sec = first; sec <= last; sec++) | |||
{ | |||
bank->sectors[sec].is_erased = 1; | |||
} | |||
@@ -952,7 +952,7 @@ static int at91sam7_protect(struct flash_bank_s *bank, int set, int first, int l | |||
at91sam7_read_clock_info(bank); | |||
at91sam7_set_flash_mode(bank, FMR_TIMING_NVBITS); | |||
for (sector=first; sector <= last; sector++) | |||
for (sector = first; sector <= last; sector++) | |||
{ | |||
if (set) | |||
cmd = SLB; | |||
@@ -1016,7 +1016,7 @@ static int at91sam7_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t o | |||
at91sam7_read_clock_info(bank); | |||
at91sam7_set_flash_mode(bank, FMR_TIMING_FLASH); | |||
for (pagen=first_page; pagen<last_page; pagen++) | |||
for (pagen = first_page; pagen<last_page; pagen++) | |||
{ | |||
if (bytes_remaining<dst_min_alignment) | |||
count = bytes_remaining; | |||
@@ -212,7 +212,7 @@ static uint16_t cfi_query_u16(flash_bank_t *bank, int sector, uint32_t offset) | |||
if (cfi_info->x16_as_x8) | |||
{ | |||
uint8_t i; | |||
for (i=0;i<2;i++) | |||
for (i = 0;i<2;i++) | |||
target_read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1, | |||
&data[i*bank->bus_width] ); | |||
} | |||
@@ -234,7 +234,7 @@ static uint32_t cfi_query_u32(flash_bank_t *bank, int sector, uint32_t offset) | |||
if (cfi_info->x16_as_x8) | |||
{ | |||
uint8_t i; | |||
for (i=0;i<4;i++) | |||
for (i = 0;i<4;i++) | |||
target_read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1, | |||
&data[i*bank->bus_width] ); | |||
} | |||
@@ -1011,7 +1011,7 @@ static void cfi_add_byte(struct flash_bank_s *bank, uint8_t *word, uint8_t byte) | |||
static void cfi_fix_code_endian(target_t *target, uint8_t *dest, const uint32_t *src, uint32_t count) | |||
{ | |||
uint32_t i; | |||
for (i=0; i< count; i++) | |||
for (i = 0; i< count; i++) | |||
{ | |||
target_buffer_set_u32(target, dest, *src); | |||
dest += 4; | |||
@@ -1452,7 +1452,7 @@ static int cfi_spansion_write_block(struct flash_bank_s *bank, uint8_t *buffer, | |||
cfi_fix_code_endian(target, target_code, src, target_code_size / 4); | |||
/* allocate working area */ | |||
retval=target_alloc_working_area(target, target_code_size, | |||
retval = target_alloc_working_area(target, target_code_size, | |||
&cfi_info->write_algorithm); | |||
if (retval != ERROR_OK) | |||
{ | |||
@@ -1987,7 +1987,7 @@ int cfi_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint3 | |||
buffer += buffersize; | |||
write_p += buffersize; | |||
count -= buffersize; | |||
fallback=0; | |||
fallback = 0; | |||
} | |||
} | |||
/* try the slow way? */ | |||
@@ -66,7 +66,7 @@ typedef struct ecosflash_flash_bank_s | |||
uint32_t start_address; | |||
} ecosflash_flash_bank_t; | |||
static const int sectorSize=0x10000; | |||
static const int sectorSize = 0x10000; | |||
char * | |||
flash_errmsg(int err); | |||
@@ -145,7 +145,7 @@ static int ecosflash_flash_bank_command(struct command_context_s *cmd_ctx, char | |||
exit(-1); | |||
} | |||
bank->driver_priv = info; | |||
info->driverPath=strdup(args[6]); | |||
info->driverPath = strdup(args[6]); | |||
/* eCos flash sector sizes are not exposed to OpenOCD, use 0x10000 as | |||
* a way to improve impeadance matach between OpenOCD and eCos flash | |||
@@ -153,7 +153,7 @@ static int ecosflash_flash_bank_command(struct command_context_s *cmd_ctx, char | |||
*/ | |||
int i = 0; | |||
uint32_t offset = 0; | |||
bank->num_sectors=bank->size/sectorSize; | |||
bank->num_sectors = bank->size/sectorSize; | |||
bank->sectors = malloc(sizeof(flash_sector_t) * bank->num_sectors); | |||
for (i = 0; i < bank->num_sectors; i++) | |||
{ | |||
@@ -181,15 +181,15 @@ static int loadDriver(ecosflash_flash_bank_t *info) | |||
image.base_address_set = 0; | |||
image.start_address_set = 0; | |||
target_t *target=info->target; | |||
target_t *target = info->target; | |||
int retval; | |||
if ((retval=image_open(&image, info->driverPath, NULL)) != ERROR_OK) | |||
if ((retval = image_open(&image, info->driverPath, NULL)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
info->start_address=image.start_address; | |||
info->start_address = image.start_address; | |||
image_size = 0x0; | |||
int i; | |||
@@ -215,12 +215,12 @@ static int loadDriver(ecosflash_flash_bank_t *info) | |||
return ERROR_OK; | |||
} | |||
static int const OFFSET_ERASE=0x0; | |||
static int const OFFSET_ERASE_SIZE=0x8; | |||
static int const OFFSET_FLASH=0xc; | |||
static int const OFFSET_FLASH_SIZE=0x8; | |||
static int const OFFSET_GET_WORKAREA=0x18; | |||
static int const OFFSET_GET_WORKAREA_SIZE=0x4; | |||
static int const OFFSET_ERASE = 0x0; | |||
static int const OFFSET_ERASE_SIZE = 0x8; | |||
static int const OFFSET_FLASH = 0xc; | |||
static int const OFFSET_FLASH_SIZE = 0x8; | |||
static int const OFFSET_GET_WORKAREA = 0x18; | |||
static int const OFFSET_GET_WORKAREA_SIZE = 0x4; | |||
static int runCode(ecosflash_flash_bank_t *info, | |||
uint32_t codeStart, uint32_t codeStop, uint32_t r0, uint32_t r1, uint32_t r2, | |||
@@ -228,7 +228,7 @@ static int runCode(ecosflash_flash_bank_t *info, | |||
/* timeout in ms */ | |||
int timeout) | |||
{ | |||
target_t *target=info->target; | |||
target_t *target = info->target; | |||
reg_param_t reg_params[3]; | |||
armv4_5_algorithm_t armv4_5_info; | |||
@@ -254,7 +254,7 @@ static int runCode(ecosflash_flash_bank_t *info, | |||
return retval; | |||
} | |||
*result=buf_get_u32(reg_params[0].value, 0, 32); | |||
*result = buf_get_u32(reg_params[0].value, 0, 32); | |||
destroy_reg_param(®_params[0]); | |||
destroy_reg_param(®_params[1]); | |||
@@ -268,12 +268,12 @@ static int eCosBoard_erase(ecosflash_flash_bank_t *info, uint32_t address, uint3 | |||
int retval; | |||
int timeout = (len / 20480 + 1) * 1000; /*asume 20 KB/s*/ | |||
retval=loadDriver(info); | |||
retval = loadDriver(info); | |||
if (retval != ERROR_OK) | |||
return retval; | |||
uint32_t flashErr; | |||
retval=runCode(info, | |||
retval = runCode(info, | |||
info->start_address+OFFSET_ERASE, | |||
info->start_address+OFFSET_ERASE+OFFSET_ERASE_SIZE, | |||
address, | |||
@@ -296,17 +296,17 @@ static int eCosBoard_erase(ecosflash_flash_bank_t *info, uint32_t address, uint3 | |||
static int eCosBoard_flash(ecosflash_flash_bank_t *info, void *data, uint32_t address, uint32_t len) | |||
{ | |||
target_t *target=info->target; | |||
const int chunk=8192; | |||
int retval=ERROR_OK; | |||
target_t *target = info->target; | |||
const int chunk = 8192; | |||
int retval = ERROR_OK; | |||
int timeout = (chunk / 20480 + 1) * 1000; /*asume 20 KB/s + 1 second*/ | |||
retval=loadDriver(info); | |||
retval = loadDriver(info); | |||
if (retval != ERROR_OK) | |||
return retval; | |||
uint32_t buffer; | |||
retval=runCode(info, | |||
retval = runCode(info, | |||
info->start_address+OFFSET_GET_WORKAREA, | |||
info->start_address+OFFSET_GET_WORKAREA+OFFSET_GET_WORKAREA_SIZE, | |||
0, | |||
@@ -319,21 +319,21 @@ static int eCosBoard_flash(ecosflash_flash_bank_t *info, void *data, uint32_t ad | |||
uint32_t i; | |||
for (i=0; i<len; i += chunk) | |||
for (i = 0; i<len; i += chunk) | |||
{ | |||
int t=len-i; | |||
int t = len-i; | |||
if (t>chunk) | |||
{ | |||
t=chunk; | |||
t = chunk; | |||
} | |||
int retval; | |||
retval=target_write_buffer(target, buffer, t, ((uint8_t *)data)+i); | |||
retval = target_write_buffer(target, buffer, t, ((uint8_t *)data)+i); | |||
if (retval != ERROR_OK) | |||
return retval; | |||
uint32_t flashErr; | |||
retval=runCode(info, | |||
retval = runCode(info, | |||
info->start_address+OFFSET_FLASH, | |||
info->start_address+OFFSET_FLASH+OFFSET_FLASH_SIZE, | |||
buffer, | |||
@@ -408,7 +408,7 @@ static uint32_t ecosflash_address(struct flash_bank_s *bank, uint32_t address) | |||
static int ecosflash_erase(struct flash_bank_s *bank, int first, int last) | |||
{ | |||
struct flash_bank_s *c=bank; | |||
struct flash_bank_s *c = bank; | |||
ecosflash_flash_bank_t *info = bank->driver_priv; | |||
return eCosBoard_erase(info, c->base+first*sectorSize, sectorSize*(last-first+1)); | |||
} | |||
@@ -421,7 +421,7 @@ static int ecosflash_protect(struct flash_bank_s *bank, int set, int first, int | |||
static int ecosflash_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count) | |||
{ | |||
ecosflash_flash_bank_t *info = bank->driver_priv; | |||
struct flash_bank_s *c=bank; | |||
struct flash_bank_s *c = bank; | |||
return eCosBoard_flash(info, buffer, c->base+offset, count); | |||
} | |||
@@ -89,7 +89,7 @@ static int flash_driver_write(struct flash_bank_s *bank, uint8_t *buffer, uint32 | |||
{ | |||
int retval; | |||
retval=bank->driver->write(bank, buffer, offset, count); | |||
retval = bank->driver->write(bank, buffer, offset, count); | |||
if (retval != ERROR_OK) | |||
{ | |||
LOG_ERROR("error writing to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32 " (%d)", | |||
@@ -103,7 +103,7 @@ static int flash_driver_erase(struct flash_bank_s *bank, int first, int last) | |||
{ | |||
int retval; | |||
retval=bank->driver->erase(bank, first, last); | |||
retval = bank->driver->erase(bank, first, last); | |||
if (retval != ERROR_OK) | |||
{ | |||
LOG_ERROR("failed erasing sectors %d to %d (%d)", first, last, retval); | |||
@@ -116,7 +116,7 @@ int flash_driver_protect(struct flash_bank_s *bank, int set, int first, int last | |||
{ | |||
int retval; | |||
retval=bank->driver->protect(bank, set, first, last); | |||
retval = bank->driver->protect(bank, set, first, last); | |||
if (retval != ERROR_OK) | |||
{ | |||
LOG_ERROR("failed setting protection for areas %d to %d (%d)", first, last, retval); | |||
@@ -142,10 +142,10 @@ static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv) | |||
return JIM_ERR; | |||
} | |||
Jim_Obj *list=Jim_NewListObj(interp, NULL, 0); | |||
Jim_Obj *list = Jim_NewListObj(interp, NULL, 0); | |||
for (p = flash_banks; p; p = p->next) | |||
{ | |||
Jim_Obj *elem=Jim_NewListObj(interp, NULL, 0); | |||
Jim_Obj *elem = Jim_NewListObj(interp, NULL, 0); | |||
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "name", -1)); | |||
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, p->driver->name, -1)); | |||
@@ -291,7 +291,7 @@ static int handle_flash_bank_command(struct command_context_s *cmd_ctx, char *cm | |||
c->sectors = NULL; | |||
c->next = NULL; | |||
if ((retval=flash_drivers[i]->flash_bank_command(cmd_ctx, cmd, args, argc, c)) != ERROR_OK) | |||
if ((retval = flash_drivers[i]->flash_bank_command(cmd_ctx, cmd, args, argc, c)) != ERROR_OK) | |||
{ | |||
LOG_ERROR("'%s' driver rejected flash bank at 0x%8.8" PRIx32 , args[0], c->base); | |||
free(c); | |||
@@ -754,13 +754,13 @@ static int handle_flash_fill_command(struct command_context_s *cmd_ctx, char *cm | |||
switch (cmd[4]) | |||
{ | |||
case 'w': | |||
wordsize=4; | |||
wordsize = 4; | |||
break; | |||
case 'h': | |||
wordsize=2; | |||
wordsize = 2; | |||
break; | |||
case 'b': | |||
wordsize=1; | |||
wordsize = 1; | |||
break; | |||
default: | |||
return ERROR_COMMAND_SYNTAX_ERROR; | |||
@@ -791,7 +791,7 @@ static int handle_flash_fill_command(struct command_context_s *cmd_ctx, char *cm | |||
duration_start_measure(&duration); | |||
for (wrote=0; wrote<(count*wordsize); wrote += cur_size) | |||
for (wrote = 0; wrote<(count*wordsize); wrote += cur_size) | |||
{ | |||
cur_size = MIN( (count*wordsize - wrote), sizeof(chunk) ); | |||
flash_bank_t *bank; | |||
@@ -809,7 +809,7 @@ static int handle_flash_fill_command(struct command_context_s *cmd_ctx, char *cm | |||
return err; | |||
unsigned i; | |||
for (i=0; i<cur_size; i++) | |||
for (i = 0; i<cur_size; i++) | |||
{ | |||
if (readback[i]!=chunk[i]) | |||
{ | |||
@@ -829,7 +829,7 @@ static int handle_flash_fill_command(struct command_context_s *cmd_ctx, char *cm | |||
if (err == ERROR_OK) | |||
{ | |||
float speed; | |||
speed=wrote / 1024.0; | |||
speed = wrote / 1024.0; | |||
speed/=((float)duration.duration.tv_sec + ((float)duration.duration.tv_usec / 1000000.0)); | |||
command_print(cmd_ctx, | |||
"wrote %" PRId32 " bytes to 0x%8.8" PRIx32 " in %s (%f kb/s)", | |||
@@ -1003,7 +1003,7 @@ int flash_erase_address_range(target_t *target, uint32_t addr, uint32_t length) | |||
/* write (optional verify) an image to flash memory of the given target */ | |||
int flash_write(target_t *target, image_t *image, uint32_t *written, int erase) | |||
{ | |||
int retval=ERROR_OK; | |||
int retval = ERROR_OK; | |||
int section; | |||
uint32_t section_offset; | |||
@@ -45,13 +45,13 @@ typedef struct flash_sector_s | |||
/// Number of bytes in this flash sector. | |||
uint32_t size; | |||
/** | |||
* Indication of erasure status: 0=not erased, 1=erased, | |||
* other=unknown. Set by @c flash_driver_s::erase_check. | |||
* Indication of erasure status: 0 = not erased, 1 = erased, | |||
* other = unknown. Set by @c flash_driver_s::erase_check. | |||
*/ | |||
int is_erased; | |||
/** | |||
* Indication of protection status: 0=unprotected/unlocked, | |||
* 1=protected/locked, other=unknown. Set by | |||
* Indication of protection status: 0 = unprotected/unlocked, | |||
* 1 = protected/locked, other = unknown. Set by | |||
* @c flash_driver_s::protect_check. | |||
*/ | |||
int is_protected; | |||
@@ -525,7 +525,7 @@ static int lpc2000_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t of | |||
checksum = 0 - checksum; | |||
LOG_DEBUG("checksum: 0x%8.8" PRIx32, checksum); | |||
uint32_t original_value=buf_get_u32(buffer + (5 * 4), 0, 32); | |||
uint32_t original_value = buf_get_u32(buffer + (5 * 4), 0, 32); | |||
if (original_value != checksum) | |||
{ | |||
LOG_WARNING("Verification will fail since checksum in image(0x%8.8" PRIx32 ") written to flash was different from calculated vector checksum(0x%8.8" PRIx32 ").", | |||
@@ -217,7 +217,7 @@ static int mg_dsk_wait(mg_io_type_wait wait, uint32_t time) | |||
uint32_t mg_task_reg = mflash_bank->base + MG_REG_OFFSET; | |||
duration_t duration; | |||
int ret; | |||
long long t=0; | |||
long long t = 0; | |||
duration_start_measure(&duration); | |||
@@ -277,7 +277,7 @@ static int mg_dsk_wait(mg_io_type_wait wait, uint32_t time) | |||
duration_stop_measure(&duration, NULL); | |||
t=duration.duration.tv_usec/1000; | |||
t = duration.duration.tv_usec/1000; | |||
t += duration.duration.tv_sec*1000; | |||
if (t > time) | |||
@@ -871,7 +871,7 @@ static int mg_pll_get_M(unsigned short feedback_div) | |||
{ | |||
int i, M; | |||
for (i = 1, M=0; i < 512; i <<= 1, feedback_div >>= 1) | |||
for (i = 1, M = 0; i < 512; i <<= 1, feedback_div >>= 1) | |||
M += (feedback_div & 1) * i; | |||
return M + 2; | |||
@@ -200,7 +200,7 @@ static int ocl_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset | |||
chksum = OCL_CHKS_INIT; | |||
/* copy data to DCC buffer in proper byte order and properly aligned */ | |||
for (i=0; i<runlen; i++) | |||
for (i = 0; i<runlen; i++) | |||
{ | |||
switch (byteofs++) | |||
{ | |||
@@ -332,7 +332,7 @@ static int ocl_probe(struct flash_bank_s *bank) | |||
return ERROR_FLASH_BANK_INVALID; | |||
} | |||
sectsize = bank->size / bank->num_sectors; | |||
for (i=0; i<bank->num_sectors; i++) | |||
for (i = 0; i<bank->num_sectors; i++) | |||
{ | |||
bank->sectors[i].offset = i * sectsize; | |||
bank->sectors[i].size = sectsize; | |||
@@ -39,19 +39,19 @@ void cmd_flash(uint32 cmd) | |||
int pagenum; | |||
int result; | |||
adr=dcc_rd(); | |||
len=cmd&0xffff; | |||
ofs=adr%flash_page_size; | |||
bi_start=ofs/4; | |||
bi_end=(ofs+len+3)/4; | |||
adr = dcc_rd(); | |||
len = cmd&0xffff; | |||
ofs = adr%flash_page_size; | |||
bi_start = ofs/4; | |||
bi_end = (ofs+len+3)/4; | |||
if (bi_end>BUFSIZE) { | |||
dcc_wr(OCL_BUFF_OVER); | |||
return; | |||
} | |||
chksum=OCL_CHKS_INIT; | |||
for (bi=0; bi<bi_end; bi++) chksum^=buffer[bi]=dcc_rd(); | |||
chksum = OCL_CHKS_INIT; | |||
for (bi = 0; bi<bi_end; bi++) chksum^=buffer[bi]=dcc_rd(); | |||
if (dcc_rd() != chksum) { | |||
dcc_wr(OCL_CHKS_FAIL); | |||
@@ -59,18 +59,18 @@ void cmd_flash(uint32 cmd) | |||
} | |||
/* fill in unused positions with unprogrammed values */ | |||
for (bi=0; bi<bi_start; bi++) buffer[bi]=0xffffffff; | |||
for (bi=bi_end; bi%flash_page_size; bi++) buffer[bi]=0xffffffff; | |||
for (bi = 0; bi<bi_start; bi++) buffer[bi]=0xffffffff; | |||
for (bi = bi_end; bi%flash_page_size; bi++) buffer[bi]=0xffffffff; | |||
result=0; | |||
pagenum=adr/flash_page_size; | |||
for (bi=0; bi<bi_end; bi += flash_page_size/4) { | |||
result=flash_page_program(buffer+bi, pagenum++); | |||
result = 0; | |||
pagenum = adr/flash_page_size; | |||
for (bi = 0; bi<bi_end; bi += flash_page_size/4) { | |||
result = flash_page_program(buffer+bi, pagenum++); | |||
if (result) break; | |||
} | |||
/* verify written data */ | |||
if (!result) result=flash_verify(adr, len, ((uint8 *)buffer)+ofs); | |||
if (!result) result = flash_verify(adr, len, ((uint8 *)buffer)+ofs); | |||
dcc_wr(OCL_CMD_DONE|result); | |||
} | |||
@@ -81,7 +81,7 @@ int main (void) | |||
uint32 cmd; | |||
for (;;) { | |||
cmd=dcc_rd(); | |||
cmd = dcc_rd(); | |||
switch (cmd&OCL_CMD_MASK) { | |||
case OCL_PROBE: | |||
dcc_wr(OCL_CMD_DONE|flash_init()); | |||
@@ -20,11 +20,11 @@ | |||
#include "samflash.h" | |||
unsigned int flash_page_count=1024; | |||
unsigned int flash_page_size=256; | |||
unsigned int flash_page_count = 1024; | |||
unsigned int flash_page_size = 256; | |||
/* pages per lock bit */ | |||
unsigned int flash_lock_pages=1024/16; | |||
unsigned int flash_lock_pages = 1024/16; | |||
/* detect chip and set loader parameters */ | |||
@@ -32,38 +32,38 @@ int flash_init(void) | |||
{ | |||
unsigned int nvpsiz; | |||
nvpsiz=(inr(DBGU_CIDR) >> 8)&0xf; | |||
nvpsiz = (inr(DBGU_CIDR) >> 8)&0xf; | |||
switch (nvpsiz) { | |||
case 3: | |||
/* AT91SAM7x32 */ | |||
flash_page_count=256; | |||
flash_page_size=128; | |||
flash_lock_pages=256/8; | |||
flash_page_count = 256; | |||
flash_page_size = 128; | |||
flash_lock_pages = 256/8; | |||
break; | |||
case 5: | |||
/* AT91SAM7x64 */ | |||
flash_page_count=512; | |||
flash_page_size=128; | |||
flash_lock_pages=512/16; | |||
flash_page_count = 512; | |||
flash_page_size = 128; | |||
flash_lock_pages = 512/16; | |||
break; | |||
case 7: | |||
/* AT91SAM7x128*/ | |||
flash_page_count=512; | |||
flash_page_size=256; | |||
flash_lock_pages=512/8; | |||
flash_page_count = 512; | |||
flash_page_size = 256; | |||
flash_lock_pages = 512/8; | |||
break; | |||
case 9: | |||
/* AT91SAM7x256 */ | |||
flash_page_count=1024; | |||
flash_page_size=256; | |||
flash_lock_pages=1024/16; | |||
flash_page_count = 1024; | |||
flash_page_size = 256; | |||
flash_lock_pages = 1024/16; | |||
break; | |||
case 10: | |||
/* AT91SAM7x512 */ | |||
flash_page_count=2048; | |||
flash_page_size=256; | |||
flash_lock_pages=2048/32; | |||
flash_page_count = 2048; | |||
flash_page_size = 256; | |||
flash_lock_pages = 2048/32; | |||
break; | |||
default: | |||
return FLASH_STAT_INITE; | |||
@@ -82,19 +82,19 @@ int flash_page_program(uint32 *data, int page_num) | |||
uint32 *data_ptr; | |||
/* select proper controller */ | |||
if (page_num >= 1024) efc_ofs=0x10; | |||
else efc_ofs=0; | |||
if (page_num >= 1024) efc_ofs = 0x10; | |||
else efc_ofs = 0; | |||
/* wait until FLASH is ready, just for sure */ | |||
while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0); | |||
/* calculate page address, only lower 8 bits are used to address the latch, | |||
but the upper part of address is needed for writing to proper EFC */ | |||
flash_ptr=(uint32 *)(FLASH_AREA_ADDR+(page_num*flash_page_size)); | |||
data_ptr=data; | |||
flash_ptr = (uint32 *)(FLASH_AREA_ADDR+(page_num*flash_page_size)); | |||
data_ptr = data; | |||
/* copy data to latch */ | |||
for (i=flash_page_size/4; i; i--) { | |||
for (i = flash_page_size/4; i; i--) { | |||
/* we do not use memcpy to be sure that only 32 bit access is used */ | |||
*(flash_ptr++)=*(data_ptr++); | |||
} | |||
@@ -111,10 +111,10 @@ int flash_page_program(uint32 *data, int page_num) | |||
#if 0 | |||
/* verify written data */ | |||
flash_ptr=(uint32 *)(FLASH_AREA_ADDR+(page_num*flash_page_size)); | |||
data_ptr=data; | |||
flash_ptr = (uint32 *)(FLASH_AREA_ADDR+(page_num*flash_page_size)); | |||
data_ptr = data; | |||
for (i=flash_page_size/4; i; i--) { | |||
for (i = flash_page_size/4; i; i--) { | |||
if (*(flash_ptr++)!=*(data_ptr++)) return FLASH_STAT_VERIFE; | |||
} | |||
#endif | |||
@@ -128,8 +128,8 @@ int flash_erase_plane(int efc_ofs) | |||
unsigned int lockbits; | |||
int page_num; | |||
page_num=0; | |||
lockbits=inr(MC_FSR+efc_ofs) >> 16; | |||
page_num = 0; | |||
lockbits = inr(MC_FSR+efc_ofs) >> 16; | |||
while (lockbits) { | |||
if (lockbits&1) { | |||
@@ -175,10 +175,10 @@ int flash_erase_all(void) | |||
{ | |||
int result; | |||
if ((result=flash_erase_plane(0)) != FLASH_STAT_OK) return result; | |||
if ((result = flash_erase_plane(0)) != FLASH_STAT_OK) return result; | |||
/* the second flash controller, if any */ | |||
if (flash_page_count>1024) result=flash_erase_plane(0x10); | |||
if (flash_page_count>1024) result = flash_erase_plane(0x10); | |||
return result; | |||
} | |||
@@ -188,7 +188,7 @@ int flash_verify(uint32 adr, unsigned int len, uint8 *src) | |||
{ | |||
unsigned char *flash_ptr; | |||
flash_ptr=(uint8 *)FLASH_AREA_ADDR+adr; | |||
flash_ptr = (uint8 *)FLASH_AREA_ADDR+adr; | |||
for ( ;len; len--) { | |||
if (*(flash_ptr++)!=*(src++)) return FLASH_STAT_VERIFE; | |||
} | |||
@@ -388,7 +388,7 @@ static int pic32mx_write_block(struct flash_bank_s *bank, uint8_t *buffer, uint3 | |||
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; | |||
}; | |||
if ((retval=target_write_buffer(target, pic32mx_info->write_algorithm->address, sizeof(pic32mx_flash_write_code), pic32mx_flash_write_code)) != ERROR_OK) | |||
if ((retval = target_write_buffer(target, pic32mx_info->write_algorithm->address, sizeof(pic32mx_flash_write_code), pic32mx_flash_write_code)) != ERROR_OK) | |||
return retval; | |||
#endif | |||
@@ -435,12 +435,12 @@ static int pic32mx_write_block(struct flash_bank_s *bank, uint8_t *buffer, uint3 | |||
#endif | |||
status = pic32mx_write_row(bank, address, source->address); | |||
if ( status & NVMCON_NVMERR ) { | |||
LOG_ERROR("Flash write error NVMERR (status=0x%08" PRIx32 ")", status); | |||
LOG_ERROR("Flash write error NVMERR (status = 0x%08" PRIx32 ")", status); | |||
retval = ERROR_FLASH_OPERATION_FAILED; | |||
break; | |||
} | |||
if ( status & NVMCON_LVDERR ) { | |||
LOG_ERROR("Flash write error LVDERR (status=0x%08" PRIx32 ")", status); | |||
LOG_ERROR("Flash write error LVDERR (status = 0x%08" PRIx32 ")", status); | |||
retval = ERROR_FLASH_OPERATION_FAILED; | |||
break; | |||
} | |||
@@ -459,12 +459,12 @@ static int pic32mx_write_block(struct flash_bank_s *bank, uint8_t *buffer, uint3 | |||
uint32_t status = pic32mx_write_word(bank, address, value); | |||
if ( status & NVMCON_NVMERR ) { | |||
LOG_ERROR("Flash write error NVMERR (status=0x%08" PRIx32 ")", status); | |||
LOG_ERROR("Flash write error NVMERR (status = 0x%08" PRIx32 ")", status); | |||
retval = ERROR_FLASH_OPERATION_FAILED; | |||
break; | |||
} | |||
if ( status & NVMCON_LVDERR ) { | |||
LOG_ERROR("Flash write error LVDERR (status=0x%08" PRIx32 ")", status); | |||
LOG_ERROR("Flash write error LVDERR (status = 0x%08" PRIx32 ")", status); | |||
retval = ERROR_FLASH_OPERATION_FAILED; | |||
break; | |||
} | |||
@@ -620,7 +620,7 @@ static int pic32mx_probe(struct flash_bank_s *bank) | |||
num_pages = 12; | |||
} else { | |||
/* 0xBD000000: Program flash size varies with device */ | |||
for (i=0; pic32mx_devs[i].name != NULL; i++) | |||
for (i = 0; pic32mx_devs[i].name != NULL; i++) | |||
if (pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) { | |||
num_pages = pic32mx_devs[i].pfm_size; | |||
break; | |||
@@ -704,7 +704,7 @@ static int pic32mx_info(struct flash_bank_s *bank, char *buf, int buf_size) | |||
PIC32MX_MANUF_ID); | |||
return ERROR_FLASH_OPERATION_FAILED; | |||
} | |||
for (i=0; pic32mx_devs[i].name != NULL; i++) | |||
for (i = 0; pic32mx_devs[i].name != NULL; i++) | |||
if (pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) { | |||
printed = snprintf(buf, buf_size, "PIC32MX%s", pic32mx_devs[i].name); | |||
break; | |||
@@ -939,7 +939,7 @@ static int pic32mx_handle_pgm_word_command(struct command_context_s *cmd_ctx, ch | |||
if (res == ERROR_OK) | |||
command_print(cmd_ctx, "pic32mx pgm word complete"); | |||
else | |||
command_print(cmd_ctx, "pic32mx pgm word failed (status=0x%x)", status); | |||
command_print(cmd_ctx, "pic32mx pgm word failed (status = 0x%x)", status); | |||
return ERROR_OK; | |||
} |
@@ -517,7 +517,7 @@ static int stm32x_write_block(struct flash_bank_s *bank, uint8_t *buffer, uint32 | |||
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; | |||
}; | |||
if ((retval=target_write_buffer(target, stm32x_info->write_algorithm->address, sizeof(stm32x_flash_write_code), stm32x_flash_write_code)) != ERROR_OK) | |||
if ((retval = target_write_buffer(target, stm32x_info->write_algorithm->address, sizeof(stm32x_flash_write_code), stm32x_flash_write_code)) != ERROR_OK) | |||
return retval; | |||
/* memory buffer */ | |||
@@ -198,11 +198,11 @@ static int str9x_protect_check(struct flash_bank_s *bank) | |||
if (str9x_info->bank1) | |||
{ | |||
adr = bank1start + 0x18; | |||
if ((retval=target_write_u16(target, adr, 0x90)) != ERROR_OK) | |||
if ((retval = target_write_u16(target, adr, 0x90)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
if ((retval=target_read_u16(target, adr, &hstatus)) != ERROR_OK) | |||
if ((retval = target_read_u16(target, adr, &hstatus)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
@@ -211,11 +211,11 @@ static int str9x_protect_check(struct flash_bank_s *bank) | |||
else | |||
{ | |||
adr = bank1start + 0x14; | |||
if ((retval=target_write_u16(target, adr, 0x90)) != ERROR_OK) | |||
if ((retval = target_write_u16(target, adr, 0x90)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
if ((retval=target_read_u32(target, adr, &status)) != ERROR_OK) | |||
if ((retval = target_read_u32(target, adr, &status)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
@@ -224,11 +224,11 @@ static int str9x_protect_check(struct flash_bank_s *bank) | |||
else | |||
{ | |||
adr = bank1start + 0x10; | |||
if ((retval=target_write_u16(target, adr, 0x90)) != ERROR_OK) | |||
if ((retval = target_write_u16(target, adr, 0x90)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
if ((retval=target_read_u16(target, adr, &hstatus)) != ERROR_OK) | |||
if ((retval = target_read_u16(target, adr, &hstatus)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
@@ -236,7 +236,7 @@ static int str9x_protect_check(struct flash_bank_s *bank) | |||
} | |||
/* read array command */ | |||
if ((retval=target_write_u16(target, adr, 0xFF)) != ERROR_OK) | |||
if ((retval = target_write_u16(target, adr, 0xFF)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
@@ -284,24 +284,24 @@ static int str9x_erase(struct flash_bank_s *bank, int first, int last) | |||
adr = bank->base + bank->sectors[i].offset; | |||
/* erase sectors */ | |||
if ((retval=target_write_u16(target, adr, erase_cmd)) != ERROR_OK) | |||
if ((retval = target_write_u16(target, adr, erase_cmd)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
if ((retval=target_write_u16(target, adr, 0xD0)) != ERROR_OK) | |||
if ((retval = target_write_u16(target, adr, 0xD0)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
/* get status */ | |||
if ((retval=target_write_u16(target, adr, 0x70)) != ERROR_OK) | |||
if ((retval = target_write_u16(target, adr, 0x70)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
int timeout; | |||
for (timeout=0; timeout<1000; timeout++) { | |||
if ((retval=target_read_u8(target, adr, &status)) != ERROR_OK) | |||
for (timeout = 0; timeout<1000; timeout++) { | |||
if ((retval = target_read_u8(target, adr, &status)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
@@ -316,13 +316,13 @@ static int str9x_erase(struct flash_bank_s *bank, int first, int last) | |||
} | |||
/* clear status, also clear read array */ | |||
if ((retval=target_write_u16(target, adr, 0x50)) != ERROR_OK) | |||
if ((retval = target_write_u16(target, adr, 0x50)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
/* read array command */ | |||
if ((retval=target_write_u16(target, adr, 0xFF)) != ERROR_OK) | |||
if ((retval = target_write_u16(target, adr, 0xFF)) != ERROR_OK) | |||
{ | |||
return retval; | |||
} | |||
@@ -575,7 +575,7 @@ static int str9x_write(struct flash_bank_s *bank, | |||
target_write_u16(target, bank_adr, 0x70); | |||
int timeout; | |||
for (timeout=0; timeout<1000; timeout++) | |||
for (timeout = 0; timeout<1000; timeout++) | |||
{ | |||
target_read_u8(target, bank_adr, &status); | |||
if ( status & 0x80 ) | |||
@@ -624,7 +624,7 @@ static int str9x_write(struct flash_bank_s *bank, | |||
target_write_u16(target, bank_adr, 0x70); | |||
int timeout; | |||
for (timeout=0; timeout<1000; timeout++) | |||
for (timeout = 0; timeout<1000; timeout++) | |||
{ | |||
target_read_u8(target, bank_adr, &status); | |||
if ( status & 0x80 ) | |||
@@ -150,7 +150,7 @@ static int tms470_read_part_info(struct flash_bank_s *bank) | |||
/* read and parse the device identification register */ | |||
target_read_u32(target, 0xFFFFFFF0, &device_ident_reg); | |||
LOG_INFO("device_ident_reg=0x%08" PRIx32 "", device_ident_reg); | |||
LOG_INFO("device_ident_reg = 0x%08" PRIx32 "", device_ident_reg); | |||
if ((device_ident_reg & 7) == 0) | |||
{ | |||
@@ -432,7 +432,7 @@ static int tms470_check_flash_unlocked(target_t * target) | |||
uint32_t fmbbusy; | |||
target_read_u32(target, 0xFFE89C08, &fmbbusy); | |||
LOG_INFO("tms470 fmbbusy=0x%08" PRIx32 " -> %s", fmbbusy, fmbbusy & 0x8000 ? "unlocked" : "LOCKED"); | |||
LOG_INFO("tms470 fmbbusy = 0x%08" PRIx32 " -> %s", fmbbusy, fmbbusy & 0x8000 ? "unlocked" : "LOCKED"); | |||
return fmbbusy & 0x8000 ? ERROR_OK : ERROR_FLASH_OPERATION_FAILED; | |||
} | |||
@@ -482,7 +482,7 @@ static int tms470_try_flash_keys(target_t * target, const uint32_t * key_set) | |||
*/ | |||
target_read_u32(target, 0x00001FF0 + 4 * i, &tmp); | |||
LOG_INFO("tms470 writing fmpkey=0x%08" PRIx32 "", key_set[i]); | |||
LOG_INFO("tms470 writing fmpkey = 0x%08" PRIx32 "", key_set[i]); | |||
target_write_u32(target, 0xFFE89C0C, key_set[i]); | |||
} | |||
@@ -570,7 +570,7 @@ static int tms470_flash_initialize_internal_state_machine(struct flash_bank_s *b | |||
fmmac2 &= ~0x0007; | |||
fmmac2 |= (tms470_info->ordinal & 7); | |||
target_write_u32(target, 0xFFE8BC04, fmmac2); | |||
LOG_DEBUG("set fmmac2=0x%04" PRIx32 "", fmmac2); | |||
LOG_DEBUG("set fmmac2 = 0x%04" PRIx32 "", fmmac2); | |||
/* | |||
* Disable level 1 sector protection by setting bit 15 of FMMAC1. | |||
@@ -578,25 +578,25 @@ static int tms470_flash_initialize_internal_state_machine(struct flash_bank_s *b | |||
target_read_u32(target, 0xFFE8BC00, &fmmac1); | |||
fmmac1 |= 0x8000; | |||
target_write_u32(target, 0xFFE8BC00, fmmac1); | |||
LOG_DEBUG("set fmmac1=0x%04" PRIx32 "", fmmac1); | |||
LOG_DEBUG("set fmmac1 = 0x%04" PRIx32 "", fmmac1); | |||
/* | |||
* FMTCREG=0x2fc0; | |||
* FMTCREG = 0x2fc0; | |||
*/ | |||
target_write_u32(target, 0xFFE8BC10, 0x2fc0); | |||
LOG_DEBUG("set fmtcreg=0x2fc0"); | |||
LOG_DEBUG("set fmtcreg = 0x2fc0"); | |||
/* | |||
* MAXPP=50 | |||
* MAXPP = 50 | |||
*/ | |||
target_write_u32(target, 0xFFE8A07C, 50); | |||
LOG_DEBUG("set fmmaxpp=50"); | |||
LOG_DEBUG("set fmmaxpp = 50"); | |||
/* | |||
* MAXCP=0xf000+2000 | |||
* MAXCP = 0xf000+2000 | |||
*/ | |||
target_write_u32(target, 0xFFE8A084, 0xf000 + 2000); | |||
LOG_DEBUG("set fmmaxcp=0x%04x", 0xf000 + 2000); | |||
LOG_DEBUG("set fmmaxcp = 0x%04x", 0xf000 + 2000); | |||
/* | |||
* configure VHV | |||
@@ -606,22 +606,22 @@ static int tms470_flash_initialize_internal_state_machine(struct flash_bank_s *b | |||
{ | |||
fmmaxep = 0xf000 + 4095; | |||
target_write_u32(target, 0xFFE8A80C, 0x9964); | |||
LOG_DEBUG("set fmptr3=0x9964"); | |||
LOG_DEBUG("set fmptr3 = 0x9964"); | |||
} | |||
else | |||
{ | |||
fmmaxep = 0xa000 + 4095; | |||
target_write_u32(target, 0xFFE8A80C, 0x9b64); | |||
LOG_DEBUG("set fmptr3=0x9b64"); | |||
LOG_DEBUG("set fmptr3 = 0x9b64"); | |||
} | |||
target_write_u32(target, 0xFFE8A080, fmmaxep); | |||
LOG_DEBUG("set fmmaxep=0x%04" PRIx32 "", fmmaxep); | |||
LOG_DEBUG("set fmmaxep = 0x%04" PRIx32 "", fmmaxep); | |||
/* | |||
* FMPTR4=0xa000 | |||
* FMPTR4 = 0xa000 | |||
*/ | |||
target_write_u32(target, 0xFFE8A810, 0xa000); | |||
LOG_DEBUG("set fmptr4=0xa000"); | |||
LOG_DEBUG("set fmptr4 = 0xa000"); | |||
/* | |||
* FMPESETUP, delay parameter selected based on clock frequency. | |||
@@ -635,56 +635,56 @@ static int tms470_flash_initialize_internal_state_machine(struct flash_bank_s *b | |||
sysclk = (plldis ? 1 : (glbctrl & 0x08) ? 4 : 8) * oscMHz / (1 + (glbctrl & 7)); | |||
delay = (sysclk > 10) ? (sysclk + 1) / 2 : 5; | |||
target_write_u32(target, 0xFFE8A018, (delay << 4) | (delay << 8)); | |||
LOG_DEBUG("set fmpsetup=0x%04" PRIx32 "", (delay << 4) | (delay << 8)); | |||
LOG_DEBUG("set fmpsetup = 0x%04" PRIx32 "", (delay << 4) | (delay << 8)); | |||
/* | |||
* FMPVEVACCESS, based on delay. | |||
*/ | |||
k = delay | (delay << 8); | |||
target_write_u32(target, 0xFFE8A05C, k); | |||
LOG_DEBUG("set fmpvevaccess=0x%04" PRIx32 "", k); | |||
LOG_DEBUG("set fmpvevaccess = 0x%04" PRIx32 "", k); | |||
/* | |||
* FMPCHOLD, FMPVEVHOLD, FMPVEVSETUP, based on delay. | |||
*/ | |||
k <<= 1; | |||
target_write_u32(target, 0xFFE8A034, k); | |||
LOG_DEBUG("set fmpchold=0x%04" PRIx32 "", k); | |||
LOG_DEBUG("set fmpchold = 0x%04" PRIx32 "", k); | |||
target_write_u32(target, 0xFFE8A040, k); | |||
LOG_DEBUG("set fmpvevhold=0x%04" PRIx32 "", k); | |||
LOG_DEBUG("set fmpvevhold = 0x%04" PRIx32 "", k); | |||
target_write_u32(target, 0xFFE8A024, k); | |||
LOG_DEBUG("set fmpvevsetup=0x%04" PRIx32 "", k); | |||
LOG_DEBUG("set fmpvevsetup = 0x%04" PRIx32 "", k); | |||
/* | |||
* FMCVACCESS, based on delay. | |||
*/ | |||
k = delay * 16; | |||
target_write_u32(target, 0xFFE8A060, k); | |||
LOG_DEBUG("set fmcvaccess=0x%04" PRIx32 "", k); | |||
LOG_DEBUG("set fmcvaccess = 0x%04" PRIx32 "", k); | |||
/* | |||
* FMCSETUP, based on delay. | |||
*/ | |||
k = 0x3000 | delay * 20; | |||
target_write_u32(target, 0xFFE8A020, k); | |||
LOG_DEBUG("set fmcsetup=0x%04" PRIx32 "", k); | |||
LOG_DEBUG("set fmcsetup = 0x%04" PRIx32 "", k); | |||
/* | |||
* FMEHOLD, based on delay. | |||
*/ | |||
k = (delay * 20) << 2; | |||
target_write_u32(target, 0xFFE8A038, k); | |||
LOG_DEBUG("set fmehold=0x%04" PRIx32 "", k); | |||
LOG_DEBUG("set fmehold = 0x%04" PRIx32 "", k); | |||
/* | |||
* PWIDTH, CWIDTH, EWIDTH, based on delay. | |||
*/ | |||
target_write_u32(target, 0xFFE8A050, delay * 8); | |||
LOG_DEBUG("set fmpwidth=0x%04" PRIx32 "", delay * 8); | |||
LOG_DEBUG("set fmpwidth = 0x%04" PRIx32 "", delay * 8); | |||
target_write_u32(target, 0xFFE8A058, delay * 1000); | |||
LOG_DEBUG("set fmcwidth=0x%04" PRIx32 "", delay * 1000); | |||
LOG_DEBUG("set fmcwidth = 0x%04" PRIx32 "", delay * 1000); | |||
target_write_u32(target, 0xFFE8A054, delay * 5400); | |||
LOG_DEBUG("set fmewidth=0x%04" PRIx32 "", delay * 5400); | |||
LOG_DEBUG("set fmewidth = 0x%04" PRIx32 "", delay * 5400); | |||
return result; | |||
} | |||
@@ -698,7 +698,7 @@ int tms470_flash_status(struct flash_bank_s *bank) | |||
uint32_t fmmstat; | |||
target_read_u32(target, 0xFFE8BC0C, &fmmstat); | |||
LOG_DEBUG("set fmmstat=0x%04" PRIx32 "", fmmstat); | |||
LOG_DEBUG("set fmmstat = 0x%04" PRIx32 "", fmmstat); | |||
if (fmmstat & 0x0080) | |||
{ | |||
@@ -760,12 +760,12 @@ static int tms470_erase_sector(struct flash_bank_s *bank, int sector) | |||
*/ | |||
target_read_u32(target, 0xFFFFFFDC, &glbctrl); | |||
target_write_u32(target, 0xFFFFFFDC, glbctrl | 0x10); | |||
LOG_DEBUG("set glbctrl=0x%08" PRIx32 "", glbctrl | 0x10); | |||
LOG_DEBUG("set glbctrl = 0x%08" PRIx32 "", glbctrl | 0x10); | |||
/* Force normal read mode. */ | |||
target_read_u32(target, 0xFFE89C00, &orig_fmregopt); | |||
target_write_u32(target, 0xFFE89C00, 0); | |||
LOG_DEBUG("set fmregopt=0x%08x", 0); | |||
LOG_DEBUG("set fmregopt = 0x%08x", 0); | |||
(void)tms470_flash_initialize_internal_state_machine(bank); | |||
@@ -777,13 +777,13 @@ static int tms470_erase_sector(struct flash_bank_s *bank, int sector) | |||
{ | |||
target_read_u32(target, 0xFFE88008, &fmbsea); | |||
target_write_u32(target, 0xFFE88008, fmbsea | (1 << sector)); | |||
LOG_DEBUG("set fmbsea=0x%04" PRIx32 "", fmbsea | (1 << sector)); | |||
LOG_DEBUG("set fmbsea = 0x%04" PRIx32 "", fmbsea | (1 << sector)); | |||
} | |||
else | |||
{ | |||
target_read_u32(target, 0xFFE8800C, &fmbseb); | |||
target_write_u32(target, 0xFFE8800C, fmbseb | (1 << (sector - 16))); | |||
LOG_DEBUG("set fmbseb=0x%04" PRIx32 "", fmbseb | (1 << (sector - 16))); | |||
LOG_DEBUG("set fmbseb = 0x%04" PRIx32 "", fmbseb | (1 << (sector - 16))); | |||
} | |||
bank->sectors[sector].is_protected = 0; | |||
@@ -816,19 +816,19 @@ static int tms470_erase_sector(struct flash_bank_s *bank, int sector) | |||
if (sector < 16) | |||
{ | |||
target_write_u32(target, 0xFFE88008, fmbsea); | |||
LOG_DEBUG("set fmbsea=0x%04" PRIx32 "", fmbsea); | |||
LOG_DEBUG("set fmbsea = 0x%04" PRIx32 "", fmbsea); | |||
bank->sectors[sector].is_protected = fmbsea & (1 << sector) ? 0 : 1; | |||
} | |||
else | |||
{ | |||
target_write_u32(target, 0xFFE8800C, fmbseb); | |||
LOG_DEBUG("set fmbseb=0x%04" PRIx32 "", fmbseb); | |||
LOG_DEBUG("set fmbseb = 0x%04" PRIx32 "", fmbseb); | |||
bank->sectors[sector].is_protected = fmbseb & (1 << (sector - 16)) ? 0 : 1; | |||
} | |||
target_write_u32(target, 0xFFE89C00, orig_fmregopt); | |||
LOG_DEBUG("set fmregopt=0x%08" PRIx32 "", orig_fmregopt); | |||
LOG_DEBUG("set fmregopt = 0x%08" PRIx32 "", orig_fmregopt); | |||
target_write_u32(target, 0xFFFFFFDC, glbctrl); | |||
LOG_DEBUG("set glbctrl=0x%08" PRIx32 "", glbctrl); | |||
LOG_DEBUG("set glbctrl = 0x%08" PRIx32 "", glbctrl); | |||
if (result == ERROR_OK) | |||
{ | |||
@@ -1028,7 +1028,7 @@ static int tms470_write(struct flash_bank_s *bank, uint8_t * buffer, uint32_t of | |||
if (fmmstat & 0x3ff) | |||
{ | |||
LOG_ERROR("fmstat=0x%04" PRIx32 "", fmmstat); | |||
LOG_ERROR("fmstat = 0x%04" PRIx32 "", fmmstat); | |||
LOG_ERROR("Could not program word 0x%04x at address 0x%08" PRIx32 ".", word, addr); | |||
result = ERROR_FLASH_OPERATION_FAILED; | |||
break; | |||
@@ -1105,7 +1105,7 @@ static int tms470_erase_check(struct flash_bank_s *bank) | |||
target_read_u32(target, 0xFFE8BC04, &fmmac2); | |||
target_write_u32(target, 0xFFE8BC04, (fmmac2 & ~7) | tms470_info->ordinal); | |||
/* TCR=0 */ | |||
/* TCR = 0 */ | |||
target_write_u32(target, 0xFFE8BC10, 0x2fc0); | |||
/* clear TEZ in fmbrdy */ | |||
@@ -42,7 +42,7 @@ static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int | |||
{ | |||
unsigned int i; | |||
for (i=first; i<first+num; i++) | |||
for (i = first; i<first+num; i++) | |||
{ | |||
if (((value >> (i-first))&1) == 1) | |||
buffer[i/8] |= 1 << (i%8); | |||
@@ -61,7 +61,7 @@ static inline uint32_t buf_get_u32(const uint8_t* buffer, unsigned int first, un | |||
uint32_t result = 0; | |||
unsigned int i; | |||
for (i=first; i<first+num; i++) | |||
for (i = first; i<first+num; i++) | |||
{ | |||
if (((buffer[i/8]>>(i%8))&1) == 1) | |||
result |= 1 << (i-first); | |||
@@ -54,7 +54,7 @@ int run_command(command_context_t *context, command_t *c, char *words[], int num | |||
static void tcl_output(void *privData, const char *file, int line, const char *function, const char *string) | |||
{ | |||
Jim_Obj *tclOutput=(Jim_Obj *)privData; | |||
Jim_Obj *tclOutput = (Jim_Obj *)privData; | |||
Jim_AppendString(interp, tclOutput, string, strlen(string)); | |||
} | |||
@@ -108,7 +108,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) | |||
for (i = 0; i < argc; i++) | |||
{ | |||
int len; | |||
const char *w=Jim_GetString(argv[i], &len); | |||
const char *w = Jim_GetString(argv[i], &len); | |||
if (*w=='#') | |||
{ | |||
/* hit an end of line comment */ | |||
@@ -228,26 +228,26 @@ command_t* register_command(command_context_t *context, command_t *parent, char | |||
/* maximum of two levels :-) */ | |||
if (c->parent != NULL) | |||
{ | |||
t1=c->parent->name; | |||
t1 = c->parent->name; | |||
t2="_"; | |||
} | |||
t3=c->name; | |||
const char *full_name=alloc_printf("ocd_%s%s%s", t1, t2, t3); | |||
t3 = c->name; | |||
const char *full_name = alloc_printf("ocd_%s%s%s", t1, t2, t3); | |||
Jim_CreateCommand(interp, full_name, script_command, c, NULL); | |||
free((void *)full_name); | |||
/* we now need to add an overrideable proc */ | |||
const char *override_name=alloc_printf("proc %s%s%s {args} {if {[catch {eval ocd_%s%s%s $args}]==0} {return \"\"} else { return -code error }", t1, t2, t3, t1, t2, t3); | |||
const char *override_name = alloc_printf("proc %s%s%s {args} {if {[catch {eval ocd_%s%s%s $args}]==0} {return \"\"} else { return -code error }", t1, t2, t3, t1, t2, t3); | |||
Jim_Eval_Named(interp, override_name, __THIS__FILE__, __LINE__ ); | |||
free((void *)override_name); | |||
/* accumulate help text in Tcl helptext list. */ | |||
Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG); | |||
Jim_Obj *helptext = Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG); | |||
if (Jim_IsShared(helptext)) | |||
helptext = Jim_DuplicateObj(interp, helptext); | |||
Jim_Obj *cmd_entry=Jim_NewListObj(interp, NULL, 0); | |||
Jim_Obj *cmd_entry = Jim_NewListObj(interp, NULL, 0); | |||
Jim_Obj *cmd_list=Jim_NewListObj(interp, NULL, 0); | |||
Jim_Obj *cmd_list = Jim_NewListObj(interp, NULL, 0); | |||
/* maximum of two levels :-) */ | |||
if (c->parent != NULL) | |||
@@ -404,7 +404,7 @@ void command_print(command_context_t *context, const char *format, ...) | |||
int run_command(command_context_t *context, command_t *c, char *words[], int num_words) | |||
{ | |||
int start_word=0; | |||
int start_word = 0; | |||
if (!((context->mode == COMMAND_CONFIG) || (c->mode == COMMAND_ANY) || (c->mode == context->mode) )) | |||
{ | |||
/* Config commands can not run after the config stage */ | |||
@@ -422,10 +422,10 @@ int run_command(command_context_t *context, command_t *c, char *words[], int num | |||
/* maximum of two levels :-) */ | |||
if (c->parent != NULL) | |||
{ | |||
t1=c->parent->name; | |||
t1 = c->parent->name; | |||
t2=" "; | |||
} | |||
t3=c->name; | |||
t3 = c->name; | |||
command_run_linef(context, "help {%s%s%s}", t1, t2, t3); | |||
} | |||
else if (retval == ERROR_COMMAND_CLOSE_CONNECTION) | |||
@@ -450,7 +450,7 @@ int command_run_line(command_context_t *context, char *line) | |||
* results | |||
*/ | |||
/* run the line thru a script engine */ | |||
int retval=ERROR_FAIL; | |||
int retval = ERROR_FAIL; | |||
int retcode; | |||
/* Beware! This code needs to be reentrant. It is also possible | |||
* for OpenOCD commands to be invoked directly from Tcl. This would | |||
@@ -508,21 +508,21 @@ int command_run_line(command_context_t *context, char *line) | |||
} | |||
LOG_USER_N("%s", "\n"); | |||
} | |||
retval=ERROR_OK; | |||
retval = ERROR_OK; | |||
} | |||
return retval; | |||
} | |||
int command_run_linef(command_context_t *context, const char *format, ...) | |||
{ | |||
int retval=ERROR_FAIL; | |||
int retval = ERROR_FAIL; | |||
char *string; | |||
va_list ap; | |||
va_start(ap, format); | |||
string = alloc_vprintf(format, ap); | |||
if (string != NULL) | |||
{ | |||
retval=command_run_line(context, string); | |||
retval = command_run_line(context, string); | |||
} | |||
va_end(ap); | |||
return retval; | |||
@@ -837,13 +837,13 @@ void register_jim(struct command_context_s *cmd_ctx, const char *name, int (*cmd | |||
/* FIX!!! it would be prettier to invoke add_help_text... | |||
* accumulate help text in Tcl helptext list. */ | |||
Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG); | |||
Jim_Obj *helptext = Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG); | |||
if (Jim_IsShared(helptext)) | |||
helptext = Jim_DuplicateObj(interp, helptext); | |||
Jim_Obj *cmd_entry=Jim_NewListObj(interp, NULL, 0); | |||
Jim_Obj *cmd_entry = Jim_NewListObj(interp, NULL, 0); | |||
Jim_Obj *cmd_list=Jim_NewListObj(interp, NULL, 0); | |||
Jim_Obj *cmd_list = Jim_NewListObj(interp, NULL, 0); | |||
Jim_ListAppendElement(interp, cmd_list, Jim_NewStringObj(interp, name, -1)); | |||
Jim_ListAppendElement(interp, cmd_entry, cmd_list); | |||
@@ -854,7 +854,7 @@ void register_jim(struct command_context_s *cmd_ctx, const char *name, int (*cmd | |||
/* return global variable long value or 0 upon failure */ | |||
long jim_global_long(const char *variable) | |||
{ | |||
Jim_Obj *objPtr=Jim_GetGlobalVariableStr(interp, variable, JIM_ERRMSG); | |||
Jim_Obj *objPtr = Jim_GetGlobalVariableStr(interp, variable, JIM_ERRMSG); | |||
long t; | |||
if (Jim_GetLong(interp, objPtr, &t) == JIM_OK) | |||
{ | |||
@@ -93,7 +93,7 @@ FILE *open_file_from_path (char *file, char *mode) | |||
return fopen(file, mode); | |||
} else | |||
{ | |||
char *full_path=find_file(file); | |||
char *full_path = find_file(file); | |||
if (full_path == NULL) | |||
return NULL; | |||
FILE *fp = NULL; | |||
@@ -115,7 +115,7 @@ int parse_config_file(struct command_context_s *cmd_ctx) | |||
while (*cfg) | |||
{ | |||
retval=command_run_line(cmd_ctx, *cfg); | |||
retval = command_run_line(cmd_ctx, *cfg); | |||
if (retval != ERROR_OK) | |||
return retval; | |||
cfg++; | |||
@@ -215,7 +215,7 @@ int handle_append_command(struct command_context_s *cmd_ctx, char *cmd, | |||
return ERROR_INVALID_ARGUMENTS; | |||
} | |||
int retval=ERROR_FAIL; | |||
int retval = ERROR_FAIL; | |||
FILE *config_file = NULL; | |||
config_file = fopen(args[0], "a"); | |||
if (config_file != NULL) | |||
@@ -235,7 +235,7 @@ int handle_append_command(struct command_context_s *cmd_ctx, char *cmd, | |||
} | |||
if ((i == argc) && (fwrite("\n", 1, 1, config_file) == 1)) | |||
{ | |||
retval=ERROR_OK; | |||
retval = ERROR_OK; | |||
} | |||
fclose(config_file); | |||
} | |||
@@ -504,7 +504,7 @@ static jim_wide JimPowWide(jim_wide b, jim_wide e) | |||
{ | |||
jim_wide i, res = 1; | |||
if ((b == 0 && e != 0) || (e<0)) return 0; | |||
for (i=0; i<e; i++) {res *= b;} | |||
for (i = 0; i<e; i++) {res *= b;} | |||
return res; | |||
} | |||
@@ -569,7 +569,7 @@ void *Jim_Alloc(int size) | |||
{ | |||
/* We allocate zero length arrayes, etc. to use a single orthogonal codepath */ | |||
if (size == 0) | |||
size=1; | |||
size = 1; | |||
void *p = malloc(size); | |||
if (p == NULL) | |||
Jim_Panic(NULL,"malloc: Out of memory"); | |||
@@ -584,7 +584,7 @@ void *Jim_Realloc(void *ptr, int size) | |||
{ | |||
/* We allocate zero length arrayes, etc. to use a single orthogonal codepath */ | |||
if (size == 0) | |||
size=1; | |||
size = 1; | |||
void *p = realloc(ptr, size); | |||
if (p == NULL) | |||
Jim_Panic(NULL,"realloc: Out of memory"); | |||
@@ -2521,8 +2521,8 @@ static Jim_Obj *Jim_FormatString_Inner(Jim_Interp *interp, Jim_Obj *fmtObjPtr, | |||
Jim_Obj *Jim_FormatString(Jim_Interp *interp, Jim_Obj *fmtObjPtr, | |||
int objc, Jim_Obj *const *objv) | |||
{ | |||
char *sprintf_buf=malloc(JIM_MAX_FMT); | |||
Jim_Obj *t=Jim_FormatString_Inner(interp, fmtObjPtr, objc, objv, sprintf_buf); | |||
char *sprintf_buf = malloc(JIM_MAX_FMT); | |||
Jim_Obj *t = Jim_FormatString_Inner(interp, fmtObjPtr, objc, objv, sprintf_buf); | |||
free(sprintf_buf); | |||
return t; | |||
} | |||
@@ -5366,7 +5366,7 @@ void ListInsertElements(Jim_Obj *listPtr, int index, int elemc, | |||
} | |||
point = listPtr->internalRep.listValue.ele + index; | |||
memmove(point+elemc, point, (currentLen-index) * sizeof(Jim_Obj*)); | |||
for (i=0; i < elemc; ++i) { | |||
for (i = 0; i < elemc; ++i) { | |||
point[i] = elemVec[i]; | |||
Jim_IncrRefCount(point[i]); | |||
} | |||
@@ -7335,7 +7335,7 @@ static int SetScanFmtFromAny(Jim_Interp *interp, Jim_Obj *objPtr) | |||
Jim_FreeIntRep(interp, objPtr); | |||
/* Count how many conversions could take place maximally */ | |||
for (i=0, maxCount=0; i < maxFmtLen; ++i) | |||
for (i = 0, maxCount = 0; i < maxFmtLen; ++i) | |||
if (fmt[i] == '%') | |||
++maxCount; | |||
/* Calculate an approximation of the memory necessary */ | |||
@@ -7356,8 +7356,8 @@ static int SetScanFmtFromAny(Jim_Interp *interp, Jim_Obj *objPtr) | |||
buffer = fmtObj->stringRep + maxFmtLen + 1; | |||
objPtr->internalRep.ptr = fmtObj; | |||
objPtr->typePtr = &scanFmtStringObjType; | |||
for (i=0, curr=0; fmt < fmtEnd; ++fmt) { | |||
int width=0, skip; | |||
for (i = 0, curr = 0; fmt < fmtEnd; ++fmt) { | |||
int width = 0, skip; | |||
ScanFmtPartDescr *descr = &fmtObj->descr[curr]; | |||
fmtObj->count++; | |||
descr->width = 0; /* Assume width unspecified */ | |||
@@ -7401,7 +7401,7 @@ static int SetScanFmtFromAny(Jim_Interp *interp, Jim_Obj *objPtr) | |||
return JIM_ERR; | |||
} | |||
/* Look if this position was already used */ | |||
for (prev=0; prev < curr; ++prev) { | |||
for (prev = 0; prev < curr; ++prev) { | |||
if (fmtObj->descr[prev].pos == -1) continue; | |||
if (fmtObj->descr[prev].pos == descr->pos) { | |||
fmtObj->error = "same \"%n$\" conversion specifier " | |||
@@ -7442,7 +7442,7 @@ static int SetScanFmtFromAny(Jim_Interp *interp, Jim_Obj *objPtr) | |||
/* In case a range fence was given "backwards", swap it */ | |||
while (swapped) { | |||
swapped = 0; | |||
for (j=beg+1; j < end-1; ++j) { | |||
for (j = beg+1; j < end-1; ++j) { | |||
if (buffer[j] == '-' && buffer[j-1] > buffer[j+1]) { | |||
char tmp = buffer[j-1]; | |||
buffer[j-1] = buffer[j+1]; | |||
@@ -7550,7 +7550,7 @@ JimScanAString(Jim_Interp *interp, const char *sdescr, const char *str) | |||
if (sdescr[1] == '-' && sdescr[2] != 0) { | |||
/* Handle range definitions */ | |||
int i; | |||
for (i=sdescr[0]; i <= sdescr[2]; ++i) | |||
for (i = sdescr[0]; i <= sdescr[2]; ++i) | |||
JimSetBit(charset, (char)i); | |||
sdescr += 3; | |||
} else { | |||
@@ -7559,7 +7559,7 @@ JimScanAString(Jim_Interp *interp, const char *sdescr, const char *str) | |||
} | |||
} | |||
/* Negate the charset if there was a NOT given */ | |||
for (i=0; notFlag && i < sizeof(charset); ++i) | |||
for (i = 0; notFlag && i < sizeof(charset); ++i) | |||
charset[i] = ~charset[i]; | |||
} | |||
/* And after all the mess above, the real work begin ... */ | |||
@@ -7600,7 +7600,7 @@ static int ScanOneEntry(Jim_Interp *interp, const char *str, long pos, | |||
if (descr->prefix) { | |||
/* There was a prefix given before the conversion, skip it and adjust | |||
* the string-to-be-parsed accordingly */ | |||
for (i=0; str[pos] && descr->prefix[i]; ++i) { | |||
for (i = 0; str[pos] && descr->prefix[i]; ++i) { | |||
/* If prefix require, skip WS */ | |||
if (isspace((int)descr->prefix[i])) | |||
while (str[pos] && isspace((int)str[pos])) ++pos; | |||
@@ -7757,12 +7757,12 @@ Jim_Obj *Jim_ScanString(Jim_Interp *interp, Jim_Obj *strObjPtr, | |||
/* Create a list and fill it with empty strings up to max specified XPG3 */ | |||
resultList = Jim_NewListObj(interp, 0, 0); | |||
if (fmtObj->maxPos > 0) { | |||
for (i=0; i < fmtObj->maxPos; ++i) | |||
for (i = 0; i < fmtObj->maxPos; ++i) | |||
Jim_ListAppendElement(interp, resultList, emptyStr); | |||
JimListGetElements(interp, resultList, &resultc, &resultVec); | |||
} | |||
/* Now handle every partial format description */ | |||
for (i=0, pos=0; i < fmtObj->count; ++i) { | |||
for (i = 0, pos = 0; i < fmtObj->count; ++i) { | |||
ScanFmtPartDescr *descr = &(fmtObj->descr[i]); | |||
Jim_Obj *value = 0; | |||
/* Only last type may be "literal" w/o conversion - skip it! */ | |||
@@ -8960,8 +8960,8 @@ int Jim_EvalFile(Jim_Interp *interp, const char *filename) | |||
Jim_Obj *scriptObjPtr; | |||
if ((fp = fopen(filename, "r")) == NULL) { | |||
const int cwd_len=2048; | |||
char *cwd=malloc(cwd_len); | |||
const int cwd_len = 2048; | |||
char *cwd = malloc(cwd_len); | |||
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); | |||
if (!getcwd( cwd, cwd_len )) strcpy(cwd, "unknown"); | |||
Jim_AppendStrings(interp, Jim_GetResult(interp), | |||
@@ -10203,7 +10203,7 @@ static int JimForeachMapHelper(Jim_Interp *interp, int argc, | |||
/* Initialize iterators and remember max nbr elements each list */ | |||
memset(listsIdx, 0, nbrOfLists * sizeof(int)); | |||
/* Remember lengths of all lists and calculate how much rounds to loop */ | |||
for (i=0; i < nbrOfLists*2; i += 2) { | |||
for (i = 0; i < nbrOfLists*2; i += 2) { | |||
div_t cnt; | |||
int count; | |||
Jim_ListLength(interp, argv[i+1], &listsEnd[i]); | |||
@@ -10218,7 +10218,7 @@ static int JimForeachMapHelper(Jim_Interp *interp, int argc, | |||
nbrOfLoops = count; | |||
} | |||
for (; nbrOfLoops-- > 0; ) { | |||
for (i=0; i < nbrOfLists; ++i) { | |||
for (i = 0; i < nbrOfLists; ++i) { | |||
int varIdx = 0, var = i * 2; | |||
while (varIdx < listsEnd[var]) { | |||
Jim_Obj *varName, *ele; | |||
@@ -10340,11 +10340,11 @@ enum {SWITCH_EXACT, SWITCH_GLOB, SWITCH_RE, SWITCH_CMD, SWITCH_UNKNOWN}; | |||
static int Jim_SwitchCoreCommand(Jim_Interp *interp, int argc, | |||
Jim_Obj *const *argv) | |||
{ | |||
int retcode = JIM_ERR, matchOpt = SWITCH_EXACT, opt=1, patCount, i; | |||
int retcode = JIM_ERR, matchOpt = SWITCH_EXACT, opt = 1, patCount, i; | |||
Jim_Obj *command = 0, *const *caseList = 0, *strObj; | |||
Jim_Obj *script = 0; | |||
if (argc < 3) goto wrongnumargs; | |||
for (opt=1; opt < argc; ++opt) { | |||
for (opt = 1; opt < argc; ++opt) { | |||
const char *option = Jim_GetString(argv[opt], 0); | |||
if (*option != '-') break; | |||
else if (strncmp(option, "--", 2) == 0) { ++opt; break; } | |||
@@ -10372,7 +10372,7 @@ static int Jim_SwitchCoreCommand(Jim_Interp *interp, int argc, | |||
} else | |||
caseList = &argv[opt]; | |||
if (patCount == 0 || patCount % 2 != 0) goto wrongnumargs; | |||
for (i=0; script == 0 && i < patCount; i += 2) { | |||
for (i = 0; script == 0 && i < patCount; i += 2) { | |||
Jim_Obj *patObj = caseList[i]; | |||
if (!Jim_CompareStringImmediate(interp, patObj, "default") | |||
|| i < (patCount-2)) { | |||
@@ -575,7 +575,7 @@ typedef struct Jim_Reference { | |||
* known string, or there may be multiple strings (aliases) that mean then same | |||
* thing. | |||
* | |||
* An NVP Table is terminated with ".name=NULL". | |||
* An NVP Table is terminated with ".name = NULL". | |||
* | |||
* During the 'name2value' operation, if no matching string is found | |||
* the pointer to the terminal element (with p->name == NULL) is returned. | |||
@@ -966,7 +966,7 @@ JIM_STATIC const char *JIM_API( Jim_Debug_ArgvString )( Jim_Interp *interp, int | |||
* Usefull when dealing with command options. | |||
* that may come in any order... | |||
* | |||
* Does not support "-foo=123" type options. | |||
* Does not support "-foo = 123" type options. | |||
* Only supports tcl type options, like "-foo 123" | |||
*/ | |||
@@ -1097,7 +1097,7 @@ JIM_STATIC int JIM_API( Jim_GetOpt_Nvp)( Jim_GetOptInfo *goi, const Jim_Nvp *loo | |||
* | |||
* This function assumes the previous option argv[-1] is the unknown string. | |||
* | |||
* If this option had some prefix, then pass "hadprefix=1" else pass "hadprefix=0" | |||
* If this option had some prefix, then pass "hadprefix = 1" else pass "hadprefix = 0" | |||
* | |||
* Example: | |||
* \code | |||
@@ -1107,7 +1107,7 @@ JIM_STATIC int JIM_API( Jim_GetOpt_Nvp)( Jim_GetOptInfo *goi, const Jim_Nvp *loo | |||
* e = Jim_GetOpt_Nvp( &goi, cmd_options, &n ); | |||
* if ( e != JIM_OK ){ | |||
* // option was not recognized | |||
* // pass 'hadprefix=0' because there is no prefix | |||
* // pass 'hadprefix = 0' because there is no prefix | |||
* Jim_GetOpt_NvpUnknown( &goi, cmd_options, 0 ); | |||
* return e; | |||
* } | |||
@@ -94,7 +94,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch | |||
if (debug_level >= LOG_LVL_DEBUG) | |||
{ | |||
/* print with count and time information */ | |||
int t=(int)(timeval_ms()-start); | |||
int t = (int)(timeval_ms()-start); | |||
#ifdef _DEBUG_FREE_SPACE_ | |||
struct mallinfo info; | |||
info = mallinfo(); | |||
@@ -136,9 +136,9 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch | |||
/* DANGER!!!! the log callback can remove itself!!!! */ | |||
while (cb) | |||
{ | |||
next=cb->next; | |||
next = cb->next; | |||
cb->fn(cb->priv, file, line, function, string); | |||
cb=next; | |||
cb = next; | |||
} | |||
} | |||
} | |||
@@ -259,7 +259,7 @@ int log_init(struct command_context_s *cmd_ctx) | |||
log_output = stderr; | |||
} | |||
start=last_time=timeval_ms(); | |||
start = last_time = timeval_ms(); | |||
return ERROR_OK; | |||
} | |||
@@ -383,7 +383,7 @@ char *alloc_printf(const char *format, ...) | |||
*/ | |||
void keep_alive() | |||
{ | |||
current_time=timeval_ms(); | |||
current_time = timeval_ms(); | |||
if (current_time-last_time>1000) | |||
{ | |||
extern int gdb_actual_connections; | |||
@@ -413,28 +413,28 @@ void keep_alive() | |||
* These functions should be invoked at a well defined spot in server.c | |||
*/ | |||
last_time=current_time; | |||
last_time = current_time; | |||
} | |||
} | |||
/* reset keep alive timer without sending message */ | |||
void kept_alive() | |||
{ | |||
current_time=timeval_ms(); | |||
last_time=current_time; | |||
current_time = timeval_ms(); | |||
last_time = current_time; | |||
} | |||
/* if we sleep for extended periods of time, we must invoke keep_alive() intermittantly */ | |||
void alive_sleep(int ms) | |||
{ | |||
int i; | |||
int napTime=10; | |||
for (i=0; i<ms; i += napTime) | |||
int napTime = 10; | |||
for (i = 0; i<ms; i += napTime) | |||
{ | |||
int sleep_a_bit=ms-i; | |||
int sleep_a_bit = ms-i; | |||
if (sleep_a_bit>napTime) | |||
{ | |||
sleep_a_bit=napTime; | |||
sleep_a_bit = napTime; | |||
} | |||
usleep(sleep_a_bit*1000); | |||
keep_alive(); | |||
@@ -444,7 +444,7 @@ void alive_sleep(int ms) | |||
void busy_sleep(int ms) | |||
{ | |||
long long then; | |||
then=timeval_ms(); | |||
then = timeval_ms(); | |||
while ((timeval_ms()-then)<ms) | |||
{ | |||
/* busy wait */ | |||
@@ -70,7 +70,7 @@ int add_default_dirs(void) | |||
/* Either this code will *always* work or it will SEGFAULT giving | |||
* excellent information on the culprit. | |||
*/ | |||
*strrchr(strExePath, '\\')=0; | |||
*strrchr(strExePath, '\\') = 0; | |||
strcat(strExePath, "\\.."); | |||
add_script_search_dir(strExePath); | |||
} | |||
@@ -88,9 +88,9 @@ int add_default_dirs(void) | |||
char strExePath [MAX_PATH]; | |||
char *p; | |||
GetModuleFileName (NULL, strExePath, MAX_PATH); | |||
*strrchr(strExePath, '\\')=0; | |||
*strrchr(strExePath, '\\') = 0; | |||
strcat(strExePath, "/../lib/"PACKAGE); | |||
for (p=strExePath; *p; p++) { | |||
for (p = strExePath; *p; p++) { | |||
if (*p == '\\') | |||
*p = '/'; | |||
} | |||
@@ -99,7 +99,7 @@ int duration_stop_measure(duration_t *duration, char **text) | |||
if (text) | |||
{ | |||
float t; | |||
t=duration->duration.tv_sec; | |||
t = duration->duration.tv_sec; | |||
t += (float)duration->duration.tv_usec/1000000.0; | |||
*text = malloc(100); | |||
snprintf(*text, 100, "%fs", t); | |||
@@ -111,7 +111,7 @@ int duration_stop_measure(duration_t *duration, char **text) | |||
long long timeval_ms() | |||
{ | |||
struct timeval now; | |||
long long t=0; | |||
long long t = 0; | |||
gettimeofday(&now, NULL); | |||
t += now.tv_usec/1000; | |||
@@ -47,7 +47,7 @@ bitbang_interface_t *bitbang_interface; | |||
* | |||
* If someone can submit a patch with an explanation it will be greatly | |||
* appreciated, but as far as I can tell (ØH) DCLK is generated upon | |||
* clk=0 in TAP_IDLE. Good luck deducing that from the ARM documentation! | |||
* clk = 0 in TAP_IDLE. Good luck deducing that from the ARM documentation! | |||
* The ARM documentation uses the term "DCLK is asserted while in the TAP_IDLE | |||
* state". With hardware there is no such thing as *while* in a state. There | |||
* are only edges. So clk => 0 is in fact a very subtle state transition that | |||
@@ -76,7 +76,7 @@ static void bitbang_end_state(tap_state_t state) | |||
static void bitbang_state_move(int skip) | |||
{ | |||
int i=0, tms=0; | |||
int i = 0, tms = 0; | |||
uint8_t tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state()); | |||
int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state()); | |||
@@ -188,24 +188,24 @@ static void bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int | |||
for (bit_cnt = 0; bit_cnt < scan_size; bit_cnt++) | |||
{ | |||
int val=0; | |||
int tms=(bit_cnt == scan_size-1) ? 1 : 0; | |||
int val = 0; | |||
int tms = (bit_cnt == scan_size-1) ? 1 : 0; | |||
int tdi; | |||
int bytec=bit_cnt/8; | |||
int bcval=1 << (bit_cnt % 8); | |||