Skip to content
This repository has been archived by the owner on Sep 28, 2019. It is now read-only.

Commit

Permalink
BUILD_RISCV cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
ilg-ul committed May 12, 2018
1 parent b853b7b commit af359c1
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 102 deletions.
4 changes: 0 additions & 4 deletions src/flash/nor/stm32f2x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,11 +1291,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
* this will also force a device unlock if set */
stm32x_info->option_bytes.RDP = 0xAA;
if (stm32x_info->has_optcr2_pcrop) {
#if BUILD_RISCV == 1
stm32x_info->option_bytes.optcr2_pcrop = OPTCR2_PCROP_RDP | (~1U << bank->num_sectors);
#else
stm32x_info->option_bytes.optcr2_pcrop = OPTCR2_PCROP_RDP | (~1 << bank->num_sectors);
#endif
}

if (stm32x_write_options(bank) != ERROR_OK) {
Expand Down
33 changes: 0 additions & 33 deletions src/jtag/drivers/bitbang.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,7 @@ static int bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer,
unsigned scan_size)
{
tap_state_t saved_end_state = tap_get_end_state();
#if BUILD_RISCV == 1
unsigned bit_cnt;
#else
int bit_cnt;
#endif

if (!((!ir_scan &&
(tap_get_state() == TAP_DRSHIFT)) ||
Expand All @@ -226,13 +222,8 @@ static int bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer,
bitbang_end_state(saved_end_state);
}

#if BUILD_RISCV == 1
size_t buffered = 0;
#endif
for (bit_cnt = 0; bit_cnt < scan_size; bit_cnt++) {
#if BUILD_RISCV != 1
int val = 0;
#endif
int tms = (bit_cnt == scan_size-1) ? 1 : 0;
int tdi;
int bytec = bit_cnt/8;
Expand All @@ -249,7 +240,6 @@ static int bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer,
if (bitbang_interface->write(0, tms, tdi) != ERROR_OK)
return ERROR_FAIL;

#if BUILD_RISCV == 1
if (type != SCAN_OUT) {
if (bitbang_interface->buf_size) {
if (bitbang_interface->sample() != ERROR_OK)
Expand All @@ -268,15 +258,10 @@ static int bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer,
}
}
}
#else
if (type != SCAN_OUT)
val = bitbang_interface->read();
#endif

if (bitbang_interface->write(1, tms, tdi) != ERROR_OK)
return ERROR_FAIL;

#if BUILD_RISCV == 1
if (type != SCAN_OUT && bitbang_interface->buf_size &&
(buffered == bitbang_interface->buf_size ||
bit_cnt == scan_size - 1)) {
Expand All @@ -294,14 +279,6 @@ static int bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer,
}
buffered = 0;
}
#else
if (type != SCAN_OUT) {
if (val)
buffer[bytec] |= bcval;
else
buffer[bytec] &= ~bcval;
}
#endif
}

if (tap_get_state() != tap_get_end_state()) {
Expand Down Expand Up @@ -391,23 +368,13 @@ int bitbang_execute_queue(void)
return ERROR_FAIL;
break;
case JTAG_SCAN:
#if BUILD_RISCV == 1
bitbang_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("%s scan %d bits; end in %s",
(cmd->cmd.scan->ir_scan) ? "IR" : "DR",
scan_size,
tap_state_name(cmd->cmd.scan->end_state));
#endif
#else
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("%s scan end in %s",
(cmd->cmd.scan->ir_scan) ? "IR" : "DR",
tap_state_name(cmd->cmd.scan->end_state));
#endif
bitbang_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
#endif
type = jtag_scan_type(cmd->cmd.scan);
if (bitbang_scan(cmd->cmd.scan->ir_scan, type, buffer,
Expand Down
8 changes: 0 additions & 8 deletions src/jtag/drivers/remote_bitbang.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,9 @@ static int remote_bitbang_blink(int on)
}

static struct bitbang_interface remote_bitbang_bitbang = {
#if BUILD_RISCV == 1
.buf_size = sizeof(remote_bitbang_buf) - 1,
.sample = &remote_bitbang_sample,
.read_sample = &remote_bitbang_read_sample,
#else
.read = &remote_bitbang_read,
#endif
.write = &remote_bitbang_write,
.reset = &remote_bitbang_reset,
.blink = &remote_bitbang_blink,
Expand All @@ -211,11 +207,7 @@ static int remote_bitbang_init_tcp(void)
{
struct addrinfo hints = { .ai_family = AF_UNSPEC, .ai_socktype = SOCK_STREAM };
struct addrinfo *result, *rp;
#if BUILD_RISCV == 1
int fd = 0;
#else
int fd;
#endif

LOG_INFO("Connecting to %s:%s",
remote_bitbang_host ? remote_bitbang_host : "localhost",
Expand Down
9 changes: 1 addition & 8 deletions src/rtos/rtos.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ int rtos_smp_init(struct target *target)
return ERROR_TARGET_INIT_FAILED;
}

#if BUILD_RISCV == 1
static int rtos_target_for_threadid(struct connection *connection, int64_t threadid, struct target **t)
{
struct target *curr = get_target_from_connection(connection);
Expand All @@ -72,7 +71,6 @@ static int rtos_target_for_threadid(struct connection *connection, int64_t threa

return ERROR_OK;
}
#endif

static int os_alloc(struct target *target, struct rtos_type *ostype)
{
Expand All @@ -91,8 +89,8 @@ static int os_alloc(struct target *target, struct rtos_type *ostype)
os->gdb_thread_packet = rtos_thread_packet;
#if BUILD_RISCV == 1
os->gdb_v_packet = NULL;
os->gdb_target_for_threadid = rtos_target_for_threadid;
#endif
os->gdb_target_for_threadid = rtos_target_for_threadid;

return JIM_OK;
}
Expand Down Expand Up @@ -357,15 +355,10 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
return ERROR_OK;
} else if (strncmp(packet, "qSymbol", 7) == 0) {
if (rtos_qsymbol(connection, packet, packet_size) == 1) {
#if BUILD_RISCV == 1
if (target->rtos_auto_detect == true) {
target->rtos_auto_detect = false;
target->rtos->type->create(target);
}
#else
target->rtos_auto_detect = false;
target->rtos->type->create(target);
#endif
target->rtos->type->update_threads(target->rtos);
}
return ERROR_OK;
Expand Down
2 changes: 1 addition & 1 deletion src/rtos/rtos.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ struct rtos {
int (*gdb_thread_packet)(struct connection *connection, char const *packet, int packet_size);
#if BUILD_RISCV == 1
int (*gdb_v_packet)(struct connection *connection, char const *packet, int packet_size);
int (*gdb_target_for_threadid)(struct connection *connection, int64_t thread_id, struct target **p_target);
#endif
int (*gdb_target_for_threadid)(struct connection *connection, int64_t thread_id, struct target **p_target);
void *rtos_specific_params;
};

Expand Down
8 changes: 0 additions & 8 deletions src/server/gdb_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -2540,11 +2540,7 @@ static int gdb_query_packet(struct connection *connection,
char gdb_reply[10];
char *separator;
uint32_t checksum;
#if BUILD_RISCV == 1
target_addr_t addr = 0;
#else
uint32_t addr = 0;
#endif
uint32_t len = 0;

/* skip command character */
Expand Down Expand Up @@ -3431,17 +3427,13 @@ static int gdb_target_add_one(struct target *target)
if (!*end) {
if (parse_long(gdb_port_next, &portnumber) == ERROR_OK) {
free(gdb_port_next);
#if BUILD_RISCV == 1
if (portnumber) {
gdb_port_next = alloc_printf("%d", portnumber+1);
} else {
/* Don't increment if gdb_port is 0, since we're just
* trying to allocate an unused port. */
gdb_port_next = strdup("0");
}
#else
gdb_port_next = alloc_printf("%d", portnumber+1);
#endif
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,12 @@ int add_service(char *name,
return ERROR_FAIL;
}

#if BUILD_RISCV == 1
struct sockaddr_in addr_in;
addr_in.sin_port = 0;
socklen_t addr_in_size = sizeof(addr_in);
if (getsockname(c->fd, (struct sockaddr *)&addr_in, &addr_in_size) == 0)
LOG_INFO("Listening on port %hu for %s connections",
ntohs(addr_in.sin_port), name);
#endif
} else if (c->type == CONNECTION_STDINOUT) {
c->fd = fileno(stdin);

Expand Down
17 changes: 11 additions & 6 deletions src/target/arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ struct arm {
/** Flag reporting armv6m based core. */
bool is_armv6m;

/** Floating point or VFP version, 0 if disabled. */
int arm_vfp_version;

// [GNU MCU Eclipse]
#if defined(USE_ORIGINAL_SEMIHOSTING)
/** Flag reporting whether semihosting is active. */
Expand All @@ -197,6 +194,9 @@ struct arm {
/** Flag reporting whether semihosting fileio operation is active. */
bool semihosting_hit_fileio;

/** Floating point or VFP version, 0 if disabled. */
int arm_vfp_version;

/** Current semihosting operation. */
int semihosting_op;

Expand All @@ -206,11 +206,16 @@ struct arm {
/** Value to be returned by semihosting SYS_ERRNO request. */
int semihosting_errno;

/** Semihosting command line. */
char *semihosting_cmdline;
#endif /* USE_ORIGINAL_SEMIHOSTING */
int (*setup_semihosting)(struct target *target, int enable);

/** Semihosting command line. */
char *semihosting_cmdline;
#else
/** Floating point or VFP version, 0 if disabled. */
int arm_vfp_version;

int (*setup_semihosting)(struct target *target, int enable);
#endif /* USE_ORIGINAL_SEMIHOSTING */

/** Backpointer to the target. */
struct target *target;
Expand Down
33 changes: 1 addition & 32 deletions src/target/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,11 +1137,7 @@ int target_add_breakpoint(struct target *target,
struct breakpoint *breakpoint)
{
if ((target->state != TARGET_HALTED) && (breakpoint->type != BKPT_HARD)) {
#if BUILD_RISCV == 1
LOG_WARNING("target %s is not halted (add breakpoint)", target_name(target));
#else
LOG_WARNING("target %s is not halted", target_name(target));
#endif
return ERROR_TARGET_NOT_HALTED;
}
return target->type->add_breakpoint(target, breakpoint);
Expand All @@ -1151,11 +1147,7 @@ int target_add_context_breakpoint(struct target *target,
struct breakpoint *breakpoint)
{
if (target->state != TARGET_HALTED) {
#if BUILD_RISCV == 1
LOG_WARNING("target %s is not halted (add context breakpoint)", target_name(target));
#else
LOG_WARNING("target %s is not halted", target_name(target));
#endif
return ERROR_TARGET_NOT_HALTED;
}
return target->type->add_context_breakpoint(target, breakpoint);
Expand All @@ -1165,11 +1157,7 @@ int target_add_hybrid_breakpoint(struct target *target,
struct breakpoint *breakpoint)
{
if (target->state != TARGET_HALTED) {
#if BUILD_RISCV == 1
LOG_WARNING("target %s is not halted (add hybrid breakpoint)", target_name(target));
#else
LOG_WARNING("target %s is not halted", target_name(target));
#endif
return ERROR_TARGET_NOT_HALTED;
}
return target->type->add_hybrid_breakpoint(target, breakpoint);
Expand All @@ -1185,11 +1173,7 @@ int target_add_watchpoint(struct target *target,
struct watchpoint *watchpoint)
{
if (target->state != TARGET_HALTED) {
#if BUILD_RISCV == 1
LOG_WARNING("target %s is not halted (add watchpoint)", target_name(target));
#else
LOG_WARNING("target %s is not halted", target_name(target));
#endif
return ERROR_TARGET_NOT_HALTED;
}
return target->type->add_watchpoint(target, watchpoint);
Expand All @@ -1203,11 +1187,7 @@ int target_hit_watchpoint(struct target *target,
struct watchpoint **hit_watchpoint)
{
if (target->state != TARGET_HALTED) {
#if BUILD_RISCV == 1
LOG_WARNING("target %s is not halted (hit watchpoint)", target->cmd_name);
#else
LOG_WARNING("target %s is not halted", target->cmd_name);
#endif
return ERROR_TARGET_NOT_HALTED;
}

Expand Down Expand Up @@ -1236,11 +1216,7 @@ int target_step(struct target *target,
int target_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fileio_info)
{
if (target->state != TARGET_HALTED) {
#if BUILD_RISCV == 1
LOG_WARNING("target %s is not halted (gdb fileio)", target->cmd_name);
#else
LOG_WARNING("target %s is not halted", target->cmd_name);
#endif
return ERROR_TARGET_NOT_HALTED;
}
return target->type->get_gdb_fileio_info(target, fileio_info);
Expand All @@ -1249,11 +1225,7 @@ int target_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fi
int target_gdb_fileio_end(struct target *target, int retcode, int fileio_errno, bool ctrl_c)
{
if (target->state != TARGET_HALTED) {
#if BUILD_RISCV == 1
LOG_WARNING("target %s is not halted (gdb fileio end)", target->cmd_name);
#else
LOG_WARNING("target %s is not halted", target->cmd_name);
#endif
return ERROR_TARGET_NOT_HALTED;
}
return target->type->gdb_fileio_end(target, retcode, fileio_errno, ctrl_c);
Expand All @@ -1263,11 +1235,7 @@ int target_profiling(struct target *target, uint32_t *samples,
uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
{
if (target->state != TARGET_HALTED) {
#if BUILD_RISCV == 1
LOG_WARNING("target %s is not halted (profiling)", target->cmd_name);
#else
LOG_WARNING("target %s is not halted", target->cmd_name);
#endif
return ERROR_TARGET_NOT_HALTED;
}
return target->type->profiling(target, samples, max_num_samples,
Expand Down Expand Up @@ -2806,6 +2774,7 @@ COMMAND_HANDLER(handle_reg_command)
struct reg *reg = NULL;
unsigned count = 0;
char *value;

#if BUILD_RISCV == 1
int retval;
#endif
Expand Down

0 comments on commit af359c1

Please sign in to comment.