diff options
author | Tim Newsome <tim@sifive.com> | 2019-04-03 12:38:27 -0700 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2019-04-03 12:38:27 -0700 |
commit | 79f9672615dfe77d415bdd7a404f1e149e31b16d (patch) | |
tree | 9af22013cb9ef87f97c92a0136d1d88e1b354587 /src/target/smp.c | |
parent | c089e6ae9a37d134e92a3d40c2be13003ea09d61 (diff) | |
parent | 11a2bfc2bcedfad0ecb1b8d7f68ac7208cd6b8c0 (diff) | |
download | riscv-openocd-79f9672615dfe77d415bdd7a404f1e149e31b16d.zip riscv-openocd-79f9672615dfe77d415bdd7a404f1e149e31b16d.tar.gz riscv-openocd-79f9672615dfe77d415bdd7a404f1e149e31b16d.tar.bz2 |
Merge branch 'master' into from_upstream
Conflicts:
src/flash/nor/at91sam4.c
src/flash/nor/at91sam4l.c
src/flash/nor/at91samd.c
src/flash/nor/ath79.c
src/flash/nor/atsame5.c
src/flash/nor/cfi.c
src/flash/nor/core.c
src/flash/nor/fespi.c
src/flash/nor/kinetis.c
src/flash/nor/kinetis_ke.c
src/flash/nor/lpc2000.c
src/flash/nor/niietcm4.c
src/flash/nor/nrf5.c
src/flash/nor/numicro.c
src/flash/nor/pic32mx.c
src/flash/nor/stm32h7x.c
src/flash/nor/stm32lx.c
src/flash/nor/stmsmi.c
src/flash/nor/tcl.c
src/flash/nor/tms470.c
src/flash/nor/virtual.c
src/flash/nor/xmc4xxx.c
src/rtos/hwthread.c
src/rtos/rtos.c
src/server/gdb_server.c
src/target/riscv/riscv-011.c
src/target/riscv/riscv-013.c
src/target/riscv/riscv.c
src/target/riscv/riscv.h
Change-Id: I9f0f373d45a9e5845bca83ca52e977f727ea4425
Diffstat (limited to 'src/target/smp.c')
-rw-r--r-- | src/target/smp.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/src/target/smp.c b/src/target/smp.c index bdf81a0..f42d8ab 100644 --- a/src/target/smp.c +++ b/src/target/smp.c @@ -96,3 +96,110 @@ int gdb_write_smp_packet(struct connection *connection, return retval; } + +COMMAND_HANDLER(default_handle_smp_command) +{ + struct target *target = get_current_target(CMD_CTX); + struct target_list *head; + + if (CMD_ARGC > 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + if (!CMD_ARGC) { + command_print(CMD_CTX, "%s", target->smp ? "on" : "off"); + return ERROR_OK; + } + + if (!strcmp(CMD_ARGV[0], "on")) { + foreach_smp_target(head, target->head) + head->target->smp = 1; + + return ERROR_OK; + } + + if (!strcmp(CMD_ARGV[0], "off")) { + foreach_smp_target(head, target->head) + head->target->smp = 0; + + /* fixes the target display to the debugger */ + if (target->head) + target->gdb_service->target = target; + + return ERROR_OK; + } + + return ERROR_COMMAND_SYNTAX_ERROR; +} + +COMMAND_HANDLER(deprecated_handle_smp_on_command) +{ + const char *argv[] = {"on", NULL}; + + LOG_WARNING("\'smp_on\' is deprecated, please use \'smp on\' instead."); + CMD_ARGC = 1; + CMD_ARGV = argv; + return CALL_COMMAND_HANDLER(default_handle_smp_command); +} + +COMMAND_HANDLER(deprecated_handle_smp_off_command) +{ + const char *argv[] = {"off", NULL}; + + LOG_WARNING("\'smp_off\' is deprecated, please use \'smp off\' instead."); + CMD_ARGC = 1; + CMD_ARGV = argv; + return CALL_COMMAND_HANDLER(default_handle_smp_command); +} + +COMMAND_HANDLER(handle_smp_gdb_command) +{ + struct target *target = get_current_target(CMD_CTX); + int retval = ERROR_OK; + struct target_list *head; + head = target->head; + if (head != (struct target_list *)NULL) { + if (CMD_ARGC == 1) { + int coreid = 0; + COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], coreid); + if (ERROR_OK != retval) + return retval; + target->gdb_service->core[1] = coreid; + + } + command_print(CMD_CTX, "gdb coreid %" PRId32 " -> %" PRId32, target->gdb_service->core[0] + , target->gdb_service->core[1]); + } + return ERROR_OK; +} + +const struct command_registration smp_command_handlers[] = { + { + .name = "smp", + .handler = default_handle_smp_command, + .mode = COMMAND_EXEC, + .help = "smp handling", + .usage = "[on|off]", + }, + { + .name = "smp_on", + .handler = deprecated_handle_smp_on_command, + .mode = COMMAND_EXEC, + .help = "Restart smp handling", + .usage = "", + }, + { + .name = "smp_off", + .handler = deprecated_handle_smp_off_command, + .mode = COMMAND_EXEC, + .help = "Stop smp handling", + .usage = "", + }, + { + .name = "smp_gdb", + .handler = handle_smp_gdb_command, + .mode = COMMAND_EXEC, + .help = "display/fix current core played to gdb", + .usage = "", + }, + COMMAND_REGISTRATION_DONE +}; |