* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
uint8_t size; /* low-N of 32 bits */
uint8_t mode; /* RO, WO, RW */
uint8_t bcd_vers; /* 1.0, 2.0, etc */
- char *name;
+ const char *name;
};
/*
ADDR_COMPARATOR(14),
ADDR_COMPARATOR(15),
ADDR_COMPARATOR(16),
+ { 0, 0, 0, 0, NULL }
#undef ADDR_COMPARATOR
};
DATA_COMPARATOR(6),
DATA_COMPARATOR(7),
DATA_COMPARATOR(8),
+ { 0, 0, 0, 0, NULL }
#undef DATA_COMPARATOR
};
ETM_COUNTER(2),
ETM_COUNTER(3),
ETM_COUNTER(4),
+ { 0, 0, 0, 0, NULL }
#undef ETM_COUNTER
};
ETM_OUTPUT(2),
ETM_OUTPUT(3),
ETM_OUTPUT(4),
+ { 0, 0, 0, 0, NULL }
#undef ETM_OUTPUT
};
* version of the ETM, to the specified cache.
*/
for (; nreg--; r++) {
+ /* No more registers to add */
+ if (!r->size) {
+ LOG_ERROR("etm_reg_add is requested to add non-existing registers, ETM config might be bogus");
+ return;
+ }
/* this ETM may be too old to have some registers */
if (r->bcd_vers > bcd_vers)
etm_core, 1);
etm_get_reg(reg_list);
- etm_ctx->config = buf_get_u32((void *)&arch_info->value, 0, 32);
+ etm_ctx->config = buf_get_u32(arch_info->value, 0, 32);
config = etm_ctx->config;
/* figure ETM version then add base registers */
etm_core + 1, 1);
etm_get_reg(reg_list + 1);
etm_ctx->id = buf_get_u32(
- (void *)&arch_info[1].value, 0, 32);
+ arch_info[1].value, 0, 32);
LOG_DEBUG("ETM ID: %08x", (unsigned) etm_ctx->id);
bcd_vers = 0x10 + (((etm_ctx->id) >> 4) & 0xff);
retval = arm_jtag_scann(etm_reg->jtag_info, 0x6, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
- retval = arm_jtag_set_instr(etm_reg->jtag_info,
+ retval = arm_jtag_set_instr(etm_reg->jtag_info->tap,
etm_reg->jtag_info->intest_instr,
NULL,
TAP_IDLE);
retval = arm_jtag_scann(etm_reg->jtag_info, 0x6, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
- retval = arm_jtag_set_instr(etm_reg->jtag_info,
+ retval = arm_jtag_set_instr(etm_reg->jtag_info->tap,
etm_reg->jtag_info->intest_instr,
NULL,
TAP_IDLE);
* and a new branch was encountered in cycle ctx->pipe_index + retval;
*/
LOG_WARNING(
- "abandoned branch encountered, correctnes of analysis uncertain");
+ "abandoned branch encountered, correctness of analysis uncertain");
ctx->pipe_index += retval;
continue;
}
/* if we got here the branch was a normal PC change
* (or a periodic synchronization point, which means the same for that matter)
- * if we didn't accquire a complete PC continue with the next cycle
+ * if we didn't acquire a complete PC continue with the next cycle
*/
if (!ctx->pc_ok)
continue;
- /* indirect branch to the exception vector means an exception occured */
+ /* indirect branch to the exception vector means an exception occurred */
if ((ctx->last_branch <= 0x20)
|| ((ctx->last_branch >= 0xffff0000) &&
(ctx->last_branch <= 0xffff0020))) {
return retval;
else if (retval == ERROR_TRACE_INSTRUCTION_UNAVAILABLE) {
/* TODO: handle incomplete images
- * for now we just quit the analsysis*/
+ * for now we just quit the analysis*/
return retval;
}
}
/* IGNORED:
* - CPRT tracing (coprocessor register transfers)
* - debug request (causes debug entry on trigger)
- * - stall on FIFOFULL (preventing tracedata lossage)
+ * - stall on FIFOFULL (preventing tracedata loss)
*/
*mode = tracemode;
* check whether our setting "took".
*
* - The "clock" and "mode" bits are interpreted differently.
- * See ARM IHI 0014O table 2-17 for the old behavior, and
+ * See ARM IHI 0014O table 2-17 for the old behaviour, and
* table 2-18 for the new. With ETB it's best to specify
* "normal full" ...
*/
COMMAND_HANDLER(handle_etm_dump_command)
{
- struct fileio file;
+ struct fileio *file;
struct target *target;
struct arm *arm;
struct etm_context *etm_ctx;
if (fileio_open(&file, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK)
return ERROR_FAIL;
- fileio_write_u32(&file, etm_ctx->capture_status);
- fileio_write_u32(&file, etm_ctx->control);
- fileio_write_u32(&file, etm_ctx->trace_depth);
+ fileio_write_u32(file, etm_ctx->capture_status);
+ fileio_write_u32(file, etm_ctx->control);
+ fileio_write_u32(file, etm_ctx->trace_depth);
for (i = 0; i < etm_ctx->trace_depth; i++) {
- fileio_write_u32(&file, etm_ctx->trace_data[i].pipestat);
- fileio_write_u32(&file, etm_ctx->trace_data[i].packet);
- fileio_write_u32(&file, etm_ctx->trace_data[i].flags);
+ fileio_write_u32(file, etm_ctx->trace_data[i].pipestat);
+ fileio_write_u32(file, etm_ctx->trace_data[i].packet);
+ fileio_write_u32(file, etm_ctx->trace_data[i].flags);
}
- fileio_close(&file);
+ fileio_close(file);
return ERROR_OK;
}
COMMAND_HANDLER(handle_etm_load_command)
{
- struct fileio file;
+ struct fileio *file;
struct target *target;
struct arm *arm;
struct etm_context *etm_ctx;
if (fileio_open(&file, CMD_ARGV[0], FILEIO_READ, FILEIO_BINARY) != ERROR_OK)
return ERROR_FAIL;
- int filesize;
- int retval = fileio_size(&file, &filesize);
+ size_t filesize;
+ int retval = fileio_size(file, &filesize);
if (retval != ERROR_OK) {
- fileio_close(&file);
+ fileio_close(file);
return retval;
}
if (filesize % 4) {
command_print(CMD_CTX, "size isn't a multiple of 4, no valid trace data");
- fileio_close(&file);
+ fileio_close(file);
return ERROR_FAIL;
}
{
uint32_t tmp;
- fileio_read_u32(&file, &tmp); etm_ctx->capture_status = tmp;
- fileio_read_u32(&file, &tmp); etm_ctx->control = tmp;
- fileio_read_u32(&file, &etm_ctx->trace_depth);
+ fileio_read_u32(file, &tmp); etm_ctx->capture_status = tmp;
+ fileio_read_u32(file, &tmp); etm_ctx->control = tmp;
+ fileio_read_u32(file, &etm_ctx->trace_depth);
}
etm_ctx->trace_data = malloc(sizeof(struct etmv1_trace_data) * etm_ctx->trace_depth);
if (etm_ctx->trace_data == NULL) {
command_print(CMD_CTX, "not enough memory to perform operation");
- fileio_close(&file);
+ fileio_close(file);
return ERROR_FAIL;
}
for (i = 0; i < etm_ctx->trace_depth; i++) {
uint32_t pipestat, packet, flags;
- fileio_read_u32(&file, &pipestat);
- fileio_read_u32(&file, &packet);
- fileio_read_u32(&file, &flags);
+ fileio_read_u32(file, &pipestat);
+ fileio_read_u32(file, &packet);
+ fileio_read_u32(file, &flags);
etm_ctx->trace_data[i].pipestat = pipestat & 0xff;
etm_ctx->trace_data[i].packet = packet & 0xffff;
etm_ctx->trace_data[i].flags = flags;
}
- fileio_close(&file);
+ fileio_close(file);
return ERROR_OK;
}
{
.name = "etm",
.mode = COMMAND_ANY,
- .help = "Emebdded Trace Macrocell command group",
+ .help = "Embedded Trace Macrocell command group",
.usage = "",
.chain = etm_config_command_handlers,
},