free(dbg);
}
-static void script_command_args_free(const char **words, unsigned nwords)
+static void script_command_args_free(char **words, unsigned nwords)
{
for (unsigned i = 0; i < nwords; i++)
- free((void *)words[i]);
+ free(words[i]);
free(words);
}
-static const char **script_command_args_alloc(
+static char **script_command_args_alloc(
unsigned argc, Jim_Obj * const *argv, unsigned *nwords)
{
- const char **words = malloc(argc * sizeof(char *));
+ char **words = malloc(argc * sizeof(char *));
if (NULL == words)
return NULL;
LOG_USER_N("%s", ""); /* Keep GDB connection alive*/
unsigned nwords;
- const char **words = script_command_args_alloc(argc, argv, &nwords);
+ char **words = script_command_args_alloc(argc, argv, &nwords);
if (NULL == words)
return JIM_ERR;
command_free(tmp);
}
- if (c->name)
- free((void *)c->name);
- if (c->help)
- free((void *)c->help);
- if (c->usage)
- free((void *)c->usage);
+ free(c->name);
+ free(c->help);
+ free(c->usage);
free(c);
}
struct command *c)
{
Jim_Interp *interp = cmd_ctx->interp;
- const char *ocd_name = alloc_printf("ocd_%s", c->name);
+ char *ocd_name = alloc_printf("ocd_%s", c->name);
if (NULL == ocd_name)
return JIM_ERR;
Jim_CmdProc func = c->handler ? &script_command : &command_unknown;
int retval = Jim_CreateCommand(interp, ocd_name, func, c, NULL);
- free((void *)ocd_name);
+ free(ocd_name);
if (JIM_OK != retval)
return retval;
/* we now need to add an overrideable proc */
- const char *override_name = alloc_printf(
+ char *override_name = alloc_printf(
"proc %s {args} {eval ocd_bouncer %s $args}",
c->name, c->name);
if (NULL == override_name)
return JIM_ERR;
retval = Jim_Eval_Named(interp, override_name, 0, 0);
- free((void *)override_name);
+ free(override_name);
return retval;
}
if (help_text) {
bool replaced = false;
if (nc->help) {
- free((void *)nc->help);
+ free(nc->help);
replaced = true;
}
nc->help = strdup(help_text);
if (usage) {
bool replaced = false;
if (nc->usage) {
- free((void *)nc->usage);
+ free(nc->usage);
replaced = true;
}
nc->usage = strdup(usage);
typedef __COMMAND_HANDLER((*command_handler_t));
struct command {
- const char *name;
- const char *help;
- const char *usage;
+ char *name;
+ char *help;
+ char *usage;
struct command *parent;
struct command *children;
command_handler_t handler;
#include "fileio.h"
struct fileio_internal {
- const char *url;
+ char *url;
ssize_t size;
enum fileio_type type;
enum fileio_access access;
retval = fileio_close_local(fileio);
- free((void *)fileio->url);
+ free(fileio->url);
fileio->url = NULL;
free(fileio);
e = Jim_GetOpt_Nvp(goi, opts, &n);
if (e != JIM_OK) {
Jim_GetOpt_NvpUnknown(goi, opts, 0);
- free((void *)pTap->dotted_name);
+ free(cp);
free(pTap);
return e;
}
case NTAP_OPT_EXPECTED_ID:
e = jim_newtap_expected_id(n, goi, pTap);
if (JIM_OK != e) {
- free((void *)pTap->dotted_name);
+ free(cp);
free(pTap);
return e;
}
jtag_unregister_event_callback(&jtag_reset_callback, tap);
/** @todo is anything missing? no memory leaks please */
- free((void *)tap->expected);
- free((void *)tap->expected_ids);
- free((void *)tap->chip);
- free((void *)tap->tapname);
- free((void *)tap->dotted_name);
+ free(tap->expected);
+ free(tap->expected_ids);
+ free(tap->chip);
+ free(tap->tapname);
+ free(tap->dotted_name);
free(tap);
}
/* ULINK MCU (Cypress EZ-USB) specific functions */
int ulink_cpu_reset(struct ulink *device, unsigned char reset_bit);
-int ulink_load_firmware_and_renumerate(struct ulink **device, char *filename,
+int ulink_load_firmware_and_renumerate(struct ulink **device, const char *filename,
uint32_t delay);
-int ulink_load_firmware(struct ulink *device, char *filename);
+int ulink_load_firmware(struct ulink *device, const char *filename);
int ulink_write_firmware_section(struct ulink *device,
struct image *firmware_image, int section_index);
* @return on failure: ERROR_FAIL
*/
int ulink_load_firmware_and_renumerate(struct ulink **device,
- char *filename, uint32_t delay)
+ const char *filename, uint32_t delay)
{
int ret;
* @return on success: ERROR_OK
* @return on failure: ERROR_FAIL
*/
-int ulink_load_firmware(struct ulink *device, char *filename)
+int ulink_load_firmware(struct ulink *device, const char *filename)
{
struct image ulink_firmware_image;
int ret, i;
LOG_INFO("Downloading ULINK firmware image %s", CMD_ARGV[0]);
/* Download firmware image in CMD_ARGV[0] */
- ret = ulink_load_firmware_and_renumerate(&ulink_handle, (char *)CMD_ARGV[0],
+ ret = ulink_load_firmware_and_renumerate(&ulink_handle, CMD_ARGV[0],
ULINK_RENUMERATION_DELAY);
return ret;
e = Jim_GetOpt_Nvp(goi, opts, &n);
if (e != JIM_OK) {
Jim_GetOpt_NvpUnknown(goi, opts, 0);
- free((void *)pTap->dotted_name);
+ free(cp);
free(pTap);
return e;
}
case NTAP_OPT_EXPECTED_ID:
e = jim_newtap_expected_id(n, goi, pTap);
if (JIM_OK != e) {
- free((void *)pTap->dotted_name);
+ free(cp);
free(pTap);
return e;
}
};
struct jtag_tap {
- const char *chip;
- const char *tapname;
- const char *dotted_name;
+ char *chip;
+ char *tapname;
+ char *dotted_name;
int abs_chain_position;
/** Is this TAP disabled after JTAG reset? */
bool disabled_after_reset;
e = Jim_GetOpt_Nvp(goi, opts, &n);
if (e != JIM_OK) {
Jim_GetOpt_NvpUnknown(goi, opts, 0);
- free((void *)pTap->dotted_name);
+ free(cp);
free(pTap);
return e;
}
case NTAP_OPT_EXPECTED_ID:
e = jim_newtap_expected_id(n, goi, pTap);
if (JIM_OK != e) {
- free((void *)pTap->dotted_name);
+ free(cp);
free(pTap);
return e;
}
case NTAP_OPT_IRCAPTURE:
e = jim_newtap_ir_param(n, goi, pTap);
if (JIM_OK != e) {
- free((void *)pTap->dotted_name);
+ free(cp);
free(pTap);
return e;
}
}
int field_size = tap->ir_length;
fields[i].num_bits = field_size;
- fields[i].out_value = malloc(DIV_ROUND_UP(field_size, 8));
+ uint8_t *v = malloc(DIV_ROUND_UP(field_size, 8));
uint64_t value;
retval = parse_u64(CMD_ARGV[i * 2 + 1], &value);
if (ERROR_OK != retval)
goto error_return;
- void *v = (void *)fields[i].out_value;
buf_set_u64(v, 0, field_size, value);
+ fields[i].out_value = v;
fields[i].in_value = NULL;
}
return -1;
}
- target->rtos->rtos_specific_params = (void *) &ChibiOS_params_list[i];
+ target->rtos->rtos_specific_params = &ChibiOS_params_list[i];
return 0;
}
return -1;
}
- target->rtos->rtos_specific_params = (void *) &embKernel_params_list[i];
+ target->rtos->rtos_specific_params = &embKernel_params_list[i];
return 0;
}
os_linux->threads_needs_update = 0;
os_linux->threadid_count = 1;
os_linux->current_threads = NULL;
- target->rtos->rtos_specific_params = (void *)os_linux;
+ target->rtos->rtos_specific_params = os_linux;
ct->core_id = target->coreid;
ct->threadid = -1;
ct->TS = 0xdeadbeef;
static enum breakpoint_type gdb_breakpoint_override_type;
static int gdb_error(struct connection *connection, int retval);
-static const char *gdb_port;
-static const char *gdb_port_next;
+static char *gdb_port;
+static char *gdb_port_next;
static void gdb_log_callback(void *priv, const char *file, unsigned line,
const char *function, const char *string);
portnumber = strtol(gdb_port_next, &end, 0);
if (!*end) {
if (parse_long(gdb_port_next, &portnumber) == ERROR_OK) {
- free((void *)gdb_port_next);
+ free(gdb_port_next);
gdb_port_next = alloc_printf("%d", portnumber+1);
}
}
{
int retval = CALL_COMMAND_HANDLER(server_pipe_command, &gdb_port);
if (ERROR_OK == retval) {
- free((void *)gdb_port_next);
+ free(gdb_port_next);
gdb_port_next = strdup(gdb_port);
}
return retval;
struct service *next = c->next;
if (c->name)
- free((void *)c->name);
+ free(c->name);
if (c->type == CONNECTION_PIPE) {
if (c->fd != -1)
close(c->fd);
}
if (c->port)
- free((void *)c->port);
+ free(c->port);
if (c->priv)
free(c->priv);
return register_commands(cmd_ctx, NULL, server_command_handlers);
}
-SERVER_PORT_COMMAND()
+COMMAND_HELPER(server_port_command, unsigned short *out)
{
switch (CMD_ARGC) {
case 0:
return ERROR_OK;
}
-SERVER_PIPE_COMMAND()
+COMMAND_HELPER(server_pipe_command, char **out)
{
switch (CMD_ARGC) {
case 0:
LOG_WARNING("unable to change server port after init");
return ERROR_COMMAND_ARGUMENT_INVALID;
}
- const char *t = strdup(CMD_ARGV[0]);
- free((void *)*out);
- *out = t;
+ free(*out);
+ *out = strdup(CMD_ARGV[0]);
break;
}
default:
typedef int (*connection_closed_handler_t)(struct connection *connection);
struct service {
- const char *name;
+ char *name;
enum connection_type type;
- const char *port;
+ char *port;
unsigned short portnumber;
int fd;
struct sockaddr_in sin;
* Call server_port like a normal COMMAND_HANDLER with an extra @a out parameter
* to receive the specified port number.
*/
-#define SERVER_PIPE_COMMAND() \
- COMMAND_HELPER(server_pipe_command, const char **out)
-SERVER_PIPE_COMMAND();
+COMMAND_HELPER(server_pipe_command, char **out);
-#define SERVER_PORT_COMMAND() \
- COMMAND_HELPER(server_port_command, unsigned short *out)
-
-SERVER_PORT_COMMAND();
+COMMAND_HELPER(server_port_command, unsigned short *out);
#define ERROR_SERVER_REMOTE_CLOSED (-400)
#define ERROR_CONNECTION_REJECTED (-401)
int tc_outerror;/* flag an output error */
};
-static const char *tcl_port;
+static char *tcl_port;
/* handlers */
static int tcl_new_connection(struct connection *connection);
#include <target/target_request.h>
#include <helper/configuration.h>
-static const char *telnet_port;
+static char *telnet_port;
static char *negotiate =
"\xFF\xFB\x03" /* IAC WILL Suppress Go Ahead */
uint32_t addr, int count, uint32_t *buf);
static int mips32_dmaacc_write_mem8(struct mips_ejtag *ejtag_info,
- uint32_t addr, int count, uint8_t *buf);
+ uint32_t addr, int count, const uint8_t *buf);
static int mips32_dmaacc_write_mem16(struct mips_ejtag *ejtag_info,
- uint32_t addr, int count, uint16_t *buf);
+ uint32_t addr, int count, const uint16_t *buf);
static int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info,
- uint32_t addr, int count, uint32_t *buf);
+ uint32_t addr, int count, const uint32_t *buf);
/*
* The following logic shamelessly cloned from HairyDairyMaid's wrt54g_debrick
return ERROR_OK;
}
-int mips32_dmaacc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf)
+int mips32_dmaacc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, const void *buf)
{
switch (size) {
case 1:
- return mips32_dmaacc_write_mem8(ejtag_info, addr, count, (uint8_t *)buf);
+ return mips32_dmaacc_write_mem8(ejtag_info, addr, count, buf);
case 2:
- return mips32_dmaacc_write_mem16(ejtag_info, addr, count, (uint16_t *)buf);
+ return mips32_dmaacc_write_mem16(ejtag_info, addr, count, buf);
case 4:
- return mips32_dmaacc_write_mem32(ejtag_info, addr, count, (uint32_t *)buf);
+ return mips32_dmaacc_write_mem32(ejtag_info, addr, count, buf);
}
return ERROR_OK;
}
-static int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint32_t *buf)
+static int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int count, const uint32_t *buf)
{
int i;
int retval;
return ERROR_OK;
}
-static int mips32_dmaacc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint16_t *buf)
+static int mips32_dmaacc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, const uint16_t *buf)
{
int i;
int retval;
return ERROR_OK;
}
-static int mips32_dmaacc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf)
+static int mips32_dmaacc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, const uint8_t *buf)
{
int i;
int retval;
int mips32_dmaacc_read_mem(struct mips_ejtag *ejtag_info,
uint32_t addr, int size, int count, void *buf);
int mips32_dmaacc_write_mem(struct mips_ejtag *ejtag_info,
- uint32_t addr, int size, int count, void *buf);
+ uint32_t addr, int size, int count, const void *buf);
#endif
return retval;
}
-static int mips32_pracc_write_mem_generic(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf)
+static int mips32_pracc_write_mem_generic(struct mips_ejtag *ejtag_info,
+ uint32_t addr, int size, int count, const void *buf)
{
struct pracc_queue_info ctx = {.max_code = 128 * 3 + 6 + 1}; /* alloc memory for the worst case */
pracc_queue_init(&ctx);
if (ctx.retval != ERROR_OK)
goto exit;
- uint32_t *buf32 = buf;
- uint16_t *buf16 = buf;
- uint8_t *buf8 = buf;
+ const uint32_t *buf32 = buf;
+ const uint16_t *buf16 = buf;
+ const uint8_t *buf8 = buf;
while (count) {
ctx.code_count = 0;
return ctx.retval;
}
-int mips32_pracc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf)
+int mips32_pracc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, const void *buf)
{
int retval = mips32_pracc_write_mem_generic(ejtag_info, addr, size, count, buf);
if (retval != ERROR_OK)
int mips32_pracc_read_mem(struct mips_ejtag *ejtag_info,
uint32_t addr, int size, int count, void *buf);
int mips32_pracc_write_mem(struct mips_ejtag *ejtag_info,
- uint32_t addr, int size, int count, void *buf);
+ uint32_t addr, int size, int count, const void *buf);
int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_area *source,
int write_t, uint32_t addr, int count, uint32_t *buf);
/* if noDMA off, use DMAACC mode for memory write */
int retval;
if (ejtag_info->impcode & EJTAG_IMP_NODMA)
- retval = mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
+ retval = mips32_pracc_write_mem(ejtag_info, address, size, count, buffer);
else
- retval = mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
+ retval = mips32_dmaacc_write_mem(ejtag_info, address, size, count, buffer);
if (t != NULL)
free(t);
}
/* write a uint32_t array to a buffer in target memory endianness */
-void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, uint32_t *srcbuf)
+void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, const uint32_t *srcbuf)
{
uint32_t i;
for (i = 0; i < count; i++)
}
/* write a uint16_t array to a buffer in target memory endianness */
-void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, uint16_t *srcbuf)
+void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, const uint16_t *srcbuf)
{
uint32_t i;
for (i = 0; i < count; i++)
n->name);
return JIM_ERR;
}
- if (target->variant)
- free((void *)(target->variant));
e = Jim_GetOpt_String(goi, &cp, NULL);
if (e != JIM_OK)
return e;
+ free(target->variant);
target->variant = strdup(cp);
} else {
if (goi->argc != 0)
int target_number; /* DO NOT USE! field to be removed in 2010 */
struct jtag_tap *tap; /* where on the jtag chain is this */
int32_t coreid; /* which device on the TAP? */
- const char *variant; /* what variant of this chip is it? */
+ char *variant; /* what variant of this chip is it? */
/**
* Indicates whether this target has been examined.
void target_buffer_get_u32_array(struct target *target, const uint8_t *buffer, uint32_t count, uint32_t *dstbuf);
void target_buffer_get_u16_array(struct target *target, const uint8_t *buffer, uint32_t count, uint16_t *dstbuf);
-void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, uint32_t *srcbuf);
-void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, uint16_t *srcbuf);
+void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, const uint32_t *srcbuf);
+void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, const uint16_t *srcbuf);
int target_read_u32(struct target *target, uint32_t address, uint32_t *value);
int target_read_u16(struct target *target, uint32_t address, uint16_t *value);