if (at91sam7_info->cidr_arch == 0x60)
{
/* AT91SAM7A3 uses master clocks in 100 ns */
- fmcn = (at91sam7_info->mck_freq/10000000ul)+1;
+ fmcn = (at91sam7_info->mck_freq/10000000ul) + 1;
}
else
{
/* master clocks in 1uS for ARCH 0x7 types */
- fmcn = (at91sam7_info->mck_freq/1000000ul)+1;
+ fmcn = (at91sam7_info->mck_freq/1000000ul) + 1;
}
}
else if (mode == FMR_TIMING_FLASH)
{
/* main clocks in 1.5uS */
fmcn = (at91sam7_info->mck_freq/1000000ul)+
- (at91sam7_info->mck_freq/2000000ul)+1;
+ (at91sam7_info->mck_freq/2000000ul) + 1;
}
/* hard overclocking */
fcr = (0x5A << 24) | ((pagen&0x3FF) << 8) | cmd;
target_write_u32(target, MC_FCR[bank->bank_number], fcr);
- LOG_DEBUG("Flash command: 0x%" PRIx32 ", flash bank: %i, page number: %u", fcr, bank->bank_number+1, pagen);
+ LOG_DEBUG("Flash command: 0x%" PRIx32 ", flash bank: %i, page number: %u", fcr, bank->bank_number + 1, pagen);
if ((at91sam7_info->cidr_arch == 0x60) && ((cmd == SLB)|(cmd == CLB)))
{
fast_check = 1;
for (nSector = 0; nSector<bank->num_sectors; nSector++)
{
- retval = target_blank_check_memory(target, bank->base+bank->sectors[nSector].offset,
+ retval = target_blank_check_memory(target, bank->base + bank->sectors[nSector].offset,
bank->sectors[nSector].size, &blank);
if (retval != ERROR_OK)
{
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,
+ retval = target_read_memory(target, bank->base + bank->sectors[nSector].offset, 4,
bank->sectors[nSector].size/4, buffer);
if (retval != ERROR_OK)
return retval;
at91sam7_info->num_lockbits_on = 0;
for (lock_pos = 0; lock_pos<bank->num_sectors; lock_pos++)
{
- if ( ((status >> (16+lock_pos))&(0x0001)) == 1)
+ if ( ((status >> (16 + lock_pos))&(0x0001)) == 1)
{
at91sam7_info->num_lockbits_on++;
bank->sectors[lock_pos].is_protected = 1;
at91sam7_info->num_nvmbits_on = 0;
for (gpnvm_pos = 0; gpnvm_pos<at91sam7_info->num_nvmbits; gpnvm_pos++)
{
- if ( ((status >> (8+gpnvm_pos))&(0x01)) == 1)
+ if ( ((status >> (8 + gpnvm_pos))&(0x01)) == 1)
{
at91sam7_info->num_nvmbits_on++;
}
page_size = atoi(args[11]);
num_nvmbits = atoi(args[12]);
- target_name = calloc(strlen(args[7])+1, sizeof(char));
+ target_name = calloc(strlen(args[7]) + 1, sizeof(char));
strcpy(target_name, args[7]);
/* calculate bank size */
/* Write one block to the PageWriteBuffer */
buffer_pos = (pagen-first_page)*dst_min_alignment;
wcount = CEIL(count,4);
- if ((retval = target_write_memory(target, bank->base+pagen*dst_min_alignment, 4, wcount, buffer+buffer_pos)) != ERROR_OK)
+ if ((retval = target_write_memory(target, bank->base + pagen*dst_min_alignment, 4, wcount, buffer + buffer_pos)) != ERROR_OK)
{
return retval;
}
{
uint8_t i;
for (i = 0;i<2;i++)
- target_read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1,
+ target_read_memory(target, flash_address(bank, sector, offset + i), bank->bus_width, 1,
&data[i*bank->bus_width] );
}
else
{
uint8_t i;
for (i = 0;i<4;i++)
- target_read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1,
+ target_read_memory(target, flash_address(bank, sector, offset + i), bank->bus_width, 1,
&data[i*bank->bus_width] );
}
else
uint32_t flashErr;
retval = runCode(info,
- info->start_address+OFFSET_ERASE,
- info->start_address+OFFSET_ERASE+OFFSET_ERASE_SIZE,
+ info->start_address + OFFSET_ERASE,
+ info->start_address + OFFSET_ERASE + OFFSET_ERASE_SIZE,
address,
len,
0,
uint32_t buffer;
retval = runCode(info,
- info->start_address+OFFSET_GET_WORKAREA,
- info->start_address+OFFSET_GET_WORKAREA+OFFSET_GET_WORKAREA_SIZE,
+ info->start_address + OFFSET_GET_WORKAREA,
+ info->start_address + OFFSET_GET_WORKAREA + OFFSET_GET_WORKAREA_SIZE,
0,
0,
0,
}
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,
- info->start_address+OFFSET_FLASH,
- info->start_address+OFFSET_FLASH+OFFSET_FLASH_SIZE,
+ info->start_address + OFFSET_FLASH,
+ info->start_address + OFFSET_FLASH + OFFSET_FLASH_SIZE,
buffer,
- address+i,
+ address + i,
t,
&flashErr,
timeout);
{
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));
+ return eCosBoard_erase(info, c->base + first*sectorSize, sectorSize*(last-first + 1));
}
static int ecosflash_protect(struct flash_bank_s *bank, int set, int first, int last)
{
ecosflash_flash_bank_t *info = bank->driver_priv;
struct flash_bank_s *c = bank;
- return eCosBoard_flash(info, buffer, c->base+offset, count);
+ return eCosBoard_flash(info, buffer, c->base + offset, count);
}
static int ecosflash_protect_check(struct flash_bank_s *bank)
/* see if we need to pad the section */
while (padding[section]--)
- (buffer+buffer_size)[size_read++] = 0xff;
+ (buffer + buffer_size)[size_read++] = 0xff;
buffer_size += size_read;
section_offset += size_read;
CLK_OUT = XIN * ((double)M / N) / NO;
- if ((int)((CLK_OUT+ROUND) / DIV)
+ if ((int)((CLK_OUT + ROUND) / DIV)
== (int)(MG_PLL_CLK_OUT / DIV)) {
if (mg_is_valid_pll(XIN, N, CLK_OUT, NO) == ERROR_OK)
{
typedef enum _mg_opmode
{
mg_op_mode_xip = 1, /* TRUE XIP */
- mg_op_mode_snd = 2, /* BOOT+Storage */
+ mg_op_mode_snd = 2, /* BOOT + Storage */
mg_op_mode_stg = 0 /* Only Storage */
} mg_opmode;
{
if (device->bus_width == 8)
{
- device->controller->read_data(device, id_buff+3);
- device->controller->read_data(device, id_buff+4);
- device->controller->read_data(device, id_buff+5);
+ device->controller->read_data(device, id_buff + 3);
+ device->controller->read_data(device, id_buff + 4);
+ device->controller->read_data(device, id_buff + 5);
}
else
{
uint8_t ecc[3];
memset(oob, 0xff, oob_size);
for (i = 0, j = 0; i < page_size; i += 256) {
- nand_calculate_ecc(p, page+i, ecc);
+ nand_calculate_ecc(p, page + i, ecc);
oob[eccpos[j++]] = ecc[0];
oob[eccpos[j++]] = ecc[1];
oob[eccpos[j++]] = ecc[2];
uint8_t *ecc = oob + oob_size - page_size/512 * 10;
memset(oob, 0xff, oob_size);
for (i = 0; i < page_size; i += 512) {
- nand_calculate_ecc_kw(p, page+i, ecc);
+ nand_calculate_ecc_kw(p, page + i, ecc);
ecc += 10;
}
}
}
/* receive response */
- if ((retval = embeddedice_receive(ocl->jtag_info, dcc_buffer+1, 1) != ERROR_OK))
+ if ((retval = embeddedice_receive(ocl->jtag_info, dcc_buffer + 1, 1) != ERROR_OK))
return retval;
if (dcc_buffer[1] != OCL_CMD_DONE)
}
/* allocate buffer for max. ocl buffer + overhead */
- dcc_buffer = malloc(sizeof(uint32_t)*(ocl->buflen/4+3));
+ dcc_buffer = malloc(sizeof(uint32_t)*(ocl->buflen/4 + 3));
while (count)
{
len = cmd&0xffff;
ofs = adr%flash_page_size;
bi_start = ofs/4;
- bi_end = (ofs+len+3)/4;
+ bi_end = (ofs + len + 3)/4;
if (bi_end>BUFSIZE) {
dcc_wr(OCL_BUFF_OVER);
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 = 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);
}
else efc_ofs = 0;
/* wait until FLASH is ready, just for sure */
- while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0);
+ 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));
+ flash_ptr = (uint32 *)(FLASH_AREA_ADDR + (page_num*flash_page_size));
data_ptr = data;
/* copy data to latch */
}
/* page number and page write command to FCR */
- outr(MC_FCR+efc_ofs, ((page_num&0x3ff) << 8) | MC_KEY | MC_FCMD_WP);
+ outr(MC_FCR + efc_ofs, ((page_num&0x3ff) << 8) | MC_KEY | MC_FCMD_WP);
/* wait until it's done */
- while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0);
+ while ((inr(MC_FSR + efc_ofs)&MC_FRDY) == 0);
/* check for errors */
- if ((inr(MC_FSR+efc_ofs)&MC_PROGE)) return FLASH_STAT_PROGE;
- if ((inr(MC_FSR+efc_ofs)&MC_LOCKE)) return FLASH_STAT_LOCKE;
+ if ((inr(MC_FSR + efc_ofs)&MC_PROGE)) return FLASH_STAT_PROGE;
+ if ((inr(MC_FSR + efc_ofs)&MC_LOCKE)) return FLASH_STAT_LOCKE;
#if 0
/* verify written data */
- flash_ptr = (uint32 *)(FLASH_AREA_ADDR+(page_num*flash_page_size));
+ flash_ptr = (uint32 *)(FLASH_AREA_ADDR + (page_num*flash_page_size));
data_ptr = data;
for (i = flash_page_size/4; i; i--) {
int page_num;
page_num = 0;
- lockbits = inr(MC_FSR+efc_ofs) >> 16;
+ lockbits = inr(MC_FSR + efc_ofs) >> 16;
while (lockbits) {
if (lockbits&1) {
/* wait until FLASH is ready, just for sure */
- while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0);
+ while ((inr(MC_FSR + efc_ofs)&MC_FRDY) == 0);
- outr(MC_FCR+efc_ofs, ((page_num&0x3ff) << 8) | 0x5a000004);
+ outr(MC_FCR + efc_ofs, ((page_num&0x3ff) << 8) | 0x5a000004);
/* wait until it's done */
- while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0);
+ while ((inr(MC_FSR + efc_ofs)&MC_FRDY) == 0);
/* check for errors */
- if ((inr(MC_FSR+efc_ofs)&MC_PROGE)) return FLASH_STAT_PROGE;
- if ((inr(MC_FSR+efc_ofs)&MC_LOCKE)) return FLASH_STAT_LOCKE;
+ if ((inr(MC_FSR + efc_ofs)&MC_PROGE)) return FLASH_STAT_PROGE;
+ if ((inr(MC_FSR + efc_ofs)&MC_LOCKE)) return FLASH_STAT_LOCKE;
}
if ((page_num += flash_lock_pages)>flash_page_count) break;
}
/* wait until FLASH is ready, just for sure */
- while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0);
+ while ((inr(MC_FSR + efc_ofs)&MC_FRDY) == 0);
/* erase all command to FCR */
- outr(MC_FCR+efc_ofs, 0x5a000008);
+ outr(MC_FCR + efc_ofs, 0x5a000008);
/* wait until it's done */
- while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0);
+ while ((inr(MC_FSR + efc_ofs)&MC_FRDY) == 0);
/* check for errors */
- if ((inr(MC_FSR+efc_ofs)&MC_PROGE)) return FLASH_STAT_PROGE;
- if ((inr(MC_FSR+efc_ofs)&MC_LOCKE)) return FLASH_STAT_LOCKE;
+ if ((inr(MC_FSR + efc_ofs)&MC_PROGE)) return FLASH_STAT_PROGE;
+ if ((inr(MC_FSR + efc_ofs)&MC_LOCKE)) return FLASH_STAT_LOCKE;
/* set no erase before programming */
- outr(MC_FMR+efc_ofs, inr(MC_FMR+efc_ofs)|0x80);
+ outr(MC_FMR + efc_ofs, inr(MC_FMR + efc_ofs)|0x80);
return FLASH_STAT_OK;
}
{
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;
}
command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[2]);
return ERROR_OK;
}
- if (address < bank->base || address >= (bank->base+bank->size))
+ if (address < bank->base || address >= (bank->base + bank->size))
{
command_print(cmd_ctx, "flash address '%s' is out of bounds", args[0]);
return ERROR_OK;
* Note: These macros only work for KSEG0/KSEG1 addresses.
*/
#define KS1Virt2Phys(vaddr) ((vaddr)-0xA0000000)
-#define Phys2KS1Virt(paddr) ((paddr)+0xA0000000)
+#define Phys2KS1Virt(paddr) ((paddr) + 0xA0000000)
#define KS0Virt2Phys(vaddr) ((vaddr)-0x80000000)
-#define Phys2KS0Virt(paddr) ((paddr)+0x80000000)
+#define Phys2KS0Virt(paddr) ((paddr) + 0x80000000)
/* pic32mx configuration register locations */
stellaris_info->did1,
stellaris_info->did1,
"ARMV7M",
- (int)((1+((stellaris_info->dc0 >> 16) & 0xFFFF))/4),
- (int)((1+(stellaris_info->dc0 & 0xFFFF))*2));
+ (int)((1 + ((stellaris_info->dc0 >> 16) & 0xFFFF))/4),
+ (int)((1 + (stellaris_info->dc0 & 0xFFFF))*2));
buf += printed;
buf_size -= printed;
mainfreq = 200000000; /* PLL out frec */
if (usesysdiv)
- stellaris_info->mck_freq = mainfreq/(1+sysdiv);
+ stellaris_info->mck_freq = mainfreq/(1 + sysdiv);
else
stellaris_info->mck_freq = mainfreq;
stellaris_info->did1 = did1;
stellaris_info->num_lockbits = 1 + (stellaris_info->dc0 & 0xFFFF);
- stellaris_info->num_pages = 2 *(1+(stellaris_info->dc0 & 0xFFFF));
+ stellaris_info->num_pages = 2 *(1 + (stellaris_info->dc0 & 0xFFFF));
stellaris_info->pagesize = 1024;
bank->size = 1024 * stellaris_info->num_pages;
stellaris_info->pages_in_lockregion = 2;
flash_cmd = FLASH_SPR;
target_write_u32(target, str7x_get_flash_adr(bank, FLASH_CR0), flash_cmd);
target_write_u32(target, str7x_get_flash_adr(bank, FLASH_AR), 0x4010DFBC);
- target_write_u32(target, str7x_get_flash_adr(bank, FLASH_DR0), ~(1 << (15+ProtectionLevel)));
+ target_write_u32(target, str7x_get_flash_adr(bank, FLASH_DR0), ~(1 << (15 + ProtectionLevel)));
flash_cmd = FLASH_SPR | FLASH_WMS;
target_write_u32(target, str7x_get_flash_adr(bank, FLASH_CR0), flash_cmd);
}
if (str9x_info->variant)
str9x_info->sector_bits[num_sectors++] = (1 << i);
else
- str9x_info->sector_bits[num_sectors++] = (1 << (i+8));
+ str9x_info->sector_bits[num_sectors++] = (1 << (i + 8));
}
return ERROR_OK;
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);
{
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);
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);
if (reslen>0)
{
int i;
- char buff[256+1];
+ char buff[256 + 1];
for (i = 0; i < reslen; i += 256)
{
int chunk;
chunk = reslen - i;
if (chunk > 256)
chunk = 256;
- strncpy(buff, result+i, chunk);
+ strncpy(buff, result + i, chunk);
buff[chunk] = 0;
LOG_USER_N("%s", buff);
}
}
/* GRR we must chunk - not null terminated */
while (nbytes) {
- char chunk[128+1];
+ char chunk[128 + 1];
int x;
x = nbytes;
void add_script_search_dir (const char *dir)
{
num_script_dirs++;
- script_search_dirs = (char **)realloc(script_search_dirs, (num_script_dirs+1) * sizeof (char *));
+ script_search_dirs = (char **)realloc(script_search_dirs, (num_script_dirs + 1) * sizeof (char *));
script_search_dirs[num_script_dirs-1] = strdup(dir);
script_search_dirs[num_script_dirs] = NULL;
void add_config_command (const char *cfg)
{
num_config_files++;
- config_file_names = (char **)realloc(config_file_names, (num_config_files+1) * sizeof (char *));
+ config_file_names = (char **)realloc(config_file_names, (num_config_files + 1) * sizeof (char *));
config_file_names[num_config_files-1] = strdup(cfg);
config_file_names[num_config_files] = NULL;
chunk = maxChunk;
}
- if ((retval == ERROR_OK) && (fwrite(((char *)data)+pos, 1, chunk, f) != chunk))
+ if ((retval == ERROR_OK) && (fwrite(((char *)data) + pos, 1, chunk, f) != chunk))
retval = ERROR_INVALID_ARGUMENTS;
if (retval != ERROR_OK)
// fprintf(stderr,"No Event\n");
}
- retval = select(maxfd+1, &rfds, &wfds, &efds, tvp);
+ retval = select(maxfd + 1, &rfds, &wfds, &efds, tvp);
if (retval < 0) {
switch (errno) {
case EINTR: fprintf(stderr,"select EINTR\n"); break;
if (patternLen == 1)
return 1; /* match */
while (stringLen) {
- if (JimStringMatch(pattern+1, patternLen-1,
+ if (JimStringMatch(pattern + 1, patternLen-1,
string, stringLen, nocase))
return 1; /* match */
string++;
* in length, this allows to avoid to check every object with a string
* repr < 32, and usually there are many of this objects. */
-#define JIM_REFERENCE_SPACE (35+JIM_REFERENCE_TAGLEN)
+#define JIM_REFERENCE_SPACE (35 + JIM_REFERENCE_TAGLEN)
static int JimFormatReference(char *buf, Jim_Reference *refPtr, jim_wide id)
{
s[0] = '.';
s[1] = '0';
s[2] = '\0';
- return len+2;
+ return len + 2;
}
return len;
}
char *Jim_StrDup(const char *s)
{
int l = strlen(s);
- char *copy = Jim_Alloc(l+1);
+ char *copy = Jim_Alloc(l + 1);
- memcpy(copy, s, l+1);
+ memcpy(copy, s, l + 1);
return copy;
}
char *Jim_StrDupLen(const char *s, int l)
{
- char *copy = Jim_Alloc(l+1);
+ char *copy = Jim_Alloc(l + 1);
- memcpy(copy, s, l+1);
+ memcpy(copy, s, l + 1);
copy[l] = 0; /* Just to be sure, original could be substring */
return copy;
}
static const void *JimStringCopyHTKeyDup(void *privdata, const void *key)
{
int len = strlen(key);
- char *copy = Jim_Alloc(len+1);
+ char *copy = Jim_Alloc(len + 1);
JIM_NOTUSED(privdata);
memcpy(copy, key, len);
static void *JimStringKeyValCopyHTValDup(void *privdata, const void *val)
{
int len = strlen(val);
- char *copy = Jim_Alloc(len+1);
+ char *copy = Jim_Alloc(len + 1);
JIM_NOTUSED(privdata);
memcpy(copy, val, len);
}
void Jim_StackPush(Jim_Stack *stack, void *element) {
- int neededLen = stack->len+1;
+ int neededLen = stack->len + 1;
if (neededLen > stack->maxlen) {
stack->maxlen = neededLen*2;
stack->vector = Jim_Realloc(stack->vector, sizeof(void*)*stack->maxlen);
}
switch (*(pc->p)) {
case '\\':
- if (*(pc->p+1) == '\n')
+ if (*(pc->p + 1) == '\n')
return JimParseSep(pc);
else {
pc->comment = 0;
pc->tstart = pc->p;
pc->tline = pc->linenr;
while (*pc->p == ' ' || *pc->p == '\t' || *pc->p == '\r' ||
- (*pc->p == '\\' && *(pc->p+1) == '\n')) {
+ (*pc->p == '\\' && *(pc->p + 1) == '\n')) {
if (*pc->p == '\\') {
pc->p++; pc->len--;
pc->linenr++;
switch (*pc->p) {
case '\\':
if (pc->state == JIM_PS_DEF &&
- *(pc->p+1) == '\n') {
+ *(pc->p + 1) == '\n') {
pc->tend = pc->p-1;
pc->tt = JIM_TT_ESC;
return JIM_OK;
for (i = 0; i < slen; i++) {
switch (s[i]) {
case '\\':
- switch (s[i+1]) {
+ switch (s[i + 1]) {
case 'a': *p++ = 0x7; i++; break;
case 'b': *p++ = 0x8; i++; break;
case 'f': *p++ = 0xc; i++; break;
case '\0': *p++ = '\\'; i++; break;
case '\n': *p++ = ' '; i++; break;
default:
- if (s[i+1] == 'x') {
+ if (s[i + 1] == 'x') {
int val = 0;
- int c = xdigitval(s[i+2]);
+ int c = xdigitval(s[i + 2]);
if (c == -1) {
*p++ = 'x';
i++;
break;
}
val = c;
- c = xdigitval(s[i+3]);
+ c = xdigitval(s[i + 3]);
if (c == -1) {
*p++ = val;
i += 2;
break;
}
- val = (val*16)+c;
+ val = (val*16) + c;
*p++ = val;
i += 3;
break;
- } else if (s[i+1] >= '0' && s[i+1] <= '7')
+ } else if (s[i + 1] >= '0' && s[i + 1] <= '7')
{
int val = 0;
- int c = odigitval(s[i+1]);
+ int c = odigitval(s[i + 1]);
val = c;
- c = odigitval(s[i+2]);
+ c = odigitval(s[i + 2]);
if (c == -1) {
*p++ = val;
i ++;
break;
}
- val = (val*8)+c;
- c = odigitval(s[i+3]);
+ val = (val*8) + c;
+ c = odigitval(s[i + 3]);
if (c == -1) {
*p++ = val;
i += 2;
break;
}
- val = (val*8)+c;
+ val = (val*8) + c;
*p++ = val;
i += 3;
} else {
- *p++ = s[i+1];
+ *p++ = s[i + 1];
i++;
}
break;
token[0] = '\0';
return token;
}
- len = (end-start)+1;
- token = Jim_Alloc(len+1);
+ len = (end-start) + 1;
+ token = Jim_Alloc(len + 1);
if (JimParserTtype(pc) != JIM_TT_ESC) {
/* No escape conversion needed? Just copy it. */
memcpy(token, start, len);
objPtr->bytes = JimEmptyStringRep;
objPtr->length = 0;
} else {
- objPtr->bytes = Jim_Alloc(length+1);
+ objPtr->bytes = Jim_Alloc(length + 1);
objPtr->length = length;
memcpy(objPtr->bytes, bytes, length);
objPtr->bytes[length] = '\0';
objPtr->bytes = JimEmptyStringRep;
objPtr->length = 0;
} else {
- objPtr->bytes = Jim_Alloc(len+1);
+ objPtr->bytes = Jim_Alloc(len + 1);
objPtr->length = len;
memcpy(objPtr->bytes, s, len);
objPtr->bytes[len] = '\0';
if (objPtr->internalRep.strValue.maxLength < needlen ||
objPtr->internalRep.strValue.maxLength == 0) {
if (objPtr->bytes == JimEmptyStringRep) {
- objPtr->bytes = Jim_Alloc((needlen*2)+1);
+ objPtr->bytes = Jim_Alloc((needlen*2) + 1);
} else {
- objPtr->bytes = Jim_Realloc(objPtr->bytes, (needlen*2)+1);
+ objPtr->bytes = Jim_Realloc(objPtr->bytes, (needlen*2) + 1);
}
objPtr->internalRep.strValue.maxLength = needlen*2;
}
memcpy(objPtr->bytes + objPtr->length, str, len);
- objPtr->bytes[objPtr->length+len] = '\0';
+ objPtr->bytes[objPtr->length + len] = '\0';
objPtr->length += len;
}
if (first > last) {
rangeLen = 0;
} else {
- rangeLen = last-first+1;
+ rangeLen = last-first + 1;
if (rangeLen) {
if (first < 0) {
rangeLen += first;
first = JimRelToAbsIndex(len, first);
last = JimRelToAbsIndex(len, last);
JimRelToAbsRange(len, first, last, &first, &last, &rangeLen);
- return Jim_NewStringObj(interp, str+first, rangeLen);
+ return Jim_NewStringObj(interp, str + first, rangeLen);
}
static Jim_Obj *JimStringToLower(Jim_Interp *interp, Jim_Obj *strObjPtr)
SetStringFromAny(interp, strObjPtr);
}
- buf = Jim_Alloc(strObjPtr->length+1);
+ buf = Jim_Alloc(strObjPtr->length + 1);
- memcpy(buf, strObjPtr->bytes, strObjPtr->length+1);
+ memcpy(buf, strObjPtr->bytes, strObjPtr->length + 1);
for (i = 0; i < strObjPtr->length; i++)
buf[i] = tolower(buf[i]);
return Jim_NewStringObjNoAlloc(interp, buf, strObjPtr->length);
SetStringFromAny(interp, strObjPtr);
}
- buf = Jim_Alloc(strObjPtr->length+1);
+ buf = Jim_Alloc(strObjPtr->length + 1);
- memcpy(buf, strObjPtr->bytes, strObjPtr->length+1);
+ memcpy(buf, strObjPtr->bytes, strObjPtr->length + 1);
for (i = 0; i < strObjPtr->length; i++)
buf[i] = toupper(buf[i]);
return Jim_NewStringObjNoAlloc(interp, buf, strObjPtr->length);
memcpy(tablePtrSorted, tablePtr, sizeof(char*)*count);
qsort(tablePtrSorted, count, sizeof(char*), qsortCompareStringPointers);
for (i = 0; i < count; i++) {
- if (i+1 == count && count > 1)
+ if (i + 1 == count && count > 1)
Jim_AppendString(interp, Jim_GetResult(interp), "or ", -1);
Jim_AppendString(interp, Jim_GetResult(interp),
tablePtrSorted[i], -1);
- if (i+1 != count)
+ if (i + 1 != count)
Jim_AppendString(interp, Jim_GetResult(interp), ", ", -1);
}
Jim_Free(tablePtrSorted);
script->token = Jim_Realloc(script->token,
sizeof(ScriptToken)*script->len);
/* Initialize the new token */
- token = script->token+(script->len-1);
+ token = script->token + (script->len-1);
token->type = type;
/* Every object is intially as a string, but the
* internal type may be specialized during execution of the
token[end-1].type == JIM_TT_EOL)
{
if (token[end].type == JIM_TT_STR &&
- token[end+1].type != JIM_TT_SEP &&
- token[end+1].type != JIM_TT_EOL &&
+ token[end + 1].type != JIM_TT_SEP &&
+ token[end + 1].type != JIM_TT_EOL &&
(!strcmp(token[end].objPtr->bytes, "expand") ||
!strcmp(token[end].objPtr->bytes, "*")))
expand++;
args++;
end++;
}
- interpolation = !((end-start+1) == args*2);
+ interpolation = !((end-start + 1) == args*2);
/* Add the 'number of arguments' info into cmdstruct.
* Negative value if there is list expansion involved. */
if (expand)
str = Jim_GetString(objPtr, &len);
p = strchr(str, '(');
p++;
- keyLen = len-((p-str)+1);
+ keyLen = len-((p-str) + 1);
nameLen = (p-str)-1;
/* Create the objects with the variable name and key. */
- t = Jim_Alloc(nameLen+1);
+ t = Jim_Alloc(nameLen + 1);
memcpy(t, str, nameLen);
t[nameLen] = '\0';
varObjPtr = Jim_NewStringObjNoAlloc(interp, t, nameLen);
- t = Jim_Alloc(keyLen+1);
+ t = Jim_Alloc(keyLen + 1);
memcpy(t, p, keyLen);
t[keyLen] = '\0';
keyObjPtr = Jim_NewStringObjNoAlloc(interp, t, keyLen);
void UpdateStringOfReference(struct Jim_Obj *objPtr)
{
int len;
- char buf[JIM_REFERENCE_SPACE+1];
+ char buf[JIM_REFERENCE_SPACE + 1];
Jim_Reference *refPtr;
refPtr = objPtr->internalRep.refValue.refPtr;
len = JimFormatReference(buf, refPtr, objPtr->internalRep.refValue.id);
- objPtr->bytes = Jim_Alloc(len+1);
- memcpy(objPtr->bytes, buf, len+1);
+ objPtr->bytes = Jim_Alloc(len + 1);
+ memcpy(objPtr->bytes, buf, len + 1);
objPtr->length = len;
}
if (len < JIM_REFERENCE_SPACE) goto badformat;
/* Trim spaces */
start = str;
- end = str+len-1;
+ end = str + len-1;
while (*start == ' ') start++;
while (*end == ' ' && end > start) end--;
- if (end-start+1 != JIM_REFERENCE_SPACE) goto badformat;
+ if (end-start + 1 != JIM_REFERENCE_SPACE) goto badformat;
/* <reference.<1234567>.%020> */
if (memcmp(start, "<reference.<", 12) != 0) goto badformat;
- if (start[12+JIM_REFERENCE_TAGLEN] != '>' || end[0] != '>') goto badformat;
+ if (start[12 + JIM_REFERENCE_TAGLEN] != '>' || end[0] != '>') goto badformat;
/* The tag can't contain chars other than a-zA-Z0-9 + '_'. */
for (i = 0; i < JIM_REFERENCE_TAGLEN; i++) {
- if (!isrefchar(start[12+i])) goto badformat;
+ if (!isrefchar(start[12 + i])) goto badformat;
}
/* Extract info from the refernece. */
- memcpy(refId, start+14+JIM_REFERENCE_TAGLEN, 20);
+ memcpy(refId, start + 14 + JIM_REFERENCE_TAGLEN, 20);
refId[20] = '\0';
/* Try to convert the ID into a jim_wide */
if (Jim_StringToWide(refId, &wideValue, 10) != JIM_OK) goto badformat;
if (!isdigit((int)p[i]))
break;
/* Get the ID */
- memcpy(buf, p+21, 20);
+ memcpy(buf, p + 21, 20);
buf[20] = '\0';
Jim_StringToWide(buf, &id, 10);
* finalizer first if registered. */
refPtr = he->val;
if (refPtr->finalizerCmdNamePtr) {
- char *refstr = Jim_Alloc(JIM_REFERENCE_SPACE+1);
+ char *refstr = Jim_Alloc(JIM_REFERENCE_SPACE + 1);
Jim_Obj *objv[3], *oldResult;
JimFormatReference(refstr, refPtr, *refId);
return JIM_OK;
}
- level = strtol(str+1, &endptr, 0);
+ level = strtol(str + 1, &endptr, 0);
if (str[1] == '\0' || endptr[0] != '\0' || level < 0)
goto badlevel;
/* An 'absolute' level is converted into the
void UpdateStringOfInt(struct Jim_Obj *objPtr)
{
int len;
- char buf[JIM_INTEGER_SPACE+1];
+ char buf[JIM_INTEGER_SPACE + 1];
len = Jim_WideToString(buf, objPtr->internalRep.wideValue);
- objPtr->bytes = Jim_Alloc(len+1);
- memcpy(objPtr->bytes, buf, len+1);
+ objPtr->bytes = Jim_Alloc(len + 1);
+ memcpy(objPtr->bytes, buf, len + 1);
objPtr->length = len;
}
void UpdateStringOfDouble(struct Jim_Obj *objPtr)
{
int len;
- char buf[JIM_DOUBLE_SPACE+1];
+ char buf[JIM_DOUBLE_SPACE + 1];
len = Jim_DoubleToString(buf, objPtr->internalRep.doubleValue);
- objPtr->bytes = Jim_Alloc(len+1);
- memcpy(objPtr->bytes, buf, len+1);
+ objPtr->bytes = Jim_Alloc(len + 1);
+ memcpy(objPtr->bytes, buf, len + 1);
objPtr->length = len;
}
if (level < 0) return JIM_ELESTR_QUOTE;
break;
case '\\':
- if (s[i+1] == '\n')
+ if (s[i + 1] == '\n')
return JIM_ELESTR_QUOTE;
else
- if (s[i+1] != '\0') i++;
+ if (s[i + 1] != '\0') i++;
break;
}
}
* using backslash to quote special chars. */
char *BackslashQuoteString(const char *s, int len, int *qlenPtr)
{
- char *q = Jim_Alloc(len*2+1), *p;
+ char *q = Jim_Alloc(len*2 + 1), *p;
p = q;
while (*s) {
Jim_Obj **ele = objPtr->internalRep.listValue.ele;
/* (Over) Estimate the space needed. */
- quotingType = Jim_Alloc(sizeof(int)*objPtr->internalRep.listValue.len+1);
+ quotingType = Jim_Alloc(sizeof(int)*objPtr->internalRep.listValue.len + 1);
bufLen = 0;
for (i = 0; i < objPtr->internalRep.listValue.len; i++) {
int len;
quotingType[i] = ListElementQuotingType(strRep, len);
switch (quotingType[i]) {
case JIM_ELESTR_SIMPLE: bufLen += len; break;
- case JIM_ELESTR_BRACE: bufLen += len+2; break;
+ case JIM_ELESTR_BRACE: bufLen += len + 2; break;
case JIM_ELESTR_QUOTE: bufLen += len*2; break;
}
bufLen++; /* elements separator. */
bufLen++;
/* Generate the string rep. */
- p = objPtr->bytes = Jim_Alloc(bufLen+1);
+ p = objPtr->bytes = Jim_Alloc(bufLen + 1);
realLength = 0;
for (i = 0; i < objPtr->internalRep.listValue.len; i++) {
int len, qlen;
memcpy(p, strRep, len);
p += len;
*p++ = '}';
- realLength += len+2;
+ realLength += len + 2;
break;
case JIM_ELESTR_QUOTE:
q = BackslashQuoteString(strRep, len, &qlen);
break;
}
/* Add a separating space */
- if (i+1 != objPtr->internalRep.listValue.len) {
+ if (i + 1 != objPtr->internalRep.listValue.len) {
*p++ = ' ';
realLength ++;
}
listPtr->internalRep.listValue.maxLen = maxLen;
}
point = listPtr->internalRep.listValue.ele + index;
- memmove(point+elemc, point, (currentLen-index) * sizeof(Jim_Obj*));
+ memmove(point + elemc, point, (currentLen-index) * sizeof(Jim_Obj*));
for (i = 0; i < elemc; ++i) {
point[i] = elemVec[i];
Jim_IncrRefCount(point[i]);
}
for (i = 0; i < appendLen; i++) {
Jim_Obj *objPtr = appendListPtr->internalRep.listValue.ele[i];
- listPtr->internalRep.listValue.ele[oldLen+i] = objPtr;
+ listPtr->internalRep.listValue.ele[oldLen + i] = objPtr;
Jim_IncrRefCount(objPtr);
}
listPtr->internalRep.listValue.len += appendLen;
return JIM_ERR;
}
if (index < 0)
- index = listPtr->internalRep.listValue.len+index;
+ index = listPtr->internalRep.listValue.len + index;
*objPtrPtr = listPtr->internalRep.listValue.ele[index];
return JIM_OK;
}
return JIM_ERR;
}
if (index < 0)
- index = listPtr->internalRep.listValue.len+index;
+ index = listPtr->internalRep.listValue.len + index;
Jim_DecrRefCount(interp, listPtr->internalRep.listValue.ele[index]);
listPtr->internalRep.listValue.ele[index] = newObjPtr;
Jim_IncrRefCount(newObjPtr);
}
if (objc) len += objc-1;
/* Create the string rep, and a stinrg object holding it. */
- p = bytes = Jim_Alloc(len+1);
+ p = bytes = Jim_Alloc(len + 1);
for (i = 0; i < objc; i++) {
const char *s = Jim_GetString(objv[i], &objLen);
while (objLen && (*s == ' ' || *s == '\t' || *s == '\n'))
}
memcpy(p, s, objLen);
p += objLen;
- if (objLen && i+1 != objc) {
+ if (objLen && i + 1 != objc) {
*p++ = ' ';
- } else if (i+1 != objc) {
+ } else if (i + 1 != objc) {
/* Drop the space calcuated for this
* element that is instead null. */
len--;
last = JimRelToAbsIndex(len, last);
JimRelToAbsRange(len, first, last, &first, &last, &rangeLen);
return Jim_NewListObj(interp,
- listObjPtr->internalRep.listValue.ele+first, rangeLen);
+ listObjPtr->internalRep.listValue.ele + first, rangeLen);
}
/* -----------------------------------------------------------------------------
quotingType[i] = ListElementQuotingType(strRep, len);
switch (quotingType[i]) {
case JIM_ELESTR_SIMPLE: bufLen += len; break;
- case JIM_ELESTR_BRACE: bufLen += len+2; break;
+ case JIM_ELESTR_BRACE: bufLen += len + 2; break;
case JIM_ELESTR_QUOTE: bufLen += len*2; break;
}
bufLen++; /* elements separator. */
bufLen++;
/* Generate the string rep. */
- p = objPtr->bytes = Jim_Alloc(bufLen+1);
+ p = objPtr->bytes = Jim_Alloc(bufLen + 1);
realLength = 0;
for (i = 0; i < objc; i++) {
int len, qlen;
memcpy(p, strRep, len);
p += len;
*p++ = '}';
- realLength += len+2;
+ realLength += len + 2;
break;
case JIM_ELESTR_QUOTE:
q = BackslashQuoteString(strRep, len, &qlen);
break;
}
/* Add a separating space */
- if (i+1 != objc) {
+ if (i + 1 != objc) {
*p++ = ' ';
realLength ++;
}
objPtr->internalRep.ptr = Jim_Alloc(sizeof(Jim_HashTable));
Jim_InitHashTable(objPtr->internalRep.ptr, &JimDictHashTableType, interp);
for (i = 0; i < len; i += 2)
- DictAddElement(interp, objPtr, elements[i], elements[i+1]);
+ DictAddElement(interp, objPtr, elements[i], elements[i + 1]);
return objPtr;
}
void UpdateStringOfIndex(struct Jim_Obj *objPtr)
{
int len;
- char buf[JIM_INTEGER_SPACE+1];
+ char buf[JIM_INTEGER_SPACE + 1];
if (objPtr->internalRep.indexValue >= 0)
len = sprintf(buf, "%d", objPtr->internalRep.indexValue);
else if (objPtr->internalRep.indexValue == -1)
len = sprintf(buf, "end");
else {
- len = sprintf(buf, "end%d", objPtr->internalRep.indexValue+1);
+ len = sprintf(buf, "end%d", objPtr->internalRep.indexValue + 1);
}
- objPtr->bytes = Jim_Alloc(len+1);
- memcpy(objPtr->bytes, buf, len+1);
+ objPtr->bytes = Jim_Alloc(len + 1);
+ memcpy(objPtr->bytes, buf, len + 1);
objPtr->length = len;
}
if (index < 0)
index = INT_MAX;
else
- index = -(index+1);
+ index = -(index + 1);
} else if (!end && index < 0)
index = -INT_MAX;
/* Free the old internal repr and set the new one. */
*(pc->p) == '\t' ||
*(pc->p) == '\r' ||
*(pc->p) == '\n' ||
- (*(pc->p) == '\\' && *(pc->p+1) == '\n')) {
+ (*(pc->p) == '\\' && *(pc->p + 1) == '\n')) {
pc->p++; pc->len--;
}
break;
case '-':
if ((pc->tt == JIM_TT_NONE || pc->tt == JIM_TT_EXPR_OPERATOR) &&
- isdigit((int)*(pc->p+1)))
+ isdigit((int)*(pc->p + 1)))
return JimParseExprNumber(pc);
else
return JimParseExprOperator(pc);
if (*pc->p == '.')
allowdot = 0;
pc->p++; pc->len--;
- if (!allowdot && *pc->p == 'e' && *(pc->p+1) == '-') {
+ if (!allowdot && *pc->p == 'e' && *(pc->p + 1) == '-') {
pc->p += 2; pc->len -= 2;
}
}
static void ExprObjAddInstr(Jim_Interp *interp, ExprByteCode *expr,
int opcode, char *str, int len)
{
- expr->opcode = Jim_Realloc(expr->opcode, sizeof(int)*(expr->len+1));
- expr->obj = Jim_Realloc(expr->obj, sizeof(Jim_Obj*)*(expr->len+1));
+ expr->opcode = Jim_Realloc(expr->opcode, sizeof(int)*(expr->len + 1));
+ expr->obj = Jim_Realloc(expr->obj, sizeof(Jim_Obj*)*(expr->len + 1));
expr->opcode[expr->len] = opcode;
expr->obj[expr->len] = Jim_NewStringObjNoAlloc(interp, str, len);
Jim_IncrRefCount(expr->obj[expr->len]);
leftindex--;
}
leftindex++;
- expr->opcode = Jim_Realloc(expr->opcode, sizeof(int)*(expr->len+2));
- expr->obj = Jim_Realloc(expr->obj, sizeof(Jim_Obj*)*(expr->len+2));
- memmove(&expr->opcode[leftindex+2], &expr->opcode[leftindex],
+ expr->opcode = Jim_Realloc(expr->opcode, sizeof(int)*(expr->len + 2));
+ expr->obj = Jim_Realloc(expr->obj, sizeof(Jim_Obj*)*(expr->len + 2));
+ memmove(&expr->opcode[leftindex + 2], &expr->opcode[leftindex],
sizeof(int)*(expr->len-leftindex));
- memmove(&expr->obj[leftindex+2], &expr->obj[leftindex],
+ memmove(&expr->obj[leftindex + 2], &expr->obj[leftindex],
sizeof(Jim_Obj*)*(expr->len-leftindex));
expr->len += 2;
index += 2;
offset = (index-leftindex)-1;
Jim_DecrRefCount(interp, expr->obj[index]);
if (expr->opcode[index] == JIM_EXPROP_LOGICAND) {
- expr->opcode[leftindex+1] = JIM_EXPROP_LOGICAND_LEFT;
+ expr->opcode[leftindex + 1] = JIM_EXPROP_LOGICAND_LEFT;
expr->opcode[index] = JIM_EXPROP_LOGICAND_RIGHT;
- expr->obj[leftindex+1] = Jim_NewStringObj(interp, "&L", -1);
+ expr->obj[leftindex + 1] = Jim_NewStringObj(interp, "&L", -1);
expr->obj[index] = Jim_NewStringObj(interp, "&R", -1);
} else {
- expr->opcode[leftindex+1] = JIM_EXPROP_LOGICOR_LEFT;
+ expr->opcode[leftindex + 1] = JIM_EXPROP_LOGICOR_LEFT;
expr->opcode[index] = JIM_EXPROP_LOGICOR_RIGHT;
- expr->obj[leftindex+1] = Jim_NewStringObj(interp, "|L", -1);
+ expr->obj[leftindex + 1] = Jim_NewStringObj(interp, "|L", -1);
expr->obj[index] = Jim_NewStringObj(interp, "|R", -1);
}
expr->opcode[leftindex] = JIM_EXPROP_NUMBER;
expr->obj[leftindex] = Jim_NewIntObj(interp, offset);
Jim_IncrRefCount(expr->obj[index]);
Jim_IncrRefCount(expr->obj[leftindex]);
- Jim_IncrRefCount(expr->obj[leftindex+1]);
+ Jim_IncrRefCount(expr->obj[leftindex + 1]);
}
}
Jim_DecrRefCount(interp, A);
Jim_DecrRefCount(interp, B);
switch (expr->opcode[i]) {
- case JIM_EXPROP_ADD: wC = wA+wB; break;
+ case JIM_EXPROP_ADD: wC = wA + wB; break;
case JIM_EXPROP_SUB: wC = wA-wB; break;
case JIM_EXPROP_MUL: wC = wA*wB; break;
case JIM_EXPROP_LT: wC = wA<wB; break;
error = 1;
goto err;
break;
- case JIM_EXPROP_ADD: dC = dA+dB; break;
+ case JIM_EXPROP_ADD: dC = dA + dB; break;
case JIM_EXPROP_SUB: dC = dA-dB; break;
case JIM_EXPROP_MUL: dC = dA*dB; break;
case JIM_EXPROP_LT: dC = dA<dB; break;
memset(fmtObj, 0, approxSize);
fmtObj->size = approxSize;
fmtObj->maxPos = 0;
- fmtObj->scratch = (char*)&fmtObj->descr[maxCount+1];
+ fmtObj->scratch = (char*)&fmtObj->descr[maxCount + 1];
fmtObj->stringRep = fmtObj->scratch + maxFmtLen + 3 + 1;
memcpy(fmtObj->stringRep, fmt, maxFmtLen);
buffer = fmtObj->stringRep + maxFmtLen + 1;
/* In case a range fence was given "backwards", swap it */
while (swapped) {
swapped = 0;
- for (j = beg+1; j < end-1; ++j) {
- if (buffer[j] == '-' && buffer[j-1] > buffer[j+1]) {
+ 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];
- buffer[j+1] = tmp;
+ buffer[j-1] = buffer[j + 1];
+ buffer[j + 1] = tmp;
swapped = 1;
}
}
{
size_t i;
Jim_Obj *result;
- char charset[256/8+1]; /* A Charset may contain max 256 chars */
- char *buffer = Jim_Alloc(strlen(str)+1), *anchor = buffer;
+ char charset[256/8 + 1]; /* A Charset may contain max 256 chars */
+ char *buffer = Jim_Alloc(strlen(str) + 1), *anchor = buffer;
/* First init charset to nothing or all, depending if a specified
* or an unspecified string has to be parsed */
prng = interp->prngState;
/* generates 'len' bytes of pseudo-random numbers */
for (x = 0; x < len; x++) {
- prng->i = (prng->i+1) & 0xff;
+ prng->i = (prng->i + 1) & 0xff;
si = prng->sbox[prng->i];
prng->j = (prng->j + si) & 0xff;
sj = prng->sbox[prng->j];
prng->sbox[prng->i] = sj;
prng->sbox[prng->j] = si;
- *destByte++ = prng->sbox[(si+sj)&0xff];
+ *destByte++ = prng->sbox[(si + sj)&0xff];
}
}
&prefixObjPtr, JIM_NONE) != JIM_OK)
continue;
prefix = Jim_GetString(prefixObjPtr, &prefixlen);
- if (prefixlen+strlen(pathName)+1 >= JIM_PATH_LEN)
+ if (prefixlen + strlen(pathName) + 1 >= JIM_PATH_LEN)
continue;
if (*pathName == '/') {
strcpy(buf, pathName);
#define JIM_PKG_ANY_VERSION -1
/* Convert a string of the type "1.2" into an integer.
- * MAJOR.MINOR is converted as MAJOR*100+MINOR, so "1.2" is converted
+ * MAJOR.MINOR is converted as MAJOR*100 + MINOR, so "1.2" is converted
* to the integer with value 102 */
static int JimPackageVersionToInt(Jim_Interp *interp, const char *v,
int *intPtr, int flags)
if (p == NULL) goto badfmt;
*p = '\0';
majorStr = copy;
- minorStr = p+1;
+ minorStr = p + 1;
if (Jim_StringToWide(majorStr, &major, 10) != JIM_OK ||
Jim_StringToWide(minorStr, &minor, 10) != JIM_OK)
goto badfmt;
- *intPtr = (int)(major*100+minor);
+ *intPtr = (int)(major*100 + minor);
Jim_Free(copy);
return JIM_OK;
int fileNameLen = strlen(fileName);
if (strncmp(fileName, "jim-", 4) == 0 &&
- strncmp(fileName+4, pkgName, pkgNameLen) == 0 &&
- *(fileName+4+pkgNameLen) == '-' &&
+ strncmp(fileName + 4, pkgName, pkgNameLen) == 0 &&
+ *(fileName + 4+pkgNameLen) == '-' &&
fileNameLen > 4 && /* note that this is not really useful */
- (strncmp(fileName+fileNameLen-4, ".tcl", 4) == 0 ||
- strncmp(fileName+fileNameLen-4, ".dll", 4) == 0 ||
- strncmp(fileName+fileNameLen-3, ".so", 3) == 0))
+ (strncmp(fileName + fileNameLen-4, ".tcl", 4) == 0 ||
+ strncmp(fileName + fileNameLen-4, ".dll", 4) == 0 ||
+ strncmp(fileName + fileNameLen-3, ".so", 3) == 0))
{
char ver[6]; /* xx.yy<nulterm> */
char *p = strrchr(fileName, '.');
int verLen, fileVer;
- verLen = p - (fileName+4+pkgNameLen+1);
+ verLen = p - (fileName + 4+pkgNameLen + 1);
if (verLen < 3 || verLen > 5) continue;
- memcpy(ver, fileName+4+pkgNameLen+1, verLen);
+ memcpy(ver, fileName + 4+pkgNameLen + 1, verLen);
ver[verLen] = '\0';
if (JimPackageVersionToInt(interp, ver, &fileVer, JIM_NONE)
!= JIM_OK) continue;
{
bestVer = fileVer;
Jim_Free(bestPackage);
- bestPackage = Jim_Alloc(strlen(buf)+strlen(fileName)+2);
+ bestPackage = Jim_Alloc(strlen(buf) + strlen(fileName) + 2);
sprintf(bestPackage, "%s/%s", buf, fileName);
}
}
* the "unknown" string, it is used in order to
* avoid to lookup the unknown command every time
* but instread to cache the result. */
- if (argc+1 <= JIM_EVAL_SARGV_LEN)
+ if (argc + 1 <= JIM_EVAL_SARGV_LEN)
v = sv;
else
- v = Jim_Alloc(sizeof(Jim_Obj*)*(argc+1));
+ v = Jim_Alloc(sizeof(Jim_Obj*)*(argc + 1));
/* Make a copy of the arguments vector, but shifted on
* the right of one position. The command name of the
* command will be instead the first argument of the
* [unknonw] call. */
- memcpy(v+1, argv, sizeof(Jim_Obj*)*argc);
+ memcpy(v + 1, argv, sizeof(Jim_Obj*)*argc);
v[0] = interp->unknown;
/* Call it */
interp->unknown_called++;
- retCode = Jim_EvalObjVector(interp, argc+1, v);
+ retCode = Jim_EvalObjVector(interp, argc + 1, v);
interp->unknown_called--;
/* Clean up */
* object. */
objPtr = Jim_NewStringObjNoAlloc(interp,
NULL, 0);
- s = objPtr->bytes = Jim_Alloc(totlen+1);
+ s = objPtr->bytes = Jim_Alloc(totlen + 1);
objPtr->length = totlen;
for (i = 0; i < tokens; i++) {
memcpy(s, intv[i]->bytes, intv[i]->length);
int *argcPtr, int expand, Jim_Obj *objPtr)
{
if (!expand) {
- (*argv) = Jim_Realloc(*argv, sizeof(Jim_Obj*)*((*argcPtr)+1));
+ (*argv) = Jim_Realloc(*argv, sizeof(Jim_Obj*)*((*argcPtr) + 1));
/* refcount of objPtr not incremented because
* we are actually transfering a reference from
* the old 'argv' to the expanded one. */
int len, i;
Jim_ListLength(interp, objPtr, &len);
- (*argv) = Jim_Realloc(*argv, sizeof(Jim_Obj*)*((*argcPtr)+len));
+ (*argv) = Jim_Realloc(*argv, sizeof(Jim_Obj*)*((*argcPtr) + len));
for (i = 0; i < len; i++) {
(*argv)[*argcPtr] = objPtr->internalRep.listValue.ele[i];
Jim_IncrRefCount(objPtr->internalRep.listValue.ele[i]);
/* For interpolation we call an helper
* function doing the work for us. */
if ((retcode = Jim_InterpolateTokens(interp,
- token+i, tokens, &tmpObjPtr)) != JIM_OK)
+ token + i, tokens, &tmpObjPtr)) != JIM_OK)
{
goto err;
}
argv[j] = tmpObjPtr;
Jim_IncrRefCount(argv[j]);
- i += tokens+1;
+ i += tokens + 1;
}
}
/* Handle {expand} expansion */
Jim_ListIndex(interp, argObjPtr, 1, &valueObjPtr, JIM_NONE);
}
else {
- valueObjPtr = argv[i+1];
+ valueObjPtr = argv[i + 1];
}
Jim_SetVariable(interp, nameObjPtr, valueObjPtr);
}
Jim_Obj *listObjPtr, *objPtr;
i++;
- listObjPtr = Jim_NewListObj(interp, argv+i, argc-i);
+ listObjPtr = Jim_NewListObj(interp, argv + i, argc-i);
Jim_ListIndex(interp, cmd->argListObjPtr, num_args, &objPtr, JIM_NONE);
Jim_SetVariable(interp, objPtr, listObjPtr);
}
buflen = 1024;
maxlen = totread = 0;
while (1) {
- if (maxlen < totread+buflen+1) {
- maxlen = totread+buflen+1;
+ if (maxlen < totread + buflen + 1) {
+ maxlen = totread + buflen + 1;
prg = Jim_Realloc(prg, maxlen);
}
/* do not use Jim_fread() - this is really a file */
- if ((nread = fread(prg+totread, 1, buflen, fp)) == 0) break;
+ if ((nread = fread(prg + totread, 1, buflen, fp)) == 0) break;
totread += nread;
}
prg[totread] = '\0';
pc->tt = JIM_TT_ESC;
if (*pc->tstart == '{') {
pc->tstart--;
- if (*(pc->tend+1))
+ if (*(pc->tend + 1))
pc->tend++;
}
}
Jim_AppendString(interp, objPtr, "wrong # args: should be \"", -1);
for (i = 0; i < argc; i++) {
Jim_AppendObj(interp, objPtr, argv[i]);
- if (!(i+1 == argc && msg[0] == '\0'))
+ if (!(i + 1 == argc && msg[0] == '\0'))
Jim_AppendString(interp, objPtr, " ", 1);
}
Jim_AppendString(interp, objPtr, msg, -1);
if (Jim_GetWide(interp, intObjPtr, &wideValue) != JIM_OK)
return JIM_ERR;
if (Jim_IsShared(intObjPtr)) {
- intObjPtr = Jim_NewIntObj(interp, wideValue+increment);
+ intObjPtr = Jim_NewIntObj(interp, wideValue + increment);
if (Jim_SetVariable(interp, argv[1], intObjPtr) != JIM_OK) {
Jim_FreeNewObj(interp, intObjPtr);
return JIM_ERR;
}
} else {
- Jim_SetWide(interp, intObjPtr, wideValue+increment);
+ Jim_SetWide(interp, intObjPtr, wideValue + increment);
/* The following step is required in order to invalidate the
* string repr of "FOO" if the var name is on the form of "FOO(IDX)" */
if (Jim_SetVariable(interp, argv[1], intObjPtr) != JIM_OK) {
Jim_DecrRefCount(interp, varNamePtr);
goto evalnext;
}
- auxObjPtr = Jim_NewIntObj(interp, currentVal+1);
+ auxObjPtr = Jim_NewIntObj(interp, currentVal + 1);
if (Jim_SetVariable(interp, varNamePtr, auxObjPtr) == JIM_ERR) {
if (stopVarNamePtr)
Jim_DecrRefCount(interp, stopVarNamePtr);
for (i = 0; i < nbrOfLists*2; i += 2) {
div_t cnt;
int count;
- Jim_ListLength(interp, argv[i+1], &listsEnd[i]);
- Jim_ListLength(interp, argv[i+2], &listsEnd[i+1]);
+ Jim_ListLength(interp, argv[i + 1], &listsEnd[i]);
+ Jim_ListLength(interp, argv[i + 2], &listsEnd[i + 1]);
if (listsEnd[i] == 0) {
Jim_SetResultString(interp, "foreach varlist is empty", -1);
goto err;
}
- cnt = div(listsEnd[i+1], listsEnd[i]);
+ cnt = div(listsEnd[i + 1], listsEnd[i]);
count = cnt.quot + (cnt.rem ? 1 : 0);
if (count > nbrOfLoops)
nbrOfLoops = count;
while (varIdx < listsEnd[var]) {
Jim_Obj *varName, *ele;
int lst = i * 2 + 1;
- if (Jim_ListIndex(interp, argv[var+1], varIdx, &varName, JIM_ERRMSG)
+ if (Jim_ListIndex(interp, argv[var + 1], varIdx, &varName, JIM_ERRMSG)
!= JIM_OK)
goto err;
if (listsIdx[i] < listsEnd[lst]) {
- if (Jim_ListIndex(interp, argv[lst+1], listsIdx[i], &ele, JIM_ERRMSG)
+ if (Jim_ListIndex(interp, argv[lst + 1], listsIdx[i], &ele, JIM_ERRMSG)
!= JIM_OK)
goto err;
if (Jim_SetVariable(interp, varName, ele) != JIM_OK) {
switch (matchOpt) {
case SWITCH_EXACT:
if (Jim_StringEqObj(strObj, patObj, 0))
- script = caseList[i+1];
+ script = caseList[i + 1];
break;
case SWITCH_GLOB:
if (Jim_StringMatchObj(patObj, strObj, 0))
- script = caseList[i+1];
+ script = caseList[i + 1];
break;
case SWITCH_RE:
command = Jim_NewStringObj(interp, "regexp", -1);
goto err;
}
if (matching)
- script = caseList[i+1];
+ script = caseList[i + 1];
break;
}
default:
goto err;
}
} else {
- script = caseList[i+1];
+ script = caseList[i + 1];
}
}
for (; i < patCount && Jim_CompareStringImmediate(interp, script, "-");
i += 2)
- script = caseList[i+1];
+ script = caseList[i + 1];
if (script && Jim_CompareStringImmediate(interp, script, "-")) {
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
Jim_AppendStrings(interp, Jim_GetResult(interp),
{
Jim_Obj *listObjPtr;
- listObjPtr = Jim_NewListObj(interp, argv+1, argc-1);
+ listObjPtr = Jim_NewListObj(interp, argv + 1, argc-1);
Jim_SetResult(interp, listObjPtr);
return JIM_OK;
}
Jim_SetResult(interp, argv[2]);
return JIM_OK;
}
- if (Jim_SetListIndex(interp, argv[1], argv+2, argc-3, argv[argc-1])
+ if (Jim_SetListIndex(interp, argv[1], argv + 2, argc-3, argv[argc-1])
== JIM_ERR) return JIM_ERR;
return JIM_OK;
}
Jim_Obj *objPtr;
int retcode;
- objPtr = Jim_ConcatObj(interp, argc-1, argv+1);
+ objPtr = Jim_ConcatObj(interp, argc-1, argv + 1);
Jim_IncrRefCount(objPtr);
retcode = Jim_EvalObj(interp, objPtr);
Jim_DecrRefCount(interp, objPtr);
if (argc == 2) {
retcode = Jim_EvalObj(interp, argv[1]);
} else {
- objPtr = Jim_ConcatObj(interp, argc-1, argv+1);
+ objPtr = Jim_ConcatObj(interp, argc-1, argv + 1);
Jim_IncrRefCount(objPtr);
retcode = Jim_EvalObj(interp, objPtr);
Jim_DecrRefCount(interp, objPtr);
} else if (argc > 2) {
Jim_Obj *objPtr;
- objPtr = Jim_ConcatObj(interp, argc-1, argv+1);
+ objPtr = Jim_ConcatObj(interp, argc-1, argv + 1);
Jim_IncrRefCount(objPtr);
retcode = Jim_EvalExpression(interp, objPtr, &exprResultPtr);
Jim_DecrRefCount(interp, objPtr);
{
Jim_Obj *objPtr;
- objPtr = Jim_NewListObj(interp, argv+1, argc-1);
+ objPtr = Jim_NewListObj(interp, argv + 1, argc-1);
Jim_SetResult(interp, objPtr);
return JIM_EVAL;
}
return JIM_ERR;
}
Jim_ListLength(interp, argv[2], &argListLen);
- arityMin = arityMax = argListLen+1;
+ arityMin = arityMax = argListLen + 1;
if (argListLen) {
const char *str;
static int Jim_ConcatCoreCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
- Jim_SetResult(interp, Jim_ConcatObj(interp, argc-1, argv+1));
+ Jim_SetResult(interp, Jim_ConcatObj(interp, argc-1, argv + 1));
return JIM_OK;
}
}
/* Now... for every other/local couple: */
for (i = 1; i < argc; i += 2) {
- if (Jim_SetVariableLink(interp, argv[i+1], argv[i],
+ if (Jim_SetVariableLink(interp, argv[i + 1], argv[i],
targetCallFrame) != JIM_OK) return JIM_ERR;
}
return JIM_OK;
Jim_ListIndex(interp, mapListObjPtr, i*2, &eleObjPtr, JIM_NONE);
key[i] = Jim_GetString(eleObjPtr, &keyLen[i]);
- Jim_ListIndex(interp, mapListObjPtr, i*2+1, &eleObjPtr, JIM_NONE);
+ Jim_ListIndex(interp, mapListObjPtr, i*2 + 1, &eleObjPtr, JIM_NONE);
value[i] = eleObjPtr;
}
str = Jim_GetString(objPtr, &strLen);
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
return JIM_OK;
} else {
- Jim_SetResult(interp, Jim_NewStringObj(interp, str+index, 1));
+ Jim_SetResult(interp, Jim_NewStringObj(interp, str + index, 1));
return JIM_OK;
}
} else if (option == OPT_FIRST) {
Jim_WrongNumArgs(interp, 2, argv, "?key value ...?");
return JIM_ERR;
}
- objPtr = Jim_NewDictObj(interp, argv+2, argc-2);
+ objPtr = Jim_NewDictObj(interp, argv + 2, argc-2);
Jim_SetResult(interp, objPtr);
return JIM_OK;
} else if (option == OPT_GET) {
Jim_Obj *objPtr;
- if (Jim_DictKeysVector(interp, argv[2], argv+3, argc-3, &objPtr,
+ if (Jim_DictKeysVector(interp, argv[2], argv + 3, argc-3, &objPtr,
JIM_ERRMSG) != JIM_OK)
return JIM_ERR;
Jim_SetResult(interp, objPtr);
Jim_WrongNumArgs(interp, 2, argv, "varName key ?key ...? value");
return JIM_ERR;
}
- return Jim_SetDictKeysVector(interp, argv[2], argv+3, argc-4,
+ return Jim_SetDictKeysVector(interp, argv[2], argv + 3, argc-4,
argv[argc-1]);
} else if (option == OPT_UNSET) {
if (argc < 4) {
Jim_WrongNumArgs(interp, 2, argv, "varName key ?key ...?");
return JIM_ERR;
}
- return Jim_SetDictKeysVector(interp, argv[2], argv+3, argc-3,
+ return Jim_SetDictKeysVector(interp, argv[2], argv + 3, argc-3,
NULL);
} else if (option == OPT_EXIST) {
Jim_Obj *objPtr;
int exists;
- if (Jim_DictKeysVector(interp, argv[2], argv+3, argc-3, &objPtr,
+ if (Jim_DictKeysVector(interp, argv[2], argv + 3, argc-3, &objPtr,
JIM_ERRMSG) == JIM_OK)
exists = 1;
else
}
i = argc-2;
while (i--) {
- if (Jim_CompareStringImmediate(interp, argv[i+1],
+ if (Jim_CompareStringImmediate(interp, argv[i + 1],
"-nobackslashes"))
flags |= JIM_SUBST_NOESC;
- else if (Jim_CompareStringImmediate(interp, argv[i+1],
+ else if (Jim_CompareStringImmediate(interp, argv[i + 1],
"-novariables"))
flags |= JIM_SUBST_NOVAR;
- else if (Jim_CompareStringImmediate(interp, argv[i+1],
+ else if (Jim_CompareStringImmediate(interp, argv[i + 1],
"-nocommands"))
flags |= JIM_SUBST_NOCMD;
else {
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
Jim_AppendStrings(interp, Jim_GetResult(interp),
- "bad option \"", Jim_GetString(argv[i+1], NULL),
+ "bad option \"", Jim_GetString(argv[i + 1], NULL),
"\": must be -nobackslashes, -nocommands, or "
"-novariables", NULL);
return JIM_ERR;
objPtr = Jim_NewStringObj(interp, noMatchStart,
(str-noMatchStart));
Jim_ListAppendElement(interp, resObjPtr, objPtr);
- noMatchStart = str+1;
+ noMatchStart = str + 1;
break;
}
}
int c = u[i];
if (objCache[c] == NULL)
- objCache[c] = Jim_NewStringObj(interp, (char*)u+i, 1);
+ objCache[c] = Jim_NewStringObj(interp, (char*)u + i, 1);
Jim_ListAppendElement(interp, resObjPtr, objCache[c]);
}
}
Jim_ListIndex(interp, argv[1], i, &objPtr, JIM_NONE);
Jim_AppendObj(interp, resObjPtr, objPtr);
- if (i+1 != listLen) {
+ if (i + 1 != listLen) {
Jim_AppendString(interp, resObjPtr, joinStr, joinStrLen);
}
}
Jim_WrongNumArgs(interp, 1, argv, "formatString ?arg arg ...?");
return JIM_ERR;
}
- objPtr = Jim_FormatString(interp, argv[1], argc-2, argv+2);
+ objPtr = Jim_FormatString(interp, argv[1], argc-2, argv + 2);
if (objPtr == NULL)
return JIM_ERR;
Jim_SetResult(interp, objPtr);
for (i = 0; i < outc; ++i) {
if (Jim_Length(outVec[i]) > 0) {
++count;
- if (Jim_SetVariable(interp, argv[3+i], outVec[i]) != JIM_OK)
+ if (Jim_SetVariable(interp, argv[3 + i], outVec[i]) != JIM_OK)
goto err;
}
}
}
objPtr = Jim_NewListObj(interp, NULL, 0);
for (i = 0; i < len; i++)
- ListAppendElement(objPtr, Jim_NewIntObj(interp, start+i*step));
+ ListAppendElement(objPtr, Jim_NewIntObj(interp, start + i*step));
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
JimRandomBytes(interp, &r, sizeof(jim_wide));
if (r < 0 || r >= maxMul) continue;
r = (len == 0) ? 0 : r%len;
- Jim_SetResult(interp, Jim_NewIntObj(interp, min+r));
+ Jim_SetResult(interp, Jim_NewIntObj(interp, min + r));
return JIM_OK;
}
}
Jim_ListIndex(interp, interp->stackTrace, i, &objPtr, JIM_NONE);
proc = Jim_GetString(objPtr, NULL);
- Jim_ListIndex(interp, interp->stackTrace, i+1, &objPtr,
+ Jim_ListIndex(interp, interp->stackTrace, i + 1, &objPtr,
JIM_NONE);
file = Jim_GetString(objPtr, NULL);
- Jim_ListIndex(interp, interp->stackTrace, i+2, &objPtr,
+ Jim_ListIndex(interp, interp->stackTrace, i + 2, &objPtr,
JIM_NONE);
line = Jim_GetString(objPtr, NULL);
if (*proc) {
const char *a;
const char *b;
- if ( (nvp+1)->name ){
+ if ( (nvp + 1)->name ){
a = nvp->name;
b = ", ";
} else {
typedef struct Jim_Reference {
Jim_Obj *objPtr;
Jim_Obj *finalizerCmdNamePtr;
- char tag[JIM_REFERENCE_TAGLEN+1];
+ char tag[JIM_REFERENCE_TAGLEN + 1];
} Jim_Reference;
/** Name Value Pairs, aka: NVP
#ifdef _DEBUG_FREE_SPACE_
" %d"
#endif
- ": %s", log_strings[level+1], count, t, file, line, function,
+ ": %s", log_strings[level + 1], count, t, file, line, function,
#ifdef _DEBUG_FREE_SPACE_
info.fordblks,
#endif
{
/* print human readable output - but skip empty lines */
fprintf(log_output, "%s%s",
- (level > LOG_LVL_USER)?log_strings[level+1]:"", string);
+ (level > LOG_LVL_USER)?log_strings[level + 1]:"", string);
}
}
} else
#include "command.h"
/* logging priorities
- * LOG_LVL_SILENT - turn off all output. In lieu of try+catch this can be used as a
+ * LOG_LVL_SILENT - turn off all output. In lieu of try + catch this can be used as a
* feeble ersatz.
* LOG_LVL_USER - user messages. Could be anything from information
* to progress messags. These messages do not represent
tvslice.tv_sec = 0;
tvslice.tv_usec = 100000;
- retcode = select(sock_max_fd+1, &aread, &awrite, &aexcept, &tvslice);
+ retcode = select(sock_max_fd + 1, &aread, &awrite, &aexcept, &tvslice);
}
if (n_handles > 0) {
/* check handles */
usb_out_buffer[0] = CMD_SET_TCK_FREQUENCY;
- buf_set_u32(usb_out_buffer+1, 0, 32, speed);
+ buf_set_u32(usb_out_buffer + 1, 0, 32, speed);
result = armjtagew_usb_message(armjtagew_jtag_handle, 4, 4);
/* query hardware version */
usb_out_buffer[0] = CMD_GET_VERSION;
- result = armjtagew_usb_message(armjtagew_jtag_handle, 1, 4+15+256);
+ result = armjtagew_usb_message(armjtagew_jtag_handle, 1, 4 + 15 + 256);
if (result != 0)
{
}
- memcpy(sn, usb_in_buffer+4, 15);
+ memcpy(sn, usb_in_buffer + 4, 15);
sn[15] = '\0';
- memcpy(auxinfo, usb_in_buffer+4+15, 256);
+ memcpy(auxinfo, usb_in_buffer + 4+15, 256);
auxinfo[256] = '\0';
LOG_INFO("ARM-JTAG-EW firmware version %d.%d, hardware revision %c, SN=%s, Additional info: %s", \
byte_length = tap_length / 8;
usb_out_buffer[0] = CMD_TAP_SHIFT;
- buf_set_u32(usb_out_buffer+1, 0, 16, byte_length);
+ buf_set_u32(usb_out_buffer + 1, 0, 16, byte_length);
tms_offset = 3;
for (i = 0; i < byte_length; i++)
static int require_send;
-/* http://urjtag.wiki.sourceforge.net/Cable+FT2232 says:
+/* http://urjtag.wiki.sourceforge.net/Cable + FT2232 says:
"There is a significant difference between libftdi and libftd2xx. The latter
one allows to schedule up to 64*64 bytes of result data while libftdi fails
//#define JLINK_TAP_BUFFER_SIZE 384
#define JLINK_IN_BUFFER_SIZE 2048
-#define JLINK_OUT_BUFFER_SIZE 2*2048+4
+#define JLINK_OUT_BUFFER_SIZE 2*2048 + 4
#define JLINK_EMU_RESULT_BUFFER_SIZE 64
/* Global USB buffers */
int jtag_get_flush_queue_count(void);
-/* can be implemented by hw+sw */
+/* can be implemented by hw + sw */
extern int jtag_power_dropout(int* dropout);
extern int jtag_srst_asserted(int* srst_asserted);
}
if (khz >= 3000) *jtag_speed = 0;
- else *jtag_speed = (1000+khz-1)/khz;
+ else *jtag_speed = (1000 + khz-1)/khz;
return 0;
}
context = Jim_GetAssocData(interp, "context");
/* go past the command */
- Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 );
+ Jim_GetOpt_Setup( &goi, interp, argc-1, argv + 1 );
e = Jim_GetOpt_Nvp( &goi, jtag_cmds, &n );
if ( e != JIM_OK ){
}
/* Not valid.. are we at the end? */
- if ( ((i+2) != argc) ){
+ if ( ((i + 2) != argc) ){
/* nope, then error */
return e;
}
/* is it the magic? */
if ( 0 == strcmp( "-endstate", cp ) ){
/* is the statename valid? */
- cp = Jim_GetString( args[i+1], NULL );
+ cp = Jim_GetString( args[i + 1], NULL );
/* see if it is a valid state name */
endstate = tap_state_by_name(cp);
const char *str;
Jim_GetLong(interp, args[i], &bits);
- str = Jim_GetString(args[i+1], &len);
+ str = Jim_GetString(args[i + 1], &len);
fields[field_count].tap = tap;
fields[field_count].num_bits = bits;
{
tap_state_t states[8];
- if ((argc < 2) || ((size_t)argc > (sizeof(states)/sizeof(*states)+1)))
+ if ((argc < 2) || ((size_t)argc > (sizeof(states)/sizeof(*states) + 1)))
{
Jim_WrongNumArgs(interp, 1, args, "wrong arguments");
return JIM_ERR;
for (i = 0; i<argc-1; i++)
{
const char *cp;
- cp = Jim_GetString( args[i+1], NULL );
+ cp = Jim_GetString( args[i + 1], NULL );
states[i] = tap_state_by_name(cp);
if ( states[i] < 0 )
{
return JIM_ERR;
}
- jtag_add_pathmove(argc-2, states+1);
+ jtag_add_pathmove(argc-2, states + 1);
if (jtag_execute_queue()!= ERROR_OK)
{
for (i = 0; i < len_tmp; i++)
{
- vsllink_tap_append_step(((len_all+i) < length-1 ? 0 : 1), (buffer[(len_all+i)/8] >> ((len_all+i)%8)) & 1);
+ vsllink_tap_append_step(((len_all + i) < length-1 ? 0 : 1), (buffer[(len_all + i)/8] >> ((len_all + i)%8)) & 1);
}
pending_scan_results_length++;
cyg_uint32 empty;
do
{
- ZY1000_PEEK(ZY1000_JTAG_BASE+0x10, empty);
+ ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, empty);
} while ((empty & 0x100) == 0);
}
#if 0
cyg_uint32 dummy;
waitIdle();
- ZY1000_PEEK(ZY1000_JTAG_BASE+0xc, dummy);
+ ZY1000_PEEK(ZY1000_JTAG_BASE + 0xc, dummy);
#endif
}
}
waitQueue();
sampleShiftRegister();
- ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (repeat << 8)|(a << 4)|a);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (repeat << 8)|(a << 4)|a);
}
b = endState;
waitQueue();
sampleShiftRegister();
- ZY1000_POKE(ZY1000_JTAG_BASE+0xc, value);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0xc, value);
#if 1
#if TEST_MANUAL()
if ((state == TAP_DRSHIFT) && (endState != TAP_DRSHIFT))
}
/* shift out value */
waitIdle();
- ZY1000_POKE(ZY1000_JTAG_BASE+0x28, (((value >> i)&1) << 1)|tms);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, (((value >> i)&1) << 1)|tms);
}
waitIdle();
- ZY1000_POKE(ZY1000_JTAG_BASE+0x28, 0);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, 0);
waitIdle();
- //ZY1000_POKE(ZY1000_JTAG_BASE+0x20, TAP_DRSHIFT); // set this state and things break => expected
- ZY1000_POKE(ZY1000_JTAG_BASE+0x20, TAP_DRPAUSE); // set this and things will work => expected. Not setting this is not sufficient to make things break.
+ //ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_DRSHIFT); // set this state and things break => expected
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_DRPAUSE); // set this and things will work => expected. Not setting this is not sufficient to make things break.
setCurrentState(endState);
} else
{
- ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (repeat << 8)|(a << 4)|b);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (repeat << 8)|(a << 4)|b);
}
#else
/* fast version */
- ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (repeat << 8)|(a << 4)|b);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (repeat << 8)|(a << 4)|b);
#endif
#else
/* maximum debug version */
for (i = 0; i<repeat-1; i++)
{
sampleShiftRegister();
- ZY1000_POKE(ZY1000_JTAG_BASE+0xc, value >> i);
- ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (1 << 8)|(a << 4)|a);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0xc, value >> i);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (1 << 8)|(a << 4)|a);
}
sampleShiftRegister();
- ZY1000_POKE(ZY1000_JTAG_BASE+0xc, value >> (repeat-1));
- ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (1 << 8)|(a << 4)|b);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0xc, value >> (repeat-1));
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (1 << 8)|(a << 4)|b);
} else
{
sampleShiftRegister();
- ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (repeat << 8)|(a << 4)|b);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (repeat << 8)|(a << 4)|b);
}
sampleShiftRegister();
#endif
{
cyg_uint32 state;
// sample and clear power dropout
- HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x80);
- HAL_READ_UINT32(ZY1000_JTAG_BASE+0x10, state);
+ HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x80);
+ HAL_READ_UINT32(ZY1000_JTAG_BASE + 0x10, state);
bool powerDropout;
powerDropout = (state & 0x80) != 0;
return powerDropout;
{
cyg_uint32 state;
// sample and clear SRST sensing
- HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x00000040);
- HAL_READ_UINT32(ZY1000_JTAG_BASE+0x10, state);
+ HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x00000040);
+ HAL_READ_UINT32(ZY1000_JTAG_BASE + 0x10, state);
bool srstAsserted;
srstAsserted = (state & 0x40) != 0;
return srstAsserted;
LOG_DEBUG("zy1000 trst=%d, srst=%d", trst, srst);
if (!srst)
{
- ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000001);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x00000001);
}
else
{
/* Danger!!! if clk != 0 when in
* idle in TAP_IDLE, reset halt on str912 will fail.
*/
- ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000001);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x00000001);
}
if (!trst)
{
- ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000002);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x00000002);
}
else
{
/* assert reset */
- ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000002);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x00000002);
}
if (trst||(srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
{
waitIdle();
/* we're now in the RESET state until trst is deasserted */
- ZY1000_POKE(ZY1000_JTAG_BASE+0x20, TAP_RESET);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_RESET);
} else
{
/* We'll get RCLK failure when we assert TRST, so clear any false positives here */
- ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x400);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x400);
}
/* wait for srst to float back up */
{
/*0 means RCLK*/
speed = 0;
- ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x100);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x100);
LOG_DEBUG("jtag_speed using RCLK");
}
else
}
LOG_USER("jtag_speed %d => JTAG clk=%f", speed, 64.0/(float)speed);
- ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x100);
- ZY1000_POKE(ZY1000_JTAG_BASE+0x1c, speed&~1);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x100);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x1c, speed&~1);
}
return ERROR_OK;
}
savePower = power;
if (power)
{
- HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x14, 0x8);
+ HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x14, 0x8);
} else
{
- HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x8);
+ HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x8);
}
}
if (strcmp("openocd", str) == 0)
{
int revision;
- revision = atol(ZYLIN_OPENOCD+strlen("XRevision: "));
+ revision = atol(ZYLIN_OPENOCD + strlen("XRevision: "));
sprintf(buff, "%d", revision);
version_str = buff;
}
}
cyg_uint32 status;
- ZY1000_PEEK(ZY1000_JTAG_BASE+0x10, status);
+ ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, status);
Jim_SetResult(interp, Jim_NewIntObj(interp, (status&0x80) != 0));
{
LOG_USER("%s", ZYLIN_OPENOCD_VERSION);
- ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x30); // Turn on LED1 & LED2
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x30); // Turn on LED1 & LED2
setPower(true); // on by default
cyg_uint32 empty;
waitIdle();
- ZY1000_PEEK(ZY1000_JTAG_BASE+0x10, empty);
+ ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, empty);
/* clear JTAG error register */
- ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x400);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x400);
if ((empty&0x400) != 0)
{
{
cyg_uint32 value;
waitIdle();
- ZY1000_PEEK(ZY1000_JTAG_BASE+0xc, value);
+ ZY1000_PEEK(ZY1000_JTAG_BASE + 0xc, value);
VERBOSE(LOG_INFO("getShiftValue %08x", value));
return value;
}
{
cyg_uint32 value;
waitIdle();
- ZY1000_PEEK(ZY1000_JTAG_BASE+0x18, value);
+ ZY1000_PEEK(ZY1000_JTAG_BASE + 0x18, value);
VERBOSE(LOG_INFO("getShiftValue %08x (flipped)", value));
return value;
}
cyg_uint32 a,b;
a = state;
b = endState;
- ZY1000_POKE(ZY1000_JTAG_BASE+0xc, value);
- ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (1 << 15)|(repeat << 8)|(a << 4)|b);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0xc, value);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (1 << 15)|(repeat << 8)|(a << 4)|b);
VERBOSE(getShiftValueFlip());
}
#endif
pause_state = end_state;
}
- // we have (num_bits+7)/8 bytes of bits to toggle out.
+ // we have (num_bits + 7)/8 bytes of bits to toggle out.
// bits are pushed out LSB to MSB
value = 0;
if (fields[i].out_value != NULL)
{
for (l = 0; l<k; l += 8)
{
- value|=fields[i].out_value[(j+l)/8]<<l;
+ value|=fields[i].out_value[(j + l)/8]<<l;
}
}
/* mask away unused bits for easier debugging */
for (l = 0; l<k; l += 8)
{
- inBuffer[(j+l)/8]=(value >> l)&0xff;
+ inBuffer[(j + l)/8]=(value >> l)&0xff;
}
}
j += k;
{
found = 1;
- scanFields(1, fields+j, TAP_IRSHIFT, end_state);
+ scanFields(1, fields + j, TAP_IRSHIFT, end_state);
/* update device information */
buf_cpy(fields[j].out_value, tap->cur_instr, scan_size);
{
found = 1;
- scanFields(1, fields+j, TAP_DRSHIFT, end_state);
+ scanFields(1, fields + j, TAP_DRSHIFT, end_state);
}
}
if (!found)
{
tms = (tms_scan >> i) & 1;
waitIdle();
- ZY1000_POKE(ZY1000_JTAG_BASE+0x28, tms);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, tms);
}
waitIdle();
- ZY1000_POKE(ZY1000_JTAG_BASE+0x20, state);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, state);
#endif
}
waitIdle();
- ZY1000_POKE(ZY1000_JTAG_BASE+0x28, tms);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, tms);
cur_state = path[state_count];
state_count++;
}
waitIdle();
- ZY1000_POKE(ZY1000_JTAG_BASE+0x20, cur_state);
+ ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, cur_state);
return ERROR_OK;
}
if ((size_t)len + 4 <= sizeof(local_buffer))
{
/* performance gain on smaller packets by only a single call to gdb_write() */
- memcpy(local_buffer+1, buffer, len++);
+ memcpy(local_buffer + 1, buffer, len++);
local_buffer[len++] = '#';
local_buffer[len++] = DIGITS[(my_checksum >> 4) & 0xf];
local_buffer[len++] = DIGITS[my_checksum & 0xf];
{
return retval;
}
- if ((retval = gdb_write(connection, local_buffer+1, 3)) != ERROR_OK)
+ if ((retval = gdb_write(connection, local_buffer + 1, 3)) != ERROR_OK)
{
return retval;
}
* We need to leave at least 2 bytes in the buffer to have
* gdb_get_char() update various bits and bobs correctly.
*/
- if ((gdb_con->buf_cnt > 2) && ((gdb_con->buf_cnt+count) < *len))
+ if ((gdb_con->buf_cnt > 2) && ((gdb_con->buf_cnt + count) < *len))
{
/* The compiler will struggle a bit with constant propagation and
* aliasing, so we help it by showing that these values do not
hex_buffer[0] = 'O';
for (i = 0; i<bin_size; i++)
snprintf(hex_buffer + 1 + i*2, 3, "%2.2x", line[i]);
- hex_buffer[bin_size*2+1] = 0;
+ hex_buffer[bin_size*2 + 1] = 0;
int retval = gdb_put_packet(connection, hex_buffer, bin_size*2 + 1);
{
int j = gdb_reg_pos(target, i, buf_len);
tstr[i*2] = DIGITS[(buf[j]>>4) & 0xf];
- tstr[i*2+1] = DIGITS[buf[j]&0xf];
+ tstr[i*2 + 1] = DIGITS[buf[j]&0xf];
}
}
for (i = 0; i < str_len; i += 2)
{
uint8_t t = hextoint(tstr[i]) << 4;
- t |= hextoint(tstr[i+1]);
+ t |= hextoint(tstr[i + 1]);
int j = gdb_reg_pos(target, i/2, str_len/2);
bin[j] = t;
return ERROR_SERVER_REMOTE_CLOSED;
}
- len = strtoul(separator+1, NULL, 16);
+ len = strtoul(separator + 1, NULL, 16);
buffer = malloc(len);
return ERROR_SERVER_REMOTE_CLOSED;
}
- len = strtoul(separator+1, &separator, 16);
+ len = strtoul(separator + 1, &separator, 16);
if (*(separator++) != ':')
{
return ERROR_SERVER_REMOTE_CLOSED;
}
- len = strtoul(separator+1, &separator, 16);
+ len = strtoul(separator + 1, &separator, 16);
if (*(separator++) != ':')
{
return ERROR_SERVER_REMOTE_CLOSED;
}
- address = strtoul(separator+1, &separator, 16);
+ address = strtoul(separator + 1, &separator, 16);
if (*separator != ',')
{
return ERROR_SERVER_REMOTE_CLOSED;
}
- size = strtoul(separator+1, &separator, 16);
+ size = strtoul(separator + 1, &separator, 16);
switch (type)
{
if (*separator != ',')
return -1;
- *len = strtoul(separator+1, NULL, 16);
+ *len = strtoul(separator + 1, NULL, 16);
return 0;
}
"<property name=\"blocksize\">0x%x</property>\n" \
"</memory>\n", \
p->base, p->size, blocksize);
- ram_start = p->base+p->size;
+ ram_start = p->base + p->size;
}
if (ram_start != 0)
{
if (line_end)
{
telnet_write(connection, "\r\n", 2);
- line += len+1;
+ line += len + 1;
}
else
{
LOG_DEBUG("Save %zi: 0x%" PRIx32 "",i,context[i]);
}
- cpsr = buf_get_u32((uint8_t*)(arm11->reg_values+ARM11_RC_CPSR),0,32);
+ cpsr = buf_get_u32((uint8_t*)(arm11->reg_values + ARM11_RC_CPSR),0,32);
LOG_DEBUG("Save CPSR: 0x%" PRIx32 "", cpsr);
for (int i = 0; i < num_mem_params; i++)
dcc_count = count;
dcc_buffer = buffer;
retval = armv4_5_run_algorithm_inner(target, 0, NULL, 1, reg_params,
- arm7_9->dcc_working_area->address, arm7_9->dcc_working_area->address+6*4, 20*1000, &armv4_5_info, arm7_9_dcc_completion);
+ arm7_9->dcc_working_area->address, arm7_9->dcc_working_area->address + 6*4, 20*1000, &armv4_5_info, arm7_9_dcc_completion);
if (retval == ERROR_OK)
{
uint32_t endaddress = buf_get_u32(reg_params[0].value, 0, 32);
- if (endaddress != (address+count*4))
+ if (endaddress != (address + count*4))
{
- LOG_ERROR("DCC write failed, expected end address 0x%08" PRIx32 " got 0x%0" PRIx32 "", (address+count*4), endaddress);
+ LOG_ERROR("DCC write failed, expected end address 0x%08" PRIx32 " got 0x%0" PRIx32 "", (address + count*4), endaddress);
retval = ERROR_FAIL;
}
}
for (i = 0; i <= 15; i++)
{
if (mask & (1 << i))
- /* nothing fetched, STM still in EXECUTE (1+i cycle) */
+ /* nothing fetched, STM still in EXECUTE (1 + i cycle) */
arm7tdmi_clock_data_in(jtag_info, core_regs[i]);
}
}
for (i = 0; i <= 15; i++)
{
- /* nothing fetched, STM still in EXECUTE (1+i cycle), read databus */
+ /* nothing fetched, STM still in EXECUTE (1 + i cycle), read databus */
if (mask & (1 << i))
{
switch (size)
for (i = 0; i <= 15; i++)
{
if (mask & (1 << i))
- /* nothing fetched, LDM still in EXECUTE (1+i cycle) */
+ /* nothing fetched, LDM still in EXECUTE (1 + i cycle) */
arm7tdmi_clock_out_inner(jtag_info, core_regs[i], 0);
}
arm7tdmi_clock_out_inner(jtag_info, ARMV4_5_NOP, 0);
for (i = 0; i <= 15; i++)
{
if (mask & (1 << i))
- /* nothing fetched, LDM still in EXECUTE (1+i cycle) */
+ /* nothing fetched, LDM still in EXECUTE (1 + i cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, core_regs[i], NULL, 0);
}
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
if (romentry&0x01)
{
uint32_t c_cid0,c_cid1,c_cid2,c_cid3,c_pid0,c_pid1,c_pid2,c_pid3,c_pid4,component_start;
- uint32_t component_base = (uint32_t)((dbgbase&0xFFFFF000)+(int)(romentry&0xFFFFF000));
+ uint32_t component_base = (uint32_t)((dbgbase&0xFFFFF000) + (int)(romentry&0xFFFFF000));
mem_ap_read_atomic_u32(swjdp, (component_base&0xFFFFF000)|0xFE0, &c_pid0);
mem_ap_read_atomic_u32(swjdp, (component_base&0xFFFFF000)|0xFE4, &c_pid1);
mem_ap_read_atomic_u32(swjdp, (component_base&0xFFFFF000)|0xFE8, &c_pid2);
};
/* Hack! Yuk! allow -1 index, which simplifies codepaths elsewhere in the code */
-char** armv4_5_mode_strings = armv4_5_mode_strings_list+1;
+char** armv4_5_mode_strings = armv4_5_mode_strings_list + 1;
char* armv4_5_state_strings[] =
{
else
buf_set_u32(fields[1].out_value, 0, 7, 0);
- fields[0].in_value = (uint8_t *)(data+i);
+ fields[0].in_value = (uint8_t *)(data + i);
jtag_add_dr_scan(3, fields, jtag_get_end_state());
- jtag_add_callback(etb_getbuf, (jtag_callback_data_t)(data+i));
+ jtag_add_callback(etb_getbuf, (jtag_callback_data_t)(data + i));
}
jtag_execute_queue();
etm_ctx->trace_data[j].flags |= ETMV1_TRIGGER_CYCLE;
}
- /* trace word j+1 */
- etm_ctx->trace_data[j+1].pipestat = (trace_data[i] & 0x100) >> 8;
- etm_ctx->trace_data[j+1].packet = (trace_data[i] & 0x7800) >> 11;
- etm_ctx->trace_data[j+1].flags = 0;
+ /* trace word j + 1 */
+ etm_ctx->trace_data[j + 1].pipestat = (trace_data[i] & 0x100) >> 8;
+ etm_ctx->trace_data[j + 1].packet = (trace_data[i] & 0x7800) >> 11;
+ etm_ctx->trace_data[j + 1].flags = 0;
if ((trace_data[i] & 0x8000) >> 15)
{
- etm_ctx->trace_data[j+1].flags |= ETMV1_TRACESYNC_CYCLE;
+ etm_ctx->trace_data[j + 1].flags |= ETMV1_TRACESYNC_CYCLE;
}
- if (etm_ctx->trace_data[j+1].pipestat == STAT_TR)
+ if (etm_ctx->trace_data[j + 1].pipestat == STAT_TR)
{
- etm_ctx->trace_data[j+1].pipestat = etm_ctx->trace_data[j+1].packet & 0x7;
- etm_ctx->trace_data[j+1].flags |= ETMV1_TRIGGER_CYCLE;
+ etm_ctx->trace_data[j + 1].pipestat = etm_ctx->trace_data[j + 1].packet & 0x7;
+ etm_ctx->trace_data[j + 1].flags |= ETMV1_TRIGGER_CYCLE;
}
- /* trace word j+2 */
- etm_ctx->trace_data[j+2].pipestat = (trace_data[i] & 0x10000) >> 16;
- etm_ctx->trace_data[j+2].packet = (trace_data[i] & 0x780000) >> 19;
- etm_ctx->trace_data[j+2].flags = 0;
+ /* trace word j + 2 */
+ etm_ctx->trace_data[j + 2].pipestat = (trace_data[i] & 0x10000) >> 16;
+ etm_ctx->trace_data[j + 2].packet = (trace_data[i] & 0x780000) >> 19;
+ etm_ctx->trace_data[j + 2].flags = 0;
if ((trace_data[i] & 0x800000) >> 23)
{
- etm_ctx->trace_data[j+2].flags |= ETMV1_TRACESYNC_CYCLE;
+ etm_ctx->trace_data[j + 2].flags |= ETMV1_TRACESYNC_CYCLE;
}
- if (etm_ctx->trace_data[j+2].pipestat == STAT_TR)
+ if (etm_ctx->trace_data[j + 2].pipestat == STAT_TR)
{
- etm_ctx->trace_data[j+2].pipestat = etm_ctx->trace_data[j+2].packet & 0x7;
- etm_ctx->trace_data[j+2].flags |= ETMV1_TRIGGER_CYCLE;
+ etm_ctx->trace_data[j + 2].pipestat = etm_ctx->trace_data[j + 2].packet & 0x7;
+ etm_ctx->trace_data[j + 2].flags |= ETMV1_TRIGGER_CYCLE;
}
j += 3;
etm_ctx->trace_data[j].flags |= ETMV1_TRIGGER_CYCLE;
}
- /* trace word j+1 */
- etm_ctx->trace_data[j+1].pipestat = (trace_data[i] & 0x7000) >> 12;
- etm_ctx->trace_data[j+1].packet = (trace_data[i] & 0x7f8000) >> 15;
- etm_ctx->trace_data[j+1].flags = 0;
+ /* trace word j + 1 */
+ etm_ctx->trace_data[j + 1].pipestat = (trace_data[i] & 0x7000) >> 12;
+ etm_ctx->trace_data[j + 1].packet = (trace_data[i] & 0x7f8000) >> 15;
+ etm_ctx->trace_data[j + 1].flags = 0;
if ((trace_data[i] & 0x800000) >> 23)
{
- etm_ctx->trace_data[j+1].flags |= ETMV1_TRACESYNC_CYCLE;
+ etm_ctx->trace_data[j + 1].flags |= ETMV1_TRACESYNC_CYCLE;
}
- if (etm_ctx->trace_data[j+1].pipestat == STAT_TR)
+ if (etm_ctx->trace_data[j + 1].pipestat == STAT_TR)
{
- etm_ctx->trace_data[j+1].pipestat = etm_ctx->trace_data[j+1].packet & 0x7;
- etm_ctx->trace_data[j+1].flags |= ETMV1_TRIGGER_CYCLE;
+ etm_ctx->trace_data[j + 1].pipestat = etm_ctx->trace_data[j + 1].packet & 0x7;
+ etm_ctx->trace_data[j + 1].flags |= ETMV1_TRIGGER_CYCLE;
}
j += 2;
for (i = 0; i <= 15; i++)
{
if (mask & (1 << i))
- /* nothing fetched, LDM still in EXECUTE (1+i cycle) */
+ /* nothing fetched, LDM still in EXECUTE (1 + i cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, core_regs[i], NULL, 0);
}
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* maximal size present in file for the current segment */
read_size = MIN(size, field32(elf,segment->p_filesz)-offset);
LOG_DEBUG("read elf: size = 0x%" PRIx32 " at 0x%" PRIx32 "",read_size,
- field32(elf,segment->p_offset)+offset);
+ field32(elf,segment->p_offset) + offset);
/* read initialized area of the segment */
- if ((retval = fileio_seek(&elf->fileio, field32(elf,segment->p_offset)+offset)) != ERROR_OK)
+ if ((retval = fileio_seek(&elf->fileio, field32(elf,segment->p_offset) + offset)) != ERROR_OK)
{
LOG_ERROR("cannot find ELF segment content, seek failed");
return retval;
int retval;
for (i = 0; i<count; i++) {
- if ((retval = ejtag_dma_read(ejtag_info, addr+i*sizeof(*buf), &buf[i])) != ERROR_OK)
+ if ((retval = ejtag_dma_read(ejtag_info, addr + i*sizeof(*buf), &buf[i])) != ERROR_OK)
return retval;
}
int retval;
for (i = 0; i<count; i++) {
- if ((retval = ejtag_dma_read_h(ejtag_info, addr+i*sizeof(*buf), &buf[i])) != ERROR_OK)
+ if ((retval = ejtag_dma_read_h(ejtag_info, addr + i*sizeof(*buf), &buf[i])) != ERROR_OK)
return retval;
}
int retval;
for (i = 0; i<count; i++) {
- if ((retval = ejtag_dma_read_b(ejtag_info, addr+i*sizeof(*buf), &buf[i])) != ERROR_OK)
+ if ((retval = ejtag_dma_read_b(ejtag_info, addr + i*sizeof(*buf), &buf[i])) != ERROR_OK)
return retval;
}
int retval;
for (i = 0; i<count; i++) {
- if ((retval = ejtag_dma_write(ejtag_info, addr+i*sizeof(*buf), buf[i])) != ERROR_OK)
+ if ((retval = ejtag_dma_write(ejtag_info, addr + i*sizeof(*buf), buf[i])) != ERROR_OK)
return retval;
}
int retval;
for (i = 0; i<count; i++) {
- if ((retval = ejtag_dma_write_h(ejtag_info, addr+i*sizeof(*buf), buf[i])) != ERROR_OK)
+ if ((retval = ejtag_dma_write_h(ejtag_info, addr + i*sizeof(*buf), buf[i])) != ERROR_OK)
return retval;
}
int retval;
for (i = 0; i<count; i++) {
- if ((retval = ejtag_dma_write_b(ejtag_info, addr+i*sizeof(*buf), buf[i])) != ERROR_OK)
+ if ((retval = ejtag_dma_write_b(ejtag_info, addr + i*sizeof(*buf), buf[i])) != ERROR_OK)
return retval;
}
MIPS32_LUI(8,UPPER16(MIPS32_PRACC_PARAM_IN)), /* $8 = MIPS32_PRACC_PARAM_IN */
MIPS32_ORI(8,8,LOWER16(MIPS32_PRACC_PARAM_IN)),
MIPS32_LW(9,0,8), /* $9 = mem[$8]; read addr */
- MIPS32_LW(10,4,8), /* $10 = mem[$8+4]; read count */
+ MIPS32_LW(10,4,8), /* $10 = mem[$8 + 4]; read count */
MIPS32_LUI(11,UPPER16(MIPS32_PRACC_PARAM_OUT)), /* $11 = MIPS32_PRACC_PARAM_OUT */
MIPS32_ORI(11,11,LOWER16(MIPS32_PRACC_PARAM_OUT)),
MIPS32_NOP,
MIPS32_LUI(8,UPPER16(MIPS32_PRACC_PARAM_IN)), /* $8 = MIPS32_PRACC_PARAM_IN */
MIPS32_ORI(8,8,LOWER16(MIPS32_PRACC_PARAM_IN)),
MIPS32_LW(9,0,8), /* $9 = mem[$8]; read addr */
- MIPS32_LW(10,4,8), /* $10 = mem[$8+4]; read count */
+ MIPS32_LW(10,4,8), /* $10 = mem[$8 + 4]; read count */
MIPS32_LUI(11,UPPER16(MIPS32_PRACC_PARAM_OUT)), /* $11 = MIPS32_PRACC_PARAM_OUT */
MIPS32_ORI(11,11,LOWER16(MIPS32_PRACC_PARAM_OUT)),
MIPS32_NOP,
MIPS32_LUI(8,UPPER16(MIPS32_PRACC_PARAM_IN)), /* $8 = MIPS32_PRACC_PARAM_IN */
MIPS32_ORI(8,8,LOWER16(MIPS32_PRACC_PARAM_IN)),
MIPS32_LW(9,0,8), /* $9 = mem[$8]; read addr */
- MIPS32_LW(10,4,8), /* $10 = mem[$8+4]; read count */
+ MIPS32_LW(10,4,8), /* $10 = mem[$8 + 4]; read count */
MIPS32_LUI(11,UPPER16(MIPS32_PRACC_PARAM_OUT)), /* $11 = MIPS32_PRACC_PARAM_OUT */
MIPS32_ORI(11,11,LOWER16(MIPS32_PRACC_PARAM_OUT)),
MIPS32_NOP,
};
/* TODO remove array */
- uint32_t param_in[count+2];
+ uint32_t param_in[count + 2];
param_in[0] = addr;
param_in[1] = addr + count * sizeof(uint32_t); //last address
};
/* TODO remove array */
- uint32_t param_in[1+1];
+ uint32_t param_in[1 + 1];
param_in[0] = addr;
param_in[1] = *buf;
};
/* TODO remove array */
- uint32_t param_in[count+2];
+ uint32_t param_in[count + 2];
int i;
param_in[0] = addr;
param_in[1] = count;
for (i = 0; i < count; i++)
{
- param_in[i+2] = buf[i];
+ param_in[i + 2] = buf[i];
}
mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
};
/* TODO remove array */
- uint32_t param_in[count+2];
+ uint32_t param_in[count + 2];
int retval;
int i;
param_in[0] = addr;
for (i = 0; i < count; i++)
{
- param_in[i+2] = buf[i];
+ param_in[i + 2] = buf[i];
}
retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
num_frames = address;
/* read data into temporary array for unpacking
- * one frame from OpenOCD+trace corresponds to 16 trace cycles
+ * one frame from OpenOCD + trace corresponds to 16 trace cycles
*/
trace_data = malloc(sizeof(uint8_t) * num_frames * 16);
oocd_trace_read_memory(oocd_trace, trace_data, first_frame, num_frames);
if (((etm_ctx->portmode & ETM_PORT_MODE_MASK) != ETM_PORT_NORMAL)
|| ((etm_ctx->portmode & ETM_PORT_WIDTH_MASK) != ETM_PORT_4BIT))
{
- LOG_DEBUG("OpenOCD+trace only supports normal 4-bit ETM mode");
+ LOG_DEBUG("OpenOCD + trace only supports normal 4-bit ETM mode");
return ERROR_ETM_PORTMODE_NOT_SUPPORTED;
}
control |= 0x2; /* half rate clock, capture at twice the clock rate */
}
- /* OpenOCD+trace holds up to 16 million samples,
+ /* OpenOCD + trace holds up to 16 million samples,
* but trigger counts is set in multiples of 16 */
trigger_count = (1048576 * etm_ctx->trigger_percent) / 100;
arm7_9->etm_ctx->capture_driver_priv = oocd_trace;
oocd_trace->etm_ctx = arm7_9->etm_ctx;
- /* copy name of TTY device used to communicate with OpenOCD+trace */
+ /* copy name of TTY device used to communicate with OpenOCD + trace */
oocd_trace->tty = strndup(args[1], 256);
}
else
{
- LOG_ERROR("target has no ETM defined, OpenOCD+trace left unconfigured");
+ LOG_ERROR("target has no ETM defined, OpenOCD + trace left unconfigured");
}
return ERROR_OK;
{
command_t *oocd_trace_cmd;
- oocd_trace_cmd = register_command(cmd_ctx, NULL, "oocd_trace", NULL, COMMAND_ANY, "OpenOCD+trace");
+ oocd_trace_cmd = register_command(cmd_ctx, NULL, "oocd_trace", NULL, COMMAND_ANY, "OpenOCD + trace");
register_command(cmd_ctx, oocd_trace_cmd, "config", handle_oocd_trace_config_command, COMMAND_CONFIG, NULL);
- register_command(cmd_ctx, oocd_trace_cmd, "status", handle_oocd_trace_status_command, COMMAND_EXEC, "display OpenOCD+trace status");
- register_command(cmd_ctx, oocd_trace_cmd, "resync", handle_oocd_trace_resync_command, COMMAND_EXEC, "resync OpenOCD+trace capture clock");
+ register_command(cmd_ctx, oocd_trace_cmd, "status", handle_oocd_trace_status_command, COMMAND_EXEC, "display OpenOCD + trace status");
+ register_command(cmd_ctx, oocd_trace_cmd, "resync", handle_oocd_trace_resync_command, COMMAND_EXEC, "resync OpenOCD + trace capture clock");
return ERROR_OK;
}
t = all_targets;
while ( t ){
if ( x < t->target_number ){
- x = (t->target_number)+1;
+ x = (t->target_number) + 1;
}
t = t->next;
}
}
t = t->next;
}
- return x+1;
+ return x + 1;
}
static int target_continuous_poll = 1;
}
-/* Targets that correctly implement init+examine, i.e.
+/* Targets that correctly implement init + examine, i.e.
* no communication with target during init:
*
* XScale
if ((address + size - 1) < address)
{
/* GDB can request this when e.g. PC is 0xfffffffc*/
- LOG_ERROR("address+size wrapped(0x%08x, 0x%08x)",
+ LOG_ERROR("address + size wrapped(0x%08x, 0x%08x)",
(unsigned)address,
(unsigned)size);
return ERROR_FAIL;
if ((address + size - 1) < address)
{
/* GDB can request this when e.g. PC is 0xfffffffc*/
- LOG_ERROR("address+size wrapped(0x%08" PRIx32 ", 0x%08" PRIx32 ")",
+ LOG_ERROR("address + size wrapped(0x%08" PRIx32 ", 0x%08" PRIx32 ")",
address,
size);
return ERROR_FAIL;
/* DANGER!!! beware of unsigned comparision here!!! */
- if ((image.sections[i].base_address+buf_cnt >= min_address)&&
+ if ((image.sections[i].base_address + buf_cnt >= min_address)&&
(image.sections[i].base_address<max_address))
{
if (image.sections[i].base_address<min_address)
length -= offset;
}
- if (image.sections[i].base_address+buf_cnt>max_address)
+ if (image.sections[i].base_address + buf_cnt>max_address)
{
- length -= (image.sections[i].base_address+buf_cnt)-max_address;
+ length -= (image.sections[i].base_address + buf_cnt)-max_address;
}
- if ((retval = target_write_buffer(target, image.sections[i].base_address+offset, length, buffer+offset)) != ERROR_OK)
+ if ((retval = target_write_buffer(target, image.sections[i].base_address + offset, length, buffer + offset)) != ERROR_OK)
{
free(buffer);
break;
image_size += length;
command_print(cmd_ctx, "%u byte written at address 0x%8.8" PRIx32 "",
(unsigned int)length,
- image.sections[i].base_address+offset);
+ image.sections[i].base_address + offset);
}
free(buffer);
}
}
- int addressSpace = (max-min+1);
+ int addressSpace = (max-min + 1);
static const uint32_t maxBuckets = 256 * 1024; /* maximum buckets. */
uint32_t length = addressSpace;
val = 65535;
}
data[i*2]=val&0xff;
- data[i*2+1]=(val >> 8)&0xff;
+ data[i*2 + 1]=(val >> 8)&0xff;
}
free(buckets);
writeData(f, data, length * 2);
return JIM_ERR;
}
- return target_mem2array(interp, target, argc-1, argv+1);
+ return target_mem2array(interp, target, argc-1, argv + 1);
}
static int target_mem2array(Jim_Interp *interp, target_t *target, int argc, Jim_Obj *const *argv)
return JIM_ERR;
}
- return target_array2mem( interp,target, argc-1, argv+1 );
+ return target_array2mem( interp,target, argc-1, argv + 1 );
}
static int target_array2mem(Jim_Interp *interp, target_t *target, int argc, Jim_Obj *const *argv)
};
/* go past the "command" */
- Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 );
+ Jim_GetOpt_Setup( &goi, interp, argc-1, argv + 1 );
target = Jim_CmdPrivData( goi.interp );
cmd_ctx = Jim_GetAssocData(goi.interp, "context");
if ( target_types[x] == NULL ){
Jim_SetResult_sprintf( goi->interp, "Unknown target type %s, try one of ", cp );
for ( x = 0 ; target_types[x] ; x++ ){
- if ( target_types[x+1] ){
+ if ( target_types[x + 1] ){
Jim_AppendStrings( goi->interp,
Jim_GetResult(goi->interp),
target_types[x]->name,
cmd_ctx = Jim_GetAssocData( interp, "context" );
- Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 );
+ Jim_GetOpt_Setup( &goi, interp, argc-1, argv + 1 );
if ( goi.argc == 0 ){
Jim_WrongNumArgs(interp, 1, argv, "missing: command ...");
/* DANGER!!! beware of unsigned comparision here!!! */
- if ((image.sections[i].base_address+buf_cnt >= min_address)&&
+ if ((image.sections[i].base_address + buf_cnt >= min_address)&&
(image.sections[i].base_address<max_address))
{
if (image.sections[i].base_address<min_address)
length -= offset;
}
- if (image.sections[i].base_address+buf_cnt>max_address)
+ if (image.sections[i].base_address + buf_cnt>max_address)
{
- length -= (image.sections[i].base_address+buf_cnt)-max_address;
+ length -= (image.sections[i].base_address + buf_cnt)-max_address;
}
- fastload[i].address = image.sections[i].base_address+offset;
+ fastload[i].address = image.sections[i].base_address + offset;
fastload[i].data = malloc(length);
if (fastload[i].data == NULL)
{
free(buffer);
break;
}
- memcpy(fastload[i].data, buffer+offset, length);
+ memcpy(fastload[i].data, buffer + offset, length);
fastload[i].length = length;
image_size += length;
command_print(cmd_ctx, "%u byte written at address 0x%8.8x",
(unsigned int)length,
- ((unsigned int)(image.sections[i].base_address+offset)));
+ ((unsigned int)(image.sections[i].base_address + offset)));
}
free(buffer);
jtag_add_dr_scan(3, fields, jtag_get_end_state());
- jtag_check_value_mask(fields+0, &field0_check_value, &field0_check_mask);
- jtag_check_value_mask(fields+2, &field2_check_value, &field2_check_mask);
+ jtag_check_value_mask(fields + 0, &field0_check_value, &field0_check_mask);
+ jtag_check_value_mask(fields + 2, &field2_check_value, &field2_check_mask);
if ((retval = jtag_execute_queue()) != ERROR_OK)
{
jtag_add_pathmove(3, path);
- fields[1].in_value = (uint8_t *)(field1+i);
+ fields[1].in_value = (uint8_t *)(field1 + i);
jtag_add_dr_scan_check(3, fields, jtag_set_end_state(TAP_IDLE));
- jtag_add_callback(xscale_getbuf, (jtag_callback_data_t)(field1+i));
+ jtag_add_callback(xscale_getbuf, (jtag_callback_data_t)(field1 + i));
words_scheduled++;
}
int j;
for (j = i; j < num_words - 1; j++)
{
- field0[j] = field0[j+1];
- field1[j] = field1[j+1];
+ field0[j] = field0[j + 1];
+ field1[j] = field1[j + 1];
}
words_scheduled--;
}
jtag_add_dr_scan(3, fields, jtag_set_end_state(TAP_IDLE));
- jtag_check_value_mask(fields+0, &field0_check_value, &field0_check_mask);
- jtag_check_value_mask(fields+2, &field2_check_value, &field2_check_mask);
+ jtag_check_value_mask(fields + 0, &field0_check_value, &field0_check_mask);
+ jtag_check_value_mask(fields + 2, &field2_check_value, &field2_check_mask);
if ((retval = jtag_execute_queue()) != ERROR_OK)
{
{
jtag_add_dr_scan(3, fields, jtag_set_end_state(TAP_IDLE));
- jtag_check_value_mask(fields+0, &field0_check_value, &field0_check_mask);
- jtag_check_value_mask(fields+2, &field2_check_value, &field2_check_mask);
+ jtag_check_value_mask(fields + 0, &field0_check_value, &field0_check_mask);
+ jtag_check_value_mask(fields + 2, &field2_check_value, &field2_check_mask);
if ((retval = jtag_execute_queue()) != ERROR_OK)
{
jtag_add_dr_scan(3, fields, jtag_get_end_state());
- jtag_check_value_mask(fields+0, &field0_check_value, &field0_check_mask);
- jtag_check_value_mask(fields+2, &field2_check_value, &field2_check_mask);
+ jtag_check_value_mask(fields + 0, &field0_check_value, &field0_check_mask);
+ jtag_check_value_mask(fields + 2, &field2_check_value, &field2_check_mask);
if ((retval = jtag_execute_queue()) != ERROR_OK)
{
! Set the maximum loop count to 25.
LCOUNT 25;
-! Step to DRPAUSE give 5 clocks and wait for 1.00e+000 SEC.
+! Step to DRPAUSE give 5 clocks and wait for 1.00e + 000 SEC.
LDELAY DRPAUSE 5 TCK 1.00E-003 SEC;
! Test for the completed status. Match means pass.
! Loop back to LDELAY line if not match and loop count less than 25.
LOG_DEBUG("XSIR2 %d", bitcount);
}
- ir_buf = malloc((bitcount+7) / 8);
+ ir_buf = malloc((bitcount + 7) / 8);
if (xsvf_read_buffer(bitcount, xsvf_fd, ir_buf) != ERROR_OK)
do_abort = 1;