X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Ftarget%2Foocd_trace.c;h=dc96d13fc44039c8024febcfca0e45665f77fb38;hb=56504fdd7353732525e34f1e3fbd44346588f979;hp=55ea67caf63dcffcd77c96bdd3a637d669ab5242;hpb=40580e2d71ac56131a5da7e5f67a0b63450e4f24;p=fw%2Fopenocd diff --git a/src/target/oocd_trace.c b/src/target/oocd_trace.c index 55ea67caf..dc96d13fc 100644 --- a/src/target/oocd_trace.c +++ b/src/target/oocd_trace.c @@ -21,25 +21,18 @@ #include "config.h" #endif +// we must define _GNU_SOURCE to get strndup +#ifndef _GNU_SOURCE #define _GNU_SOURCE -#include -#include +#endif #include "oocd_trace.h" -#include "etm.h" - -#include "log.h" -#include "types.h" -#include "binarybuffer.h" -#include "target.h" -#include "register.h" -#include "jtag.h" #include "arm7_9_common.h" -#include "replacements.h" -#include -int oocd_trace_read_reg(oocd_trace_t *oocd_trace, int reg, u32 *value) +static int oocd_trace_register_commands(struct command_context_s *cmd_ctx); + +static int oocd_trace_read_reg(oocd_trace_t *oocd_trace, int reg, u32 *value) { size_t bytes_written, bytes_read, bytes_to_read; u8 cmd; @@ -59,7 +52,7 @@ int oocd_trace_read_reg(oocd_trace_t *oocd_trace, int reg, u32 *value) return ERROR_OK; } -int oocd_trace_write_reg(oocd_trace_t *oocd_trace, int reg, u32 value) +static int oocd_trace_write_reg(oocd_trace_t *oocd_trace, int reg, u32 value) { size_t bytes_written; u8 data[5]; @@ -76,7 +69,7 @@ int oocd_trace_write_reg(oocd_trace_t *oocd_trace, int reg, u32 value) return ERROR_OK; } -int oocd_trace_read_memory(oocd_trace_t *oocd_trace, u8 *data, u32 address, u32 size) +static int oocd_trace_read_memory(oocd_trace_t *oocd_trace, u8 *data, u32 address, u32 size) { size_t bytes_written, bytes_to_read; ssize_t bytes_read; @@ -94,7 +87,7 @@ int oocd_trace_read_memory(oocd_trace_t *oocd_trace, u8 *data, u32 address, u32 if ((bytes_read = read(oocd_trace->tty_fd, ((u8*)data) + (size * 16) - bytes_to_read, bytes_to_read)) < 0) { - LOG_DEBUG("read() returned %i (%s)", bytes_read, strerror(errno)); + LOG_DEBUG("read() returned %zi (%s)", bytes_read, strerror(errno)); } else bytes_to_read -= bytes_read; @@ -103,7 +96,7 @@ int oocd_trace_read_memory(oocd_trace_t *oocd_trace, u8 *data, u32 address, u32 return ERROR_OK; } -int oocd_trace_init(etm_context_t *etm_ctx) +static int oocd_trace_init(etm_context_t *etm_ctx) { u8 trash[256]; oocd_trace_t *oocd_trace = etm_ctx->capture_driver_priv; @@ -144,13 +137,13 @@ int oocd_trace_init(etm_context_t *etm_ctx) * read up any leftover characters to ensure communication is in sync */ while ((bytes_read = read(oocd_trace->tty_fd, trash, sizeof(trash))) > 0) { - LOG_DEBUG("%i bytes read\n", bytes_read); + LOG_DEBUG("%zi bytes read\n", bytes_read); }; return ERROR_OK; } -trace_status_t oocd_trace_status(etm_context_t *etm_ctx) +static trace_status_t oocd_trace_status(etm_context_t *etm_ctx) { oocd_trace_t *oocd_trace = etm_ctx->capture_driver_priv; u32 status; @@ -182,7 +175,7 @@ trace_status_t oocd_trace_status(etm_context_t *etm_ctx) return etm_ctx->capture_status; } -int oocd_trace_read_trace(etm_context_t *etm_ctx) +static int oocd_trace_read_trace(etm_context_t *etm_ctx) { oocd_trace_t *oocd_trace = etm_ctx->capture_driver_priv; u32 status, address; @@ -240,7 +233,7 @@ int oocd_trace_read_trace(etm_context_t *etm_ctx) return ERROR_OK; } -int oocd_trace_start_capture(etm_context_t *etm_ctx) +static int oocd_trace_start_capture(etm_context_t *etm_ctx) { oocd_trace_t *oocd_trace = etm_ctx->capture_driver_priv; u32 control = 0x1; /* 0x1: enabled */ @@ -273,7 +266,7 @@ int oocd_trace_start_capture(etm_context_t *etm_ctx) return ERROR_OK; } -int oocd_trace_stop_capture(etm_context_t *etm_ctx) +static int oocd_trace_stop_capture(etm_context_t *etm_ctx) { oocd_trace_t *oocd_trace = etm_ctx->capture_driver_priv; @@ -296,7 +289,7 @@ etm_capture_driver_t oocd_trace_capture_driver = .read_trace = oocd_trace_read_trace, }; -int handle_oocd_trace_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_oocd_trace_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { target_t *target; armv4_5_common_t *armv4_5; @@ -334,7 +327,7 @@ int handle_oocd_trace_config_command(struct command_context_s *cmd_ctx, char *cm return ERROR_OK; } -int handle_oocd_trace_status_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_oocd_trace_status_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { target_t *target; armv4_5_common_t *armv4_5; @@ -374,7 +367,7 @@ int handle_oocd_trace_status_command(struct command_context_s *cmd_ctx, char *cm return ERROR_OK; } -int handle_oocd_trace_resync_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_oocd_trace_resync_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { target_t *target; armv4_5_common_t *armv4_5;