target: rename CamelCase symbols

No major cross dependencies, mostly changes internal to each
file/function.

Change-Id: I7cc87458a341bae29a4f772b0af5d97b4bfc2da3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6343
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
This commit is contained in:
Antonio Borneo 2021-04-27 18:46:43 +02:00
parent 20b29b7767
commit b159f5cded
11 changed files with 202 additions and 202 deletions

View File

@ -526,7 +526,7 @@ static int avr32_ap7k_target_create(struct target *target, Jim_Interp *interp)
struct avr32_ap7k_common *ap7k = calloc(1, sizeof(struct struct avr32_ap7k_common *ap7k = calloc(1, sizeof(struct
avr32_ap7k_common)); avr32_ap7k_common));
ap7k->common_magic = AP7k_COMMON_MAGIC; ap7k->common_magic = AP7K_COMMON_MAGIC;
target->arch_info = ap7k; target->arch_info = ap7k;
return ERROR_OK; return ERROR_OK;

View File

@ -20,7 +20,7 @@
struct target; struct target;
#define AP7k_COMMON_MAGIC 0x4150374b #define AP7K_COMMON_MAGIC 0x4150374b
struct avr32_ap7k_common { struct avr32_ap7k_common {
int common_magic; int common_magic;
struct avr32_jtag jtag; struct avr32_jtag jtag;

View File

@ -96,10 +96,10 @@
/* /*
* OBCR Register bit definitions * OBCR Register bit definitions
*/ */
#define OBCR_b0_and_b1 ((0x0) << 10) #define OBCR_B0_AND_B1 ((0x0) << 10)
#define OBCR_b0_or_b1 ((0x1) << 10) #define OBCR_B0_OR_B1 ((0x1) << 10)
#define OBCR_b1_after_b0 ((0x2) << 10) #define OBCR_B1_AFTER_B0 ((0x2) << 10)
#define OBCR_b0_after_b1 ((0x3) << 10) #define OBCR_B0_AFTER_B1 ((0x3) << 10)
#define OBCR_BP_DISABLED (0x0) #define OBCR_BP_DISABLED (0x0)
#define OBCR_BP_MEM_P (0x1) #define OBCR_BP_MEM_P (0x1)
@ -1885,17 +1885,17 @@ static int dsp563xx_remove_watchpoint(struct target *target, struct watchpoint *
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
} }
static int dsp563xx_add_custom_watchpoint(struct target *target, uint32_t address, uint32_t memType, static int dsp563xx_add_custom_watchpoint(struct target *target, uint32_t address, uint32_t mem_type,
enum watchpoint_rw rw, enum watchpoint_condition cond) enum watchpoint_rw rw, enum watchpoint_condition cond)
{ {
int err = ERROR_OK; int err = ERROR_OK;
struct dsp563xx_common *dsp563xx = target_to_dsp563xx(target); struct dsp563xx_common *dsp563xx = target_to_dsp563xx(target);
bool wasRunning = false; bool was_running = false;
/* Only set breakpoint when halted */ /* Only set breakpoint when halted */
if (target->state != TARGET_HALTED) { if (target->state != TARGET_HALTED) {
dsp563xx_halt(target); dsp563xx_halt(target);
wasRunning = true; was_running = true;
} }
if (dsp563xx->hardware_breakpoint[0].used) { if (dsp563xx->hardware_breakpoint[0].used) {
@ -1905,8 +1905,8 @@ static int dsp563xx_add_custom_watchpoint(struct target *target, uint32_t addres
uint32_t obcr_value = 0; uint32_t obcr_value = 0;
if (err == ERROR_OK) { if (err == ERROR_OK) {
obcr_value |= OBCR_b0_or_b1; obcr_value |= OBCR_B0_OR_B1;
switch (memType) { switch (mem_type) {
case MEM_X: case MEM_X:
obcr_value |= OBCR_BP_MEM_X; obcr_value |= OBCR_BP_MEM_X;
break; break;
@ -1917,7 +1917,7 @@ static int dsp563xx_add_custom_watchpoint(struct target *target, uint32_t addres
obcr_value |= OBCR_BP_MEM_P; obcr_value |= OBCR_BP_MEM_P;
break; break;
default: default:
LOG_ERROR("Unknown memType parameter (%" PRIu32 ")", memType); LOG_ERROR("Unknown mem_type parameter (%" PRIu32 ")", mem_type);
err = ERROR_TARGET_INVALID; err = ERROR_TARGET_INVALID;
} }
} }
@ -1981,7 +1981,7 @@ static int dsp563xx_add_custom_watchpoint(struct target *target, uint32_t addres
if (err == ERROR_OK) if (err == ERROR_OK)
dsp563xx->hardware_breakpoint[0].used = BPU_WATCHPOINT; dsp563xx->hardware_breakpoint[0].used = BPU_WATCHPOINT;
if (err == ERROR_OK && wasRunning) { if (err == ERROR_OK && was_running) {
/* Resume from current PC */ /* Resume from current PC */
err = dsp563xx_resume(target, 1, 0x0, 0, 0); err = dsp563xx_resume(target, 1, 0x0, 0, 0);
} }

View File

@ -501,7 +501,7 @@ static int core_move_value_to_pc(struct target *target, uint32_t value)
return retval; return retval;
} }
static int eonce_load_TX_RX_to_r0(struct target *target) static int eonce_load_tx_rx_to_r0(struct target *target)
{ {
int retval; int retval;
@ -512,7 +512,7 @@ static int eonce_load_TX_RX_to_r0(struct target *target)
return retval; return retval;
} }
static int core_load_TX_RX_high_addr_to_r0(struct target *target) static int core_load_tx_rx_high_addr_to_r0(struct target *target)
{ {
int retval = 0; int retval = 0;
@ -855,7 +855,7 @@ static int eonce_pc_store(struct target *target)
err_check_propagate(retval); err_check_propagate(retval);
retval = core_move_r4_to_y(target); retval = core_move_r4_to_y(target);
err_check_propagate(retval); err_check_propagate(retval);
retval = eonce_load_TX_RX_to_r0(target); retval = eonce_load_tx_rx_to_r0(target);
err_check_propagate(retval); err_check_propagate(retval);
retval = core_move_y0_at_r0(target); retval = core_move_y0_at_r0(target);
err_check_propagate(retval); err_check_propagate(retval);
@ -1110,7 +1110,7 @@ static int dsp5680xx_read_16_single(struct target *t, uint32_t a,
else else
retval = core_move_at_r0_to_y0(target); retval = core_move_at_r0_to_y0(target);
err_check_propagate(retval); err_check_propagate(retval);
retval = eonce_load_TX_RX_to_r0(target); retval = eonce_load_tx_rx_to_r0(target);
err_check_propagate(retval); err_check_propagate(retval);
retval = core_move_y0_at_r0(target); retval = core_move_y0_at_r0(target);
err_check_propagate(retval); err_check_propagate(retval);
@ -1147,7 +1147,7 @@ static int dsp5680xx_read_32_single(struct target *t, uint32_t a,
err_check_propagate(retval); err_check_propagate(retval);
} }
/* Get lower part of data to TX/RX */ /* Get lower part of data to TX/RX */
retval = eonce_load_TX_RX_to_r0(target); retval = eonce_load_tx_rx_to_r0(target);
err_check_propagate(retval); err_check_propagate(retval);
retval = core_move_y0_at_r0_inc(target); /* This also load TX/RX high to r0 */ retval = core_move_y0_at_r0_inc(target); /* This also load TX/RX high to r0 */
err_check_propagate(retval); err_check_propagate(retval);
@ -1543,7 +1543,7 @@ static int perl_crc(const uint8_t *buff8, uint32_t word_count)
* *
* @return * @return
*/ */
static int dsp5680xx_f_SIM_reset(struct target *target) static int dsp5680xx_f_sim_reset(struct target *target)
{ {
int retval = ERROR_OK; int retval = ERROR_OK;
@ -1575,7 +1575,7 @@ static int dsp5680xx_soft_reset_halt(struct target *target)
retval = dsp5680xx_halt(target); retval = dsp5680xx_halt(target);
err_check_propagate(retval); err_check_propagate(retval);
retval = dsp5680xx_f_SIM_reset(target); retval = dsp5680xx_f_sim_reset(target);
err_check_propagate(retval); err_check_propagate(retval);
return retval; return retval;
} }
@ -1617,7 +1617,7 @@ static int dsp5680xx_f_ex(struct target *target, uint16_t c, uint32_t address, u
uint32_t command = c; uint32_t command = c;
int retval; int retval;
retval = core_load_TX_RX_high_addr_to_r0(target); retval = core_load_tx_rx_high_addr_to_r0(target);
err_check_propagate(retval); err_check_propagate(retval);
retval = core_move_long_to_r2(target, HFM_BASE_ADDR); retval = core_move_long_to_r2(target, HFM_BASE_ADDR);
err_check_propagate(retval); err_check_propagate(retval);
@ -1727,7 +1727,7 @@ static int set_fm_ck_div(struct target *target)
retval = core_move_long_to_r2(target, HFM_BASE_ADDR); retval = core_move_long_to_r2(target, HFM_BASE_ADDR);
err_check_propagate(retval); err_check_propagate(retval);
retval = core_load_TX_RX_high_addr_to_r0(target); retval = core_load_tx_rx_high_addr_to_r0(target);
err_check_propagate(retval); err_check_propagate(retval);
/* read HFM_CLKD */ /* read HFM_CLKD */
retval = core_move_at_r2_to_y0(target); retval = core_move_at_r2_to_y0(target);
@ -1882,7 +1882,7 @@ int dsp5680xx_f_erase(struct target *target, int first, int last)
* Reset SIM * Reset SIM
* *
*/ */
retval = dsp5680xx_f_SIM_reset(target); retval = dsp5680xx_f_sim_reset(target);
err_check_propagate(retval); err_check_propagate(retval);
/* /*
* Set hfmdiv * Set hfmdiv
@ -2014,7 +2014,7 @@ int dsp5680xx_f_wr(struct target *t, const uint8_t *b, uint32_t a, uint32_t coun
retval = core_move_long_to_r3(target, address); /* Destination address to r3 */ retval = core_move_long_to_r3(target, address); /* Destination address to r3 */
err_check_propagate(retval); err_check_propagate(retval);
core_load_TX_RX_high_addr_to_r0(target); /* TX/RX reg address to r0 */ core_load_tx_rx_high_addr_to_r0(target); /* TX/RX reg address to r0 */
err_check_propagate(retval); err_check_propagate(retval);
retval = core_move_long_to_r2(target, HFM_BASE_ADDR); /* FM base address to r2 */ retval = core_move_long_to_r2(target, HFM_BASE_ADDR); /* FM base address to r2 */
err_check_propagate(retval); err_check_propagate(retval);

View File

@ -238,7 +238,7 @@
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
#define MC568013_SIM_BASE_ADDR 0xF140 #define MC568013_SIM_BASE_ADDR 0xF140
#define MC56803x_2x_SIM_BASE_ADDR 0xF100 #define MC56803X_2X_SIM_BASE_ADDR 0xF100
#define SIM_CMD_RESET 0x10 #define SIM_CMD_RESET 0x10
/** /**

View File

@ -56,38 +56,38 @@ static const char * const esirisc_exception_strings[] = {
[EID_SYSTEM_CALL] = "SystemCall", [EID_SYSTEM_CALL] = "SystemCall",
[EID_MEMORY_MANAGEMENT] = "MemoryManagement", [EID_MEMORY_MANAGEMENT] = "MemoryManagement",
[EID_UNRECOVERABLE] = "Unrecoverable", [EID_UNRECOVERABLE] = "Unrecoverable",
[EID_INTERRUPTn+0] = "Interrupt0", [EID_INTERRUPT_N+0] = "Interrupt0",
[EID_INTERRUPTn+1] = "Interrupt1", [EID_INTERRUPT_N+1] = "Interrupt1",
[EID_INTERRUPTn+2] = "Interrupt2", [EID_INTERRUPT_N+2] = "Interrupt2",
[EID_INTERRUPTn+3] = "Interrupt3", [EID_INTERRUPT_N+3] = "Interrupt3",
[EID_INTERRUPTn+4] = "Interrupt4", [EID_INTERRUPT_N+4] = "Interrupt4",
[EID_INTERRUPTn+5] = "Interrupt5", [EID_INTERRUPT_N+5] = "Interrupt5",
[EID_INTERRUPTn+6] = "Interrupt6", [EID_INTERRUPT_N+6] = "Interrupt6",
[EID_INTERRUPTn+7] = "Interrupt7", [EID_INTERRUPT_N+7] = "Interrupt7",
[EID_INTERRUPTn+8] = "Interrupt8", [EID_INTERRUPT_N+8] = "Interrupt8",
[EID_INTERRUPTn+9] = "Interrupt9", [EID_INTERRUPT_N+9] = "Interrupt9",
[EID_INTERRUPTn+10] = "Interrupt10", [EID_INTERRUPT_N+10] = "Interrupt10",
[EID_INTERRUPTn+11] = "Interrupt11", [EID_INTERRUPT_N+11] = "Interrupt11",
[EID_INTERRUPTn+12] = "Interrupt12", [EID_INTERRUPT_N+12] = "Interrupt12",
[EID_INTERRUPTn+13] = "Interrupt13", [EID_INTERRUPT_N+13] = "Interrupt13",
[EID_INTERRUPTn+14] = "Interrupt14", [EID_INTERRUPT_N+14] = "Interrupt14",
[EID_INTERRUPTn+15] = "Interrupt15", [EID_INTERRUPT_N+15] = "Interrupt15",
[EID_INTERRUPTn+16] = "Interrupt16", [EID_INTERRUPT_N+16] = "Interrupt16",
[EID_INTERRUPTn+17] = "Interrupt17", [EID_INTERRUPT_N+17] = "Interrupt17",
[EID_INTERRUPTn+18] = "Interrupt18", [EID_INTERRUPT_N+18] = "Interrupt18",
[EID_INTERRUPTn+19] = "Interrupt19", [EID_INTERRUPT_N+19] = "Interrupt19",
[EID_INTERRUPTn+20] = "Interrupt20", [EID_INTERRUPT_N+20] = "Interrupt20",
[EID_INTERRUPTn+21] = "Interrupt21", [EID_INTERRUPT_N+21] = "Interrupt21",
[EID_INTERRUPTn+22] = "Interrupt22", [EID_INTERRUPT_N+22] = "Interrupt22",
[EID_INTERRUPTn+23] = "Interrupt23", [EID_INTERRUPT_N+23] = "Interrupt23",
[EID_INTERRUPTn+24] = "Interrupt24", [EID_INTERRUPT_N+24] = "Interrupt24",
[EID_INTERRUPTn+25] = "Interrupt25", [EID_INTERRUPT_N+25] = "Interrupt25",
[EID_INTERRUPTn+26] = "Interrupt26", [EID_INTERRUPT_N+26] = "Interrupt26",
[EID_INTERRUPTn+27] = "Interrupt27", [EID_INTERRUPT_N+27] = "Interrupt27",
[EID_INTERRUPTn+28] = "Interrupt28", [EID_INTERRUPT_N+28] = "Interrupt28",
[EID_INTERRUPTn+29] = "Interrupt29", [EID_INTERRUPT_N+29] = "Interrupt29",
[EID_INTERRUPTn+30] = "Interrupt30", [EID_INTERRUPT_N+30] = "Interrupt30",
[EID_INTERRUPTn+31] = "Interrupt31", [EID_INTERRUPT_N+31] = "Interrupt31",
}; };
/* /*
@ -508,7 +508,7 @@ static int esirisc_add_breakpoint(struct target *target, struct breakpoint *brea
esirisc->breakpoints_p[bp_index] = breakpoint; esirisc->breakpoints_p[bp_index] = breakpoint;
/* specify instruction breakpoint address */ /* specify instruction breakpoint address */
retval = esirisc_jtag_write_csr(jtag_info, CSR_DEBUG, CSR_DEBUG_IBAn + bp_index, retval = esirisc_jtag_write_csr(jtag_info, CSR_DEBUG, CSR_DEBUG_IBA_N + bp_index,
breakpoint->address); breakpoint->address);
if (retval != ERROR_OK) { if (retval != ERROR_OK) {
LOG_ERROR("%s: failed to write Debug CSR: IBA", target_name(target)); LOG_ERROR("%s: failed to write Debug CSR: IBA", target_name(target));
@ -634,7 +634,7 @@ static int esirisc_add_watchpoint(struct target *target, struct watchpoint *watc
esirisc->watchpoints_p[wp_index] = watchpoint; esirisc->watchpoints_p[wp_index] = watchpoint;
/* specify data breakpoint address */ /* specify data breakpoint address */
retval = esirisc_jtag_write_csr(jtag_info, CSR_DEBUG, CSR_DEBUG_DBAn + wp_index, retval = esirisc_jtag_write_csr(jtag_info, CSR_DEBUG, CSR_DEBUG_DBA_N + wp_index,
watchpoint->address); watchpoint->address);
if (retval != ERROR_OK) { if (retval != ERROR_OK) {
LOG_ERROR("%s: failed to write Debug CSR: DBA", target_name(target)); LOG_ERROR("%s: failed to write Debug CSR: DBA", target_name(target));

View File

@ -47,7 +47,7 @@
#define EID_SYSTEM_CALL 0x0b #define EID_SYSTEM_CALL 0x0b
#define EID_MEMORY_MANAGEMENT 0x0c #define EID_MEMORY_MANAGEMENT 0x0c
#define EID_UNRECOVERABLE 0x0d #define EID_UNRECOVERABLE 0x0d
#define EID_INTERRUPTn 0x20 #define EID_INTERRUPT_N 0x20
/* Exception Entry Points */ /* Exception Entry Points */
#define ENTRY_RESET 0x00 #define ENTRY_RESET 0x00
@ -58,7 +58,7 @@
#define ENTRY_SYSCALL 0x05 #define ENTRY_SYSCALL 0x05
#define ENTRY_DEBUG 0x06 #define ENTRY_DEBUG 0x06
#define ENTRY_NMI 0x07 #define ENTRY_NMI 0x07
#define ENTRY_INTERRUPTn 0x08 #define ENTRY_INTERRUPT_N 0x08
/* Hardware Debug Control */ /* Hardware Debug Control */
#define HWDC_R (1<<4) /* Reset & Hardware Failure */ #define HWDC_R (1<<4) /* Reset & Hardware Failure */

View File

@ -148,8 +148,8 @@ enum esirisc_reg_num {
#define CSR_DEBUG_HWDC 0x03 /* Hardware Debug Control */ #define CSR_DEBUG_HWDC 0x03 /* Hardware Debug Control */
#define CSR_DEBUG_DBS 0x04 /* Data Breakpoint Size */ #define CSR_DEBUG_DBS 0x04 /* Data Breakpoint Size */
#define CSR_DEBUG_DBR 0x05 /* Data Breakpoint Range */ #define CSR_DEBUG_DBR 0x05 /* Data Breakpoint Range */
#define CSR_DEBUG_IBAn 0x08 /* Instruction Breakpoint Address [0..7] */ #define CSR_DEBUG_IBA_N 0x08 /* Instruction Breakpoint Address [0..7] */
#define CSR_DEBUG_DBAn 0x10 /* Data Breakpoint Address [0..7] */ #define CSR_DEBUG_DBA_N 0x10 /* Data Breakpoint Address [0..7] */
/* Configuration CSRs */ /* Configuration CSRs */
#define CSR_CONFIG_ARCH0 0x00 /* Architectural Configuration 0 */ #define CSR_CONFIG_ARCH0 0x00 /* Architectural Configuration 0 */
@ -160,12 +160,12 @@ enum esirisc_reg_num {
#define CSR_CONFIG_IC 0x05 /* Instruction Cache Configuration */ #define CSR_CONFIG_IC 0x05 /* Instruction Cache Configuration */
#define CSR_CONFIG_DC 0x06 /* Data Cache Configuration */ #define CSR_CONFIG_DC 0x06 /* Data Cache Configuration */
#define CSR_CONFIG_INT 0x07 /* Interrupt Configuration */ #define CSR_CONFIG_INT 0x07 /* Interrupt Configuration */
#define CSR_CONFIG_ISAn 0x08 /* Instruction Set Configuration [0..6] */ #define CSR_CONFIG_ISA_N 0x08 /* Instruction Set Configuration [0..6] */
#define CSR_CONFIG_DBG 0x0f /* Debug Configuration */ #define CSR_CONFIG_DBG 0x0f /* Debug Configuration */
#define CSR_CONFIG_MID 0x10 /* Manufacturer ID */ #define CSR_CONFIG_MID 0x10 /* Manufacturer ID */
#define CSR_CONFIG_REV 0x11 /* Revision Number */ #define CSR_CONFIG_REV 0x11 /* Revision Number */
#define CSR_CONFIG_MPID 0x12 /* Multiprocessor ID */ #define CSR_CONFIG_MPID 0x12 /* Multiprocessor ID */
#define CSR_CONFIG_FREQn 0x13 /* Frequency [0..2] */ #define CSR_CONFIG_FREQ_N 0x13 /* Frequency [0..2] */
#define CSR_CONFIG_TRACE 0x16 /* Trace Configuration */ #define CSR_CONFIG_TRACE 0x16 /* Trace Configuration */
/* Trace CSRs */ /* Trace CSRs */

View File

@ -123,7 +123,7 @@ static int identify_image_type(struct image *image, const char *type_string, con
} }
static int image_ihex_buffer_complete_inner(struct image *image, static int image_ihex_buffer_complete_inner(struct image *image,
char *lpszLine, char *lpsz_line,
struct imagesection *section) struct imagesection *section)
{ {
struct image_ihex *ihex = image->type_private; struct image_ihex *ihex = image->type_private;
@ -152,7 +152,7 @@ static int image_ihex_buffer_complete_inner(struct image *image,
section[image->num_sections].size = 0x0; section[image->num_sections].size = 0x0;
section[image->num_sections].flags = 0; section[image->num_sections].flags = 0;
while (fileio_fgets(fileio, 1023, lpszLine) == ERROR_OK) { while (fileio_fgets(fileio, 1023, lpsz_line) == ERROR_OK) {
uint32_t count; uint32_t count;
uint32_t address; uint32_t address;
uint32_t record_type; uint32_t record_type;
@ -161,10 +161,10 @@ static int image_ihex_buffer_complete_inner(struct image *image,
size_t bytes_read = 0; size_t bytes_read = 0;
/* skip comments and blank lines */ /* skip comments and blank lines */
if ((lpszLine[0] == '#') || (strlen(lpszLine + strspn(lpszLine, "\n\t\r ")) == 0)) if ((lpsz_line[0] == '#') || (strlen(lpsz_line + strspn(lpsz_line, "\n\t\r ")) == 0))
continue; continue;
if (sscanf(&lpszLine[bytes_read], ":%2" SCNx32 "%4" SCNx32 "%2" SCNx32, &count, if (sscanf(&lpsz_line[bytes_read], ":%2" SCNx32 "%4" SCNx32 "%2" SCNx32, &count,
&address, &record_type) != 3) &address, &record_type) != 3)
return ERROR_IMAGE_FORMAT_ERROR; return ERROR_IMAGE_FORMAT_ERROR;
bytes_read += 9; bytes_read += 9;
@ -199,7 +199,7 @@ static int image_ihex_buffer_complete_inner(struct image *image,
while (count-- > 0) { while (count-- > 0) {
unsigned value; unsigned value;
sscanf(&lpszLine[bytes_read], "%2x", &value); sscanf(&lpsz_line[bytes_read], "%2x", &value);
ihex->buffer[cooked_bytes] = (uint8_t)value; ihex->buffer[cooked_bytes] = (uint8_t)value;
cal_checksum += (uint8_t)ihex->buffer[cooked_bytes]; cal_checksum += (uint8_t)ihex->buffer[cooked_bytes];
bytes_read += 2; bytes_read += 2;
@ -225,7 +225,7 @@ static int image_ihex_buffer_complete_inner(struct image *image,
} else if (record_type == 2) { /* Linear Address Record */ } else if (record_type == 2) { /* Linear Address Record */
uint16_t upper_address; uint16_t upper_address;
sscanf(&lpszLine[bytes_read], "%4hx", &upper_address); sscanf(&lpsz_line[bytes_read], "%4hx", &upper_address);
cal_checksum += (uint8_t)(upper_address >> 8); cal_checksum += (uint8_t)(upper_address >> 8);
cal_checksum += (uint8_t)upper_address; cal_checksum += (uint8_t)upper_address;
bytes_read += 4; bytes_read += 4;
@ -257,14 +257,14 @@ static int image_ihex_buffer_complete_inner(struct image *image,
/* "Start Segment Address Record" will not be supported /* "Start Segment Address Record" will not be supported
* but we must consume it, and do not create an error. */ * but we must consume it, and do not create an error. */
while (count-- > 0) { while (count-- > 0) {
sscanf(&lpszLine[bytes_read], "%2" SCNx32, &dummy); sscanf(&lpsz_line[bytes_read], "%2" SCNx32, &dummy);
cal_checksum += (uint8_t)dummy; cal_checksum += (uint8_t)dummy;
bytes_read += 2; bytes_read += 2;
} }
} else if (record_type == 4) { /* Extended Linear Address Record */ } else if (record_type == 4) { /* Extended Linear Address Record */
uint16_t upper_address; uint16_t upper_address;
sscanf(&lpszLine[bytes_read], "%4hx", &upper_address); sscanf(&lpsz_line[bytes_read], "%4hx", &upper_address);
cal_checksum += (uint8_t)(upper_address >> 8); cal_checksum += (uint8_t)(upper_address >> 8);
cal_checksum += (uint8_t)upper_address; cal_checksum += (uint8_t)upper_address;
bytes_read += 4; bytes_read += 4;
@ -293,7 +293,7 @@ static int image_ihex_buffer_complete_inner(struct image *image,
} else if (record_type == 5) { /* Start Linear Address Record */ } else if (record_type == 5) { /* Start Linear Address Record */
uint32_t start_address; uint32_t start_address;
sscanf(&lpszLine[bytes_read], "%8" SCNx32, &start_address); sscanf(&lpsz_line[bytes_read], "%8" SCNx32, &start_address);
cal_checksum += (uint8_t)(start_address >> 24); cal_checksum += (uint8_t)(start_address >> 24);
cal_checksum += (uint8_t)(start_address >> 16); cal_checksum += (uint8_t)(start_address >> 16);
cal_checksum += (uint8_t)(start_address >> 8); cal_checksum += (uint8_t)(start_address >> 8);
@ -307,7 +307,7 @@ static int image_ihex_buffer_complete_inner(struct image *image,
return ERROR_IMAGE_FORMAT_ERROR; return ERROR_IMAGE_FORMAT_ERROR;
} }
sscanf(&lpszLine[bytes_read], "%2" SCNx32, &checksum); sscanf(&lpsz_line[bytes_read], "%2" SCNx32, &checksum);
if ((uint8_t)checksum != (uint8_t)(~cal_checksum + 1)) { if ((uint8_t)checksum != (uint8_t)(~cal_checksum + 1)) {
/* checksum failed */ /* checksum failed */
@ -317,7 +317,7 @@ static int image_ihex_buffer_complete_inner(struct image *image,
if (end_rec) { if (end_rec) {
end_rec = false; end_rec = false;
LOG_WARNING("continuing after end-of-file record: %.40s", lpszLine); LOG_WARNING("continuing after end-of-file record: %.40s", lpsz_line);
} }
} }
} }
@ -336,23 +336,23 @@ static int image_ihex_buffer_complete_inner(struct image *image,
*/ */
static int image_ihex_buffer_complete(struct image *image) static int image_ihex_buffer_complete(struct image *image)
{ {
char *lpszLine = malloc(1023); char *lpsz_line = malloc(1023);
if (lpszLine == NULL) { if (lpsz_line == NULL) {
LOG_ERROR("Out of memory"); LOG_ERROR("Out of memory");
return ERROR_FAIL; return ERROR_FAIL;
} }
struct imagesection *section = malloc(sizeof(struct imagesection) * IMAGE_MAX_SECTIONS); struct imagesection *section = malloc(sizeof(struct imagesection) * IMAGE_MAX_SECTIONS);
if (section == NULL) { if (section == NULL) {
free(lpszLine); free(lpsz_line);
LOG_ERROR("Out of memory"); LOG_ERROR("Out of memory");
return ERROR_FAIL; return ERROR_FAIL;
} }
int retval; int retval;
retval = image_ihex_buffer_complete_inner(image, lpszLine, section); retval = image_ihex_buffer_complete_inner(image, lpsz_line, section);
free(section); free(section);
free(lpszLine); free(lpsz_line);
return retval; return retval;
} }
@ -755,7 +755,7 @@ static int image_elf_read_section(struct image *image,
} }
static int image_mot_buffer_complete_inner(struct image *image, static int image_mot_buffer_complete_inner(struct image *image,
char *lpszLine, char *lpsz_line,
struct imagesection *section) struct imagesection *section)
{ {
struct image_mot *mot = image->type_private; struct image_mot *mot = image->type_private;
@ -784,7 +784,7 @@ static int image_mot_buffer_complete_inner(struct image *image,
section[image->num_sections].size = 0x0; section[image->num_sections].size = 0x0;
section[image->num_sections].flags = 0; section[image->num_sections].flags = 0;
while (fileio_fgets(fileio, 1023, lpszLine) == ERROR_OK) { while (fileio_fgets(fileio, 1023, lpsz_line) == ERROR_OK) {
uint32_t count; uint32_t count;
uint32_t address; uint32_t address;
uint32_t record_type; uint32_t record_type;
@ -793,11 +793,11 @@ static int image_mot_buffer_complete_inner(struct image *image,
uint32_t bytes_read = 0; uint32_t bytes_read = 0;
/* skip comments and blank lines */ /* skip comments and blank lines */
if ((lpszLine[0] == '#') || (strlen(lpszLine + strspn(lpszLine, "\n\t\r ")) == 0)) if ((lpsz_line[0] == '#') || (strlen(lpsz_line + strspn(lpsz_line, "\n\t\r ")) == 0))
continue; continue;
/* get record type and record length */ /* get record type and record length */
if (sscanf(&lpszLine[bytes_read], "S%1" SCNx32 "%2" SCNx32, &record_type, if (sscanf(&lpsz_line[bytes_read], "S%1" SCNx32 "%2" SCNx32, &record_type,
&count) != 2) &count) != 2)
return ERROR_IMAGE_FORMAT_ERROR; return ERROR_IMAGE_FORMAT_ERROR;
@ -809,18 +809,18 @@ static int image_mot_buffer_complete_inner(struct image *image,
if (record_type == 0) { if (record_type == 0) {
/* S0 - starting record (optional) */ /* S0 - starting record (optional) */
int iValue; int value;
while (count-- > 0) { while (count-- > 0) {
sscanf(&lpszLine[bytes_read], "%2x", &iValue); sscanf(&lpsz_line[bytes_read], "%2x", &value);
cal_checksum += (uint8_t)iValue; cal_checksum += (uint8_t)value;
bytes_read += 2; bytes_read += 2;
} }
} else if (record_type >= 1 && record_type <= 3) { } else if (record_type >= 1 && record_type <= 3) {
switch (record_type) { switch (record_type) {
case 1: case 1:
/* S1 - 16 bit address data record */ /* S1 - 16 bit address data record */
sscanf(&lpszLine[bytes_read], "%4" SCNx32, &address); sscanf(&lpsz_line[bytes_read], "%4" SCNx32, &address);
cal_checksum += (uint8_t)(address >> 8); cal_checksum += (uint8_t)(address >> 8);
cal_checksum += (uint8_t)address; cal_checksum += (uint8_t)address;
bytes_read += 4; bytes_read += 4;
@ -829,7 +829,7 @@ static int image_mot_buffer_complete_inner(struct image *image,
case 2: case 2:
/* S2 - 24 bit address data record */ /* S2 - 24 bit address data record */
sscanf(&lpszLine[bytes_read], "%6" SCNx32, &address); sscanf(&lpsz_line[bytes_read], "%6" SCNx32, &address);
cal_checksum += (uint8_t)(address >> 16); cal_checksum += (uint8_t)(address >> 16);
cal_checksum += (uint8_t)(address >> 8); cal_checksum += (uint8_t)(address >> 8);
cal_checksum += (uint8_t)address; cal_checksum += (uint8_t)address;
@ -839,7 +839,7 @@ static int image_mot_buffer_complete_inner(struct image *image,
case 3: case 3:
/* S3 - 32 bit address data record */ /* S3 - 32 bit address data record */
sscanf(&lpszLine[bytes_read], "%8" SCNx32, &address); sscanf(&lpsz_line[bytes_read], "%8" SCNx32, &address);
cal_checksum += (uint8_t)(address >> 24); cal_checksum += (uint8_t)(address >> 24);
cal_checksum += (uint8_t)(address >> 16); cal_checksum += (uint8_t)(address >> 16);
cal_checksum += (uint8_t)(address >> 8); cal_checksum += (uint8_t)(address >> 8);
@ -868,7 +868,7 @@ static int image_mot_buffer_complete_inner(struct image *image,
while (count-- > 0) { while (count-- > 0) {
unsigned value; unsigned value;
sscanf(&lpszLine[bytes_read], "%2x", &value); sscanf(&lpsz_line[bytes_read], "%2x", &value);
mot->buffer[cooked_bytes] = (uint8_t)value; mot->buffer[cooked_bytes] = (uint8_t)value;
cal_checksum += (uint8_t)mot->buffer[cooked_bytes]; cal_checksum += (uint8_t)mot->buffer[cooked_bytes];
bytes_read += 2; bytes_read += 2;
@ -881,7 +881,7 @@ static int image_mot_buffer_complete_inner(struct image *image,
uint32_t dummy; uint32_t dummy;
while (count-- > 0) { while (count-- > 0) {
sscanf(&lpszLine[bytes_read], "%2" SCNx32, &dummy); sscanf(&lpsz_line[bytes_read], "%2" SCNx32, &dummy);
cal_checksum += (uint8_t)dummy; cal_checksum += (uint8_t)dummy;
bytes_read += 2; bytes_read += 2;
} }
@ -906,7 +906,7 @@ static int image_mot_buffer_complete_inner(struct image *image,
} }
/* account for checksum, will always be 0xFF */ /* account for checksum, will always be 0xFF */
sscanf(&lpszLine[bytes_read], "%2" SCNx32, &checksum); sscanf(&lpsz_line[bytes_read], "%2" SCNx32, &checksum);
cal_checksum += (uint8_t)checksum; cal_checksum += (uint8_t)checksum;
if (cal_checksum != 0xFF) { if (cal_checksum != 0xFF) {
@ -917,7 +917,7 @@ static int image_mot_buffer_complete_inner(struct image *image,
if (end_rec) { if (end_rec) {
end_rec = false; end_rec = false;
LOG_WARNING("continuing after end-of-file record: %.40s", lpszLine); LOG_WARNING("continuing after end-of-file record: %.40s", lpsz_line);
} }
} }
} }
@ -936,23 +936,23 @@ static int image_mot_buffer_complete_inner(struct image *image,
*/ */
static int image_mot_buffer_complete(struct image *image) static int image_mot_buffer_complete(struct image *image)
{ {
char *lpszLine = malloc(1023); char *lpsz_line = malloc(1023);
if (lpszLine == NULL) { if (lpsz_line == NULL) {
LOG_ERROR("Out of memory"); LOG_ERROR("Out of memory");
return ERROR_FAIL; return ERROR_FAIL;
} }
struct imagesection *section = malloc(sizeof(struct imagesection) * IMAGE_MAX_SECTIONS); struct imagesection *section = malloc(sizeof(struct imagesection) * IMAGE_MAX_SECTIONS);
if (section == NULL) { if (section == NULL) {
free(lpszLine); free(lpsz_line);
LOG_ERROR("Out of memory"); LOG_ERROR("Out of memory");
return ERROR_FAIL; return ERROR_FAIL;
} }
int retval; int retval;
retval = image_mot_buffer_complete_inner(image, lpszLine, section); retval = image_mot_buffer_complete_inner(image, lpsz_line, section);
free(section); free(section);
free(lpszLine); free(lpsz_line);
return retval; return retval;
} }

View File

@ -2884,57 +2884,57 @@ COMMAND_HANDLER(handle_targets_command)
/* every 300ms we check for reset & powerdropout and issue a "reset halt" if so. */ /* every 300ms we check for reset & powerdropout and issue a "reset halt" if so. */
static int powerDropout; static int power_dropout;
static int srstAsserted; static int srst_asserted;
static int runPowerRestore; static int run_power_restore;
static int runPowerDropout; static int run_power_dropout;
static int runSrstAsserted; static int run_srst_asserted;
static int runSrstDeasserted; static int run_srst_deasserted;
static int sense_handler(void) static int sense_handler(void)
{ {
static int prevSrstAsserted; static int prev_srst_asserted;
static int prevPowerdropout; static int prev_power_dropout;
int retval = jtag_power_dropout(&powerDropout); int retval = jtag_power_dropout(&power_dropout);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
int powerRestored; int power_restored;
powerRestored = prevPowerdropout && !powerDropout; power_restored = prev_power_dropout && !power_dropout;
if (powerRestored) if (power_restored)
runPowerRestore = 1; run_power_restore = 1;
int64_t current = timeval_ms(); int64_t current = timeval_ms();
static int64_t lastPower; static int64_t last_power;
bool waitMore = lastPower + 2000 > current; bool wait_more = last_power + 2000 > current;
if (powerDropout && !waitMore) { if (power_dropout && !wait_more) {
runPowerDropout = 1; run_power_dropout = 1;
lastPower = current; last_power = current;
} }
retval = jtag_srst_asserted(&srstAsserted); retval = jtag_srst_asserted(&srst_asserted);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
int srstDeasserted; int srst_deasserted;
srstDeasserted = prevSrstAsserted && !srstAsserted; srst_deasserted = prev_srst_asserted && !srst_asserted;
static int64_t lastSrst; static int64_t last_srst;
waitMore = lastSrst + 2000 > current; wait_more = last_srst + 2000 > current;
if (srstDeasserted && !waitMore) { if (srst_deasserted && !wait_more) {
runSrstDeasserted = 1; run_srst_deasserted = 1;
lastSrst = current; last_srst = current;
} }
if (!prevSrstAsserted && srstAsserted) if (!prev_srst_asserted && srst_asserted)
runSrstAsserted = 1; run_srst_asserted = 1;
prevSrstAsserted = srstAsserted; prev_srst_asserted = srst_asserted;
prevPowerdropout = powerDropout; prev_power_dropout = power_dropout;
if (srstDeasserted || powerRestored) { if (srst_deasserted || power_restored) {
/* Other than logging the event we can't do anything here. /* Other than logging the event we can't do anything here.
* Issuing a reset is a particularly bad idea as we might * Issuing a reset is a particularly bad idea as we might
* be inside a reset already. * be inside a reset already.
@ -2965,21 +2965,21 @@ static int handle_target(void *priv)
* clearing the flags after running these events. * clearing the flags after running these events.
*/ */
int did_something = 0; int did_something = 0;
if (runSrstAsserted) { if (run_srst_asserted) {
LOG_INFO("srst asserted detected, running srst_asserted proc."); LOG_INFO("srst asserted detected, running srst_asserted proc.");
Jim_Eval(interp, "srst_asserted"); Jim_Eval(interp, "srst_asserted");
did_something = 1; did_something = 1;
} }
if (runSrstDeasserted) { if (run_srst_deasserted) {
Jim_Eval(interp, "srst_deasserted"); Jim_Eval(interp, "srst_deasserted");
did_something = 1; did_something = 1;
} }
if (runPowerDropout) { if (run_power_dropout) {
LOG_INFO("Power dropout detected, running power_dropout proc."); LOG_INFO("Power dropout detected, running power_dropout proc.");
Jim_Eval(interp, "power_dropout"); Jim_Eval(interp, "power_dropout");
did_something = 1; did_something = 1;
} }
if (runPowerRestore) { if (run_power_restore) {
Jim_Eval(interp, "power_restore"); Jim_Eval(interp, "power_restore");
did_something = 1; did_something = 1;
} }
@ -2991,10 +2991,10 @@ static int handle_target(void *priv)
/* clear action flags */ /* clear action flags */
runSrstAsserted = 0; run_srst_asserted = 0;
runSrstDeasserted = 0; run_srst_deasserted = 0;
runPowerRestore = 0; run_power_restore = 0;
runPowerDropout = 0; run_power_dropout = 0;
recursive = 0; recursive = 0;
} }
@ -3020,7 +3020,7 @@ static int handle_target(void *priv)
target->backoff.count = 0; target->backoff.count = 0;
/* only poll target if we've got power and srst isn't asserted */ /* only poll target if we've got power and srst isn't asserted */
if (!powerDropout && !srstAsserted) { if (!power_dropout && !srst_asserted) {
/* polling may fail silently until the target has been examined */ /* polling may fail silently until the target has been examined */
retval = target_poll(target); retval = target_poll(target);
if (retval != ERROR_OK) { if (retval != ERROR_OK) {
@ -3596,7 +3596,7 @@ COMMAND_HANDLER(handle_mw_command)
return target_fill_mem(target, address, fn, wordsize, value, count); return target_fill_mem(target, address, fn, wordsize, value, count);
} }
static COMMAND_HELPER(parse_load_image_command_CMD_ARGV, struct image *image, static COMMAND_HELPER(parse_load_image_command, struct image *image,
target_addr_t *min_address, target_addr_t *max_address) target_addr_t *min_address, target_addr_t *max_address)
{ {
if (CMD_ARGC < 1 || CMD_ARGC > 5) if (CMD_ARGC < 1 || CMD_ARGC > 5)
@ -3637,7 +3637,7 @@ COMMAND_HANDLER(handle_load_image_command)
target_addr_t max_address = -1; target_addr_t max_address = -1;
struct image image; struct image image;
int retval = CALL_COMMAND_HANDLER(parse_load_image_command_CMD_ARGV, int retval = CALL_COMMAND_HANDLER(parse_load_image_command,
&image, &min_address, &max_address); &image, &min_address, &max_address);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
@ -4166,44 +4166,44 @@ COMMAND_HANDLER(handle_virt2phys_command)
return retval; return retval;
} }
static void writeData(FILE *f, const void *data, size_t len) static void write_data(FILE *f, const void *data, size_t len)
{ {
size_t written = fwrite(data, 1, len, f); size_t written = fwrite(data, 1, len, f);
if (written != len) if (written != len)
LOG_ERROR("failed to write %zu bytes: %s", len, strerror(errno)); LOG_ERROR("failed to write %zu bytes: %s", len, strerror(errno));
} }
static void writeLong(FILE *f, int l, struct target *target) static void write_long(FILE *f, int l, struct target *target)
{ {
uint8_t val[4]; uint8_t val[4];
target_buffer_set_u32(target, val, l); target_buffer_set_u32(target, val, l);
writeData(f, val, 4); write_data(f, val, 4);
} }
static void writeString(FILE *f, char *s) static void write_string(FILE *f, char *s)
{ {
writeData(f, s, strlen(s)); write_data(f, s, strlen(s));
} }
typedef unsigned char UNIT[2]; /* unit of profiling */ typedef unsigned char UNIT[2]; /* unit of profiling */
/* Dump a gmon.out histogram file. */ /* Dump a gmon.out histogram file. */
static void write_gmon(uint32_t *samples, uint32_t sampleNum, const char *filename, bool with_range, static void write_gmon(uint32_t *samples, uint32_t sample_num, const char *filename, bool with_range,
uint32_t start_address, uint32_t end_address, struct target *target, uint32_t duration_ms) uint32_t start_address, uint32_t end_address, struct target *target, uint32_t duration_ms)
{ {
uint32_t i; uint32_t i;
FILE *f = fopen(filename, "w"); FILE *f = fopen(filename, "w");
if (f == NULL) if (f == NULL)
return; return;
writeString(f, "gmon"); write_string(f, "gmon");
writeLong(f, 0x00000001, target); /* Version */ write_long(f, 0x00000001, target); /* Version */
writeLong(f, 0, target); /* padding */ write_long(f, 0, target); /* padding */
writeLong(f, 0, target); /* padding */ write_long(f, 0, target); /* padding */
writeLong(f, 0, target); /* padding */ write_long(f, 0, target); /* padding */
uint8_t zero = 0; /* GMON_TAG_TIME_HIST */ uint8_t zero = 0; /* GMON_TAG_TIME_HIST */
writeData(f, &zero, 1); write_data(f, &zero, 1);
/* figure out bucket size */ /* figure out bucket size */
uint32_t min; uint32_t min;
@ -4214,7 +4214,7 @@ static void write_gmon(uint32_t *samples, uint32_t sampleNum, const char *filena
} else { } else {
min = samples[0]; min = samples[0];
max = samples[0]; max = samples[0];
for (i = 0; i < sampleNum; i++) { for (i = 0; i < sample_num; i++) {
if (min > samples[i]) if (min > samples[i])
min = samples[i]; min = samples[i];
if (max < samples[i]) if (max < samples[i])
@ -4226,50 +4226,50 @@ static void write_gmon(uint32_t *samples, uint32_t sampleNum, const char *filena
max++; max++;
} }
int addressSpace = max - min; int address_space = max - min;
assert(addressSpace >= 2); assert(address_space >= 2);
/* FIXME: What is the reasonable number of buckets? /* FIXME: What is the reasonable number of buckets?
* The profiling result will be more accurate if there are enough buckets. */ * The profiling result will be more accurate if there are enough buckets. */
static const uint32_t maxBuckets = 128 * 1024; /* maximum buckets. */ static const uint32_t max_buckets = 128 * 1024; /* maximum buckets. */
uint32_t numBuckets = addressSpace / sizeof(UNIT); uint32_t num_buckets = address_space / sizeof(UNIT);
if (numBuckets > maxBuckets) if (num_buckets > max_buckets)
numBuckets = maxBuckets; num_buckets = max_buckets;
int *buckets = malloc(sizeof(int) * numBuckets); int *buckets = malloc(sizeof(int) * num_buckets);
if (buckets == NULL) { if (buckets == NULL) {
fclose(f); fclose(f);
return; return;
} }
memset(buckets, 0, sizeof(int) * numBuckets); memset(buckets, 0, sizeof(int) * num_buckets);
for (i = 0; i < sampleNum; i++) { for (i = 0; i < sample_num; i++) {
uint32_t address = samples[i]; uint32_t address = samples[i];
if ((address < min) || (max <= address)) if ((address < min) || (max <= address))
continue; continue;
long long a = address - min; long long a = address - min;
long long b = numBuckets; long long b = num_buckets;
long long c = addressSpace; long long c = address_space;
int index_t = (a * b) / c; /* danger!!!! int32 overflows */ int index_t = (a * b) / c; /* danger!!!! int32 overflows */
buckets[index_t]++; buckets[index_t]++;
} }
/* append binary memory gmon.out &profile_hist_hdr ((char*)&profile_hist_hdr + sizeof(struct gmon_hist_hdr)) */ /* append binary memory gmon.out &profile_hist_hdr ((char*)&profile_hist_hdr + sizeof(struct gmon_hist_hdr)) */
writeLong(f, min, target); /* low_pc */ write_long(f, min, target); /* low_pc */
writeLong(f, max, target); /* high_pc */ write_long(f, max, target); /* high_pc */
writeLong(f, numBuckets, target); /* # of buckets */ write_long(f, num_buckets, target); /* # of buckets */
float sample_rate = sampleNum / (duration_ms / 1000.0); float sample_rate = sample_num / (duration_ms / 1000.0);
writeLong(f, sample_rate, target); write_long(f, sample_rate, target);
writeString(f, "seconds"); write_string(f, "seconds");
for (i = 0; i < (15-strlen("seconds")); i++) for (i = 0; i < (15-strlen("seconds")); i++)
writeData(f, &zero, 1); write_data(f, &zero, 1);
writeString(f, "s"); write_string(f, "s");
/*append binary memory gmon.out profile_hist_data (profile_hist_data + profile_hist_hdr.hist_size) */ /*append binary memory gmon.out profile_hist_data (profile_hist_data + profile_hist_hdr.hist_size) */
char *data = malloc(2 * numBuckets); char *data = malloc(2 * num_buckets);
if (data != NULL) { if (data != NULL) {
for (i = 0; i < numBuckets; i++) { for (i = 0; i < num_buckets; i++) {
int val; int val;
val = buckets[i]; val = buckets[i];
if (val > 65535) if (val > 65535)
@ -4278,7 +4278,7 @@ static void write_gmon(uint32_t *samples, uint32_t sampleNum, const char *filena
data[i * 2 + 1] = (val >> 8) & 0xff; data[i * 2 + 1] = (val >> 8) & 0xff;
} }
free(buckets); free(buckets);
writeData(f, data, numBuckets * 2); write_data(f, data, num_buckets * 2);
free(data); free(data);
} else } else
free(buckets); free(buckets);
@ -4375,26 +4375,26 @@ COMMAND_HANDLER(handle_profile_command)
static int new_u64_array_element(Jim_Interp *interp, const char *varname, int idx, uint64_t val) static int new_u64_array_element(Jim_Interp *interp, const char *varname, int idx, uint64_t val)
{ {
char *namebuf; char *namebuf;
Jim_Obj *nameObjPtr, *valObjPtr; Jim_Obj *obj_name, *obj_val;
int result; int result;
namebuf = alloc_printf("%s(%d)", varname, idx); namebuf = alloc_printf("%s(%d)", varname, idx);
if (!namebuf) if (!namebuf)
return JIM_ERR; return JIM_ERR;
nameObjPtr = Jim_NewStringObj(interp, namebuf, -1); obj_name = Jim_NewStringObj(interp, namebuf, -1);
jim_wide wide_val = val; jim_wide wide_val = val;
valObjPtr = Jim_NewWideObj(interp, wide_val); obj_val = Jim_NewWideObj(interp, wide_val);
if (!nameObjPtr || !valObjPtr) { if (!obj_name || !obj_val) {
free(namebuf); free(namebuf);
return JIM_ERR; return JIM_ERR;
} }
Jim_IncrRefCount(nameObjPtr); Jim_IncrRefCount(obj_name);
Jim_IncrRefCount(valObjPtr); Jim_IncrRefCount(obj_val);
result = Jim_SetVariable(interp, nameObjPtr, valObjPtr); result = Jim_SetVariable(interp, obj_name, obj_val);
Jim_DecrRefCount(interp, nameObjPtr); Jim_DecrRefCount(interp, obj_name);
Jim_DecrRefCount(interp, valObjPtr); Jim_DecrRefCount(interp, obj_val);
free(namebuf); free(namebuf);
/* printf("%s(%d) <= 0%08x\n", varname, idx, val); */ /* printf("%s(%d) <= 0%08x\n", varname, idx, val); */
return result; return result;
@ -4579,21 +4579,21 @@ static int get_u64_array_element(Jim_Interp *interp, const char *varname, size_t
if (!namebuf) if (!namebuf)
return JIM_ERR; return JIM_ERR;
Jim_Obj *nameObjPtr = Jim_NewStringObj(interp, namebuf, -1); Jim_Obj *obj_name = Jim_NewStringObj(interp, namebuf, -1);
if (!nameObjPtr) { if (!obj_name) {
free(namebuf); free(namebuf);
return JIM_ERR; return JIM_ERR;
} }
Jim_IncrRefCount(nameObjPtr); Jim_IncrRefCount(obj_name);
Jim_Obj *valObjPtr = Jim_GetVariable(interp, nameObjPtr, JIM_ERRMSG); Jim_Obj *obj_val = Jim_GetVariable(interp, obj_name, JIM_ERRMSG);
Jim_DecrRefCount(interp, nameObjPtr); Jim_DecrRefCount(interp, obj_name);
free(namebuf); free(namebuf);
if (valObjPtr == NULL) if (obj_val == NULL)
return JIM_ERR; return JIM_ERR;
jim_wide wide_val; jim_wide wide_val;
int result = Jim_GetWide(interp, valObjPtr, &wide_val); int result = Jim_GetWide(interp, obj_val, &wide_val);
*val = wide_val; *val = wide_val;
return result; return result;
} }
@ -5456,11 +5456,11 @@ static int jim_target_wait_state(Jim_Interp *interp, int argc, Jim_Obj *const *a
e = target_wait_state(target, n->value, a); e = target_wait_state(target, n->value, a);
if (e != ERROR_OK) { if (e != ERROR_OK) {
Jim_Obj *eObj = Jim_NewIntObj(interp, e); Jim_Obj *obj = Jim_NewIntObj(interp, e);
Jim_SetResultFormatted(goi.interp, Jim_SetResultFormatted(goi.interp,
"target: %s wait %s fails (%#s) %s", "target: %s wait %s fails (%#s) %s",
target_name(target), n->name, target_name(target), n->name,
eObj, target_strerror_safe(e)); obj, target_strerror_safe(e));
return JIM_ERR; return JIM_ERR;
} }
return JIM_OK; return JIM_OK;
@ -6069,7 +6069,7 @@ static const struct command_registration target_subcommand_handlers[] = {
COMMAND_REGISTRATION_DONE COMMAND_REGISTRATION_DONE
}; };
struct FastLoad { struct fast_load {
target_addr_t address; target_addr_t address;
uint8_t *data; uint8_t *data;
int length; int length;
@ -6077,7 +6077,7 @@ struct FastLoad {
}; };
static int fastload_num; static int fastload_num;
static struct FastLoad *fastload; static struct fast_load *fastload;
static void free_fastload(void) static void free_fastload(void)
{ {
@ -6099,7 +6099,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
struct image image; struct image image;
int retval = CALL_COMMAND_HANDLER(parse_load_image_command_CMD_ARGV, int retval = CALL_COMMAND_HANDLER(parse_load_image_command,
&image, &min_address, &max_address); &image, &min_address, &max_address);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
@ -6114,13 +6114,13 @@ COMMAND_HANDLER(handle_fast_load_image_command)
image_size = 0x0; image_size = 0x0;
retval = ERROR_OK; retval = ERROR_OK;
fastload_num = image.num_sections; fastload_num = image.num_sections;
fastload = malloc(sizeof(struct FastLoad)*image.num_sections); fastload = malloc(sizeof(struct fast_load)*image.num_sections);
if (fastload == NULL) { if (fastload == NULL) {
command_print(CMD, "out of memory"); command_print(CMD, "out of memory");
image_close(&image); image_close(&image);
return ERROR_FAIL; return ERROR_FAIL;
} }
memset(fastload, 0, sizeof(struct FastLoad)*image.num_sections); memset(fastload, 0, sizeof(struct fast_load)*image.num_sections);
for (unsigned int i = 0; i < image.num_sections; i++) { for (unsigned int i = 0; i < image.num_sections; i++) {
buffer = malloc(image.sections[i].size); buffer = malloc(image.sections[i].size);
if (buffer == NULL) { if (buffer == NULL) {

View File

@ -472,10 +472,10 @@ int calcaddr_physfromlin(struct target *t, target_addr_t addr, target_addr_t *ph
} }
uint32_t cr4 = buf_get_u32(x86_32->cache->reg_list[CR4].value, 0, 32); uint32_t cr4 = buf_get_u32(x86_32->cache->reg_list[CR4].value, 0, 32);
bool isPAE = cr4 & 0x00000020; /* PAE - Physical Address Extension */ bool is_pae = cr4 & 0x00000020; /* PAE - Physical Address Extension */
uint32_t cr3 = buf_get_u32(x86_32->cache->reg_list[CR3].value, 0, 32); uint32_t cr3 = buf_get_u32(x86_32->cache->reg_list[CR3].value, 0, 32);
if (isPAE) { if (is_pae) {
uint32_t pdpt_base = cr3 & 0xFFFFF000; /* lower 12 bits of CR3 must always be 0 */ uint32_t pdpt_base = cr3 & 0xFFFFF000; /* lower 12 bits of CR3 must always be 0 */
uint32_t pdpt_index = (addr & 0xC0000000) >> 30; /* A[31:30] index to PDPT */ uint32_t pdpt_index = (addr & 0xC0000000) >> 30; /* A[31:30] index to PDPT */
uint32_t pdpt_addr = pdpt_base + (8 * pdpt_index); uint32_t pdpt_addr = pdpt_base + (8 * pdpt_index);