You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(75) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(70) |
Feb
(20) |
Mar
(52) |
Apr
(149) |
May
(387) |
Jun
(466) |
Jul
(133) |
Aug
(87) |
Sep
(122) |
Oct
(140) |
Nov
(185) |
Dec
(105) |
2010 |
Jan
(85) |
Feb
(45) |
Mar
(75) |
Apr
(17) |
May
(41) |
Jun
(52) |
Jul
(33) |
Aug
(29) |
Sep
(36) |
Oct
(15) |
Nov
(26) |
Dec
(34) |
2011 |
Jan
(26) |
Feb
(25) |
Mar
(26) |
Apr
(29) |
May
(20) |
Jun
(27) |
Jul
(15) |
Aug
(32) |
Sep
(13) |
Oct
(64) |
Nov
(60) |
Dec
(10) |
2012 |
Jan
(64) |
Feb
(63) |
Mar
(39) |
Apr
(43) |
May
(54) |
Jun
(11) |
Jul
(30) |
Aug
(45) |
Sep
(11) |
Oct
(70) |
Nov
(24) |
Dec
(23) |
2013 |
Jan
(17) |
Feb
(8) |
Mar
(35) |
Apr
(40) |
May
(20) |
Jun
(24) |
Jul
(36) |
Aug
(25) |
Sep
(42) |
Oct
(40) |
Nov
(9) |
Dec
(21) |
2014 |
Jan
(29) |
Feb
(24) |
Mar
(60) |
Apr
(22) |
May
(22) |
Jun
(46) |
Jul
(11) |
Aug
(23) |
Sep
(26) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
2015 |
Jan
(28) |
Feb
(47) |
Mar
(33) |
Apr
(58) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(8) |
Sep
(12) |
Oct
(25) |
Nov
(58) |
Dec
(21) |
2016 |
Jan
(12) |
Feb
(40) |
Mar
(2) |
Apr
(1) |
May
(67) |
Jun
(2) |
Jul
(5) |
Aug
(36) |
Sep
|
Oct
(24) |
Nov
(17) |
Dec
(50) |
2017 |
Jan
(14) |
Feb
(16) |
Mar
(2) |
Apr
(35) |
May
(14) |
Jun
(16) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
(19) |
Nov
|
Dec
(16) |
2018 |
Jan
(55) |
Feb
(11) |
Mar
(34) |
Apr
(14) |
May
(4) |
Jun
(20) |
Jul
(39) |
Aug
(16) |
Sep
(17) |
Oct
(16) |
Nov
(20) |
Dec
(30) |
2019 |
Jan
(29) |
Feb
(24) |
Mar
(37) |
Apr
(26) |
May
(19) |
Jun
(21) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(12) |
Nov
(12) |
Dec
(12) |
2020 |
Jan
(47) |
Feb
(36) |
Mar
(54) |
Apr
(44) |
May
(37) |
Jun
(19) |
Jul
(32) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(32) |
Dec
(11) |
2021 |
Jan
(14) |
Feb
(5) |
Mar
(40) |
Apr
(32) |
May
(42) |
Jun
(31) |
Jul
(29) |
Aug
(47) |
Sep
(38) |
Oct
(17) |
Nov
(74) |
Dec
(33) |
2022 |
Jan
(11) |
Feb
(15) |
Mar
(40) |
Apr
(21) |
May
(39) |
Jun
(44) |
Jul
(19) |
Aug
(46) |
Sep
(79) |
Oct
(35) |
Nov
(21) |
Dec
(15) |
2023 |
Jan
(56) |
Feb
(13) |
Mar
(43) |
Apr
(28) |
May
(60) |
Jun
(15) |
Jul
(29) |
Aug
(28) |
Sep
(32) |
Oct
(21) |
Nov
(42) |
Dec
(39) |
2024 |
Jan
(35) |
Feb
(17) |
Mar
(28) |
Apr
(7) |
May
(14) |
Jun
(35) |
Jul
(30) |
Aug
(35) |
Sep
(30) |
Oct
(28) |
Nov
(38) |
Dec
(18) |
2025 |
Jan
(21) |
Feb
(28) |
Mar
(36) |
Apr
(35) |
May
(34) |
Jun
(58) |
Jul
(9) |
Aug
(37) |
Sep
|
Oct
|
Nov
|
Dec
|
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-30 07:24:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via ef0da7944886466bc09386616fa089925be5ac62 (commit) from fd40d0967607f8ee7d0aabf7ea7fd93cfc419bf1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ef0da7944886466bc09386616fa089925be5ac62 Author: Tarek BOCHKATI <tar...@gm...> Date: Tue Jan 12 20:10:23 2021 +0100 cortex_m: mark FPU register as non-existent instead of playing with num_regs Change-Id: Iac7c5bfbb95c8d9a8c6d65104d138692a44eca78 Signed-off-by: Tarek BOCHKATI <tar...@gm...> Reviewed-on: http://openocd.zylin.com/6015 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/target/armv7m.h b/src/target/armv7m.h index f5679b91d..652dbe798 100644 --- a/src/target/armv7m.h +++ b/src/target/armv7m.h @@ -164,7 +164,12 @@ enum { /* Floating-point status register */ ARMV7M_FPSCR, + /* for convenience add registers' block delimiters */ ARMV7M_LAST_REG, + ARMV7M_CORE_FIRST_REG = ARMV7M_R0, + ARMV7M_CORE_LAST_REG = ARMV7M_xPSR, + ARMV7M_FPU_FIRST_REG = ARMV7M_D0, + ARMV7M_FPU_LAST_REG = ARMV7M_FPSCR, }; enum { @@ -174,8 +179,7 @@ enum { FPV5_DP, }; -#define ARMV7M_NUM_CORE_REGS (ARMV7M_xPSR + 1) -#define ARMV7M_NUM_CORE_REGS_NOFP (ARMV7M_CONTROL + 1) +#define ARMV7M_NUM_CORE_REGS (ARMV7M_CORE_LAST_REG - ARMV7M_CORE_FIRST_REG + 1) #define ARMV7M_COMMON_MAGIC 0x2A452A45 diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index e7a2fadda..46b0e3c2a 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -2038,19 +2038,11 @@ int cortex_m_examine(struct target *target) armv7m->arm.is_armv6m = true; } - if (armv7m->fp_feature == FP_NONE && - armv7m->arm.core_cache->num_regs > ARMV7M_NUM_CORE_REGS_NOFP) { - /* free unavailable FPU registers */ - size_t idx; - - for (idx = ARMV7M_NUM_CORE_REGS_NOFP; - idx < armv7m->arm.core_cache->num_regs; - idx++) { - free(armv7m->arm.core_cache->reg_list[idx].feature); - free(armv7m->arm.core_cache->reg_list[idx].reg_data_type); - } - armv7m->arm.core_cache->num_regs = ARMV7M_NUM_CORE_REGS_NOFP; - } + /* Check for FPU, otherwise mark FPU register as non-existent */ + if (armv7m->fp_feature == FP_NONE) + for (size_t idx = ARMV7M_FPU_FIRST_REG; idx <= ARMV7M_FPU_LAST_REG; idx++) + armv7m->arm.core_cache->reg_list[idx].exist = false; + if (!armv7m->stlink) { if (i == 3 || i == 4) ----------------------------------------------------------------------- Summary of changes: src/target/armv7m.h | 8 ++++++-- src/target/cortex_m.c | 18 +++++------------- 2 files changed, 11 insertions(+), 15 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-30 07:23:29
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via fd40d0967607f8ee7d0aabf7ea7fd93cfc419bf1 (commit) from 2c4f7efbf6ca467121e96dd044b9fdf373774550 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fd40d0967607f8ee7d0aabf7ea7fd93cfc419bf1 Author: Tarek BOCHKATI <tar...@gm...> Date: Thu Apr 22 14:34:14 2021 +0100 doc/openocd.texi: fix warning fix the warning below by adding a '.' after xref in line 10184: ./doc/openocd.texi:10184: warning: `.' or `,' must follow @xref, not c Change-Id: Ibd976ae61cf6845e925b839321444dcb25a3c04a Reported-by: Tomas Vanek <va...@fb...> Signed-off-by: Tarek BOCHKATI <tar...@gm...> Reviewed-on: http://openocd.zylin.com/6179 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 21b6e952a..c39e7c168 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -10167,7 +10167,7 @@ startbit endbit}. @deffn {Command} {arc get-reg-field} reg-name field-name Returns value of bit-field in a register. Register must be ``struct'' register -type, @xref{add-reg-type-struct} command definition. +type, @xref{add-reg-type-struct}. command definition. @end deffn @deffn {Command} {arc set-reg-exists} reg-names... ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-30 07:22:32
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 2c4f7efbf6ca467121e96dd044b9fdf373774550 (commit) from ef0aa38c108be536deff73c299ba542e215a892f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 2c4f7efbf6ca467121e96dd044b9fdf373774550 Author: Tarek BOCHKATI <tar...@gm...> Date: Wed Apr 21 10:18:04 2021 +0100 doc/openocd.texi: fix warning fix the warning below by adding a '.' after xref in line 4517: ../code/doc/openocd.texi:4517: warning: `.' or `,' must follow @xref, not ) Change-Id: I6e529c7e83c9f912e1dd899abf5f630c90b583d9 Signed-off-by: Tarek BOCHKATI <tar...@gm...> Reviewed-on: http://openocd.zylin.com/6174 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 4dd3a3389..21b6e952a 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -4500,7 +4500,7 @@ a CPU, through which bus read and write cycles can be generated; it may be useful for working with non-CPU hardware behind an AP or during development of support for new CPUs. It's possible to connect a GDB client to this target (the GDB port has to be -specified, @xref{gdbportoverride,,option -gdb-port}), and a fake ARM core will +specified, @xref{gdbportoverride,,option -gdb-port}.), and a fake ARM core will be emulated to comply to GDB remote protocol. @item @code{mips_m4k} -- a MIPS core. @item @code{mips_mips64} -- a MIPS64 core. ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-30 07:21:53
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via ef0aa38c108be536deff73c299ba542e215a892f (commit) from ab337d05f432465fdfedb694ac862fb22f80d7a6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ef0aa38c108be536deff73c299ba542e215a892f Author: Tomas Vanek <va...@fb...> Date: Thu Apr 22 08:40:02 2021 +0200 target/armv7m: change FPv4_SP and FPv5_SP/DP identifiers to uppercase Change-Id: Ia421a973e5fb4767715c9f95c91745f8ca1de1da Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: http://openocd.zylin.com/6177 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/rtos/FreeRTOS.c b/src/rtos/FreeRTOS.c index 4d520b9b4..f04b0a268 100644 --- a/src/rtos/FreeRTOS.c +++ b/src/rtos/FreeRTOS.c @@ -438,7 +438,7 @@ static int FreeRTOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, int cm4_fpu_enabled = 0; struct armv7m_common *armv7m_target = target_to_armv7m(rtos->target); if (is_armv7m(armv7m_target)) { - if (armv7m_target->fp_feature == FPv4_SP) { + if (armv7m_target->fp_feature == FPV4_SP) { /* Found ARM v7m target which includes a FPU */ uint32_t cpacr; diff --git a/src/rtos/nuttx.c b/src/rtos/nuttx.c index 6569e38f2..0705b17b3 100644 --- a/src/rtos/nuttx.c +++ b/src/rtos/nuttx.c @@ -352,7 +352,7 @@ static int nuttx_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, bool cm4_fpu_enabled = false; struct armv7m_common *armv7m_target = target_to_armv7m(rtos->target); if (is_armv7m(armv7m_target)) { - if (armv7m_target->fp_feature == FPv4_SP) { + if (armv7m_target->fp_feature == FPV4_SP) { /* Found ARM v7m target which includes a FPU */ uint32_t cpacr; diff --git a/src/target/armv7m.h b/src/target/armv7m.h index db6f8bc52..f5679b91d 100644 --- a/src/target/armv7m.h +++ b/src/target/armv7m.h @@ -169,9 +169,9 @@ enum { enum { FP_NONE = 0, - FPv4_SP, - FPv5_SP, - FPv5_DP, + FPV4_SP, + FPV5_SP, + FPV5_DP, }; #define ARMV7M_NUM_CORE_REGS (ARMV7M_xPSR + 1) diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 6dc33c867..e7a2fadda 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -2019,7 +2019,7 @@ int cortex_m_examine(struct target *target) /* test for floating point feature on Cortex-M4 */ if ((mvfr0 == MVFR0_DEFAULT_M4) && (mvfr1 == MVFR1_DEFAULT_M4)) { LOG_DEBUG("Cortex-M%d floating point feature FPv4_SP found", i); - armv7m->fp_feature = FPv4_SP; + armv7m->fp_feature = FPV4_SP; } } else if (i == 7 || i == 33 || i == 35 || i == 55) { target_read_u32(target, MVFR0, &mvfr0); @@ -2028,10 +2028,10 @@ int cortex_m_examine(struct target *target) /* test for floating point features on Cortex-M7 */ if ((mvfr0 == MVFR0_DEFAULT_M7_SP) && (mvfr1 == MVFR1_DEFAULT_M7_SP)) { LOG_DEBUG("Cortex-M%d floating point feature FPv5_SP found", i); - armv7m->fp_feature = FPv5_SP; + armv7m->fp_feature = FPV5_SP; } else if ((mvfr0 == MVFR0_DEFAULT_M7_DP) && (mvfr1 == MVFR1_DEFAULT_M7_DP)) { LOG_DEBUG("Cortex-M%d floating point feature FPv5_DP found", i); - armv7m->fp_feature = FPv5_DP; + armv7m->fp_feature = FPV5_DP; } } else if (i == 0) { /* Cortex-M0 does not support unaligned memory access */ ----------------------------------------------------------------------- Summary of changes: src/rtos/FreeRTOS.c | 2 +- src/rtos/nuttx.c | 2 +- src/target/armv7m.h | 6 +++--- src/target/cortex_m.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-25 22:09:35
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via ab337d05f432465fdfedb694ac862fb22f80d7a6 (commit) via 44554698472aae5b02620eb91837118ada4d2bfe (commit) from a5471b1b2c5675fa0caa462e742916c54f9a08e2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ab337d05f432465fdfedb694ac862fb22f80d7a6 Author: Tomas Vanek <va...@fb...> Date: Tue Apr 6 13:46:07 2021 +0200 target/arm_adi_v5: move DP register definitions to one block DP and MEM-AP definitions were mixed. Change-Id: I2f691b2274c01e9090c1e5160c6903d3207e35c2 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: http://openocd.zylin.com/6138 Tested-by: jenkins diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index 047606c43..00e4ea2b2 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -85,6 +85,15 @@ #define CSYSPWRUPREQ (1UL << 30) #define CSYSPWRUPACK (1UL << 31) +#define DP_SELECT_APSEL 0xFF000000 +#define DP_SELECT_APBANK 0x000000F0 +#define DP_SELECT_DPBANK 0x0000000F +#define DP_SELECT_INVALID 0x00FFFF00 /* Reserved bits one */ + +#define DP_APSEL_MAX (255) +#define DP_APSEL_INVALID (-1) + + /* MEM-AP register addresses */ #define MEM_AP_REG_CSW 0x00 #define MEM_AP_REG_TAR 0x04 @@ -150,14 +159,6 @@ #define IDR_JEP106_ARM 0x04760000 -#define DP_SELECT_APSEL 0xFF000000 -#define DP_SELECT_APBANK 0x000000F0 -#define DP_SELECT_DPBANK 0x0000000F -#define DP_SELECT_INVALID 0x00FFFF00 /* Reserved bits one */ - -#define DP_APSEL_MAX (255) -#define DP_APSEL_INVALID (-1) - /* FIXME: not SWD specific; should be renamed, e.g. adiv5_special_seq */ enum swd_special_seq { LINE_RESET, commit 44554698472aae5b02620eb91837118ada4d2bfe Author: Tomas Vanek <va...@fb...> Date: Mon Apr 5 06:32:47 2021 +0200 target/adi_v5_swd: remove double space from swd_cmd() parameters Change-Id: I6b68868947010512c4de76e5d37142f067e27b06 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: http://openocd.zylin.com/6137 Tested-by: jenkins diff --git a/src/target/adi_v5_swd.c b/src/target/adi_v5_swd.c index b25181e21..f1fca40ae 100644 --- a/src/target/adi_v5_swd.c +++ b/src/target/adi_v5_swd.c @@ -74,7 +74,7 @@ static void swd_clear_sticky_errors(struct adiv5_dap *dap) const struct swd_driver *swd = adiv5_dap_swd_driver(dap); assert(swd); - swd->write_reg(swd_cmd(false, false, DP_ABORT), + swd->write_reg(swd_cmd(false, false, DP_ABORT), STKCMPCLR | STKERRCLR | WDERRCLR | ORUNERRCLR, 0); } @@ -174,7 +174,7 @@ static int swd_connect(struct adiv5_dap *dap) dap->do_reconnect = false; - swd->write_reg(swd_cmd(false, false, DP_ABORT), + swd->write_reg(swd_cmd(false, false, DP_ABORT), DAPABORT | STKCMPCLR | STKERRCLR | WDERRCLR | ORUNERRCLR, 0); status = swd_run_inner(dap); } @@ -325,7 +325,7 @@ static int swd_queue_ap_read(struct adiv5_ap *ap, unsigned reg, if (retval != ERROR_OK) return retval; - swd->read_reg(swd_cmd(true, true, reg), dap->last_read, ap->memaccess_tck); + swd->read_reg(swd_cmd(true, true, reg), dap->last_read, ap->memaccess_tck); dap->last_read = data; return check_sync(dap); @@ -347,7 +347,7 @@ static int swd_queue_ap_write(struct adiv5_ap *ap, unsigned reg, if (retval != ERROR_OK) return retval; - swd->write_reg(swd_cmd(false, true, reg), data, ap->memaccess_tck); + swd->write_reg(swd_cmd(false, true, reg), data, ap->memaccess_tck); return check_sync(dap); } ----------------------------------------------------------------------- Summary of changes: src/target/adi_v5_swd.c | 8 ++++---- src/target/arm_adi_v5.h | 17 +++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-25 22:09:04
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via a5471b1b2c5675fa0caa462e742916c54f9a08e2 (commit) via 45eff3a8069dd95a6614f6c6482c7b21f2a84ad6 (commit) from 6f1252373ba3ff584011ad9568da117ce7ecdc35 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a5471b1b2c5675fa0caa462e742916c54f9a08e2 Author: Peter Lawrence <maj...@gm...> Date: Fri Mar 19 16:26:52 2021 +0100 drivers/cmsis-dap: add multidrop capability Uses CMSIS-DAP v 1.2 or higher protocol command DAP_SWD_Sequence to write to DP TARGETSEL register. This write is not acknowledged by device so we cannot use standard DAP_Transfer Change-Id: Ib252d09570bcc2282be5f854e0ab9a0dfda06189 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: http://openocd.zylin.com/6117 Tested-by: jenkins Reviewed-by: Peter Lawrence <maj...@gm...> diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index 6ab087598..fb5c86aec 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -136,6 +136,7 @@ static bool swd_mode; /* CMSIS-DAP SWD Commands */ #define CMD_DAP_SWD_CONFIGURE 0x13 +#define CMD_DAP_SWD_SEQUENCE 0x1D /* CMSIS-DAP JTAG Commands */ #define CMD_DAP_JTAG_SEQ 0x14 @@ -542,6 +543,45 @@ static int cmsis_dap_cmd_DAP_Delay(uint16_t delay_us) } #endif +static int cmsis_dap_metacmd_targetsel(uint32_t instance_id) +{ + int retval; + uint8_t *command = cmsis_dap_handle->command; + const uint32_t SEQ_RD = 0x80, SEQ_WR = 0x00; + + /* SWD multi-drop requires a transfer ala CMD_DAP_TFER, + but with no expectation of an SWD ACK response. In + CMSIS-DAP v1.20 and v2.00, CMD_DAP_SWD_SEQUENCE was + added to allow this special sequence to be generated. + The purpose of this operation is to select the target + corresponding to the instance_id that is written */ + + size_t idx = 0; + command[idx++] = CMD_DAP_SWD_SEQUENCE; + command[idx++] = 3; /* sequence count */ + + /* sequence 0: packet request for TARGETSEL */ + command[idx++] = SEQ_WR | 8; + command[idx++] = SWD_CMD_START | swd_cmd(false, false, DP_TARGETSEL) | SWD_CMD_STOP | SWD_CMD_PARK; + + /* sequence 1: read Trn ACK Trn, no expectation for target to ACK */ + command[idx++] = SEQ_RD | 5; + + /* sequence 2: WDATA plus parity */ + command[idx++] = SEQ_WR | (32 + 1); + h_u32_to_le(command + idx, instance_id); + idx += 4; + command[idx++] = parity_u32(instance_id); + + retval = cmsis_dap_xfer(cmsis_dap_handle, idx); + + if (retval != ERROR_OK || cmsis_dap_handle->response[1] != DAP_OK) { + LOG_ERROR("CMSIS-DAP command SWD_Sequence failed."); + return ERROR_JTAG_DEVICE_ERROR; + } + return ERROR_OK; +} + static void cmsis_dap_swd_write_from_queue(struct cmsis_dap *dap) { uint8_t *command = cmsis_dap_handle->command; @@ -715,7 +755,10 @@ static int cmsis_dap_swd_run_queue(void) static void cmsis_dap_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data) { - if (pending_fifo[pending_fifo_put_idx].transfer_count == pending_queue_len) { + bool targetsel_cmd = swd_cmd(false, false, DP_TARGETSEL) == cmd; + + if (pending_fifo[pending_fifo_put_idx].transfer_count == pending_queue_len + || targetsel_cmd) { if (pending_fifo_block_count) cmsis_dap_swd_read_process(cmsis_dap_handle, 0); @@ -729,6 +772,11 @@ static void cmsis_dap_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data) if (queued_retval != ERROR_OK) return; + if (targetsel_cmd) { + cmsis_dap_metacmd_targetsel(data); + return; + } + struct pending_request_block *block = &pending_fifo[pending_fifo_put_idx]; struct pending_transfer_result *transfer = &(block->transfers[block->transfer_count]); transfer->data = data; @@ -846,7 +894,7 @@ static int cmsis_dap_swd_switch_seq(enum swd_special_seq seq) switch (seq) { case LINE_RESET: - LOG_DEBUG("SWD line reset"); + LOG_DEBUG_IO("SWD line reset"); s = swd_seq_line_reset; s_len = swd_seq_line_reset_len; break; @@ -855,11 +903,26 @@ static int cmsis_dap_swd_switch_seq(enum swd_special_seq seq) s = swd_seq_jtag_to_swd; s_len = swd_seq_jtag_to_swd_len; break; + case JTAG_TO_DORMANT: + LOG_DEBUG("JTAG-to-DORMANT"); + s = swd_seq_jtag_to_dormant; + s_len = swd_seq_jtag_to_dormant_len; + break; case SWD_TO_JTAG: LOG_DEBUG("SWD-to-JTAG"); s = swd_seq_swd_to_jtag; s_len = swd_seq_swd_to_jtag_len; break; + case SWD_TO_DORMANT: + LOG_DEBUG("SWD-to-DORMANT"); + s = swd_seq_swd_to_dormant; + s_len = swd_seq_swd_to_dormant_len; + break; + case DORMANT_TO_SWD: + LOG_DEBUG("DORMANT-to-SWD"); + s = swd_seq_dormant_to_swd; + s_len = swd_seq_dormant_to_swd_len; + break; default: LOG_ERROR("Sequence %d not supported", seq); return ERROR_FAIL; commit 45eff3a8069dd95a6614f6c6482c7b21f2a84ad6 Author: Tomas Vanek <va...@fb...> Date: Mon Apr 5 08:44:39 2021 +0200 target/arm_adi_v5: add JTAG_TO_DORMANT sequence Change-Id: Ie9e32e42a84cf88bf779e691a67c114eef1bb457 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: http://openocd.zylin.com/6136 Tested-by: jenkins diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index 8edfaa816..047606c43 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -162,6 +162,7 @@ enum swd_special_seq { LINE_RESET, JTAG_TO_SWD, + JTAG_TO_DORMANT, SWD_TO_JTAG, SWD_TO_DORMANT, DORMANT_TO_SWD, ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/cmsis_dap.c | 67 ++++++++++++++++++++++++++++++++++++++++++-- src/target/arm_adi_v5.h | 1 + 2 files changed, 66 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-25 22:05:42
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 6f1252373ba3ff584011ad9568da117ce7ecdc35 (commit) via df443551a8d4cf74cea695ebf16b05db684f3d4e (commit) from 642cdae32167df80d4dc757f0da5f204e0298088 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6f1252373ba3ff584011ad9568da117ce7ecdc35 Author: Antonio Borneo <bor...@gm...> Date: Sat Apr 10 15:58:22 2021 +0200 tcl/at91/sam9_smc: fix syntax errors This file has been added to OpenOCD 0.5.0 in 2011, before gerrit gets in use, with commit ba71e8c521a7 ("at91: add chip register definition and generic init support"). The only procedure in the file has never been referenced in any other part of OpenOCD. This procedure has syntax errors while uses its argument 'cs' and several unmatched parenthesis, which clearly highlights that it has never been used so far. Gerrit does not report any patch aimed at fixing it. Even if the file seems unused and could be removed, let's fix it in the hope it could get used. While there, remove some useless parenthesis and format it using the new simplified syntax required by jimtcl 0.81. Change-Id: Ied26456262e7b99de37667a8ce418f4f12e237bd Signed-off-by: Antonio Borneo <bor...@gm...> Fixes: ba71e8c521a7 ("at91: add chip register definition and generic init support") Reviewed-on: http://openocd.zylin.com/6157 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/tcl/chip/atmel/at91/sam9_smc.cfg b/tcl/chip/atmel/at91/sam9_smc.cfg index db943cb24..0628d4d18 100644 --- a/tcl/chip/atmel/at91/sam9_smc.cfg +++ b/tcl/chip/atmel/at91/sam9_smc.cfg @@ -26,30 +26,30 @@ # tdf_cycles proc sam9_smc_config { cs smc_config } { ;# Setup Register for CS n - set AT91_SMC_SETUP [expr ($::AT91_SMC + 0x00 + ((cs)*0x10))] - set val [expr ($smc_config(nwe_setup) << 0)] - set val [expr ($val | $smc_config(ncs_write_setup) << 8] - set val [expr ($val | $smc_config(nrd_setup)) << 16] - set val [expr ($val | $smc_config(ncs_read_setup) << 24] + set AT91_SMC_SETUP [expr {$::AT91_SMC + 0x00 + $cs * 0x10}] + set val [expr {$smc_config(nwe_setup) << 0}] + set val [expr {$val | $smc_config(ncs_write_setup) << 8}] + set val [expr {$val | $smc_config(nrd_setup)) << 16}] + set val [expr {$val | $smc_config(ncs_read_setup) << 24}] mww $AT91_SMC_SETUP $val ;# Pulse Register for CS n - set AT91_SMC_PULSE [expr ($::AT91_SMC + 0x04 + ((cs)*0x10))] - set val [expr ($smc_config(nwe_pulse) << 0)] - set val [expr ($val | $smc_config(ncs_write_pulse) << 8] - set val [expr ($val | $smc_config(nrd_pulse) << 16] - set val [expr ($val | $smc_config(ncs_read_pulse) << 24] + set AT91_SMC_PULSE [expr {$::AT91_SMC + 0x04 + $cs * 0x10}] + set val [expr {$smc_config(nwe_pulse) << 0}] + set val [expr {$val | $smc_config(ncs_write_pulse) << 8}] + set val [expr {$val | $smc_config(nrd_pulse) << 16}] + set val [expr {$val | $smc_config(ncs_read_pulse) << 24}] mww $AT91_SMC_PULSE $val ;# Cycle Register for CS n - set AT91_SMC_CYCLE [expr ($::AT91_SMC + 0x08 + ((cs)*0x10))] - set val [expr ($smc_config(write_cycle) << 0)] - set val [expr ($val | $smc_config(read_cycle) << 16] + set AT91_SMC_CYCLE [expr {$::AT91_SMC + 0x08 + $cs * 0x10}] + set val [expr {$smc_config(write_cycle) << 0}] + set val [expr {$val | $smc_config(read_cycle) << 16}] mww $AT91_SMC_CYCLE $val ;# Mode Register for CS n - set AT91_SMC_MODE [expr ($::AT91_SMC + 0x0c + ((cs)*0x10))] - set val [expr ($smc_config(mode) << 0)] - set val [expr ($val | $smc_config(tdf_cycles) << 16] + set AT91_SMC_MODE [expr {$::AT91_SMC + 0x0c + $cs * 0x10}] + set val [expr {$smc_config(mode) << 0}] + set val [expr {$val | $smc_config(tdf_cycles) << 16}] mww $AT91_SMC_MODE $val } commit df443551a8d4cf74cea695ebf16b05db684f3d4e Author: Antonio Borneo <bor...@gm...> Date: Sat Apr 10 15:31:39 2021 +0200 board: imx53: fix l2 cache initialization Both http://openocd.zylin.com/542/ and http://openocd.zylin.com/543/ introduce the same typo in the bitfield for initializing the l2 cache of imx53. One year later, http://openocd.zylin.com/1461/ copy-pastes the same typo. The comment above the code show that it's really an error and not the expected behaviour. Fix the typo replacing the incorrect comparison '<' with a left shift. Change-Id: I43725731a2228e28a676215f76936fa289d9395e Signed-off-by: Antonio Borneo <bor...@gm...> Fixes: e3b327343394 ("cfg: add imx53loco board config") Fixes: 108a458ab888 ("cfg: add icnova_imx53_sodimm board config") Fixes: e608ced33001 ("ftdi/board: Add support for DENX M53EVK") Reviewed-on: http://openocd.zylin.com/6156 Tested-by: jenkins Reviewed-by: Adrian M Negreanu <adr...@nx...> Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/tcl/board/icnova_imx53_sodimm.cfg b/tcl/board/icnova_imx53_sodimm.cfg index dce9c470e..af9818814 100644 --- a/tcl/board/icnova_imx53_sodimm.cfg +++ b/tcl/board/icnova_imx53_sodimm.cfg @@ -79,7 +79,7 @@ proc init_l2cc { } { ; #orr r0, r0, #(1 << 22) /* disable write allocate */ ; #mcr 15, 1, r0, c9, c0, 2 - arm mcr 15 1 9 0 2 [expr 0xC4 | (1<<24) | (1<<23) | (1<22)] + arm mcr 15 1 9 0 2 [expr 0xC4 | (1<<24) | (1<<23) | (1<<22)] } diff --git a/tcl/board/imx53-m53evk.cfg b/tcl/board/imx53-m53evk.cfg index baeb3cd9d..b529c4940 100644 --- a/tcl/board/imx53-m53evk.cfg +++ b/tcl/board/imx53-m53evk.cfg @@ -75,7 +75,7 @@ proc init_l2cc { } { ; #orr r0, r0, #(1 << 22) /* disable write allocate */ ; #mcr 15, 1, r0, c9, c0, 2 - arm mcr 15 1 9 0 2 [expr 0xC4 | (1<<24) | (1<<23) | (1<22)] + arm mcr 15 1 9 0 2 [expr 0xC4 | (1<<24) | (1<<23) | (1<<22)] } diff --git a/tcl/board/imx53loco.cfg b/tcl/board/imx53loco.cfg index 18caca574..91c260138 100644 --- a/tcl/board/imx53loco.cfg +++ b/tcl/board/imx53loco.cfg @@ -80,7 +80,7 @@ proc init_l2cc { } { ; #orr r0, r0, #(1 << 22) /* disable write allocate */ ; #mcr 15, 1, r0, c9, c0, 2 - arm mcr 15 1 9 0 2 [expr 0xC4 | (1<<24) | (1<<23) | (1<22)] + arm mcr 15 1 9 0 2 [expr 0xC4 | (1<<24) | (1<<23) | (1<<22)] } ----------------------------------------------------------------------- Summary of changes: tcl/board/icnova_imx53_sodimm.cfg | 2 +- tcl/board/imx53-m53evk.cfg | 2 +- tcl/board/imx53loco.cfg | 2 +- tcl/chip/atmel/at91/sam9_smc.cfg | 32 ++++++++++++++++---------------- 4 files changed, 19 insertions(+), 19 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-25 22:05:16
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 642cdae32167df80d4dc757f0da5f204e0298088 (commit) from 833a2a56f4649d4a59738d902405f1093adf4e58 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 642cdae32167df80d4dc757f0da5f204e0298088 Author: Antonio Borneo <bor...@gm...> Date: Wed Apr 7 15:25:37 2021 +0200 doc: command 'ftdi_layout_signal' can run after config The mode of command 'ftdi_layout_signal' is set to COMMAND_ANY in [1] and the command has no constraints that limits its use to the config phase only. But [2] documents it as '{Config Command}'. Update the documentation to report the correct mode '{Command}'. [1] commit f5e97b5e1b62 ("Add FTDI JTAG driver using MPSSE layer") [2] commit 76afadeb7b4e ("doc: Add documentation for the ftdi driver") Change-Id: I6b14aebb98e48f7080c585f3df881714bb188af0 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/6155 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <and...@gm...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 3523a222a..4dd3a3389 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2531,7 +2531,7 @@ minimal impact on the target system. Avoid floating inputs, conflicting outputs and initially asserted reset signals. @end deffn -@deffn {Config Command} {ftdi_layout_signal} name [@option{-data}|@option{-ndata} data_mask] [@option{-input}|@option{-ninput} input_mask] [@option{-oe}|@option{-noe} oe_mask] [@option{-alias}|@option{-nalias} name] +@deffn {Command} {ftdi_layout_signal} name [@option{-data}|@option{-ndata} data_mask] [@option{-input}|@option{-ninput} input_mask] [@option{-oe}|@option{-noe} oe_mask] [@option{-alias}|@option{-nalias} name] Creates a signal with the specified @var{name}, controlled by one or more FTDI GPIO pins via a range of possible buffer connections. The masks are FTDI GPIO register bitmasks to tell the driver the connection and type of the output ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-25 22:04:48
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 833a2a56f4649d4a59738d902405f1093adf4e58 (commit) via 3ebcb62f9ff2f1c7a99a6207b158219b9892e72a (commit) from 3cacfd86ab208a99c91b25f54a79528227d6ea50 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 833a2a56f4649d4a59738d902405f1093adf4e58 Author: Antonio Borneo <bor...@gm...> Date: Wed Apr 7 15:18:04 2021 +0200 doc: do not document commands that are already deprecated The command 'ftdi_location' is deprecated and a TCL procedure is in place to direct the user to the replacement command. There is no need to document the deprecated command. Remove 'ftdi_location' from the documentation. Change-Id: Ia431c6b0e7444d3f3288c088429bfb47089ff1b5 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/6154 Tested-by: jenkins Reviewed-by: Marc Schink <de...@za...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 44dcbdb8a..3523a222a 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2517,19 +2517,6 @@ If not specified, serial numbers are not considered. and are not restricted to containing only decimal digits.) @end deffn -@deffn {Config Command} {ftdi_location} <bus>-<port>[.<port>]... -@emph{DEPRECATED -- avoid using this. -Use the command @ref{adapter_usb_location,,adapter usb location} instead.} - -Specifies the physical USB port of the adapter to use. The path -roots at @var{bus} and walks down the physical ports, with each -@var{port} option specifying a deeper level in the bus topology, the last -@var{port} denoting where the target adapter is actually plugged. -The USB bus topology can be queried with the command @emph{lsusb -t}. - -This command is only available if your libusb1 is at least version 1.0.16. -@end deffn - @deffn {Config Command} {ftdi_channel} channel Selects the channel of the FTDI device to use for MPSSE operations. Most adapters use the default, channel 0, but there are exceptions. commit 3ebcb62f9ff2f1c7a99a6207b158219b9892e72a Author: Antonio Borneo <bor...@gm...> Date: Wed Apr 7 14:42:36 2021 +0200 doc: annotate configuration commands Some command that is only valid during configuration is documented as generic command. Annotate them as {Config Command} in the documentation. Change-Id: Ifdbb6ec89b945e3d7adce94af379d94f511a64b6 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/6153 Tested-by: jenkins Reviewed-by: Jonathan McDowell <noo...@ea...> diff --git a/doc/openocd.texi b/doc/openocd.texi index fdef3309d..44dcbdb8a 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2115,7 +2115,7 @@ If you disable all access through TCP/IP, you will need to use the command line @option{-pipe} option. @anchor{gdb_port} -@deffn {Command} {gdb_port} [number] +@deffn {Config Command} {gdb_port} [number] @cindex GDB server Normally gdb listens to a TCP/IP port, but GDB can also communicate via pipes(stdin/out or named pipes). The name @@ -2148,7 +2148,7 @@ gdb (with 'set remotetimeout') is recommended. An insufficient timeout may cause initialization to fail with "Unknown remote qXfer reply: OK". @end deffn -@deffn {Command} {tcl_port} [number] +@deffn {Config Command} {tcl_port} [number] Specify or query the port used for a simplified RPC connection that can be used by clients to issue TCL commands and get the output from the Tcl engine. @@ -2158,7 +2158,7 @@ the port @var{number} defaults to 6666. When specified as "disabled", this service is not activated. @end deffn -@deffn {Command} {telnet_port} [number] +@deffn {Config Command} {telnet_port} [number] Specify or query the port on which to listen for incoming telnet connections. This port is intended for interaction with one human through TCL commands. @@ -2343,7 +2343,7 @@ target. List the debug adapter drivers that have been built into the running copy of OpenOCD. @end deffn -@deffn {Command} {adapter transports} transport_name+ +@deffn {Config Command} {adapter transports} transport_name+ Specifies the transports supported by this debug adapter. The adapter driver builds-in similar knowledge; use this only when external configuration (such as jumpering) changes what @@ -2357,7 +2357,7 @@ Returns the name of the debug adapter driver being used. @end deffn @anchor{adapter_usb_location} -@deffn {Command} {adapter usb location} [<bus>-<port>[.<port>]...] +@deffn {Config Command} {adapter usb location} [<bus>-<port>[.<port>]...] Displays or specifies the physical USB port of the adapter to use. The path roots at @var{bus} and walks down the physical ports, with each @var{port} option specifying a deeper level in the bus topology, the last @@ -2775,13 +2775,13 @@ reset_config srst_only @end example @end deffn -@deffn {Command} {usb_blaster_lowlevel_driver} (@option{ftdi}|@option{ublast2}) +@deffn {Config Command} {usb_blaster_lowlevel_driver} (@option{ftdi}|@option{ublast2}) Chooses the low level access method for the adapter. If not specified, @option{ftdi} is selected unless it wasn't enabled during the configure stage. USB-Blaster II needs @option{ublast2}. @end deffn -@deffn {Command} {usb_blaster_firmware} @var{path} +@deffn {Config Command} {usb_blaster_firmware} @var{path} This command specifies @var{path} to access USB-Blaster II firmware image. To be used with USB-Blaster II only. @end deffn @@ -2873,7 +2873,7 @@ The following example shows how to read 4 bytes from the EMUCOM channel 0x0: 77a90000 @end example @end deffn -@deffn {Config} {jlink usb} <@option{0} to @option{3}> +@deffn {Config Command} {jlink usb} <@option{0} to @option{3}> Set the USB address of the interface, in case more than one adapter is connected to the host. If not specified, USB addresses are not considered. Device selection via USB address is not always unambiguous. It is recommended to use @@ -2881,7 +2881,7 @@ the serial number instead, if possible. As a configuration command, it can be used only before 'init'. @end deffn -@deffn {Config} {jlink serial} <serial number> +@deffn {Config Command} {jlink serial} <serial number> Set the serial number of the interface, in case more than one adapter is connected to the host. If not specified, serial numbers are not considered. @@ -2992,7 +2992,7 @@ When using PPDEV to access the parallel port, use the number of the parallel por you may encounter a problem. @end deffn -@deffn {Command} {parport_toggling_time} [nanoseconds] +@deffn {Config Command} {parport_toggling_time} [nanoseconds] Displays how many nanoseconds the hardware needs to toggle TCK; the parport driver uses this value to obey the @command{adapter speed} configuration. @@ -3335,7 +3335,7 @@ driver} (in which case the command is @command{transport select hla_swd}) or @ref{st_link_dap_interface,the st-link interface driver} (in which case the command is @command{transport select dapdirect_swd}). -@deffn {Command} {swd newdap} ... +@deffn {Config Command} {swd newdap} ... Declares a single DAP which uses SWD transport. Parameters are currently the same as "jtag newtap" but this is expected to change. @@ -3933,8 +3933,7 @@ and underscores are OK; while others (including dots!) are not. @section TAP Declaration Commands -@c shouldn't this be(come) a {Config Command}? -@deffn {Command} {jtag newtap} chipname tapname configparams... +@deffn {Config Command} {jtag newtap} chipname tapname configparams... Declares a new TAP with the dotted name @var{chipname}.@var{tapname}, and configured according to the various @var{configparams}. @@ -4381,7 +4380,7 @@ xxx.dap apcsw default @end example @end deffn -@deffn {Command} {$dap_name ti_be_32_quirks} [@option{enable}] +@deffn {Config Command} {$dap_name ti_be_32_quirks} [@option{enable}] Set/get quirks mode for TI TMS450/TMS570 processors Disabled by default @end deffn @@ -4612,7 +4611,7 @@ That may be needed to let you write the boot loader into flash, in order to ``de-brick'' your board; or to load programs into external DDR memory without having run the boot loader. -@deffn {Command} {target create} target_name type configparams... +@deffn {Config Command} {target create} target_name type configparams... This command creates a GDB debug target that refers to a specific JTAG tap. It enters that target into a list, and creates a new command (@command{@var{target_name}}) which is used for various @@ -6238,7 +6237,7 @@ The @var{kinetis} driver defines option: flash bank $_FLASHNAME kinetis 0 0 0 0 $_TARGETNAME @end example -@deffn {Command} {kinetis create_banks} +@deffn {Config Command} {kinetis create_banks} Configuration command enables automatic creation of additional flash banks based on real flash layout of device. Banks are created during device probe. Use 'flash probe 0' to force probe. @@ -7806,23 +7805,23 @@ AT91SAM9 chips support single-bit ECC hardware. The @code{write_page} and disabled by using the @command{nand raw_access} command. There are four additional commands that are needed to fully configure the AT91SAM9 NAND controller. Two are optional; most boards use the same wiring for ALE/CLE: -@deffn {Command} {at91sam9 cle} num addr_line +@deffn {Config Command} {at91sam9 cle} num addr_line Configure the address line used for latching commands. The @var{num} parameter is the value shown by @command{nand list}. @end deffn -@deffn {Command} {at91sam9 ale} num addr_line +@deffn {Config Command} {at91sam9 ale} num addr_line Configure the address line used for latching addresses. The @var{num} parameter is the value shown by @command{nand list}. @end deffn For the next two commands, it is assumed that the pins have already been properly configured for input or output. -@deffn {Command} {at91sam9 rdy_busy} num pio_base_addr pin +@deffn {Config Command} {at91sam9 rdy_busy} num pio_base_addr pin Configure the RDY/nBUSY input from the NAND device. The @var{num} parameter is the value shown by @command{nand list}. @var{pio_base_addr} is the base address of the PIO controller and @var{pin} is the pin number. @end deffn -@deffn {Command} {at91sam9 ce} num pio_base_addr pin +@deffn {Config Command} {at91sam9 ce} num pio_base_addr pin Configure the chip enable input to the NAND device. The @var{num} parameter is the value shown by @command{nand list}. @var{pio_base_addr} is the base address of the PIO controller and @var{pin} is the pin number. @@ -8109,7 +8108,7 @@ the default log output channel is stderr. Add @var{directory} to the file/script search path. @end deffn -@deffn {Command} {bindto} [@var{name}] +@deffn {Config Command} {bindto} [@var{name}] Specify hostname or IPv4 address on which to listen for incoming TCP/IP connections. By default, OpenOCD will listen on the loopback interface only. If your network environment is safe, @code{bindto ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 54 ++++++++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 34 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-25 22:04:12
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 3cacfd86ab208a99c91b25f54a79528227d6ea50 (commit) from 7dd323b26d93e49e409e02053e30f53ac8138cd5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3cacfd86ab208a99c91b25f54a79528227d6ea50 Author: Antonio Borneo <bor...@gm...> Date: Wed May 13 17:22:12 2020 +0200 smp: move command deprecation to startup.tcl Commit 246782229f8f ("smp: replace commands smp_on/smp_off with "smp [on|off]"") deprecates some multi-word comments, when openocd was unable to properly handle mixes of multi-word commands and tcl procedures having a common initial word. This limitation is over, so move in startup.tcl the multi-word commands deprecation, making it easy to remove them after a grace period. Change-Id: Icb550d1fa7559b95692d2a1244880da6c90ec0b2 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5677 Tested-by: jenkins diff --git a/src/target/smp.c b/src/target/smp.c index acd4628e2..6501dc08a 100644 --- a/src/target/smp.c +++ b/src/target/smp.c @@ -131,26 +131,6 @@ COMMAND_HANDLER(default_handle_smp_command) 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); @@ -180,20 +160,6 @@ const struct command_registration smp_command_handlers[] = { .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, diff --git a/src/target/startup.tcl b/src/target/startup.tcl index a8f78ab49..f128d3b5e 100644 --- a/src/target/startup.tcl +++ b/src/target/startup.tcl @@ -206,3 +206,34 @@ proc init_target_events {} { # Additionally board config scripts can define a procedure init_board that will be executed after init and init_targets proc init_board {} { } + +# smp_on/smp_off were already DEPRECATED in v0.11.0 through http://openocd.zylin.com/4615 +proc "aarch64 smp_on" {args} { + echo "DEPRECATED! use 'aarch64 smp on' not 'aarch64 smp_on'" + eval aarch64 smp on $args +} + +proc "aarch64 smp_off" {args} { + echo "DEPRECATED! use 'aarch64 smp off' not 'aarch64 smp_off'" + eval aarch64 smp off $args +} + +proc "cortex_a smp_on" {args} { + echo "DEPRECATED! use 'cortex_a smp on' not 'cortex_a smp_on'" + eval cortex_a smp on $args +} + +proc "cortex_a smp_off" {args} { + echo "DEPRECATED! use 'cortex_a smp off' not 'cortex_a smp_off'" + eval cortex_a smp off $args +} + +proc "mips_m4k smp_on" {args} { + echo "DEPRECATED! use 'mips_m4k smp on' not 'mips_m4k smp_on'" + eval mips_m4k smp on $args +} + +proc "mips_m4k smp_off" {args} { + echo "DEPRECATED! use 'mips_m4k smp off' not 'mips_m4k smp_off'" + eval mips_m4k smp off $args +} ----------------------------------------------------------------------- Summary of changes: src/target/smp.c | 34 ---------------------------------- src/target/startup.tcl | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 34 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-24 16:15:44
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 7dd323b26d93e49e409e02053e30f53ac8138cd5 (commit) from 29af9040436a9bb0a937c25c122018494bd3fe08 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7dd323b26d93e49e409e02053e30f53ac8138cd5 Author: Yun Liu <liu...@gm...> Date: Fri Mar 12 15:07:13 2021 +0800 remote_bitbang: Add Windows support Windows socket descriptor is not file descriptor, so when using remote_bitbang on Windows, it fails with "fdopen: failed to open write stream". This patch removes the file write stream, replaces it with socket write calls. Change-Id: Ifd7c8a4139a5ac51ecd2846835a7a947a90fe16c Signed-off-by: Yun Liu <liu...@gm...> Reviewed-on: http://openocd.zylin.com/6096 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/jtag/drivers/remote_bitbang.c b/src/jtag/drivers/remote_bitbang.c index 663795296..114e018b7 100644 --- a/src/jtag/drivers/remote_bitbang.c +++ b/src/jtag/drivers/remote_bitbang.c @@ -33,7 +33,6 @@ static char *remote_bitbang_host; static char *remote_bitbang_port; -static FILE *remote_bitbang_file; static int remote_bitbang_fd; /* Circular buffer. When start == end, the buffer is empty. */ @@ -63,7 +62,7 @@ static int remote_bitbang_fill_buf(void) contiguous_available_space = remote_bitbang_start - remote_bitbang_end - 1; } - ssize_t count = read(remote_bitbang_fd, + ssize_t count = read_socket(remote_bitbang_fd, remote_bitbang_buf + remote_bitbang_end, contiguous_available_space); if (count > 0) { @@ -73,11 +72,14 @@ static int remote_bitbang_fill_buf(void) } else if (count == 0) { return ERROR_OK; } else if (count < 0) { +#ifdef _WIN32 + if (WSAGetLastError() == WSAEWOULDBLOCK) { +#else if (errno == EAGAIN) { +#endif return ERROR_OK; } else { - LOG_ERROR("remote_bitbang_fill_buf: %s (%d)", - strerror(errno), errno); + log_socket_error("remote_bitbang_fill_buf"); return ERROR_FAIL; } } @@ -88,8 +90,10 @@ static int remote_bitbang_fill_buf(void) static int remote_bitbang_putc(int c) { - if (EOF == fputc(c, remote_bitbang_file)) { - LOG_ERROR("remote_bitbang_putc: %s", strerror(errno)); + char buf = c; + ssize_t count = write_socket(remote_bitbang_fd, &buf, sizeof(buf)); + if (count < 0) { + log_socket_error("remote_bitbang_putc"); return ERROR_FAIL; } return ERROR_OK; @@ -97,20 +101,11 @@ static int remote_bitbang_putc(int c) static int remote_bitbang_quit(void) { - if (EOF == fputc('Q', remote_bitbang_file)) { - LOG_ERROR("fputs: %s", strerror(errno)); - return ERROR_FAIL; - } - - if (EOF == fflush(remote_bitbang_file)) { - LOG_ERROR("fflush: %s", strerror(errno)); + if (remote_bitbang_putc('Q') == ERROR_FAIL) return ERROR_FAIL; - } - /* We only need to close one of the FILE*s, because they both use the same */ - /* underlying file descriptor. */ - if (EOF == fclose(remote_bitbang_file)) { - LOG_ERROR("fclose: %s", strerror(errno)); + if (close_socket(remote_bitbang_fd) != 0) { + log_socket_error("close_socket"); return ERROR_FAIL; } @@ -138,21 +133,16 @@ static bb_value_t char_to_int(int c) /* Get the next read response. */ static bb_value_t remote_bitbang_rread(void) { - if (EOF == fflush(remote_bitbang_file)) { - remote_bitbang_quit(); - LOG_ERROR("fflush: %s", strerror(errno)); - return BB_ERROR; - } - /* Enable blocking access. */ socket_block(remote_bitbang_fd); char c; - ssize_t count = read(remote_bitbang_fd, &c, 1); + ssize_t count = read_socket(remote_bitbang_fd, &c, 1); if (count == 1) { return char_to_int(c); } else { remote_bitbang_quit(); - LOG_ERROR("read: count=%d, error=%s", (int) count, strerror(errno)); + LOG_ERROR("read_socket: count=%d", (int) count); + log_socket_error("read_socket"); return BB_ERROR; } } @@ -238,7 +228,7 @@ static int remote_bitbang_init_tcp(void) freeaddrinfo(result); /* No longer needed */ if (rp == NULL) { /* No address succeeded */ - LOG_ERROR("Failed to connect: %s", strerror(errno)); + log_socket_error("Failed to connect"); return ERROR_FAIL; } @@ -255,7 +245,7 @@ static int remote_bitbang_init_unix(void) LOG_INFO("Connecting to unix socket %s", remote_bitbang_host); int fd = socket(PF_UNIX, SOCK_STREAM, 0); if (fd < 0) { - LOG_ERROR("socket: %s", strerror(errno)); + log_socket_error("socket"); return ERROR_FAIL; } @@ -265,7 +255,7 @@ static int remote_bitbang_init_unix(void) addr.sun_path[sizeof(addr.sun_path)-1] = '\0'; if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) { - LOG_ERROR("connect: %s", strerror(errno)); + log_socket_error("connect"); return ERROR_FAIL; } @@ -288,13 +278,6 @@ static int remote_bitbang_init(void) if (remote_bitbang_fd < 0) return remote_bitbang_fd; - remote_bitbang_file = fdopen(remote_bitbang_fd, "w+"); - if (remote_bitbang_file == NULL) { - LOG_ERROR("fdopen: failed to open write stream"); - close(remote_bitbang_fd); - return ERROR_FAIL; - } - LOG_INFO("remote_bitbang driver initialized"); return ERROR_OK; } ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/remote_bitbang.c | 55 ++++++++++++++------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-24 04:54:44
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 29af9040436a9bb0a937c25c122018494bd3fe08 (commit) from 41a6089504823433817ea67d9af3d2d85f402336 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 29af9040436a9bb0a937c25c122018494bd3fe08 Author: Leonard Crestez <leo...@nx...> Date: Thu Apr 4 15:44:25 2019 +0300 target/imx8qm: Initial support Chip is similar to imx8x series but has different cores at different addresses. Support for reduced versions is not yet available. Tested on imx8qm-mek board Change-Id: Ia34a80d561ab2849a570d8c375b936a45cbf45ca Signed-off-by: Leonard Crestez <leo...@nx...> Reviewed-by: Oliver Graute <oli...@ko...> Reviewed-on: http://openocd.zylin.com/5042 Reviewed-by: Oleksij Rempel <li...@re...> Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/tcl/target/imx8qm.cfg b/tcl/target/imx8qm.cfg new file mode 100644 index 000000000..08cb8137d --- /dev/null +++ b/tcl/target/imx8qm.cfg @@ -0,0 +1,89 @@ +# +# NXP i.MX8QuadMax +# + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME imx8qm +} + +# CoreSight Debug Access Port (DAP) +if { [info exists DAP_TAPID] } { + set _DAP_TAPID $DAP_TAPID +} else { + # TAPID is from FreeScale! + set _DAP_TAPID 0x1890101d +} + +jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x01 -irmask 0x0f \ + -expected-id $_DAP_TAPID + +dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu + +# AXI: Main SOC bus on AP #0 +target create ${_CHIPNAME}.axi mem_ap -dap ${_CHIPNAME}.dap -ap-num 0 + +# 4x Cortex-A53 on AP #6 +set _A53_DBGBASE {0x80410000 0x80510000 0x80610000 0x80710000} +set _A53_CTIBASE {0x80420000 0x80520000 0x80620000 0x80720000} + +cti create $_CHIPNAME.a53_cti.0 -dap $_CHIPNAME.dap \ + -ap-num 6 -baseaddr [lindex $_A53_CTIBASE 0] +cti create $_CHIPNAME.a53_cti.1 -dap $_CHIPNAME.dap \ + -ap-num 6 -baseaddr [lindex $_A53_CTIBASE 1] +cti create $_CHIPNAME.a53_cti.2 -dap $_CHIPNAME.dap \ + -ap-num 6 -baseaddr [lindex $_A53_CTIBASE 2] +cti create $_CHIPNAME.a53_cti.3 -dap $_CHIPNAME.dap \ + -ap-num 6 -baseaddr [lindex $_A53_CTIBASE 3] +target create $_CHIPNAME.a53.0 aarch64 -dap $_CHIPNAME.dap \ + -cti $_CHIPNAME.a53_cti.0 -dbgbase [lindex $_A53_DBGBASE 0] +target create $_CHIPNAME.a53.1 aarch64 -dap $_CHIPNAME.dap \ + -cti $_CHIPNAME.a53_cti.1 -dbgbase [lindex $_A53_DBGBASE 1] -defer-examine +target create $_CHIPNAME.a53.2 aarch64 -dap $_CHIPNAME.dap \ + -cti $_CHIPNAME.a53_cti.2 -dbgbase [lindex $_A53_DBGBASE 2] -defer-examine +target create $_CHIPNAME.a53.3 aarch64 -dap $_CHIPNAME.dap \ + -cti $_CHIPNAME.a53_cti.3 -dbgbase [lindex $_A53_DBGBASE 3] -defer-examine + +# 2x Cortex-A72 on AP #6 +set _A72_DBGBASE {0x80210000 0x80310000} +set _A72_CTIBASE {0x80220000 0x80220000} + +cti create $_CHIPNAME.a72_cti.0 -dap $_CHIPNAME.dap \ + -ap-num 6 -baseaddr [lindex $_A72_CTIBASE 0] +cti create $_CHIPNAME.a72_cti.1 -dap $_CHIPNAME.dap \ + -ap-num 6 -baseaddr [lindex $_A72_CTIBASE 1] +target create $_CHIPNAME.a72.0 aarch64 -dap $_CHIPNAME.dap \ + -cti $_CHIPNAME.a72_cti.0 -dbgbase [lindex $_A72_DBGBASE 0] -defer-examine +target create $_CHIPNAME.a72.1 aarch64 -dap $_CHIPNAME.dap \ + -cti $_CHIPNAME.a72_cti.1 -dbgbase [lindex $_A72_DBGBASE 1] -defer-examine + +# All Cortex-A in SMP +target smp \ + $_CHIPNAME.a53.0 \ + $_CHIPNAME.a53.1 \ + $_CHIPNAME.a53.2 \ + $_CHIPNAME.a53.3 \ + $_CHIPNAME.a72.0 \ + $_CHIPNAME.a72.1 + +# SCU: Cortex-M4 core +# always running imx SC firmware +target create ${_CHIPNAME}.scu cortex_m -dap ${_CHIPNAME}.dap -ap-num 1 + +# AHB from SCU perspective +target create ${_CHIPNAME}.scu_ahb mem_ap -dap ${_CHIPNAME}.dap -ap-num 4 + +# Cortex-M4 M4_0 core on AP #2 (default off) +target create ${_CHIPNAME}.m4_0 cortex_m -dap ${_CHIPNAME}.dap -ap-num 2 \ + -defer-examine + +# Cortex-M4 M4_1 core on AP #3 (default off) +target create ${_CHIPNAME}.m4_1 cortex_m -dap ${_CHIPNAME}.dap -ap-num 3 \ + -defer-examine + +# Debug APB bus +target create ${_CHIPNAME}.apb mem_ap -dap ${_CHIPNAME}.dap -ap-num 6 + +# Default target is boot core a53.0 +targets $_CHIPNAME.a53.0 ----------------------------------------------------------------------- Summary of changes: tcl/target/imx8qm.cfg | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 tcl/target/imx8qm.cfg hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-22 12:07:23
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 41a6089504823433817ea67d9af3d2d85f402336 (commit) via dc277057f57780354278cdc4876d393735f49369 (commit) from ff755a575ebf0218c2eb8745eff8050f8f02a53d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 41a6089504823433817ea67d9af3d2d85f402336 Author: Marc Schink <de...@za...> Date: Mon Apr 12 18:54:16 2021 +0200 flash/nor/nrf5: Fix data types and const correctness Change-Id: I8c5bac7098d92e9b3bd1b045735879cf32ac218d Signed-off-by: Marc Schink <de...@za...> Reviewed-on: http://openocd.zylin.com/6163 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/src/flash/nor/nrf5.c b/src/flash/nor/nrf5.c index 1784bcde5..12bbac64f 100644 --- a/src/flash/nor/nrf5.c +++ b/src/flash/nor/nrf5.c @@ -289,7 +289,7 @@ static const struct nrf5_device_package nrf5_packages_table[] = { const struct flash_driver nrf5_flash, nrf51_flash; -static int nrf5_bank_is_probed(struct flash_bank *bank) +static bool nrf5_bank_is_probed(const struct flash_bank *bank) { struct nrf5_bank *nbank = bank->driver_priv; @@ -309,13 +309,10 @@ static int nrf5_get_probed_chip_if_halted(struct flash_bank *bank, struct nrf5_i struct nrf5_bank *nbank = bank->driver_priv; *chip = nbank->chip; - int probed = nrf5_bank_is_probed(bank); - if (probed < 0) - return probed; - else if (!probed) - return nrf5_probe(bank); - else + if (nrf5_bank_is_probed(bank)) return ERROR_OK; + + return nrf5_probe(bank); } static int nrf5_wait_for_nvmc(struct nrf5_info *chip) @@ -872,14 +869,10 @@ static int nrf5_probe(struct flash_bank *bank) static int nrf5_auto_probe(struct flash_bank *bank) { - int probed = nrf5_bank_is_probed(bank); - - if (probed < 0) - return probed; - else if (probed) + if (nrf5_bank_is_probed(bank)) return ERROR_OK; - else - return nrf5_probe(bank); + + return nrf5_probe(bank); } static int nrf5_erase_all(struct nrf5_info *chip) commit dc277057f57780354278cdc4876d393735f49369 Author: Marc Schink <de...@za...> Date: Sun Apr 11 21:36:00 2021 +0200 flash/nor/numicro: Use 'bool' data type Change-Id: Ib4ee64dec9c1253ae45bc58e9f175ab36964180a Signed-off-by: Marc Schink <de...@za...> Reviewed-on: http://openocd.zylin.com/6162 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/flash/nor/numicro.c b/src/flash/nor/numicro.c index 1971daa24..d9ea16d27 100644 --- a/src/flash/nor/numicro.c +++ b/src/flash/nor/numicro.c @@ -1132,7 +1132,7 @@ static const struct numicro_cpu_type NuMicroParts[] = { /* Private bank information for NuMicro. */ struct numicro_flash_bank { struct working_area *write_algorithm; - int probed; + bool probed; const struct numicro_cpu_type *cpu; }; ----------------------------------------------------------------------- Summary of changes: src/flash/nor/nrf5.c | 21 +++++++-------------- src/flash/nor/numicro.c | 2 +- 2 files changed, 8 insertions(+), 15 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-18 20:23:03
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via ff755a575ebf0218c2eb8745eff8050f8f02a53d (commit) from 80970811f4558b610792b01d37740be8af4258f6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ff755a575ebf0218c2eb8745eff8050f8f02a53d Author: Tomas Vanek <va...@fb...> Date: Tue Apr 6 18:55:22 2021 +0200 drivers/cmsis-dap: flush read Some CMSIS-DAP adapters keep buffered packets over USB close/open so we need to flush up to 64 old packets to be sure all buffers are empty. Flush just after cmsis_dap_open() and in the case of command mismatch. Change-Id: If21a118639e64d90635b4ecf81013d29a7b9f78d Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: http://openocd.zylin.com/6135 Tested-by: jenkins Reviewed-by: Adrian M Negreanu <adr...@nx...> diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index b5ceb6cef..6ab087598 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -281,6 +281,21 @@ static void cmsis_dap_close(struct cmsis_dap *dap) } } +static void cmsis_dap_flush_read(struct cmsis_dap *dap) +{ + unsigned int i; + /* Some CMSIS-DAP adapters keep buffered packets over + * USB close/open so we need to flush up to 64 old packets + * to be sure all buffers are empty */ + for (i = 0; i < 64; i++) { + int retval = dap->backend->read(dap, 10); + if (retval == ERROR_TIMEOUT_REACHED) + break; + } + if (i) + LOG_DEBUG("Flushed %u packets", i); +} + /* Send a message and receive the reply */ static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen) { @@ -313,6 +328,8 @@ static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen) if (resp[0] != current_cmd) { LOG_ERROR("CMSIS-DAP command mismatch. Sent 0x%" PRIx8 " received 0x%" PRIx8, current_cmd, resp[0]); + + cmsis_dap_flush_read(dap); return ERROR_FAIL; } @@ -885,6 +902,8 @@ static int cmsis_dap_init(void) if (retval != ERROR_OK) return retval; + cmsis_dap_flush_read(cmsis_dap_handle); + retval = cmsis_dap_get_caps_info(); if (retval != ERROR_OK) return retval; ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/cmsis_dap.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-18 20:22:12
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 80970811f4558b610792b01d37740be8af4258f6 (commit) from d3a687432f96d90fdaa7c1264cf2c17df3ad58c1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 80970811f4558b610792b01d37740be8af4258f6 Author: Tomas Vanek <va...@fb...> Date: Sat Mar 20 19:04:15 2021 +0100 drivers/cmsis-dap: improve error checking Check returned HID report number (or the first byte of returned bulk packet) which should be equal to the issued command or 0xff in case of the command is not implemented. Fix error return paths in cmsis_dap_init() to clean up the adapter connection. Don't fail cmsis_dap_init() when an unimportant function fails (for the case the adapter doesn't implement some parts of protocol). Change-Id: Ief8382aabe9915346b2273702fb2ff17bbb5eb1b Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: http://openocd.zylin.com/6121 Tested-by: jenkins Reviewed-by: Peter Lawrence <maj...@gm...> diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index eb973642c..b5ceb6cef 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -221,6 +221,8 @@ static uint8_t output_pins = SWJ_PIN_SRST | SWJ_PIN_TRST; static struct cmsis_dap *cmsis_dap_handle; +static int cmsis_dap_quit(void); + static int cmsis_dap_open(void) { const struct cmsis_dap_backend *backend = NULL; @@ -292,6 +294,7 @@ static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen) pending_fifo_get_idx = 0; } + uint8_t current_cmd = cmsis_dap_handle->command[0]; int retval = dap->backend->write(dap, txlen, USB_TIMEOUT); if (retval < 0) return retval; @@ -301,6 +304,18 @@ static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen) if (retval < 0) return retval; + uint8_t *resp = cmsis_dap_handle->response; + if (resp[0] == DAP_ERROR) { + LOG_ERROR("CMSIS-DAP command 0x%" PRIx8 " not implemented", current_cmd); + return ERROR_NOT_IMPLEMENTED; + } + + if (resp[0] != current_cmd) { + LOG_ERROR("CMSIS-DAP command mismatch. Sent 0x%" PRIx8 + " received 0x%" PRIx8, current_cmd, resp[0]); + return ERROR_FAIL; + } + return ERROR_OK; } @@ -605,6 +620,13 @@ static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, int timeout_ms) } uint8_t *resp = dap->response; + if (resp[0] != CMD_DAP_TFER) { + LOG_ERROR("CMSIS-DAP command mismatch. Expected 0x%" PRIx8 + " received 0x%" PRIx8, CMD_DAP_TFER, resp[0]); + queued_retval = ERROR_FAIL; + goto skip; + } + uint8_t transfer_count = resp[1]; uint8_t ack = resp[2] & 0x07; if (resp[2] & 0x08) { @@ -616,6 +638,7 @@ static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, int timeout_ms) LOG_DEBUG("SWD ack not OK @ %d %s", transfer_count, ack == SWD_ACK_WAIT ? "WAIT" : ack == SWD_ACK_FAULT ? "FAULT" : "JUNK"); queued_retval = ack == SWD_ACK_WAIT ? ERROR_WAIT : ERROR_FAIL; + /* TODO: use results of transfers completed before the error occurred? */ goto skip; } @@ -900,7 +923,7 @@ static int cmsis_dap_init(void) /* INFO_ID_PKT_SZ - short */ retval = cmsis_dap_cmd_DAP_Info(INFO_ID_PKT_SZ, &data); if (retval != ERROR_OK) - return retval; + goto init_err; if (data[0] == 2) { /* short */ uint16_t pkt_sz = data[1] + (data[2] << 8); @@ -914,7 +937,7 @@ static int cmsis_dap_init(void) free(cmsis_dap_handle->packet_buffer); retval = cmsis_dap_handle->backend->packet_buffer_alloc(cmsis_dap_handle, pkt_sz); if (retval != ERROR_OK) - return retval; + goto init_err; LOG_DEBUG("CMSIS-DAP: Packet Size = %" PRIu16, pkt_sz); } @@ -923,7 +946,7 @@ static int cmsis_dap_init(void) /* INFO_ID_PKT_CNT - byte */ retval = cmsis_dap_cmd_DAP_Info(INFO_ID_PKT_CNT, &data); if (retval != ERROR_OK) - return retval; + goto init_err; if (data[0] == 1) { /* byte */ int pkt_cnt = data[1]; @@ -938,43 +961,40 @@ static int cmsis_dap_init(void) pending_fifo[i].transfers = malloc(pending_queue_len * sizeof(struct pending_transfer_result)); if (!pending_fifo[i].transfers) { LOG_ERROR("Unable to allocate memory for CMSIS-DAP queue"); - return ERROR_FAIL; + retval = ERROR_FAIL; + goto init_err; } } - - retval = cmsis_dap_get_status(); - if (retval != ERROR_OK) - return ERROR_FAIL; + /* Intentionally not checked for error, just logs an info message + * not vital for further debugging */ + (void)cmsis_dap_get_status(); /* Now try to connect to the target * TODO: This is all SWD only @ present */ retval = cmsis_dap_cmd_DAP_SWJ_Clock(jtag_get_speed_khz()); if (retval != ERROR_OK) - return ERROR_FAIL; + goto init_err; /* Ask CMSIS-DAP to automatically retry on receiving WAIT for * up to 64 times. This must be changed to 0 if sticky * overrun detection is enabled. */ retval = cmsis_dap_cmd_DAP_TFER_Configure(0, 64, 0); if (retval != ERROR_OK) - return ERROR_FAIL; + goto init_err; if (swd_mode) { /* Data Phase (bit 2) must be set to 1 if sticky overrun * detection is enabled */ retval = cmsis_dap_cmd_DAP_SWD_Configure(0); /* 1 TRN, no Data Phase */ if (retval != ERROR_OK) - return ERROR_FAIL; + goto init_err; } /* Both LEDs on */ - retval = cmsis_dap_cmd_DAP_LED(LED_ID_CONNECT, LED_ON); - if (retval != ERROR_OK) - return ERROR_FAIL; - - retval = cmsis_dap_cmd_DAP_LED(LED_ID_RUN, LED_ON); - if (retval != ERROR_OK) - return ERROR_FAIL; + /* Intentionally not checked for error, debugging will work + * without LEDs */ + (void)cmsis_dap_cmd_DAP_LED(LED_ID_CONNECT, LED_ON); + (void)cmsis_dap_cmd_DAP_LED(LED_ID_RUN, LED_ON); /* support connecting with srst asserted */ enum reset_types jtag_reset_config = jtag_get_reset_config(); @@ -983,13 +1003,16 @@ static int cmsis_dap_init(void) if (jtag_reset_config & RESET_SRST_NO_GATING) { retval = cmsis_dap_cmd_DAP_SWJ_Pins(0, SWJ_PIN_SRST, 0, NULL); if (retval != ERROR_OK) - return ERROR_FAIL; + goto init_err; LOG_INFO("Connecting under reset"); } } LOG_INFO("CMSIS-DAP: Interface ready"); - return ERROR_OK; + +init_err: + cmsis_dap_quit(); + return retval; } static int cmsis_dap_swd_init(void) ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/cmsis_dap.c | 63 ++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 20 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-18 14:36:29
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via d3a687432f96d90fdaa7c1264cf2c17df3ad58c1 (commit) from 6b5e77ada6520398f9a2135e43e60067bc072e27 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d3a687432f96d90fdaa7c1264cf2c17df3ad58c1 Author: Antonio Borneo <bor...@gm...> Date: Mon Aug 3 23:03:46 2020 +0200 helper/command: rename s/command_unknown/jim_command_dispatch/ The function's name was consistent with its purpose to handle commands that were not at root level, thus not directly 'known' by jimtcl. Rename it as jim_command_dispatch() to highlight that now it is a jim_handler and its purpose is to dispatch the call to the proper command handler. Change-Id: I9491a6d6459b8eb37a6c402abcae08388c693764 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5791 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index a7990d4f8..80e297b1f 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -51,7 +51,7 @@ struct log_capture_state { static int unregister_command(struct command_context *context, const char *cmd_prefix, const char *name); -static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj * const *argv); +static int jim_command_dispatch(Jim_Interp *interp, int argc, Jim_Obj * const *argv); static int help_add_command(struct command_context *cmd_ctx, const char *cmd_name, const char *help_text, const char *usage_text); static int help_del_command(struct command_context *cmd_ctx, const char *cmd_name); @@ -64,7 +64,7 @@ static inline bool jimcmd_is_proc(Jim_Cmd *cmd) static inline bool jimcmd_is_ocd_command(Jim_Cmd *cmd) { - return !cmd->isproc && cmd->u.native.cmdProc == command_unknown; + return !cmd->isproc && cmd->u.native.cmdProc == jim_command_dispatch; } static inline void *jimcmd_privdata(Jim_Cmd *cmd) @@ -340,7 +340,7 @@ static struct command *register_command(struct command_context *context, LOG_DEBUG("registering '%s'...", full_name); int retval = Jim_CreateCommand(context->interp, full_name, - command_unknown, c, command_free); + jim_command_dispatch, c, command_free); if (retval != JIM_OK) { command_run_linef(context, "del_help_text {%s}", full_name); command_run_linef(context, "del_usage_text {%s}", full_name); @@ -942,7 +942,7 @@ static int exec_command(Jim_Interp *interp, struct command_context *cmd_ctx, return command_retval_set(interp, retval); } -static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv) +static int jim_command_dispatch(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { script_debug(interp, argc, argv); @@ -982,7 +982,7 @@ static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv) * current_target_override is used also for event handlers * therefore we prevent touching it if command has no prefix. * Previous override is saved and restored back to ensure - * correct work when command_unknown() is re-entered. + * correct work when jim_command_dispatch() is re-entered. */ struct target *saved_target_override = cmd_ctx->current_target_override; if (c->jim_override_target) ----------------------------------------------------------------------- Summary of changes: src/helper/command.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-18 14:35:55
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 6b5e77ada6520398f9a2135e43e60067bc072e27 (commit) via fa23b1a71e4f1974791e90055c301f9bf124e835 (commit) via a7d68878e4ba5dfd5ca15c058980cf6c5fc55208 (commit) via d8d24f3b3696f5d2e64a67df87684132b48031d2 (commit) from f238337c9c2fdabb48992487e5243d03d32e215d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6b5e77ada6520398f9a2135e43e60067bc072e27 Author: Antonio Borneo <bor...@gm...> Date: Wed May 13 16:51:00 2020 +0200 helper/command: make script_debug() static Now that all commands are executed through the common handler command_unknown(), the message about command execution is logged by command_unknown(). There is no need, for "native" commands (.jim_handler) at root level to log the message (again) by itself. Remove calls to script_debug() apart from command_unknown(). Make script_debug() static as only used in command.c. Change-Id: I9b2728b69e7643d6121c4b35a96bc825bcb5488d Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5676 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index 630630f38..a7990d4f8 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -180,7 +180,7 @@ extern struct command_context *global_cmd_ctx; /* dump a single line to the log for the command. * Do nothing in case we are not at debug level 3 */ -void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * const *argv) +static void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * const *argv) { if (debug_level < LOG_LVL_DEBUG) return; diff --git a/src/helper/command.h b/src/helper/command.h index 1f2dc5b59..68f4c14fe 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -456,6 +456,4 @@ COMMAND_HELPER(handle_command_parse_bool, bool *out, const char *label); #define COMMAND_PARSE_ENABLE(in, out) \ COMMAND_PARSE_BOOL(in, out, "enable", "disable") -void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * const *argv); - #endif /* OPENOCD_HELPER_COMMAND_H */ diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index bf65e8119..3e7333515 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -108,8 +108,6 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args endstate = TAP_IDLE; - script_debug(interp, argc, args); - /* validate arguments as numbers */ e = JIM_OK; for (i = 2; i < argc; i += 2) { @@ -234,8 +232,6 @@ static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *ar return JIM_ERR; } - script_debug(interp, argc, args); - int i; for (i = 0; i < argc-1; i++) { const char *cp; @@ -266,8 +262,6 @@ static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *ar static int Jim_Command_flush_count(Jim_Interp *interp, int argc, Jim_Obj *const *args) { - script_debug(interp, argc, args); - Jim_SetResult(interp, Jim_NewIntObj(interp, jtag_get_flush_queue_count())); return JIM_OK; commit fa23b1a71e4f1974791e90055c301f9bf124e835 Author: Antonio Borneo <bor...@gm...> Date: Mon May 25 16:09:12 2020 +0200 helper/command: get rid of the tree of struct command There is no need anymore to keep alive the tree of struct command. Remove it and let jim to free() the command's struct command that is referenced through command's private data. Change-Id: I2cd84e0274a969ce200320e3a177ac20c7823da0 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5675 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index d79d7f464..630630f38 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -50,8 +50,7 @@ struct log_capture_state { }; static int unregister_command(struct command_context *context, - struct command *parent, const char *name); -static char *command_name(struct command *c, char delim); + const char *cmd_prefix, const char *name); static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj * const *argv); static int help_add_command(struct command_context *cmd_ctx, const char *cmd_name, const char *help_text, const char *usage_text); @@ -263,68 +262,8 @@ static struct command *command_find_from_name(Jim_Interp *interp, const char *na return jimcmd_privdata(cmd); } -/** - * Find a command by name from a list of commands. - * @returns Returns the named command if it exists in the list. - * Returns NULL otherwise. - */ -static struct command *command_find(struct command *head, const char *name) -{ - for (struct command *cc = head; cc; cc = cc->next) { - if (strcmp(cc->name, name) == 0) - return cc; - } - return NULL; -} - -/** - * Add the command into the linked list, sorted by name. - * @param head Address to head of command list pointer, which may be - * updated if @c c gets inserted at the beginning of the list. - * @param c The command to add to the list pointed to by @c head. - */ -static void command_add_child(struct command **head, struct command *c) -{ - assert(head); - if (NULL == *head) { - *head = c; - return; - } - - while ((*head)->next && (strcmp(c->name, (*head)->name) > 0)) - head = &(*head)->next; - - if (strcmp(c->name, (*head)->name) > 0) { - c->next = (*head)->next; - (*head)->next = c; - } else { - c->next = *head; - *head = c; - } -} - -static struct command **command_list_for_parent( - struct command_context *cmd_ctx, struct command *parent) -{ - return parent ? &parent->children : &cmd_ctx->commands; -} - -static void command_free(struct command *c) -{ - /** @todo if command has a handler, unregister its jim command! */ - - while (NULL != c->children) { - struct command *tmp = c->children; - c->children = tmp->next; - command_free(tmp); - } - - free(c->name); - free(c); -} - static struct command *command_new(struct command_context *cmd_ctx, - struct command *parent, const struct command_registration *cr) + const char *full_name, const struct command_registration *cr) { assert(cr->name); @@ -335,76 +274,86 @@ static struct command *command_new(struct command_context *cmd_ctx, * strlen(.usage) == 0 means that the command takes no * arguments. */ - if ((cr->jim_handler == NULL) && (cr->usage == NULL)) { - LOG_ERROR("BUG: command '%s%s%s' does not have the " + if (!cr->jim_handler && !cr->usage) + LOG_ERROR("BUG: command '%s' does not have the " "'.usage' field filled out", - parent && parent->name ? parent->name : "", - parent && parent->name ? " " : "", - cr->name); - } + full_name); struct command *c = calloc(1, sizeof(struct command)); if (NULL == c) return NULL; c->name = strdup(cr->name); - if (!c->name) - goto command_new_error; + if (!c->name) { + free(c); + return NULL; + } - c->parent = parent; c->handler = cr->handler; c->jim_handler = cr->jim_handler; c->mode = cr->mode; - command_add_child(command_list_for_parent(cmd_ctx, parent), c); - - if (cr->help || cr->usage) { - char *full_name = command_name(c, ' '); + if (cr->help || cr->usage) help_add_command(cmd_ctx, full_name, cr->help, cr->usage); - free(full_name); - } return c; +} + +static void command_free(struct Jim_Interp *interp, void *priv) +{ + struct command *c = priv; -command_new_error: - command_free(c); - return NULL; + free(c->name); + free(c); } static struct command *register_command(struct command_context *context, - struct command *parent, const struct command_registration *cr) + const char *cmd_prefix, const struct command_registration *cr) { + char *full_name; + if (!context || !cr->name) return NULL; - const char *name = cr->name; - struct command **head = command_list_for_parent(context, parent); - struct command *c = command_find(*head, name); - if (NULL != c) { + if (cmd_prefix) + full_name = alloc_printf("%s %s", cmd_prefix, cr->name); + else + full_name = strdup(cr->name); + if (!full_name) + return NULL; + + struct command *c = command_find_from_name(context->interp, full_name); + if (c) { /* TODO: originally we treated attempting to register a cmd twice as an error * Sometimes we need this behaviour, such as with flash banks. * http://www.mail-archive.com/ope...@li.../msg11152.html */ - LOG_DEBUG("command '%s' is already registered in '%s' context", - name, parent ? parent->name : "<global>"); + LOG_DEBUG("command '%s' is already registered", full_name); + free(full_name); return c; } - c = command_new(context, parent, cr); - if (NULL == c) + c = command_new(context, full_name, cr); + if (!c) { + free(full_name); return NULL; + } - char *full_name = command_name(c, ' '); LOG_DEBUG("registering '%s'...", full_name); int retval = Jim_CreateCommand(context->interp, full_name, - command_unknown, c, NULL); + command_unknown, c, command_free); if (retval != JIM_OK) { - unregister_command(context, parent, name); + command_run_linef(context, "del_help_text {%s}", full_name); + command_run_linef(context, "del_usage_text {%s}", full_name); + free(c); + free(full_name); return NULL; } + + free(full_name); return c; } -static int ___register_commands(struct command_context *cmd_ctx, struct command *parent, +int __register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds, void *data, struct target *override_target) { @@ -415,7 +364,7 @@ static int ___register_commands(struct command_context *cmd_ctx, struct command struct command *c = NULL; if (NULL != cr->name) { - c = register_command(cmd_ctx, parent, cr); + c = register_command(cmd_ctx, cmd_prefix, cr); if (NULL == c) { retval = ERROR_FAIL; break; @@ -424,31 +373,32 @@ static int ___register_commands(struct command_context *cmd_ctx, struct command c->jim_override_target = override_target; } if (NULL != cr->chain) { - struct command *p = c ? : parent; - retval = ___register_commands(cmd_ctx, p, cr->chain, data, override_target); + if (cr->name) { + if (cmd_prefix) { + char *new_prefix = alloc_printf("%s %s", cmd_prefix, cr->name); + if (!new_prefix) { + retval = ERROR_FAIL; + break; + } + retval = __register_commands(cmd_ctx, new_prefix, cr->chain, data, override_target); + free(new_prefix); + } else { + retval = __register_commands(cmd_ctx, cr->name, cr->chain, data, override_target); + } + } else { + retval = __register_commands(cmd_ctx, cmd_prefix, cr->chain, data, override_target); + } if (ERROR_OK != retval) break; } } if (ERROR_OK != retval) { for (unsigned j = 0; j < i; j++) - unregister_command(cmd_ctx, parent, cmds[j].name); + unregister_command(cmd_ctx, cmd_prefix, cmds[j].name); } return retval; } -int __register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, - const struct command_registration *cmds, void *data, - struct target *override_target) -{ - struct command *parent = NULL; - - if (cmd_prefix) - parent = command_find(cmd_ctx->commands, cmd_prefix); - - return ___register_commands(cmd_ctx, parent, cmds, data, override_target); -} - static __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3))) int unregister_commands_match(struct command_context *cmd_ctx, const char *format, ...) { @@ -501,68 +451,29 @@ int unregister_commands_match(struct command_context *cmd_ctx, const char *forma int unregister_all_commands(struct command_context *context, const char *cmd_prefix) { - struct command *parent = NULL; - if (!context) return ERROR_OK; - if (!cmd_prefix || !*cmd_prefix) { - int retval = unregister_commands_match(context, "*"); - if (retval != ERROR_OK) - return retval; - } else { - Jim_Cmd *cmd = Jim_GetCommand(context->interp, Jim_NewStringObj(context->interp, cmd_prefix, -1), JIM_NONE); - if (cmd && jimcmd_is_ocd_command(cmd)) - parent = jimcmd_privdata(cmd); - - int retval = unregister_commands_match(context, "%s *", cmd_prefix); - if (retval != ERROR_OK) - return retval; - retval = unregister_commands_match(context, "%s", cmd_prefix); - if (retval != ERROR_OK) - return retval; - } + if (!cmd_prefix || !*cmd_prefix) + return unregister_commands_match(context, "*"); - struct command **head = command_list_for_parent(context, parent); - while (NULL != *head) { - struct command *tmp = *head; - *head = tmp->next; - command_free(tmp); - } + int retval = unregister_commands_match(context, "%s *", cmd_prefix); + if (retval != ERROR_OK) + return retval; - return ERROR_OK; + return unregister_commands_match(context, "%s", cmd_prefix); } static int unregister_command(struct command_context *context, - struct command *parent, const char *name) + const char *cmd_prefix, const char *name) { - if ((!context) || (!name)) + if (!context || !name) return ERROR_COMMAND_SYNTAX_ERROR; - struct command *p = NULL; - struct command **head = command_list_for_parent(context, parent); - for (struct command *c = *head; NULL != c; p = c, c = c->next) { - if (strcmp(name, c->name) != 0) - continue; - - char *full_name = command_name(c, ' '); - - int retval = unregister_commands_match(context, "%s", full_name); - if (retval != ERROR_OK) - return retval; - - free(full_name); - - if (p) - p->next = c->next; - else - *head = c->next; - - command_free(c); - return ERROR_OK; - } + if (!cmd_prefix || !*cmd_prefix) + return unregister_commands_match(context, "%s", name); - return ERROR_OK; + return unregister_commands_match(context, "%s %s", cmd_prefix, name); } void command_output_text(struct command_context *context, const char *data) @@ -619,33 +530,6 @@ void command_print(struct command_invocation *cmd, const char *format, ...) va_end(ap); } -static char *__command_name(struct command *c, char delim, unsigned extra) -{ - char *name; - unsigned len = strlen(c->name); - if (NULL == c->parent) { - /* allocate enough for the name, child names, and '\0' */ - name = malloc(len + extra + 1); - if (!name) { - LOG_ERROR("Out of memory"); - return NULL; - } - strcpy(name, c->name); - } else { - /* parent's extra must include both the space and name */ - name = __command_name(c->parent, delim, 1 + len + extra); - char dstr[2] = { delim, 0 }; - strcat(name, dstr); - strcat(name, c->name); - } - return name; -} - -static char *command_name(struct command *c, char delim) -{ - return __command_name(c, delim, 0); -} - static bool command_can_run(struct command_context *cmd_ctx, struct command *c, const char *full_name) { if (c->mode == COMMAND_ANY || c->mode == cmd_ctx->mode) diff --git a/src/helper/command.h b/src/helper/command.h index 4d1928c5a..1f2dc5b59 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -54,7 +54,6 @@ typedef int (*command_output_handler_t)(struct command_context *context, struct command_context { Jim_Interp *interp; enum command_mode mode; - struct command *commands; struct target *current_target; /* The target set by 'targets xx' command or the latest created */ struct target *current_target_override; @@ -182,8 +181,6 @@ typedef __COMMAND_HANDLER((*command_handler_t)); struct command { char *name; - struct command *parent; - struct command *children; command_handler_t handler; Jim_CmdProc *jim_handler; void *jim_handler_data; @@ -191,7 +188,6 @@ struct command { struct target *jim_override_target; /* Used only for target of target-prefixed cmd */ enum command_mode mode; - struct command *next; }; /* commit a7d68878e4ba5dfd5ca15c058980cf6c5fc55208 Author: Antonio Borneo <bor...@gm...> Date: Wed May 13 15:35:19 2020 +0200 helper/command: unregister commands through their full-name While keeping the struct command in place, unregister the jim commands by scanning the list of jim commands through their full-name. Change-Id: I0e903fbc31172858b703d67ccd471809c7949e86 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5674 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index 5cddf2150..d79d7f464 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -243,6 +243,26 @@ struct command_context *current_command_context(Jim_Interp *interp) return cmd_ctx; } +/** + * Find a openocd command from fullname. + * @returns Returns the named command if it is registred in interp. + * Returns NULL otherwise. + */ +static struct command *command_find_from_name(Jim_Interp *interp, const char *name) +{ + if (!name) + return NULL; + + Jim_Obj *jim_name = Jim_NewStringObj(interp, name, -1); + Jim_IncrRefCount(jim_name); + Jim_Cmd *cmd = Jim_GetCommand(interp, jim_name, JIM_NONE); + Jim_DecrRefCount(interp, jim_name); + if (!cmd || jimcmd_is_proc(cmd) || !jimcmd_is_ocd_command(cmd)) + return NULL; + + return jimcmd_privdata(cmd); +} + /** * Find a command by name from a list of commands. * @returns Returns the named command if it exists in the list. @@ -429,12 +449,80 @@ int __register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, return ___register_commands(cmd_ctx, parent, cmds, data, override_target); } +static __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3))) +int unregister_commands_match(struct command_context *cmd_ctx, const char *format, ...) +{ + Jim_Interp *interp = cmd_ctx->interp; + va_list ap; + + va_start(ap, format); + char *query = alloc_vprintf(format, ap); + va_end(ap); + if (!query) + return ERROR_FAIL; + + char *query_cmd = alloc_printf("info commands {%s}", query); + free(query); + if (!query_cmd) + return ERROR_FAIL; + + int retval = Jim_EvalSource(interp, __THIS__FILE__, __LINE__, query_cmd); + free(query_cmd); + if (retval != JIM_OK) + return ERROR_FAIL; + + Jim_Obj *list = Jim_GetResult(interp); + Jim_IncrRefCount(list); + + int len = Jim_ListLength(interp, list); + for (int i = 0; i < len; i++) { + Jim_Obj *elem = Jim_ListGetIndex(interp, list, i); + Jim_IncrRefCount(elem); + + const char *name = Jim_GetString(elem, NULL); + struct command *c = command_find_from_name(interp, name); + if (!c) { + /* not openocd command */ + Jim_DecrRefCount(interp, elem); + continue; + } + LOG_DEBUG("delete command \"%s\"", name); + Jim_DeleteCommand(interp, elem); + + help_del_command(cmd_ctx, name); + + Jim_DecrRefCount(interp, elem); + } + + Jim_DecrRefCount(interp, list); + return ERROR_OK; +} + int unregister_all_commands(struct command_context *context, - struct command *parent) + const char *cmd_prefix) { - if (context == NULL) + struct command *parent = NULL; + + if (!context) return ERROR_OK; + if (!cmd_prefix || !*cmd_prefix) { + int retval = unregister_commands_match(context, "*"); + if (retval != ERROR_OK) + return retval; + } else { + Jim_Cmd *cmd = Jim_GetCommand(context->interp, Jim_NewStringObj(context->interp, cmd_prefix, -1), JIM_NONE); + if (cmd && jimcmd_is_ocd_command(cmd)) + parent = jimcmd_privdata(cmd); + + int retval = unregister_commands_match(context, "%s *", cmd_prefix); + if (retval != ERROR_OK) + return retval; + retval = unregister_commands_match(context, "%s", cmd_prefix); + if (retval != ERROR_OK) + return retval; + } + struct command **head = command_list_for_parent(context, parent); while (NULL != *head) { struct command *tmp = *head; @@ -458,7 +546,11 @@ static int unregister_command(struct command_context *context, continue; char *full_name = command_name(c, ' '); - help_del_command(context, full_name); + + int retval = unregister_commands_match(context, "%s", full_name); + if (retval != ERROR_OK) + return retval; + free(full_name); if (p) diff --git a/src/helper/command.h b/src/helper/command.h index db095972a..4d1928c5a 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -311,11 +311,11 @@ static inline int register_commands_with_data(struct command_context *cmd_ctx, /** * Unregisters all commands from the specified context. * @param cmd_ctx The context that will be cleared of registered commands. - * @param parent If given, only clear commands from under this one command. + * @param cmd_prefix If given, only clear commands from under this one command. * @returns ERROR_OK on success, or an error code. */ int unregister_all_commands(struct command_context *cmd_ctx, - struct command *parent); + const char *cmd_prefix); /** * Unregisters the help for all commands. Used at exit to remove the help commit d8d24f3b3696f5d2e64a67df87684132b48031d2 Author: Antonio Borneo <bor...@gm...> Date: Sun May 10 17:48:25 2020 +0200 helper/command: simplify jim_command_mode() Now that every command has struct command as private data, use jim to get access to the struct command to read the command mode, instead of running through the tree of struct command. Change-Id: Iddacdbac604714f6abe38a050daad245bdcfd20c Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5673 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index 1628b6ee7..5cddf2150 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -52,16 +52,27 @@ struct log_capture_state { static int unregister_command(struct command_context *context, struct command *parent, const char *name); static char *command_name(struct command *c, char delim); +static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj * const *argv); static int help_add_command(struct command_context *cmd_ctx, const char *cmd_name, const char *help_text, const char *usage_text); static int help_del_command(struct command_context *cmd_ctx, const char *cmd_name); -/* wrap jimtcl internal data */ +/* set of functions to wrap jimtcl internal data */ static inline bool jimcmd_is_proc(Jim_Cmd *cmd) { return cmd->isproc; } +static inline bool jimcmd_is_ocd_command(Jim_Cmd *cmd) +{ + return !cmd->isproc && cmd->u.native.cmdProc == command_unknown; +} + +static inline void *jimcmd_privdata(Jim_Cmd *cmd) +{ + return cmd->isproc ? NULL : cmd->u.native.privData; +} + static void tcl_output(void *privData, const char *file, unsigned line, const char *function, const char *string) { @@ -340,8 +351,6 @@ command_new_error: return NULL; } -static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv); - static struct command *register_command(struct command_context *context, struct command *parent, const struct command_registration *cr) { @@ -914,19 +923,6 @@ COMMAND_HANDLER(handle_help_command) return retval; } -static int command_unknown_find(unsigned argc, Jim_Obj *const *argv, - struct command *head, struct command **out) -{ - if (0 == argc) - return argc; - const char *cmd_name = Jim_GetString(argv[0], NULL); - struct command *c = command_find(head, cmd_name); - if (NULL == c) - return argc; - *out = c; - return command_unknown_find(--argc, ++argv, (*out)->children, out); -} - static char *alloc_concatenate_strings(int argc, Jim_Obj * const *argv) { char *prev, *all; @@ -1038,18 +1034,19 @@ static int jim_command_mode(Jim_Interp *interp, int argc, Jim_Obj *const *argv) Jim_Cmd *cmd = Jim_GetCommand(interp, s, JIM_NONE); Jim_DecrRefCount(interp, s); free(full_name); - if (cmd && jimcmd_is_proc(cmd)) { - Jim_SetResultString(interp, "any", -1); - return JIM_OK; - } - struct command *c = cmd_ctx->commands; - int remaining = command_unknown_find(argc - 1, argv + 1, c, &c); - /* if nothing could be consumed, then it's an unknown command */ - if (remaining == argc - 1) { + if (!cmd || !(jimcmd_is_proc(cmd) || jimcmd_is_ocd_command(cmd))) { Jim_SetResultString(interp, "unknown", -1); return JIM_OK; } - mode = c->mode; + + if (jimcmd_is_proc(cmd)) { + /* tcl proc */ + mode = COMMAND_ANY; + } else { + struct command *c = jimcmd_privdata(cmd); + + mode = c->mode; + } } else mode = cmd_ctx->mode; ----------------------------------------------------------------------- Summary of changes: src/helper/command.c | 333 +++++++++++++++++++++++---------------------------- src/helper/command.h | 10 +- src/jtag/tcl.c | 6 - 3 files changed, 155 insertions(+), 194 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-18 14:35:06
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via f238337c9c2fdabb48992487e5243d03d32e215d (commit) via e216186fab59d71fdee24af926d1807a1d7fc950 (commit) via aacc26559e4984b649083ac046db2cbcb54e2f70 (commit) via cb83bc747ce1106c50d713f6d552da8c3e476e0f (commit) from 41c95aa4ea1506a951dad0147f6cd4b8d7043358 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f238337c9c2fdabb48992487e5243d03d32e215d Author: Antonio Borneo <bor...@gm...> Date: Wed May 13 02:30:11 2020 +0200 helper/command: simplify run_command() Now that the commands are registered using their full-name, the full-name is in argv[0]. Don't rebuild the full-name but use directly argv[0]. Change-Id: Ic9e469ac39276367b8c47527e70791ff470fefbc Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5672 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index 41b86796a..1628b6ee7 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -586,20 +586,13 @@ static int run_command(struct command_context *context, int retval = c->handler(&cmd); if (retval == ERROR_COMMAND_SYNTAX_ERROR) { /* Print help for command */ - char *full_name = command_name(c, ' '); - if (NULL != full_name) { - command_run_linef(context, "usage %s", full_name); - free(full_name); - } + command_run_linef(context, "usage %s", words[0]); } else if (retval == ERROR_COMMAND_CLOSE_CONNECTION) { /* just fall through for a shutdown request */ } else { - if (retval != ERROR_OK) { - char *full_name = command_name(c, ' '); + if (retval != ERROR_OK) LOG_DEBUG("Command '%s' failed with error code %d", - full_name ? full_name : c->name, retval); - free(full_name); - } + words[0], retval); /* Use the command output as the Tcl result */ Jim_SetResult(context->interp, cmd.output); } commit e216186fab59d71fdee24af926d1807a1d7fc950 Author: Antonio Borneo <bor...@gm...> Date: Wed May 13 01:59:59 2020 +0200 helper/command: register full-name commands in jim While still keeping the tree of struct command, stop registering commands in jim by the root "word" only. Register the full-name of the command and pass as private data the struct command of the command itself. Still use the tree of struct command to un-register the commands. Some "native" commands (.jim_handler) share the same handler, then the handler checks the command name to run the right code. Now argv[0] returns the full-name of the command, so check the name by looking in the struct command passed as private data. Change-Id: I5623c61cceee8a75f5d5a551ef3fbf5a303af6be Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5671 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index 3b531807f..41b86796a 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -232,13 +232,6 @@ struct command_context *current_command_context(Jim_Interp *interp) return cmd_ctx; } -static struct command *command_root(struct command *c) -{ - while (NULL != c->parent) - c = c->parent; - return c; -} - /** * Find a command by name from a list of commands. * @returns Returns the named command if it exists in the list. @@ -349,18 +342,6 @@ command_new_error: static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv); -static int register_command_handler(struct command_context *cmd_ctx, - struct command *c) -{ - Jim_Interp *interp = cmd_ctx->interp; - -#if 0 - LOG_DEBUG("registering '%s'...", c->name); -#endif - - return Jim_CreateCommand(interp, c->name, command_unknown, c, NULL); -} - static struct command *register_command(struct command_context *context, struct command *parent, const struct command_registration *cr) { @@ -383,12 +364,13 @@ static struct command *register_command(struct command_context *context, if (NULL == c) return NULL; - if (cr->jim_handler || cr->handler) { - int retval = register_command_handler(context, command_root(c)); - if (retval != JIM_OK) { - unregister_command(context, parent, name); - return NULL; - } + char *full_name = command_name(c, ' '); + LOG_DEBUG("registering '%s'...", full_name); + int retval = Jim_CreateCommand(context->interp, full_name, + command_unknown, c, NULL); + if (retval != JIM_OK) { + unregister_command(context, parent, name); + return NULL; } return c; } @@ -563,7 +545,7 @@ static char *command_name(struct command *c, char delim) return __command_name(c, delim, 0); } -static bool command_can_run(struct command_context *cmd_ctx, struct command *c) +static bool command_can_run(struct command_context *cmd_ctx, struct command *c, const char *full_name) { if (c->mode == COMMAND_ANY || c->mode == cmd_ctx->mode) return true; @@ -582,10 +564,8 @@ static bool command_can_run(struct command_context *cmd_ctx, struct command *c) when = "if Cthulhu is summoned by"; break; } - char *full_name = command_name(c, ' '); LOG_ERROR("The '%s' command must be used %s 'init'.", full_name ? full_name : c->name, when); - free(full_name); return false; } @@ -980,41 +960,8 @@ static char *alloc_concatenate_strings(int argc, Jim_Obj * const *argv) return all; } -static int run_usage(Jim_Interp *interp, int argc_valid, int argc, Jim_Obj * const *argv) -{ - struct command_context *cmd_ctx = current_command_context(interp); - char *command; - int retval; - - assert(argc_valid >= 1); - assert(argc >= argc_valid); - - command = alloc_concatenate_strings(argc_valid, argv); - if (!command) - return JIM_ERR; - - retval = command_run_linef(cmd_ctx, "usage %s", command); - if (retval != ERROR_OK) { - LOG_ERROR("unable to execute command \"usage %s\"", command); - return JIM_ERR; - } - - if (argc_valid == argc) - LOG_ERROR("%s: command requires more arguments", command); - else { - free(command); - command = alloc_concatenate_strings(argc - argc_valid, argv + argc_valid); - if (!command) - return JIM_ERR; - LOG_ERROR("invalid subcommand \"%s\"", command); - } - - free(command); - return retval; -} - static int exec_command(Jim_Interp *interp, struct command_context *cmd_ctx, - struct command *c, int argc, Jim_Obj *const *argv) + struct command *c, int argc, Jim_Obj * const *argv) { if (c->jim_handler) return c->jim_handler(interp, argc, argv); @@ -1034,30 +981,30 @@ static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { script_debug(interp, argc, argv); - struct command_context *cmd_ctx = current_command_context(interp); - struct command *c = cmd_ctx->commands; - int remaining = command_unknown_find(argc, argv, c, &c); - /* if nothing could be consumed, then it's really an unknown command */ - if (remaining == argc) { - const char *cmd = Jim_GetString(argv[0], NULL); - LOG_ERROR("Unknown command:\n %s", cmd); - return JIM_OK; + /* check subcommands */ + if (argc > 1) { + char *s = alloc_printf("%s %s", Jim_GetString(argv[0], NULL), Jim_GetString(argv[1], NULL)); + Jim_Obj *js = Jim_NewStringObj(interp, s, -1); + Jim_IncrRefCount(js); + free(s); + Jim_Cmd *cmd = Jim_GetCommand(interp, js, JIM_NONE); + if (cmd) { + int retval = Jim_EvalObjPrefix(interp, js, argc - 2, argv + 2); + Jim_DecrRefCount(interp, js); + return retval; + } + Jim_DecrRefCount(interp, js); } - Jim_Obj *const *start; - unsigned count; - if (c->handler || c->jim_handler) { - /* include the command name in the list */ - count = remaining + 1; - start = argv + (argc - remaining - 1); - } else { - count = argc - remaining; - start = argv; - run_usage(interp, count, argc, start); + struct command *c = jim_to_command(interp); + if (!c->jim_handler && !c->handler) { + Jim_EvalObjPrefix(interp, Jim_NewStringObj(interp, "usage", -1), 1, argv); return JIM_ERR; } - if (!command_can_run(cmd_ctx, c)) + struct command_context *cmd_ctx = current_command_context(interp); + + if (!command_can_run(cmd_ctx, c, Jim_GetString(argv[0], NULL))) return JIM_ERR; target_call_timer_callbacks_now(); @@ -1076,7 +1023,7 @@ static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv) if (c->jim_override_target) cmd_ctx->current_target_override = c->jim_override_target; - int retval = exec_command(interp, cmd_ctx, c, count, start); + int retval = exec_command(interp, cmd_ctx, c, argc, argv); if (c->jim_override_target) cmd_ctx->current_target_override = saved_target_override; diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 2fa162e56..bf65e8119 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -767,7 +767,8 @@ static bool jtag_tap_disable(struct jtag_tap *t) int jim_jtag_tap_enabler(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - const char *cmd_name = Jim_GetString(argv[0], NULL); + struct command *c = jim_to_command(interp); + const char *cmd_name = c->name; Jim_GetOptInfo goi; Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1); if (goi.argc != 1) { @@ -804,7 +805,8 @@ int jim_jtag_tap_enabler(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int jim_jtag_configure(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - const char *cmd_name = Jim_GetString(argv[0], NULL); + struct command *c = jim_to_command(interp); + const char *cmd_name = c->name; Jim_GetOptInfo goi; Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1); goi.isconfigure = !strcmp(cmd_name, "configure"); diff --git a/src/target/aarch64.c b/src/target/aarch64.c index 46ed49f68..4ba92c8a0 100644 --- a/src/target/aarch64.c +++ b/src/target/aarch64.c @@ -2966,6 +2966,7 @@ COMMAND_HANDLER(aarch64_mask_interrupts_command) static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { + struct command *c = jim_to_command(interp); struct command_context *context; struct target *target; struct arm *arm; @@ -2973,7 +2974,7 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj * const *argv) bool is_mcr = false; int arg_cnt = 0; - if (Jim_CompareStringImmediate(interp, argv[0], "mcr")) { + if (!strcmp(c->name, "mcr")) { is_mcr = true; arg_cnt = 7; } else { diff --git a/src/target/arm_tpiu_swo.c b/src/target/arm_tpiu_swo.c index 186ce5d0e..f93508622 100644 --- a/src/target/arm_tpiu_swo.c +++ b/src/target/arm_tpiu_swo.c @@ -550,16 +550,16 @@ err_no_params: static int jim_arm_tpiu_swo_configure(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { + struct command *c = jim_to_command(interp); Jim_GetOptInfo goi; Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1); - goi.isconfigure = !strcmp(Jim_GetString(argv[0], NULL), "configure"); + goi.isconfigure = !strcmp(c->name, "configure"); if (goi.argc < 1) { Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv, "missing: -option ..."); return JIM_ERR; } - struct command *c = jim_to_command(interp); struct arm_tpiu_swo_object *obj = c->jim_handler_data; return arm_tpiu_swo_configure(&goi, obj); } diff --git a/src/target/target.c b/src/target/target.c index fa033d351..e9d67702e 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5197,10 +5197,11 @@ no_params: static int jim_target_configure(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { + struct command *c = jim_to_command(interp); Jim_GetOptInfo goi; Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1); - goi.isconfigure = !strcmp(Jim_GetString(argv[0], NULL), "configure"); + goi.isconfigure = !strcmp(c->name, "configure"); if (goi.argc < 1) { Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv, "missing: -option ..."); commit aacc26559e4984b649083ac046db2cbcb54e2f70 Author: Antonio Borneo <bor...@gm...> Date: Sat Mar 27 16:12:11 2021 +0100 help: re-implement 'help' independent from tree of struct command The current implementation of "help" related commands is tightly connected to the tree of struct command. The TCL commands 'add_usage_text' and 'add_help_text' have to add fake commands in the tree of struct command to handle the help of TCL procs. Move all the help texts in a list accessible from the struct command_context and register the commands through their full name. Keep the list sorted alphabetically by the command name, so the result of commands 'help' and 'usage' will be sorted too. Remove the associated help and usage during commands un-register, but call help_del_all_commands() for the text added through TCL commands 'add_usage_text' and 'add_help_text'. The resulting help and usage output is not changed by this patch (tested on all the help and usage strings in current master branch). Change-Id: Ifd37bb5bd374cba1a22cd7aac208505b4ae1e6fc Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5670 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index 288ba99aa..3b531807f 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -52,6 +52,9 @@ struct log_capture_state { static int unregister_command(struct command_context *context, struct command *parent, const char *name); static char *command_name(struct command *c, char delim); +static int help_add_command(struct command_context *cmd_ctx, + const char *cmd_name, const char *help_text, const char *usage_text); +static int help_del_command(struct command_context *cmd_ctx, const char *cmd_name); /* wrap jimtcl internal data */ static inline bool jimcmd_is_proc(Jim_Cmd *cmd) @@ -293,8 +296,6 @@ static void command_free(struct command *c) } free(c->name); - free(c->help); - free(c->usage); free(c); } @@ -323,12 +324,7 @@ static struct command *command_new(struct command_context *cmd_ctx, return NULL; c->name = strdup(cr->name); - if (cr->help) - c->help = strdup(cr->help); - if (cr->usage) - c->usage = strdup(cr->usage); - - if (!c->name || (cr->help && !c->help) || (cr->usage && !c->usage)) + if (!c->name) goto command_new_error; c->parent = parent; @@ -338,6 +334,12 @@ static struct command *command_new(struct command_context *cmd_ctx, command_add_child(command_list_for_parent(cmd_ctx, parent), c); + if (cr->help || cr->usage) { + char *full_name = command_name(c, ' '); + help_add_command(cmd_ctx, full_name, cr->help, cr->usage); + free(full_name); + } + return c; command_new_error: @@ -464,6 +466,10 @@ static int unregister_command(struct command_context *context, if (strcmp(name, c->name) != 0) continue; + char *full_name = command_name(c, ' '); + help_del_command(context, full_name); + free(full_name); + if (p) p->next = c->next; else @@ -785,28 +791,22 @@ static int jim_capture(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return retcode; } -static COMMAND_HELPER(command_help_find, struct command *head, - struct command **out) -{ - if (0 == CMD_ARGC) - return ERROR_COMMAND_SYNTAX_ERROR; - *out = command_find(head, CMD_ARGV[0]); - if (NULL == *out) - return ERROR_COMMAND_SYNTAX_ERROR; - if (--CMD_ARGC == 0) - return ERROR_OK; - CMD_ARGV++; - return CALL_COMMAND_HANDLER(command_help_find, (*out)->children, out); -} +struct help_entry { + struct list_head lh; + char *cmd_name; + char *help; + char *usage; +}; -static COMMAND_HELPER(command_help_show, struct command *c, unsigned n, +static COMMAND_HELPER(command_help_show, struct help_entry *c, bool show_help, const char *cmd_match); -static COMMAND_HELPER(command_help_show_list, struct command *head, unsigned n, - bool show_help, const char *cmd_match) +static COMMAND_HELPER(command_help_show_list, bool show_help, const char *cmd_match) { - for (struct command *c = head; NULL != c; c = c->next) - CALL_COMMAND_HANDLER(command_help_show, c, n, show_help, cmd_match); + struct help_entry *entry; + + list_for_each_entry(entry, CMD_CTX->help_list, lh) + CALL_COMMAND_HANDLER(command_help_show, entry, show_help, cmd_match); return ERROR_OK; } @@ -837,26 +837,23 @@ static void command_help_show_wrap(const char *str, unsigned n, unsigned n2) } } -static COMMAND_HELPER(command_help_show, struct command *c, unsigned n, +static COMMAND_HELPER(command_help_show, struct help_entry *c, bool show_help, const char *cmd_match) { - char *cmd_name = command_name(c, ' '); - if (NULL == cmd_name) - return ERROR_FAIL; + unsigned int n = 0; + for (const char *s = strchr(c->cmd_name, ' '); s; s = strchr(s + 1, ' ')) + n++; /* If the match string occurs anywhere, we print out * stuff for this command. */ - bool is_match = (strstr(cmd_name, cmd_match) != NULL) || + bool is_match = (strstr(c->cmd_name, cmd_match) != NULL) || ((c->usage != NULL) && (strstr(c->usage, cmd_match) != NULL)) || ((c->help != NULL) && (strstr(c->help, cmd_match) != NULL)); if (is_match) { command_help_show_indent(n); - LOG_USER_N("%s", cmd_name); - } - free(cmd_name); + LOG_USER_N("%s", c->cmd_name); - if (is_match) { if (c->usage && strlen(c->usage) > 0) { LOG_USER_N(" "); command_help_show_wrap(c->usage, 0, n + 5); @@ -867,11 +864,30 @@ static COMMAND_HELPER(command_help_show, struct command *c, unsigned n, if (is_match && show_help) { char *msg; + /* TODO: factorize jim_command_mode() to avoid running jim command here */ + char *request = alloc_printf("command mode %s", c->cmd_name); + if (!request) { + LOG_ERROR("Out of memory"); + return ERROR_FAIL; + } + int retval = Jim_Eval(CMD_CTX->interp, request); + free(request); + enum command_mode mode = COMMAND_UNKNOWN; + if (retval != JIM_ERR) { + const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), NULL); + if (!strcmp(result, "any")) + mode = COMMAND_ANY; + else if (!strcmp(result, "config")) + mode = COMMAND_CONFIG; + else if (!strcmp(result, "exec")) + mode = COMMAND_EXEC; + } + /* Normal commands are runtime-only; highlight exceptions */ - if (c->mode != COMMAND_EXEC) { + if (mode != COMMAND_EXEC) { const char *stage_msg = ""; - switch (c->mode) { + switch (mode) { case COMMAND_CONFIG: stage_msg = " (configuration command)"; break; @@ -893,20 +909,13 @@ static COMMAND_HELPER(command_help_show, struct command *c, unsigned n, return -ENOMEM; } - if (++n > 5) { - LOG_ERROR("command recursion exceeded"); - return ERROR_FAIL; - } - - return CALL_COMMAND_HANDLER(command_help_show_list, - c->children, n, show_help, cmd_match); + return ERROR_OK; } COMMAND_HANDLER(handle_help_command) { bool full = strcmp(CMD_NAME, "help") == 0; int retval; - struct command *c = CMD_CTX->commands; char *cmd_match; if (CMD_ARGC <= 0) @@ -926,8 +935,7 @@ COMMAND_HANDLER(handle_help_command) LOG_ERROR("unable to build search string"); return -ENOMEM; } - retval = CALL_COMMAND_HANDLER(command_help_show_list, - c, 0, full, cmd_match); + retval = CALL_COMMAND_HANDLER(command_help_show_list, full, cmd_match); free(cmd_match); return retval; @@ -1124,81 +1132,104 @@ static int jim_command_mode(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_OK; } -int help_add_command(struct command_context *cmd_ctx, struct command *parent, - const char *cmd_name, const char *help_text, const char *usage) +int help_del_all_commands(struct command_context *cmd_ctx) +{ + struct help_entry *curr, *n; + + list_for_each_entry_safe(curr, n, cmd_ctx->help_list, lh) { + list_del(&curr->lh); + free(curr->cmd_name); + free(curr->help); + free(curr->usage); + free(curr); + } + return ERROR_OK; +} + +static int help_del_command(struct command_context *cmd_ctx, const char *cmd_name) { - struct command **head = command_list_for_parent(cmd_ctx, parent); - struct command *nc = command_find(*head, cmd_name); - if (NULL == nc) { - /* add a new command with help text */ - struct command_registration cr = { - .name = cmd_name, - .mode = COMMAND_ANY, - .help = help_text, - .usage = usage ? : "", - }; - nc = register_command(cmd_ctx, parent, &cr); - if (NULL == nc) { - LOG_ERROR("failed to add '%s' help text", cmd_name); + struct help_entry *curr; + + list_for_each_entry(curr, cmd_ctx->help_list, lh) { + if (!strcmp(cmd_name, curr->cmd_name)) { + list_del(&curr->lh); + free(curr->cmd_name); + free(curr->help); + free(curr->usage); + free(curr); + break; + } + } + + return ERROR_OK; +} + +static int help_add_command(struct command_context *cmd_ctx, + const char *cmd_name, const char *help_text, const char *usage_text) +{ + int cmp = -1; /* add after curr */ + struct help_entry *curr; + + list_for_each_entry_reverse(curr, cmd_ctx->help_list, lh) { + cmp = strcmp(cmd_name, curr->cmd_name); + if (cmp >= 0) + break; + } + + struct help_entry *entry; + if (cmp) { + entry = calloc(1, sizeof(*entry)); + if (!entry) { + LOG_ERROR("Out of memory"); return ERROR_FAIL; } - LOG_DEBUG("added '%s' help text", cmd_name); - return ERROR_OK; + entry->cmd_name = strdup(cmd_name); + if (!entry->cmd_name) { + LOG_ERROR("Out of memory"); + free(entry); + return ERROR_FAIL; + } + list_add(&entry->lh, &curr->lh); + } else { + entry = curr; } + if (help_text) { - bool replaced = false; - if (nc->help) { - free(nc->help); - replaced = true; + char *text = strdup(help_text); + if (!text) { + LOG_ERROR("Out of memory"); + return ERROR_FAIL; } - nc->help = strdup(help_text); - if (replaced) - LOG_INFO("replaced existing '%s' help", cmd_name); - else - LOG_DEBUG("added '%s' help text", cmd_name); + free(entry->help); + entry->help = text; } - if (usage) { - bool replaced = false; - if (nc->usage) { - if (*nc->usage) - replaced = true; - free(nc->usage); + + if (usage_text) { + char *text = strdup(usage_text); + if (!text) { + LOG_ERROR("Out of memory"); + return ERROR_FAIL; } - nc->usage = strdup(usage); - if (replaced) - LOG_INFO("replaced existing '%s' usage", cmd_name); - else - LOG_DEBUG("added '%s' usage text", cmd_name); + free(entry->usage); + entry->usage = text; } + return ERROR_OK; } COMMAND_HANDLER(handle_help_add_command) { - if (CMD_ARGC < 2) { - LOG_ERROR("%s: insufficient arguments", CMD_NAME); + if (CMD_ARGC != 2) return ERROR_COMMAND_SYNTAX_ERROR; - } - /* save help text and remove it from argument list */ - const char *str = CMD_ARGV[--CMD_ARGC]; - const char *help = !strcmp(CMD_NAME, "add_help_text") ? str : NULL; - const char *usage = !strcmp(CMD_NAME, "add_usage_text") ? str : NULL; + const char *help = !strcmp(CMD_NAME, "add_help_text") ? CMD_ARGV[1] : NULL; + const char *usage = !strcmp(CMD_NAME, "add_usage_text") ? CMD_ARGV[1] : NULL; if (!help && !usage) { LOG_ERROR("command name '%s' is unknown", CMD_NAME); return ERROR_COMMAND_SYNTAX_ERROR; } - /* likewise for the leaf command name */ - const char *cmd_name = CMD_ARGV[--CMD_ARGC]; - - struct command *c = NULL; - if (CMD_ARGC > 0) { - c = CMD_CTX->commands; - int retval = CALL_COMMAND_HANDLER(command_help_find, c, &c); - if (ERROR_OK != retval) - return retval; - } - return help_add_command(CMD_CTX, c, cmd_name, help, usage); + const char *cmd_name = CMD_ARGV[0]; + return help_add_command(CMD_CTX, cmd_name, help, usage); } /* sleep command sleeps for <n> milliseconds @@ -1329,6 +1360,10 @@ struct command_context *command_init(const char *startup_tcl, Jim_Interp *interp context->mode = COMMAND_EXEC; + /* context can be duplicated. Put list head on separate mem-chunk to keep list consistent */ + context->help_list = malloc(sizeof(*context->help_list)); + INIT_LIST_HEAD(context->help_list); + /* Create a jim interpreter if we were not handed one */ if (interp == NULL) { /* Create an interpreter */ @@ -1393,6 +1428,7 @@ void command_exit(struct command_context *context) return; Jim_FreeInterp(context->interp); + free(context->help_list); command_done(context); } diff --git a/src/helper/command.h b/src/helper/command.h index 9a04e9fa1..db095972a 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -26,6 +26,7 @@ #include <stdbool.h> #include <jim-nvp.h> +#include <helper/list.h> #include <helper/types.h> /* To achieve C99 printf compatibility in MinGW, gnu_printf should be @@ -41,6 +42,7 @@ enum command_mode { COMMAND_EXEC, COMMAND_CONFIG, COMMAND_ANY, + COMMAND_UNKNOWN = -1, /* error condition */ }; struct command_context; @@ -64,6 +66,7 @@ struct command_context { */ command_output_handler_t output_handler; void *output_handler_priv; + struct list_head *help_list; }; struct command; @@ -179,8 +182,6 @@ typedef __COMMAND_HANDLER((*command_handler_t)); struct command { char *name; - char *help; - char *usage; struct command *parent; struct command *children; command_handler_t handler; @@ -316,6 +317,14 @@ static inline int register_commands_with_data(struct command_context *cmd_ctx, int unregister_all_commands(struct command_context *cmd_ctx, struct command *parent); +/** + * Unregisters the help for all commands. Used at exit to remove the help + * added through the commands 'add_help_text' and 'add_usage_text'. + * @param cmd_ctx The context that will be cleared of registered helps. + * @returns ERROR_OK on success, or an error code. + */ +int help_del_all_commands(struct command_context *cmd_ctx); + void command_set_output_handler(struct command_context *context, command_output_handler_t output_handler, void *priv); diff --git a/src/openocd.c b/src/openocd.c index fcefdbe70..32b68b6fc 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -361,6 +361,7 @@ int openocd_main(int argc, char *argv[]) server_free(); unregister_all_commands(cmd_ctx, NULL); + help_del_all_commands(cmd_ctx); /* free all DAP and CTI objects */ dap_cleanup_all(); commit cb83bc747ce1106c50d713f6d552da8c3e476e0f Author: Antonio Borneo <bor...@gm...> Date: Sat May 9 02:00:45 2020 +0200 command mode: return "any" for tcl proc A tcl proc can be executed anytime, in any command mode. Let the command "command mode" to detect a tcl proc and return the string "any". Change-Id: I0559076c3063632ee0ea9a57a25f91060209b77f Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5669 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index 114d07328..288ba99aa 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -53,6 +53,12 @@ static int unregister_command(struct command_context *context, struct command *parent, const char *name); static char *command_name(struct command *c, char delim); +/* wrap jimtcl internal data */ +static inline bool jimcmd_is_proc(Jim_Cmd *cmd) +{ + return cmd->isproc; +} + static void tcl_output(void *privData, const char *file, unsigned line, const char *function, const char *string) { @@ -1076,6 +1082,18 @@ static int jim_command_mode(Jim_Interp *interp, int argc, Jim_Obj *const *argv) enum command_mode mode; if (argc > 1) { + char *full_name = alloc_concatenate_strings(argc - 1, argv + 1); + if (!full_name) + return JIM_ERR; + Jim_Obj *s = Jim_NewStringObj(interp, full_name, -1); + Jim_IncrRefCount(s); + Jim_Cmd *cmd = Jim_GetCommand(interp, s, JIM_NONE); + Jim_DecrRefCount(interp, s); + free(full_name); + if (cmd && jimcmd_is_proc(cmd)) { + Jim_SetResultString(interp, "any", -1); + return JIM_OK; + } struct command *c = cmd_ctx->commands; int remaining = command_unknown_find(argc - 1, argv + 1, c, &c); /* if nothing could be consumed, then it's an unknown command */ ----------------------------------------------------------------------- Summary of changes: src/helper/command.c | 382 +++++++++++++++++++++++----------------------- src/helper/command.h | 13 +- src/jtag/tcl.c | 6 +- src/openocd.c | 1 + src/target/aarch64.c | 3 +- src/target/arm_tpiu_swo.c | 4 +- src/target/target.c | 3 +- 7 files changed, 210 insertions(+), 202 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-18 14:34:29
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 41c95aa4ea1506a951dad0147f6cd4b8d7043358 (commit) via 428938993742f4f961cdc948593d9553f721c321 (commit) via 7cd679a2de697065bbd36cde9042516ccf20f0f1 (commit) via 462323f123ede2c8da59cb4acb772dc4f98dee79 (commit) from a510c8e23c23b7a888623faf0c4a9982489ddf83 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 41c95aa4ea1506a951dad0147f6cd4b8d7043358 Author: Antonio Borneo <bor...@gm...> Date: Sun May 10 19:35:56 2020 +0200 helper/command: pass command prefix to command registration Replace the "struct command *parent" parameter with a string that contains the command prefix. This abstracts the openocd code from the knowledge of the tree of struct command. This also makes unused the function command_find_in_context(), so remove it. Change-Id: I598d60719cfdc1811ee6f6edfff8a116f82c7ed6 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5668 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/flash/nand/tcl.c b/src/flash/nand/tcl.c index ca8b9dad4..9e0ca41ac 100644 --- a/src/flash/nand/tcl.c +++ b/src/flash/nand/tcl.c @@ -479,8 +479,8 @@ static int nand_init(struct command_context *cmd_ctx) { if (!nand_devices) return ERROR_OK; - struct command *parent = command_find_in_context(cmd_ctx, "nand"); - return register_commands(cmd_ctx, parent, nand_exec_command_handlers); + + return register_commands(cmd_ctx, "nand", nand_exec_command_handlers); } COMMAND_HANDLER(handle_nand_init_command) diff --git a/src/flash/nor/esirisc_flash.c b/src/flash/nor/esirisc_flash.c index 88f00bcca..24e811704 100644 --- a/src/flash/nor/esirisc_flash.c +++ b/src/flash/nor/esirisc_flash.c @@ -109,7 +109,6 @@ static const struct command_registration esirisc_flash_command_handlers[]; FLASH_BANK_COMMAND_HANDLER(esirisc_flash_bank_command) { struct esirisc_flash_bank *esirisc_info; - struct command *esirisc_cmd; if (CMD_ARGC < 9) return ERROR_COMMAND_SYNTAX_ERROR; @@ -123,8 +122,7 @@ FLASH_BANK_COMMAND_HANDLER(esirisc_flash_bank_command) bank->driver_priv = esirisc_info; /* register commands using existing esirisc context */ - esirisc_cmd = command_find_in_context(CMD_CTX, "esirisc"); - register_commands(CMD_CTX, esirisc_cmd, esirisc_flash_command_handlers); + register_commands(CMD_CTX, "esirisc", esirisc_flash_command_handlers); return ERROR_OK; } diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index 66b9a4cb6..3f737aca3 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -1248,8 +1248,7 @@ static int flash_init_drivers(struct command_context *cmd_ctx) if (!flash_bank_list()) return ERROR_OK; - struct command *parent = command_find_in_context(cmd_ctx, "flash"); - return register_commands(cmd_ctx, parent, flash_exec_command_handlers); + return register_commands(cmd_ctx, "flash", flash_exec_command_handlers); } COMMAND_HANDLER(handle_flash_bank_command) diff --git a/src/helper/command.c b/src/helper/command.c index 89e217382..114d07328 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -244,12 +244,6 @@ static struct command *command_find(struct command *head, const char *name) return NULL; } -struct command *command_find_in_context(struct command_context *cmd_ctx, - const char *name) -{ - return command_find(cmd_ctx->commands, name); -} - /** * Add the command into the linked list, sorted by name. * @param head Address to head of command list pointer, which may be @@ -391,7 +385,7 @@ static struct command *register_command(struct command_context *context, return c; } -int __register_commands(struct command_context *cmd_ctx, struct command *parent, +static int ___register_commands(struct command_context *cmd_ctx, struct command *parent, const struct command_registration *cmds, void *data, struct target *override_target) { @@ -412,7 +406,7 @@ int __register_commands(struct command_context *cmd_ctx, struct command *parent, } if (NULL != cr->chain) { struct command *p = c ? : parent; - retval = __register_commands(cmd_ctx, p, cr->chain, data, override_target); + retval = ___register_commands(cmd_ctx, p, cr->chain, data, override_target); if (ERROR_OK != retval) break; } @@ -424,6 +418,18 @@ int __register_commands(struct command_context *cmd_ctx, struct command *parent, return retval; } +int __register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, + const struct command_registration *cmds, void *data, + struct target *override_target) +{ + struct command *parent = NULL; + + if (cmd_prefix) + parent = command_find(cmd_ctx->commands, cmd_prefix); + + return ___register_commands(cmd_ctx, parent, cmds, data, override_target); +} + int unregister_all_commands(struct command_context *context, struct command *parent) { diff --git a/src/helper/command.h b/src/helper/command.h index 871c064d3..9a04e9fa1 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -240,7 +240,7 @@ struct command_registration { /** Use this as the last entry in an array of command_registration records. */ #define COMMAND_REGISTRATION_DONE { .name = NULL, .chain = NULL } -int __register_commands(struct command_context *cmd_ctx, struct command *parent, +int __register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds, void *data, struct target *override_target); @@ -252,17 +252,17 @@ int __register_commands(struct command_context *cmd_ctx, struct command *parent, * Otherwise, the chained commands are added as children of the command. * * @param cmd_ctx The command_context in which to register the command. - * @param parent Register this command as a child of this, or NULL to + * @param cmd_prefix Register this command as a child of this, or NULL to * register a top-level command. * @param cmds Pointer to an array of command_registration records that * contains the desired command parameters. The last record must have * NULL for all fields. * @returns ERROR_OK on success; ERROR_FAIL if any registration fails. */ -static inline int register_commands(struct command_context *cmd_ctx, struct command *parent, +static inline int register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds) { - return __register_commands(cmd_ctx, parent, cmds, NULL, NULL); + return __register_commands(cmd_ctx, cmd_prefix, cmds, NULL, NULL); } /** @@ -270,7 +270,7 @@ static inline int register_commands(struct command_context *cmd_ctx, struct comm * that command should override the current target * * @param cmd_ctx The command_context in which to register the command. - * @param parent Register this command as a child of this, or NULL to + * @param cmd_prefix Register this command as a child of this, or NULL to * register a top-level command. * @param cmds Pointer to an array of command_registration records that * contains the desired command parameters. The last record must have @@ -279,10 +279,10 @@ static inline int register_commands(struct command_context *cmd_ctx, struct comm * @returns ERROR_OK on success; ERROR_FAIL if any registration fails. */ static inline int register_commands_override_target(struct command_context *cmd_ctx, - struct command *parent, const struct command_registration *cmds, + const char *cmd_prefix, const struct command_registration *cmds, struct target *target) { - return __register_commands(cmd_ctx, parent, cmds, NULL, target); + return __register_commands(cmd_ctx, cmd_prefix, cmds, NULL, target); } /** @@ -292,7 +292,7 @@ static inline int register_commands_override_target(struct command_context *cmd_ * is unregistered. * * @param cmd_ctx The command_context in which to register the command. - * @param parent Register this command as a child of this, or NULL to + * @param cmd_prefix Register this command as a child of this, or NULL to * register a top-level command. * @param cmds Pointer to an array of command_registration records that * contains the desired command parameters. The last record must have @@ -301,10 +301,10 @@ static inline int register_commands_override_target(struct command_context *cmd_ * @returns ERROR_OK on success; ERROR_FAIL if any registration fails. */ static inline int register_commands_with_data(struct command_context *cmd_ctx, - struct command *parent, const struct command_registration *cmds, + const char *cmd_prefix, const struct command_registration *cmds, void *data) { - return __register_commands(cmd_ctx, parent, cmds, data, NULL); + return __register_commands(cmd_ctx, cmd_prefix, cmds, data, NULL); } /** @@ -316,9 +316,6 @@ static inline int register_commands_with_data(struct command_context *cmd_ctx, int unregister_all_commands(struct command_context *cmd_ctx, struct command *parent); -struct command *command_find_in_context(struct command_context *cmd_ctx, - const char *name); - void command_set_output_handler(struct command_context *context, command_output_handler_t output_handler, void *priv); diff --git a/src/pld/pld.c b/src/pld/pld.c index ef7993c5d..9e8c07d80 100644 --- a/src/pld/pld.c +++ b/src/pld/pld.c @@ -187,8 +187,7 @@ static int pld_init(struct command_context *cmd_ctx) if (!pld_devices) return ERROR_OK; - struct command *parent = command_find_in_context(cmd_ctx, "pld"); - return register_commands(cmd_ctx, parent, pld_exec_command_handlers); + return register_commands(cmd_ctx, "pld", pld_exec_command_handlers); } COMMAND_HANDLER(handle_pld_init_command) diff --git a/src/target/etm.c b/src/target/etm.c index 19f3691bd..6dc2bd48c 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -2107,6 +2107,5 @@ static const struct command_registration etm_exec_command_handlers[] = { static int etm_register_user_commands(struct command_context *cmd_ctx) { - struct command *etm_cmd = command_find_in_context(cmd_ctx, "etm"); - return register_commands(cmd_ctx, etm_cmd, etm_exec_command_handlers); + return register_commands(cmd_ctx, "etm", etm_exec_command_handlers); } commit 428938993742f4f961cdc948593d9553f721c321 Author: Antonio Borneo <bor...@gm...> Date: Tue May 12 11:52:56 2020 +0200 helper/command: override target only on target prefixed cmds In current code the current target is overridden whenever jim_handler_data is not NULL. This happens not only with target prefixed commands, but also with cti, dap and swo/tpiu prefixed commands. While this is not causing any run-time issue, by now, the behaviour is tricky and makes the code cryptic. Add a specific field to struct command for the target override so the content of jim_handler_data can be restricted to command specific data only (today only cti, dap and swo/tpiu). Extend the API register_commands() to specify the presence of either the command data or the override target. The new API makes obsolete calling command_set_handler_data() to set jim_handler_data, so remove it. Change-Id: Icc323faf754b0546a72208f90abd9e68ff2ef52f Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5667 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index ecca75db6..89e217382 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -391,8 +391,9 @@ static struct command *register_command(struct command_context *context, return c; } -int register_commands(struct command_context *cmd_ctx, struct command *parent, - const struct command_registration *cmds) +int __register_commands(struct command_context *cmd_ctx, struct command *parent, + const struct command_registration *cmds, void *data, + struct target *override_target) { int retval = ERROR_OK; unsigned i; @@ -406,10 +407,12 @@ int register_commands(struct command_context *cmd_ctx, struct command *parent, retval = ERROR_FAIL; break; } + c->jim_handler_data = data; + c->jim_override_target = override_target; } if (NULL != cr->chain) { struct command *p = c ? : parent; - retval = register_commands(cmd_ctx, p, cr->chain); + retval = __register_commands(cmd_ctx, p, cr->chain, data, override_target); if (ERROR_OK != retval) break; } @@ -461,13 +464,6 @@ static int unregister_command(struct command_context *context, return ERROR_OK; } -void command_set_handler_data(struct command *c, void *p) -{ - c->jim_handler_data = p; - for (struct command *cc = c->children; NULL != cc; cc = cc->next) - command_set_handler_data(cc, p); -} - void command_output_text(struct command_context *context, const char *data) { if (context && context->output_handler && data) @@ -1057,12 +1053,12 @@ static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv) * correct work when command_unknown() is re-entered. */ struct target *saved_target_override = cmd_ctx->current_target_override; - if (c->jim_handler_data) - cmd_ctx->current_target_override = c->jim_handler_data; + if (c->jim_override_target) + cmd_ctx->current_target_override = c->jim_override_target; int retval = exec_command(interp, cmd_ctx, c, count, start); - if (c->jim_handler_data) + if (c->jim_override_target) cmd_ctx->current_target_override = saved_target_override; return retval; diff --git a/src/helper/command.h b/src/helper/command.h index cb088d743..871c064d3 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -186,11 +186,9 @@ struct command { command_handler_t handler; Jim_CmdProc *jim_handler; void *jim_handler_data; - /* Currently used only for target of target-prefixed cmd. - * Native OpenOCD commands use jim_handler_data exclusively - * as a target override. - * Jim handlers outside of target cmd tree can use - * jim_handler_data for any handler specific data */ + /* Command handlers can use it for any handler specific data */ + struct target *jim_override_target; + /* Used only for target of target-prefixed cmd */ enum command_mode mode; struct command *next; }; @@ -242,6 +240,10 @@ struct command_registration { /** Use this as the last entry in an array of command_registration records. */ #define COMMAND_REGISTRATION_DONE { .name = NULL, .chain = NULL } +int __register_commands(struct command_context *cmd_ctx, struct command *parent, + const struct command_registration *cmds, void *data, + struct target *override_target); + /** * Register one or more commands in the specified context, as children * of @c parent (or top-level commends, if NULL). In a registration's @@ -257,8 +259,53 @@ struct command_registration { * NULL for all fields. * @returns ERROR_OK on success; ERROR_FAIL if any registration fails. */ -int register_commands(struct command_context *cmd_ctx, struct command *parent, - const struct command_registration *cmds); +static inline int register_commands(struct command_context *cmd_ctx, struct command *parent, + const struct command_registration *cmds) +{ + return __register_commands(cmd_ctx, parent, cmds, NULL, NULL); +} + +/** + * Register one or more commands, as register_commands(), plus specify + * that command should override the current target + * + * @param cmd_ctx The command_context in which to register the command. + * @param parent Register this command as a child of this, or NULL to + * register a top-level command. + * @param cmds Pointer to an array of command_registration records that + * contains the desired command parameters. The last record must have + * NULL for all fields. + * @param target The target that has to override current target. + * @returns ERROR_OK on success; ERROR_FAIL if any registration fails. + */ +static inline int register_commands_override_target(struct command_context *cmd_ctx, + struct command *parent, const struct command_registration *cmds, + struct target *target) +{ + return __register_commands(cmd_ctx, parent, cmds, NULL, target); +} + +/** + * Register one or more commands, as register_commands(), plus specify + * a pointer to command private data that would be accessible through + * the macro CMD_DATA. The private data will not be freed when command + * is unregistered. + * + * @param cmd_ctx The command_context in which to register the command. + * @param parent Register this command as a child of this, or NULL to + * register a top-level command. + * @param cmds Pointer to an array of command_registration records that + * contains the desired command parameters. The last record must have + * NULL for all fields. + * @param data The command private data. + * @returns ERROR_OK on success; ERROR_FAIL if any registration fails. + */ +static inline int register_commands_with_data(struct command_context *cmd_ctx, + struct command *parent, const struct command_registration *cmds, + void *data) +{ + return __register_commands(cmd_ctx, parent, cmds, data, NULL); +} /** * Unregisters all commands from the specified context. @@ -272,16 +319,6 @@ int unregister_all_commands(struct command_context *cmd_ctx, struct command *command_find_in_context(struct command_context *cmd_ctx, const char *name); -/** - * Update the private command data field for a command and all descendents. - * This is used when creating a new hierarchy of commands that depends - * on obtaining a dynamically created context. The value will be available - * in command handlers by using the CMD_DATA macro. - * @param c The command (group) whose data pointer(s) will be updated. - * @param p The new data pointer to use for the command or its descendents. - */ -void command_set_handler_data(struct command *c, void *p); - void command_set_output_handler(struct command_context *context, command_output_handler_t output_handler, void *priv); diff --git a/src/target/arm_cti.c b/src/target/arm_cti.c index 689e9df9f..ee9d8aafd 100644 --- a/src/target/arm_cti.c +++ b/src/target/arm_cti.c @@ -507,17 +507,13 @@ static int cti_create(Jim_GetOptInfo *goi) }, COMMAND_REGISTRATION_DONE }; - e = register_commands(cmd_ctx, NULL, cti_commands); + e = register_commands_with_data(cmd_ctx, NULL, cti_commands, cti); if (ERROR_OK != e) return JIM_ERR; - struct command *c = command_find_in_context(cmd_ctx, cp); - assert(c); - command_set_handler_data(c, cti); - list_add_tail(&cti->lh, &all_cti); - return (ERROR_OK == e) ? JIM_OK : JIM_ERR; + return JIM_OK; } static int jim_cti_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv) diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c index 56442f183..a9277e798 100644 --- a/src/target/arm_dap.c +++ b/src/target/arm_dap.c @@ -265,17 +265,13 @@ static int dap_create(Jim_GetOptInfo *goi) if (transport_is_hla()) dap_commands[0].chain = NULL; - e = register_commands(cmd_ctx, NULL, dap_commands); + e = register_commands_with_data(cmd_ctx, NULL, dap_commands, dap); if (ERROR_OK != e) return JIM_ERR; - struct command *c = command_find_in_context(cmd_ctx, cp); - assert(c); - command_set_handler_data(c, dap); - list_add_tail(&dap->lh, &all_dap); - return (ERROR_OK == e) ? JIM_OK : JIM_ERR; + return JIM_OK; } static int jim_dap_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv) diff --git a/src/target/arm_tpiu_swo.c b/src/target/arm_tpiu_swo.c index 543b4f008..186ce5d0e 100644 --- a/src/target/arm_tpiu_swo.c +++ b/src/target/arm_tpiu_swo.c @@ -886,14 +886,10 @@ static int arm_tpiu_swo_create(Jim_Interp *interp, struct arm_tpiu_swo_object *o }, COMMAND_REGISTRATION_DONE }; - e = register_commands(cmd_ctx, NULL, obj_commands); + e = register_commands_with_data(cmd_ctx, NULL, obj_commands, obj); if (ERROR_OK != e) return JIM_ERR; - struct command *c = command_find_in_context(cmd_ctx, obj->name); - assert(c); - command_set_handler_data(c, obj); - list_add_tail(&obj->lh, &all_tpiu_swo); return JIM_OK; diff --git a/src/target/target.c b/src/target/target.c index 619a8b490..fa033d351 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5871,7 +5871,7 @@ static int target_create(Jim_GetOptInfo *goi) }, COMMAND_REGISTRATION_DONE }; - e = register_commands(cmd_ctx, NULL, target_commands); + e = register_commands_override_target(cmd_ctx, NULL, target_commands, target); if (e != ERROR_OK) { if (target->type->deinit_target) target->type->deinit_target(target); @@ -5884,10 +5884,6 @@ static int target_create(Jim_GetOptInfo *goi) return JIM_ERR; } - struct command *c = command_find_in_context(cmd_ctx, cp); - assert(c); - command_set_handler_data(c, target); - /* append to end of list */ append_to_list_all_targets(target); commit 7cd679a2de697065bbd36cde9042516ccf20f0f1 Author: Antonio Borneo <bor...@gm...> Date: Tue May 12 02:36:56 2020 +0200 helper/command: get current target from dedicated API Now that target override is uniformly implemented for all types of commands, there is no need for target-prefixed "native" commands (.jim_handler) to sneakily extract the overridden target from the struct command. Modify the commands to use the standard API get_current_target(). Change-Id: I732a09c3261e56524edd5217634fa409eb97a8c6 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5666 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/target/nds32_cmd.c b/src/target/nds32_cmd.c index 89da845d3..246dbd034 100644 --- a/src/target/nds32_cmd.c +++ b/src/target/nds32_cmd.c @@ -722,8 +722,9 @@ static int jim_nds32_bulk_write(Jim_Interp *interp, int argc, Jim_Obj * const *a return JIM_ERR; } - struct command *c = jim_to_command(goi.interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); int result; result = target_write_buffer(target, address, count * 4, (const uint8_t *)data); @@ -752,8 +753,9 @@ static int jim_nds32_multi_write(Jim_Interp *interp, int argc, Jim_Obj * const * if (e != JIM_OK) return e; - struct command *c = jim_to_command(goi.interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); struct aice_port_s *aice = target_to_aice(target); int result; uint32_t address; @@ -814,8 +816,9 @@ static int jim_nds32_bulk_read(Jim_Interp *interp, int argc, Jim_Obj * const *ar if (goi.argc != 0) return JIM_ERR; - struct command *c = jim_to_command(goi.interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); uint32_t *data = malloc(count * sizeof(uint32_t)); int result; result = target_read_buffer(target, address, count * 4, (uint8_t *)data); @@ -866,8 +869,9 @@ static int jim_nds32_read_edm_sr(Jim_Interp *interp, int argc, Jim_Obj * const * else return ERROR_FAIL; - struct command *c = jim_to_command(goi.interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); struct aice_port_s *aice = target_to_aice(target); char data_str[11]; @@ -915,8 +919,9 @@ static int jim_nds32_write_edm_sr(Jim_Interp *interp, int argc, Jim_Obj * const else return ERROR_FAIL; - struct command *c = jim_to_command(goi.interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); struct aice_port_s *aice = target_to_aice(target); aice_write_debug_reg(aice, edm_sr_number, value); diff --git a/src/target/target.c b/src/target/target.c index e481d526c..619a8b490 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5206,24 +5206,27 @@ static int jim_target_configure(Jim_Interp *interp, int argc, Jim_Obj * const *a "missing: -option ..."); return JIM_ERR; } - struct command *c = jim_to_command(goi.interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); return target_configure(&goi, target); } static int jim_target_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); return target_mem2array(interp, target, argc - 1, argv + 1); } static int jim_target_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); return target_array2mem(interp, target, argc - 1, argv + 1); } @@ -5255,8 +5258,9 @@ static int jim_target_examine(Jim_Interp *interp, int argc, Jim_Obj *const *argv allow_defer = true; } - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); if (!target->tap->enabled) return jim_target_tap_disabled(interp); @@ -5274,8 +5278,9 @@ static int jim_target_examine(Jim_Interp *interp, int argc, Jim_Obj *const *argv static int jim_target_was_examined(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); Jim_SetResultBool(interp, target_was_examined(target)); return JIM_OK; @@ -5283,8 +5288,9 @@ static int jim_target_was_examined(Jim_Interp *interp, int argc, Jim_Obj * const static int jim_target_examine_deferred(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); Jim_SetResultBool(interp, target->defer_examine); return JIM_OK; @@ -5296,8 +5302,9 @@ static int jim_target_halt_gdb(Jim_Interp *interp, int argc, Jim_Obj *const *arg Jim_WrongNumArgs(interp, 1, argv, "[no parameters]"); return JIM_ERR; } - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); if (target_call_event_callbacks(target, TARGET_EVENT_GDB_HALT) != ERROR_OK) return JIM_ERR; @@ -5311,8 +5318,9 @@ static int jim_target_poll(Jim_Interp *interp, int argc, Jim_Obj *const *argv) Jim_WrongNumArgs(interp, 1, argv, "[no parameters]"); return JIM_ERR; } - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); if (!target->tap->enabled) return jim_target_tap_disabled(interp); @@ -5349,8 +5357,9 @@ static int jim_target_reset(Jim_Interp *interp, int argc, Jim_Obj *const *argv) if (e != JIM_OK) return e; - struct command *c = jim_to_command(goi.interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); if (!target->tap->enabled) return jim_target_tap_disabled(interp); @@ -5383,8 +5392,9 @@ static int jim_target_halt(Jim_Interp *interp, int argc, Jim_Obj *const *argv) Jim_WrongNumArgs(interp, 1, argv, "[no parameters]"); return JIM_ERR; } - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); if (!target->tap->enabled) return jim_target_tap_disabled(interp); int e = target->type->halt(target); @@ -5414,8 +5424,9 @@ static int jim_target_wait_state(Jim_Interp *interp, int argc, Jim_Obj *const *a e = Jim_GetOpt_Wide(&goi, &a); if (e != JIM_OK) return e; - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); if (!target->tap->enabled) return jim_target_tap_disabled(interp); @@ -5459,8 +5470,9 @@ static int jim_target_current_state(Jim_Interp *interp, int argc, Jim_Obj *const Jim_WrongNumArgs(interp, 1, argv, "[no parameters]"); return JIM_ERR; } - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); Jim_SetResultString(interp, target_state_name(target), -1); return JIM_OK; } @@ -5479,8 +5491,9 @@ static int jim_target_invoke_event(Jim_Interp *interp, int argc, Jim_Obj *const Jim_GetOpt_NvpUnknown(&goi, nvp_target_event, 1); return e; } - struct command *c = jim_to_command(interp); - struct target *target = c->jim_handler_data; + struct command_context *cmd_ctx = current_command_context(interp); + assert(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); target_handle_event(target, n->value); return JIM_OK; } commit 462323f123ede2c8da59cb4acb772dc4f98dee79 Author: Antonio Borneo <bor...@gm...> Date: Tue May 12 01:59:06 2020 +0200 helper/command: use one single handler for all the commands Today openocd registers the commands to jim with three methods: 1) "native" commands (.jim_handler) at root level are registered directly as jim commands; 2) "simple" commands (.handler) at root level are registered through the handler script_command(); 3) all other commands not at root level are registered through the handler command_unknown(). Apart from using different handler, other inconsistencies are present: a) command in 1) are not checked for their "mode", so are run with no check about current mode (COMMAND_CONFIG or COMMAND_EXEC); b) target_call_timer_callbacks_now() is called only for "simple" commands and not for "native" commands; c) target override is performed only for "simple" commands and not for "native" commands. Drop script_command() and extend command_unknown() to uniformly handle all the cases above, fixing all the inconsistencies already mentioned. The handler's name command_unknown() is probably not anymore appropriate, but will be renamed in a separate change. Note: today all the commands in a) have mode CONFIG_ANY, apart for "mem2array" and "array2mem" that have mode COMMAND_EXEC. But the latter commands are registered during target init, so do not exist during COMMAND_CONFIG and no issue is present. Change-Id: I67bd6e47eb2c575107251b9192c676c27d4aabae Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5665 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index b44e4667f..ecca75db6 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -44,9 +44,6 @@ /* nice short description of source file */ #define __THIS__FILE__ "command.c" -static int run_command(struct command_context *context, - struct command *c, const char *words[], unsigned num_words); - struct log_capture_state { Jim_Interp *interp; Jim_Obj *output; @@ -226,34 +223,6 @@ struct command_context *current_command_context(Jim_Interp *interp) return cmd_ctx; } -static int script_command_run(Jim_Interp *interp, - int argc, Jim_Obj * const *argv, struct command *c) -{ - target_call_timer_callbacks_now(); - LOG_USER_N("%s", ""); /* Keep GDB connection alive*/ - - unsigned nwords; - char **words = script_command_args_alloc(argc, argv, &nwords); - if (NULL == words) - return JIM_ERR; - - struct command_context *cmd_ctx = current_command_context(interp); - int retval = run_command(cmd_ctx, c, (const char **)words, nwords); - - script_command_args_free(words, nwords); - return command_retval_set(interp, retval); -} - -static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) -{ - /* the private data is stashed in the interp structure */ - - struct command *c = jim_to_command(interp); - assert(c); - script_debug(interp, argc, argv); - return script_command_run(interp, argc, argv, c); -} - static struct command *command_root(struct command *c) { while (NULL != c->parent) @@ -387,10 +356,7 @@ static int register_command_handler(struct command_context *cmd_ctx, LOG_DEBUG("registering '%s'...", c->name); #endif - Jim_CmdProc *func = c->handler ? &script_command : &command_unknown; - int retval = Jim_CreateCommand(interp, c->name, func, c, NULL); - - return retval; + return Jim_CreateCommand(interp, c->name, command_unknown, c, NULL); } static struct command *register_command(struct command_context *context, @@ -415,16 +381,12 @@ static struct command *register_command(struct command_context *context, if (NULL == c) return NULL; - int retval = JIM_OK; - if (NULL != cr->jim_handler && NULL == parent) { - retval = Jim_CreateCommand(context->interp, cr->name, - cr->jim_handler, c, NULL); - } else if (NULL != cr->handler || NULL != parent) - retval = register_command_handler(context, command_root(c)); - - if (retval != JIM_OK) { - unregister_command(context, parent, name); - c = NULL; + if (cr->jim_handler || cr->handler) { + int retval = register_command_handler(context, command_root(c)); + if (retval != JIM_OK) { + unregister_command(context, parent, name); + return NULL; + } } return c; } @@ -614,11 +576,8 @@ static bool command_can_run(struct command_context *cmd_ctx, struct command *c) } static int run_command(struct command_context *context, - struct command *c, const char *words[], unsigned num_words) + struct command *c, const char **words, unsigned num_words) { - if (!command_can_run(context, c)) - return ERROR_FAIL; - struct command_invocation cmd = { .ctx = context, .current = c, @@ -626,26 +585,11 @@ static int run_command(struct command_context *context, .argc = num_words - 1, .argv = words + 1, }; - /* Black magic of overridden current target: - * If the command we are going to handle has a target prefix, - * override the current target temporarily for the time - * of processing the command. - * current_target_override is used also for event handlers - * therefore we prevent touching it if command has no prefix. - * Previous override is saved and restored back to ensure - * correct work when run_command() is re-entered. */ - struct target *saved_target_override = context->current_target_override; - if (c->jim_handler_data) - context->current_target_override = c->jim_handler_data; cmd.output = Jim_NewEmptyStringObj(context->interp); Jim_IncrRefCount(cmd.output); int retval = c->handler(&cmd); - - if (c->jim_handler_data) - context->current_target_override = saved_target_override; - if (retval == ERROR_COMMAND_SYNTAX_ERROR) { /* Print help for command */ char *full_name = command_name(c, ' '); @@ -1053,6 +997,23 @@ static int run_usage(Jim_Interp *interp, int argc_valid, int argc, Jim_Obj * con return retval; } +static int exec_command(Jim_Interp *interp, struct command_context *cmd_ctx, + struct command *c, int argc, Jim_Obj *const *argv) +{ + if (c->jim_handler) + return c->jim_handler(interp, argc, argv); + + /* use c->handler */ + unsigned int nwords; + char **words = script_command_args_alloc(argc, argv, &nwords); + if (!words) + return JIM_ERR; + + int retval = run_command(cmd_ctx, c, (const char **)words, nwords); + script_command_args_free(words, nwords); + return command_retval_set(interp, retval); +} + static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { script_debug(interp, argc, argv); @@ -1079,15 +1040,32 @@ static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv) run_usage(interp, count, argc, start); return JIM_ERR; } - /* pass the command through to the intended handler */ - if (c->jim_handler) { - if (!command_can_run(cmd_ctx, c)) - return JIM_ERR; - return (*c->jim_handler)(interp, count, start); - } + if (!command_can_run(cmd_ctx, c)) + return JIM_ERR; + + target_call_timer_callbacks_now(); - return script_command_run(interp, count, start, c); + /* + * Black magic of overridden current target: + * If the command we are going to handle has a target prefix, + * override the current target temporarily for the time + * of processing the command. + * current_target_override is used also for event handlers + * therefore we prevent touching it if command has no prefix. + * Previous override is saved and restored back to ensure + * correct work when command_unknown() is re-entered. + */ + struct target *saved_target_override = cmd_ctx->current_target_override; + if (c->jim_handler_data) + cmd_ctx->current_target_override = c->jim_handler_data; + + int retval = exec_command(interp, cmd_ctx, c, count, start); + + if (c->jim_handler_data) + cmd_ctx->current_target_override = saved_target_override; + + return retval; } static int jim_command_mode(Jim_Interp *interp, int argc, Jim_Obj *const *argv) ----------------------------------------------------------------------- Summary of changes: src/flash/nand/tcl.c | 4 +- src/flash/nor/esirisc_flash.c | 4 +- src/flash/nor/tcl.c | 3 +- src/helper/command.c | 154 ++++++++++++++++++------------------------ src/helper/command.h | 76 +++++++++++++++------ src/pld/pld.c | 3 +- src/target/arm_cti.c | 8 +-- src/target/arm_dap.c | 8 +-- src/target/arm_tpiu_swo.c | 6 +- src/target/etm.c | 3 +- src/target/nds32_cmd.c | 25 ++++--- src/target/target.c | 71 ++++++++++--------- 12 files changed, 188 insertions(+), 177 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-18 14:33:35
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via a510c8e23c23b7a888623faf0c4a9982489ddf83 (commit) via a9904ba22c6a8c9cd56c85296e80396c9e05ee9e (commit) from fa94a42a09aadc3851015bbaedecd0300732a8b1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a510c8e23c23b7a888623faf0c4a9982489ddf83 Author: Antonio Borneo <bor...@gm...> Date: Tue May 12 00:22:13 2020 +0200 helper/command: always pass struct command as jim private data While registering a new command, jim accepts a pointer to command's private data that will be accessible during the command execution. Today openocd is not consistent and passes different private data depending on the command, and then even overwrites it: - "simple" commands (.handler) are registered with their own struct command pointer as command private data; - "native" commands (.jim_handler) at root level are registered with NULL command private data; - "native" commands (.jim_handler) not at root level are registered with the struct command pointer of their root command as command private data but, when executed, the command private data is overwritten by the value in field jim_handler_data taken from their struct command. Uniform the usage of command private data by always set it to the struct command pointer while registering the new commands. Note: for multi-word commands only the root command is registered, so command private data will be set to the struct command of the root command. This will change later in this series when the full- name of the command will be registered. Don't overwrite the command private data, but let the commands that needs jim_handler_data to get it directly through struct command. For sake of uniformity, let function command_set_handler_data() to set the field jim_handler_data also for "group" commands, even if such value will not be used. Now Jim_CmdPrivData() always returns a struct command pointer, so wrap it in the inline function jim_to_command() to gain compile time check on the returned type. While there, uniform the code to use the macro Jim_CmdPrivData() to access the command's private data pointer. Change-Id: Idba16242ba1f6769341b4030a49cdf35a5278695 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5664 Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> diff --git a/src/helper/command.c b/src/helper/command.c index e2726f258..b44e4667f 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -248,7 +248,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { /* the private data is stashed in the interp structure */ - struct command *c = interp->cmdPrivData; + struct command *c = jim_to_command(interp); assert(c); script_debug(interp, argc, argv); return script_command_run(interp, argc, argv, c); @@ -418,7 +418,7 @@ static struct command *register_command(struct command_context *context, int retval = JIM_OK; if (NULL != cr->jim_handler && NULL == parent) { retval = Jim_CreateCommand(context->interp, cr->name, - cr->jim_handler, NULL, NULL); + cr->jim_handler, c, NULL); } else if (NULL != cr->handler || NULL != parent) retval = register_command_handler(context, command_root(c)); @@ -501,8 +501,7 @@ static int unregister_command(struct command_context *context, void command_set_handler_data(struct command *c, void *p) { - if (NULL != c->handler || NULL != c->jim_handler) - c->jim_handler_data = p; + c->jim_handler_data = p; for (struct command *cc = c->children; NULL != cc; cc = cc->next) command_set_handler_data(cc, p); } @@ -1085,7 +1084,6 @@ static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv) if (!command_can_run(cmd_ctx, c)) return JIM_ERR; - interp->cmdPrivData = c->jim_handler_data; return (*c->jim_handler)(interp, count, start); } diff --git a/src/helper/command.h b/src/helper/command.h index b0c84bb43..cb088d743 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -195,6 +195,15 @@ struct command { struct command *next; }; +/* + * Return the struct command pointer kept in private data + * Used to enforce check on data type + */ +static inline struct command *jim_to_command(Jim_Interp *interp) +{ + return Jim_CmdPrivData(interp); +} + /* * Commands should be registered by filling in one or more of these * structures and passing them to [un]register_commands(). diff --git a/src/target/arm_tpiu_swo.c b/src/target/arm_tpiu_swo.c index 2da52e892..543b4f008 100644 --- a/src/target/arm_tpiu_swo.c +++ b/src/target/arm_tpiu_swo.c @@ -559,7 +559,8 @@ static int jim_arm_tpiu_swo_configure(Jim_Interp *interp, int argc, Jim_Obj * co "missing: -option ..."); return JIM_ERR; } - struct arm_tpiu_swo_object *obj = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct arm_tpiu_swo_object *obj = c->jim_handler_data; return arm_tpiu_swo_configure(&goi, obj); } @@ -583,7 +584,8 @@ static int wrap_read_u32(struct target *target, struct adiv5_ap *tpiu_ap, static int jim_arm_tpiu_swo_enable(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - struct arm_tpiu_swo_object *obj = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct arm_tpiu_swo_object *obj = c->jim_handler_data; struct command_context *cmd_ctx = current_command_context(interp); struct adiv5_ap *tpiu_ap = dap_ap(obj->spot.dap, obj->spot.ap_num); uint32_t value; @@ -786,7 +788,8 @@ error_exit: static int jim_arm_tpiu_swo_disable(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - struct arm_tpiu_swo_object *obj = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct arm_tpiu_swo_object *obj = c->jim_handler_data; if (argc != 1) { Jim_WrongNumArgs(interp, 1, argv, "Too many parameters"); diff --git a/src/target/nds32_cmd.c b/src/target/nds32_cmd.c index 1684ea882..89da845d3 100644 --- a/src/target/nds32_cmd.c +++ b/src/target/nds32_cmd.c @@ -722,7 +722,8 @@ static int jim_nds32_bulk_write(Jim_Interp *interp, int argc, Jim_Obj * const *a return JIM_ERR; } - struct target *target = Jim_CmdPrivData(goi.interp); + struct command *c = jim_to_command(goi.interp); + struct target *target = c->jim_handler_data; int result; result = target_write_buffer(target, address, count * 4, (const uint8_t *)data); @@ -751,7 +752,8 @@ static int jim_nds32_multi_write(Jim_Interp *interp, int argc, Jim_Obj * const * if (e != JIM_OK) return e; - struct target *target = Jim_CmdPrivData(goi.interp); + struct command *c = jim_to_command(goi.interp); + struct target *target = c->jim_handler_data; struct aice_port_s *aice = target_to_aice(target); int result; uint32_t address; @@ -812,7 +814,8 @@ static int jim_nds32_bulk_read(Jim_Interp *interp, int argc, Jim_Obj * const *ar if (goi.argc != 0) return JIM_ERR; - struct target *target = Jim_CmdPrivData(goi.interp); + struct command *c = jim_to_command(goi.interp); + struct target *target = c->jim_handler_data; uint32_t *data = malloc(count * sizeof(uint32_t)); int result; result = target_read_buffer(target, address, count * 4, (uint8_t *)data); @@ -863,7 +866,8 @@ static int jim_nds32_read_edm_sr(Jim_Interp *interp, int argc, Jim_Obj * const * else return ERROR_FAIL; - struct target *target = Jim_CmdPrivData(goi.interp); + struct command *c = jim_to_command(goi.interp); + struct target *target = c->jim_handler_data; struct aice_port_s *aice = target_to_aice(target); char data_str[11]; @@ -911,7 +915,8 @@ static int jim_nds32_write_edm_sr(Jim_Interp *interp, int argc, Jim_Obj * const else return ERROR_FAIL; - struct target *target = Jim_CmdPrivData(goi.interp); + struct command *c = jim_to_command(goi.interp); + struct target *target = c->jim_handler_data; struct aice_port_s *aice = target_to_aice(target); aice_write_debug_reg(aice, edm_sr_number, value); diff --git a/src/target/target.c b/src/target/target.c index 200368b13..e481d526c 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5206,21 +5206,24 @@ static int jim_target_configure(Jim_Interp *interp, int argc, Jim_Obj * const *a "missing: -option ..."); return JIM_ERR; } - struct target *target = Jim_CmdPrivData(goi.interp); + struct command *c = jim_to_command(goi.interp); + struct target *target = c->jim_handler_data; return target_configure(&goi, target); } static int jim_target_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; return target_mem2array(interp, target, argc - 1, argv + 1); } static int jim_target_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; return target_array2mem(interp, target, argc - 1, argv + 1); } @@ -5252,7 +5255,8 @@ static int jim_target_examine(Jim_Interp *interp, int argc, Jim_Obj *const *argv allow_defer = true; } - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; if (!target->tap->enabled) return jim_target_tap_disabled(interp); @@ -5270,7 +5274,8 @@ static int jim_target_examine(Jim_Interp *interp, int argc, Jim_Obj *const *argv static int jim_target_was_examined(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; Jim_SetResultBool(interp, target_was_examined(target)); return JIM_OK; @@ -5278,7 +5283,8 @@ static int jim_target_was_examined(Jim_Interp *interp, int argc, Jim_Obj * const static int jim_target_examine_deferred(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; Jim_SetResultBool(interp, target->defer_examine); return JIM_OK; @@ -5290,7 +5296,8 @@ static int jim_target_halt_gdb(Jim_Interp *interp, int argc, Jim_Obj *const *arg Jim_WrongNumArgs(interp, 1, argv, "[no parameters]"); return JIM_ERR; } - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; if (target_call_event_callbacks(target, TARGET_EVENT_GDB_HALT) != ERROR_OK) return JIM_ERR; @@ -5304,7 +5311,8 @@ static int jim_target_poll(Jim_Interp *interp, int argc, Jim_Obj *const *argv) Jim_WrongNumArgs(interp, 1, argv, "[no parameters]"); return JIM_ERR; } - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; if (!target->tap->enabled) return jim_target_tap_disabled(interp); @@ -5341,7 +5349,8 @@ static int jim_target_reset(Jim_Interp *interp, int argc, Jim_Obj *const *argv) if (e != JIM_OK) return e; - struct target *target = Jim_CmdPrivData(goi.interp); + struct command *c = jim_to_command(goi.interp); + struct target *target = c->jim_handler_data; if (!target->tap->enabled) return jim_target_tap_disabled(interp); @@ -5374,7 +5383,8 @@ static int jim_target_halt(Jim_Interp *interp, int argc, Jim_Obj *const *argv) Jim_WrongNumArgs(interp, 1, argv, "[no parameters]"); return JIM_ERR; } - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; if (!target->tap->enabled) return jim_target_tap_disabled(interp); int e = target->type->halt(target); @@ -5404,7 +5414,8 @@ static int jim_target_wait_state(Jim_Interp *interp, int argc, Jim_Obj *const *a e = Jim_GetOpt_Wide(&goi, &a); if (e != JIM_OK) return e; - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; if (!target->tap->enabled) return jim_target_tap_disabled(interp); @@ -5448,7 +5459,8 @@ static int jim_target_current_state(Jim_Interp *interp, int argc, Jim_Obj *const Jim_WrongNumArgs(interp, 1, argv, "[no parameters]"); return JIM_ERR; } - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; Jim_SetResultString(interp, target_state_name(target), -1); return JIM_OK; } @@ -5467,7 +5479,8 @@ static int jim_target_invoke_event(Jim_Interp *interp, int argc, Jim_Obj *const Jim_GetOpt_NvpUnknown(&goi, nvp_target_event, 1); return e; } - struct target *target = Jim_CmdPrivData(interp); + struct command *c = jim_to_command(interp); + struct target *target = c->jim_handler_data; target_handle_event(target, n->value); return JIM_OK; } commit a9904ba22c6a8c9cd56c85296e80396c9e05ee9e Author: Cheng-Shiun Tsai <che...@gm...> Date: Sat Feb 6 23:04:14 2021 +0000 Aarch64:Switch to EL1 from EL0 before manipulate MMU If current core is in EL0, it cannot use 'msr sctlr_el1, x0' Change-Id: I04e60e39e4c84f9d9de7cc87a8e438f5d2737dc3 Signed-off-by: Cheng-Shiun Tsai <che...@gm...> Reviewed-on: http://openocd.zylin.com/6051 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> Reviewed-by: Matthias Welwarsky <mat...@we...> diff --git a/src/target/aarch64.c b/src/target/aarch64.c index d6b12cd59..46ed49f68 100644 --- a/src/target/aarch64.c +++ b/src/target/aarch64.c @@ -133,6 +133,7 @@ static int aarch64_mmu_modify(struct target *target, int enable) struct aarch64_common *aarch64 = target_to_aarch64(target); struct armv8_common *armv8 = &aarch64->armv8_common; int retval = ERROR_OK; + enum arm_mode target_mode = ARM_MODE_ANY; uint32_t instr = 0; if (enable) { @@ -158,6 +159,8 @@ static int aarch64_mmu_modify(struct target *target, int enable) switch (armv8->arm.core_mode) { case ARMV8_64_EL0T: + target_mode = ARMV8_64_EL1H; + /* fall through */ case ARMV8_64_EL1T: case ARMV8_64_EL1H: instr = ARMV8_MSR_GP(SYSTEM_SCTLR_EL1, 0); @@ -184,9 +187,15 @@ static int aarch64_mmu_modify(struct target *target, int enable) LOG_DEBUG("unknown cpu state 0x%x", armv8->arm.core_mode); break; } + if (target_mode != ARM_MODE_ANY) + armv8_dpm_modeswitch(&armv8->dpm, target_mode); retval = armv8->dpm.instr_write_data_r0(&armv8->dpm, instr, aarch64->system_control_reg_curr); + + if (target_mode != ARM_MODE_ANY) + armv8_dpm_modeswitch(&armv8->dpm, ARM_MODE_ANY); + return retval; } ----------------------------------------------------------------------- Summary of changes: src/helper/command.c | 8 +++----- src/helper/command.h | 9 +++++++++ src/target/aarch64.c | 9 +++++++++ src/target/arm_tpiu_swo.c | 9 ++++++--- src/target/nds32_cmd.c | 15 ++++++++++----- src/target/target.c | 39 ++++++++++++++++++++++++++------------- 6 files changed, 63 insertions(+), 26 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-18 14:33:02
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via fa94a42a09aadc3851015bbaedecd0300732a8b1 (commit) via d4eecfaab57db2a3dbbd4ecdc713ffe61a07d6d8 (commit) via 7c4458fe283bf01fb6bb7042c00d63ea781d6d15 (commit) from eb6a5faf6ac8aa1791ada64e95768ff4ed29084c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fa94a42a09aadc3851015bbaedecd0300732a8b1 Author: Antonio Borneo <bor...@gm...> Date: Tue Apr 6 23:44:37 2021 +0200 doc: [3/3] uniform the texinfo syntax for commands definition To avoid errors in the documentation, like the one fixed by change http://openocd.zylin.com/6134/ , use a uniform notation across the file so simple copy-paste will work. Enclose every command within curly-brackets '{...}', even single word commands. Patch generated through: sed -i 's/^\(@deffn {[^{]*} \)\([^{][^ ]*\)/\1{\2}/' doc/openocd.texi sed -i 's/^\(@deffnx {[^{]*} \)\([^{][^ ]*\)/\1{\2}/' doc/openocd.texi Change-Id: I41a8447d487ec8f6f32c2babcbc73ac21c769344 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/6152 Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 8b4113aac..fdef3309d 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2063,7 +2063,7 @@ a target has been successfully instantiated. If you want to use those commands, you may need to force entry to the run stage. -@deffn {Config Command} init +@deffn {Config Command} {init} This command terminates the configuration stage and enters the run stage. This helps when you need to have the startup scripts manage tasks such as resetting the target, @@ -2082,7 +2082,7 @@ read/write memory on your target, @command{init} must occur before the memory read/write commands. This includes @command{nand probe}. @end deffn -@deffn {Overridable Procedure} jtag_init +@deffn {Overridable Procedure} {jtag_init} This is invoked at server startup to verify that it can talk to the scan chain (list of TAPs) which has been configured. @@ -2186,13 +2186,13 @@ breakpoints if the memory map has been set up for flash regions. @end deffn @anchor{gdbflashprogram} -@deffn {Config Command} gdb_flash_program (@option{enable}|@option{disable}) +@deffn {Config Command} {gdb_flash_program} (@option{enable}|@option{disable}) Set to @option{enable} to cause OpenOCD to program the flash memory when a vFlash packet is received. The default behaviour is @option{enable}. @end deffn -@deffn {Config Command} gdb_memory_map (@option{enable}|@option{disable}) +@deffn {Config Command} {gdb_memory_map} (@option{enable}|@option{disable}) Set to @option{enable} to cause OpenOCD to send the memory configuration to GDB when requested. GDB will then know when to set hardware breakpoints, and program flash using the GDB load command. @command{gdb_flash_program enable} must also be enabled @@ -2201,21 +2201,21 @@ Default behaviour is @option{enable}. @xref{gdbflashprogram,,gdb_flash_program}. @end deffn -@deffn {Config Command} gdb_report_data_abort (@option{enable}|@option{disable}) +@deffn {Config Command} {gdb_report_data_abort} (@option{enable}|@option{disable}) Specifies whether data aborts cause an error to be reported by GDB memory read packets. The default behaviour is @option{disable}; use @option{enable} see these errors reported. @end deffn -@deffn {Config Command} gdb_report_register_access_error (@option{enable}|@option{disable}) +@deffn {Config Command} {gdb_report_register_access_error} (@option{enable}|@option{disable}) Specifies whether register accesses requested by GDB register read/write packets report errors or not. The default behaviour is @option{disable}; use @option{enable} see these errors reported. @end deffn -@deffn {Config Command} gdb_target_description (@option{enable}|@option{disable}) +@deffn {Config Command} {gdb_target_description} (@option{enable}|@option{disable}) Set to @option{enable} to cause OpenOCD to send the target descriptions to gdb via qXfer:features:read packet. The default behaviour is @option{enable}. @end deffn @@ -2383,7 +2383,7 @@ Specifies either the address of the I/O port (default: 0x378 for LPT1) or the number of the @file{/dev/parport} device. @end deffn -@deffn {Config Command} rtck [@option{enable}|@option{disable}] +@deffn {Config Command} {rtck} [@option{enable}|@option{disable}] Displays status of RTCK option. Optionally sets that option first. @end deffn @@ -3745,7 +3745,7 @@ schemes. For example, on a multi-target board the standard may need the ability to reset only one target at time and thus want to avoid using the board-wide SRST signal. -@deffn {Overridable Procedure} init_reset mode +@deffn {Overridable Procedure} {init_reset} mode This is invoked near the beginning of the @command{reset} command, usually to provide as much of a cold (power-up) reset as practical. By default it is also invoked from @command{jtag_init} if @@ -5354,7 +5354,7 @@ As noted above, the @command{flash bank} command requires a driver name, and allows driver-specific options and behaviors. Some drivers also activate driver-specific commands. -@deffn {Flash Driver} virtual +@deffn {Flash Driver} {virtual} This is a special driver that maps a previously defined bank to another address. All bank settings will be copied from the master physical bank. @@ -5378,7 +5378,7 @@ flash bank vbank1 virtual 0x9fc00000 0 0 0 \ @subsection External Flash -@deffn {Flash Driver} cfi +@deffn {Flash Driver} {cfi} @cindex Common Flash Interface @cindex CFI The ``Common Flash Interface'' (CFI) is the main standard for @@ -5423,7 +5423,7 @@ flash bank $_FLASHNAME cfi 0x00000000 0x02000000 2 4 $_TARGETNAME @c "cfi part_id" disabled @end deffn -@deffn {Flash Driver} jtagspi +@deffn {Flash Driver} {jtagspi} @cindex Generic JTAG2SPI driver @cindex SPI @cindex jtagspi @@ -5464,7 +5464,7 @@ flash bank $_FLASHNAME spi 0x0 0 0 0 \ @end example @end deffn -@deffn {Flash Driver} xcf +@deffn {Flash Driver} {xcf} @cindex Xilinx Platform flash driver @cindex xcf Xilinx FPGAs can be configured from specialized flash ICs named Platform Flash. @@ -5510,7 +5510,7 @@ only "bin" (raw binary, do not confuse it with "bit") and "mcs" @end itemize @end deffn -@deffn {Flash Driver} lpcspifi +@deffn {Flash Driver} {lpcspifi} @cindex NXP SPI Flash Interface @cindex SPIFI @cindex lpcspifi @@ -5534,7 +5534,7 @@ flash bank $_FLASHNAME lpcspifi 0x14000000 0 0 0 $_TARGETNAME @end deffn -@deffn {Flash Driver} stmsmi +@deffn {Flash Driver} {stmsmi} @cindex STMicroelectronics Serial Memory Interface @cindex SMI @cindex stmsmi @@ -5562,7 +5562,7 @@ flash bank $_FLASHNAME stmsmi 0xf8000000 0 0 0 $_TARGETNAME @end deffn -@deffn {Flash Driver} stmqspi +@deffn {Flash Driver} {stmqspi} @cindex STMicroelectronics QuadSPI/OctoSPI Interface @cindex QuadSPI @cindex OctoSPI @@ -5677,7 +5677,7 @@ should return the status register contents. @end deffn -@deffn {Flash Driver} mrvlqspi +@deffn {Flash Driver} {mrvlqspi} This driver supports QSPI flash controller of Marvell's Wireless Microcontroller platform. @@ -5690,7 +5690,7 @@ flash bank $_FLASHNAME mrvlqspi 0x0 0 0 0 $_TARGETNAME 0x46010000 @end deffn -@deffn {Flash Driver} ath79 +@deffn {Flash Driver} {ath79} @cindex Atheros ath79 SPI driver @cindex ath79 Members of ATH79 SoC family from Atheros include a SPI interface with 3 @@ -5729,7 +5729,7 @@ flash bank flash2 ath79 0x20000000 0 0 0 $_TARGETNAME cs2 @end deffn -@deffn {Flash Driver} fespi +@deffn {Flash Driver} {fespi} @cindex Freedom E SPI @cindex fespi @@ -5742,7 +5742,7 @@ flash bank $_FLASHNAME fespi 0x20000000 0 0 0 $_TARGETNAME @subsection Internal Flash (Microcontrollers) -@deffn {Flash Driver} aduc702x +@deffn {Flash Driver} {aduc702x} The ADUC702x analog microcontrollers from Analog Devices include internal flash and use ARM7TDMI cores. The aduc702x flash driver works with models ADUC7019 through ADUC7028. @@ -5754,7 +5754,7 @@ flash bank $_FLASHNAME aduc702x 0 0 0 0 $_TARGETNAME @end example @end deffn -@deffn {Flash Driver} ambiqmicro +@deffn {Flash Driver} {ambiqmicro} @cindex ambiqmicro @cindex apollo All members of the Apollo microcontroller family from @@ -5802,7 +5802,7 @@ the flash. @end deffn @anchor{at91samd} -@deffn {Flash Driver} at91samd +@deffn {Flash Driver} {at91samd} @cindex at91samd All members of the ATSAM D2x, D1x, D0x, ATSAMR, ATSAML and ATSAMC microcontroller families from Atmel include internal flash and use ARM's Cortex-M0+ core. @@ -5891,7 +5891,7 @@ NVMUSERROW: 0xFFFFFC5DD8E0C788 @end deffn @anchor{at91sam3} -@deffn {Flash Driver} at91sam3 +@deffn {Flash Driver} {at91sam3} @cindex at91sam3 All members of the AT91SAM3 microcontroller family from Atmel include internal flash and use ARM's Cortex-M3 core. The driver @@ -5955,14 +5955,14 @@ This command shows/sets the slow clock frequency used in the @end deffn @end deffn -@deffn {Flash Driver} at91sam4 +@deffn {Flash Driver} {at91sam4} @cindex at91sam4 All members of the AT91SAM4 microcontroller family from Atmel include internal flash and use ARM's Cortex-M4 core. This driver uses the same command names/syntax as @xref{at91sam3}. @end deffn -@deffn {Flash Driver} at91sam4l +@deffn {Flash Driver} {at91sam4l} @cindex at91sam4l All members of the AT91SAM4L microcontroller family from Atmel include internal flash and use ARM's Cortex-M4 core. @@ -5977,7 +5977,7 @@ Command is used internally in event reset-deassert-post. @end deffn @anchor{atsame5} -@deffn {Flash Driver} atsame5 +@deffn {Flash Driver} {atsame5} @cindex atsame5 All members of the SAM E54, E53, E51 and D51 microcontroller families from Microchip (former Atmel) include internal flash @@ -6040,14 +6040,14 @@ USER PAGE: 0xAEECFF80FE9A9239 @end deffn -@deffn {Flash Driver} atsamv +@deffn {Flash Driver} {atsamv} @cindex atsamv All members of the ATSAMV7x, ATSAMS70, and ATSAME70 families from Atmel include internal flash and use ARM's Cortex-M7 core. This driver uses the same command names/syntax as @xref{at91sam3}. @end deffn -@deffn {Flash Driver} at91sam7 +@deffn {Flash Driver} {at91sam7} All members of the AT91SAM7 microcontroller family from Atmel include internal flash and use ARM7TDMI cores. The driver automatically recognizes a number of these chips using the chip identification @@ -6094,13 +6094,13 @@ the appropriate at91sam7 target. @end deffn @end deffn -@deffn {Flash Driver} avr +@deffn {Flash Driver} {avr} The AVR 8-bit microcontrollers from Atmel integrate flash memory. @emph{The current implementation is incomplete.} @comment - defines mass_erase ... pointless given flash_erase_address @end deffn -@deffn {Flash Driver} bluenrg-x +@deffn {Flash Driver} {bluenrg-x} STMicroelectronics BlueNRG-1, BlueNRG-2 and BlueNRG-LP Bluetooth low energy wireless system-on-chip. They include ARM Cortex-M0/M0+ core and internal flash memory. The driver automatically recognizes these chips using the chip identification registers, and autoconfigures itself. @@ -6119,7 +6119,7 @@ flash erase_sector 0 0 last # It will perform a mass erase Triggering a mass erase is also useful when users want to disable readout protection. @end deffn -@deffn {Flash Driver} cc26xx +@deffn {Flash Driver} {cc26xx} All versions of the SimpleLink CC13xx and CC26xx microcontrollers from Texas Instruments include internal flash. The cc26xx flash driver supports both the CC13xx and CC26xx family of devices. The driver automatically recognizes the @@ -6131,7 +6131,7 @@ flash bank $_FLASHNAME cc26xx 0 0 0 0 $_TARGETNAME @end example @end deffn -@deffn {Flash Driver} cc3220sf +@deffn {Flash Driver} {cc3220sf} The CC3220SF version of the SimpleLink CC32xx microcontrollers from Texas Instruments includes 1MB of internal flash. The cc3220sf flash driver only supports the internal flash. The serial flash on SimpleLink boards is @@ -6145,7 +6145,7 @@ flash bank $_FLASHNAME cc3220sf 0 0 0 0 $_TARGETNAME @end example @end deffn -@deffn {Flash Driver} efm32 +@deffn {Flash Driver} {efm32} All members of the EFM32 microcontroller family from Energy Micro include internal flash and use ARM Cortex-M3 cores. The driver automatically recognizes a number of these chips using the chip identification register, and @@ -6165,7 +6165,7 @@ Note that in order for this command to take effect, the target needs to be reset supported.} @end deffn -@deffn {Flash Driver} esirisc +@deffn {Flash Driver} {esirisc} Members of the eSi-RISC family may optionally include internal flash programmed via the eSi-TSMC Flash interface. Additional parameters are required to configure the driver: @option{cfg_address} is the base address of the @@ -6187,7 +6187,7 @@ is an uncommon operation.} @end deffn @end deffn -@deffn {Flash Driver} fm3 +@deffn {Flash Driver} {fm3} All members of the FM3 microcontroller family from Fujitsu include internal flash and use ARM Cortex-M3 cores. The @var{fm3} driver uses the @var{target} parameter to select the @@ -6200,7 +6200,7 @@ flash bank $_FLASHNAME fm3 0 0 0 0 $_TARGETNAME @end example @end deffn -@deffn {Flash Driver} fm4 +@deffn {Flash Driver} {fm4} All members of the FM4 microcontroller family from Spansion (formerly Fujitsu) include internal flash and use ARM Cortex-M4 cores. The @var{fm4} driver uses a @var{family} parameter to select the @@ -6220,7 +6220,7 @@ flash bank $@{_FLASHNAME@}1 fm4 0x00100000 0 0 0 \ nor is Chip Erase (only Sector Erase is implemented).} @end deffn -@deffn {Flash Driver} kinetis +@deffn {Flash Driver} {kinetis} @cindex kinetis Kx, KLx, KVx and KE1x members of the Kinetis microcontroller family from NXP (former Freescale) include @@ -6319,7 +6319,7 @@ Command disables watchdog timer. @end deffn @end deffn -@deffn {Flash Driver} kinetis_ke +@deffn {Flash Driver} {kinetis_ke} @cindex kinetis_ke KE0x and KEAx members of the Kinetis microcontroller family from NXP include internal flash and use ARM Cortex-M0+. The driver automatically recognizes @@ -6347,7 +6347,7 @@ Command disables watchdog timer. @end deffn @end deffn -@deffn {Flash Driver} lpc2000 +@deffn {Flash Driver} {lpc2000} This is the driver to support internal flash of all members of the LPC11(x)00 and LPC1300 microcontroller families and most members of the LPC800, LPC1500, LPC1700, LPC1800, LPC2000, LPC4000, LPC54100, @@ -6404,7 +6404,7 @@ the specified flash @var{bank}. @end deffn @end deffn -@deffn {Flash Driver} lpc288x +@deffn {Flash Driver} {lpc288x} The LPC2888 microcontroller from NXP needs slightly different flash support from its lpc2000 siblings. The @var{lpc288x} driver defines one mandatory parameter, @@ -6416,7 +6416,7 @@ flash bank $_FLASHNAME lpc288x 0 0 0 0 $_TARGETNAME 12000000 @end example @end deffn -@deffn {Flash Driver} lpc2900 +@deffn {Flash Driver} {lpc2900} This driver supports the LPC29xx ARM968E based microcontroller family from NXP. @@ -6539,7 +6539,7 @@ lpc2900 secure_jtag 0 @end deffn @end deffn -@deffn {Flash Driver} mdr +@deffn {Flash Driver} {mdr} This drivers handles the integrated NOR flash on Milandr Cortex-M based controllers. A known limitation is that the Info memory can't be read or verified as it's not memory mapped. @@ -6567,7 +6567,7 @@ if @{ [info exists IMEMORY] && [string equal $IMEMORY true] @} @{ @end example @end deffn -@deffn {Flash Driver} msp432 +@deffn {Flash Driver} {msp432} All versions of the SimpleLink MSP432 microcontrollers from Texas Instruments include internal flash. The msp432 flash driver automatically recognizes the specific version's flash parameters and autoconfigures itself. @@ -6602,7 +6602,7 @@ msp432 bsl lock @end deffn @end deffn -@deffn {Flash Driver} niietcm4 +@deffn {Flash Driver} {niietcm4} This drivers handles the integrated NOR flash on NIIET Cortex-M4 based controllers. Flash size and sector layout are auto-configured by the driver. Main flash memory is called "Bootflash" and has main region and info region. @@ -6662,7 +6662,7 @@ Show information about flash driver. @end deffn -@deffn {Flash Driver} nrf5 +@deffn {Flash Driver} {nrf5} All members of the nRF51 microcontroller families from Nordic Semiconductor include internal flash and use ARM Cortex-M0 core. Also, the nRF52832 microcontroller from Nordic Semiconductor, which include @@ -6687,7 +6687,7 @@ Decodes and shows information from FICR and UICR registers. @end deffn -@deffn {Flash Driver} ocl +@deffn {Flash Driver} {ocl} This driver is an implementation of the ``on chip flash loader'' protocol proposed by Pavel Chromy. @@ -6701,7 +6701,7 @@ flash bank $_FLASHNAME ocl 0 0 0 0 $_TARGETNAME @end example @end deffn -@deffn {Flash Driver} pic32mx +@deffn {Flash Driver} {pic32mx} The PIC32MX microcontrollers are based on the MIPS 4K cores, and integrate flash memory. @@ -6725,7 +6725,7 @@ This will remove any Code Protection. @end deffn @end deffn -@deffn {Flash Driver} psoc4 +@deffn {Flash Driver} {psoc4} All members of the PSoC 41xx/42xx microcontroller family from Cypress include internal flash and use ARM Cortex-M0 cores. The driver automatically recognizes a number of these chips using @@ -6759,7 +6759,7 @@ The @var{num} parameter is a value shown by @command{flash banks}. @end deffn @end deffn -@deffn {Flash Driver} psoc5lp +@deffn {Flash Driver} {psoc5lp} All members of the PSoC 5LP microcontroller family from Cypress include internal program flash and use ARM Cortex-M3 cores. The driver probes for a number of these chips and autoconfigures itself, @@ -6785,7 +6785,7 @@ and all row latches in all flash arrays on the device. @end deffn @end deffn -@deffn {Flash Driver} psoc5lp_eeprom +@deffn {Flash Driver} {psoc5lp_eeprom} All members of the PSoC 5LP microcontroller family from Cypress include internal EEPROM and use ARM Cortex-M3 cores. The driver probes for a number of these chips and autoconfigures itself, @@ -6797,7 +6797,7 @@ flash bank $_CHIPNAME.eeprom psoc5lp_eeprom 0x40008000 0 0 0 \ @end example @end deffn -@deffn {Flash Driver} psoc5lp_nvl +@deffn {Flash Driver} {psoc5lp_nvl} All members of the PSoC 5LP microcontroller family from Cypress include internal Nonvolatile Latches and use ARM Cortex-M3 cores. The driver probes for a number of these chips and autoconfigures itself. @@ -6822,7 +6822,7 @@ after successful write. @end quotation @end deffn -@deffn {Flash Driver} psoc6 +@deffn {Flash Driver} {psoc6} Supports PSoC6 (CY8C6xxx) family of Cypress microcontrollers. PSoC6 is a dual-core device with CM0+ and CM4 cores. Both cores share the same Flash/RAM/MMIO address space. @@ -6890,7 +6890,7 @@ Note: only Main and Work flash regions support Erase operation. @end deffn @end deffn -@deffn {Flash Driver} sim3x +@deffn {Flash Driver} {sim3x} All members of the SiM3 microcontroller family from Silicon Laboratories include internal flash and use ARM Cortex-M3 cores. It supports both JTAG and SWD interface. @@ -6913,7 +6913,7 @@ Lock the flash. To unlock use the @command{sim3x mass_erase} command. @end deffn @end deffn -@deffn {Flash Driver} stellaris +@deffn {Flash Driver} {stellaris} All members of the Stellaris LM3Sxxx, LM4x and Tiva C microcontroller families from Texas Instruments include internal flash. The driver automatically recognizes a number of these chips using the chip @@ -6939,7 +6939,7 @@ applied to all of them. @end deffn @end deffn -@deffn {Flash Driver} stm32f1x +@deffn {Flash Driver} {stm32f1x} All members of the STM32F0, STM32F1 and STM32F3 microcontroller families from STMicroelectronics include internal flash and use ARM Cortex-M0/M3/M4 cores. The driver automatically recognizes a number of these chips using @@ -7001,7 +7001,7 @@ The @var{num} parameter is a value shown by @command{flash banks}. @end deffn @end deffn -@deffn {Flash Driver} stm32f2x +@deffn {Flash Driver} {stm32f2x} All members of the STM32F2, STM32F4 and STM32F7 microcontroller families from STMicroelectronics include internal flash and use ARM Cortex-M3/M4/M7 cores. The driver automatically recognizes a number of these chips using @@ -7066,7 +7066,7 @@ The @var{num} parameter is a value shown by @command{flash banks}, @var{optcr2} @end deffn @end deffn -@deffn {Flash Driver} stm32h7x +@deffn {Flash Driver} {stm32h7x} All members of the STM32H7 microcontroller families from STMicroelectronics include internal flash and use ARM Cortex-M7 core. The driver automatically recognizes a number of these chips using @@ -7134,7 +7134,7 @@ stm32h7x option_write 0 0x20 0x8000000 0x8000000 @end deffn @end deffn -@deffn {Flash Driver} stm32lx +@deffn {Flash Driver} {stm32lx} All members of the STM32L0 and STM32L1 microcontroller families from STMicroelectronics include internal flash and use ARM Cortex-M3 and Cortex-M0+ cores. The driver automatically recognizes a number of these chips using @@ -7174,7 +7174,7 @@ The @var{num} parameter is a value shown by @command{flash banks}. @end deffn @end deffn -@deffn {Flash Driver} stm32l4x +@deffn {Flash Driver} {stm32l4x} All members of the STM32 G0, G4, L4, L4+, L5, WB and WL microcontroller families from STMicroelectronics include internal flash and use ARM Cortex-M0+, M4 and M33 cores. @@ -7275,7 +7275,7 @@ The @var{num} parameter is a value shown by @command{flash banks}. @end deffn @end deffn -@deffn {Flash Driver} str7x +@deffn {Flash Driver} {str7x} All members of the STR7 microcontroller family from STMicroelectronics include internal flash and use ARM7TDMI cores. The @var{str7x} driver defines one mandatory parameter, @var{variant}, @@ -7292,7 +7292,7 @@ for the specified flash bank. @end deffn @end deffn -@deffn {Flash Driver} str9x +@deffn {Flash Driver} {str9x} Most members of the STR9 microcontroller family from STMicroelectronics include internal flash and use ARM966E cores. The str9 needs the flash controller to be configured using @@ -7317,7 +7317,7 @@ The @var{num} parameter is a value shown by @command{flash banks}. @end deffn -@deffn {Flash Driver} str9xpec +@deffn {Flash Driver} {str9xpec} @cindex str9xpec Only use this driver for locking/unlocking the device or configuring the option bytes. @@ -7412,7 +7412,7 @@ unlock str9 device. @end deffn -@deffn {Flash Driver} swm050 +@deffn {Flash Driver} {swm050} @cindex swm050 All members of the swm050 microcontroller family from Foshan Synwit Tech. @@ -7429,7 +7429,7 @@ Erases the entire flash bank. @end deffn -@deffn {Flash Driver} tms470 +@deffn {Flash Driver} {tms470} Most members of the TMS470 microcontroller family from Texas Instruments include internal flash and use ARM7TDMI cores. This driver doesn't require the chip and bus width to be specified. @@ -7450,7 +7450,7 @@ the flash clock. @end deffn @end deffn -@deffn {Flash Driver} w600 +@deffn {Flash Driver} {w600} W60x series Wi-Fi SoC from WinnerMicro are designed with ARM Cortex-M3 and have 1M Byte QFLASH inside. The @var{w600} driver uses the @var{target} parameter to select the @@ -7461,12 +7461,12 @@ flash bank $_FLASHNAME w600 0x08000000 0 0 0 $_TARGETNAMEs @end example @end deffn -@deffn {Flash Driver} xmc1xxx +@deffn {Flash Driver} {xmc1xxx} All members of the XMC1xxx microcontroller family from Infineon. This driver does not require the chip and bus width to be specified. @end deffn -@deffn {Flash Driver} xmc4xxx +@deffn {Flash Driver} {xmc4xxx} All members of the XMC4xxx microcontroller family from Infineon. This driver does not require the chip and bus width to be specified. @@ -7794,7 +7794,7 @@ As noted above, the @command{nand device} command allows driver-specific options and behaviors. Some controllers also activate controller-specific commands. -@deffn {NAND Driver} at91sam9 +@deffn {NAND Driver} {at91sam9} This driver handles the NAND controllers found on AT91SAM9 family chips from Atmel. It takes two extra parameters: address of the NAND chip; address of the ECC controller. @@ -7829,7 +7829,7 @@ is the base address of the PIO controller and @var{pin} is the pin number. @end deffn @end deffn -@deffn {NAND Driver} davinci +@deffn {NAND Driver} {davinci} This driver handles the NAND controllers found on DaVinci family chips from Texas Instruments. It takes three extra parameters: @@ -7847,7 +7847,7 @@ to implement those ECC modes, unless they are disabled using the @command{nand raw_access} command. @end deffn -@deffn {NAND Driver} lpc3180 +@deffn {NAND Driver} {lpc3180} These controllers require an extra @command{nand device} parameter: the clock rate used by the controller. @deffn {Command} {lpc3180 select} num [mlc|slc] @@ -7863,12 +7863,12 @@ in the MLC controller mode, but won't change SLC behavior. @end deffn @comment current lpc3180 code won't issue 5-byte address cycles -@deffn {NAND Driver} mx3 +@deffn {NAND Driver} {mx3} This driver handles the NAND controller in i.MX31. The mxc driver should work for this chip as well. @end deffn -@deffn {NAND Driver} mxc +@deffn {NAND Driver} {mxc} This driver handles the NAND controller found in Freescale i.MX chips. It has support for v1 (i.MX27 and i.MX31) and v2 (i.MX35). The driver takes 3 extra arguments, chip (@option{mx27}, @@ -7884,7 +7884,7 @@ without parameter query status. @end deffn @end deffn -@deffn {NAND Driver} orion +@deffn {NAND Driver} {orion} These controllers require an extra @command{nand device} parameter: the address of the controller. @example @@ -7896,11 +7896,11 @@ or @code{read_page} methods, so @command{nand raw_access} won't change any behavior. @end deffn -@deffn {NAND Driver} s3c2410 -@deffnx {NAND Driver} s3c2412 -@deffnx {NAND Driver} s3c2440 -@deffnx {NAND Driver} s3c2443 -@deffnx {NAND Driver} s3c6400 +@deffn {NAND Driver} {s3c2410} +@deffnx {NAND Driver} {s3c2412} +@deffnx {NAND Driver} {s3c2440} +@deffnx {NAND Driver} {s3c2443} +@deffnx {NAND Driver} {s3c6400} These S3C family controllers don't have any special @command{nand device} options, and don't define any specialized commands. @@ -7987,7 +7987,7 @@ Drivers may support PLD-specific options to the @command{pld device} definition command, and may also define commands usable only with that particular type of PLD. -@deffn {FPGA Driver} virtex2 [no_jstart] +@deffn {FPGA Driver} {virtex2} [no_jstart] Virtex-II is a family of FPGAs sold by Xilinx. It supports the IEEE 1532 standard for In-System Configuration (ISC). @@ -8756,7 +8756,7 @@ Stops trace data collection. To use an ETM trace port it must be associated with a driver. -@deffn {Trace Port Driver} dummy +@deffn {Trace Port Driver} {dummy} Use the @option{dummy} driver if you are configuring an ETM that's not connected to anything (on-chip ETB or off-chip trace connector). @emph{This driver lets OpenOCD talk to the ETM, but it does not expose @@ -8766,7 +8766,7 @@ Associates the ETM for @var{target} with a dummy driver. @end deffn @end deffn -@deffn {Trace Port Driver} etb +@deffn {Trace Port Driver} {etb} Use the @option{etb} driver if you are configuring an ETM to use on-chip ETB memory. @deffn {Config Command} {etb config} target etb_tap commit d4eecfaab57db2a3dbbd4ecdc713ffe61a07d6d8 Author: Antonio Borneo <bor...@gm...> Date: Tue Apr 6 23:31:32 2021 +0200 doc: [2/3] uniform the texinfo syntax for commands definition To avoid errors in the documentation, like the one fixed by change http://openocd.zylin.com/6134/ , use a uniform notation across the file so simple copy-paste will work. Enclose every Command within curly-brackets '{...}', even single word commands. Patch generated through: sed -i 's/^\(@deffn {Command} \)\([^{][^ ]*\)/\1{\2}/' doc/openocd.texi sed -i 's/^\(@deffnx {Command} \)\([^{][^ ]*\)/\1{\2}/' doc/openocd.texi Change-Id: I797e8d9f5ab0aa1936f350b340d3bdd52373f5aa Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/6151 Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 247938fae..8b4113aac 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2115,7 +2115,7 @@ If you disable all access through TCP/IP, you will need to use the command line @option{-pipe} option. @anchor{gdb_port} -@deffn {Command} gdb_port [number] +@deffn {Command} {gdb_port} [number] @cindex GDB server Normally gdb listens to a TCP/IP port, but GDB can also communicate via pipes(stdin/out or named pipes). The name @@ -2148,7 +2148,7 @@ gdb (with 'set remotetimeout') is recommended. An insufficient timeout may cause initialization to fail with "Unknown remote qXfer reply: OK". @end deffn -@deffn {Command} tcl_port [number] +@deffn {Command} {tcl_port} [number] Specify or query the port used for a simplified RPC connection that can be used by clients to issue TCL commands and get the output from the Tcl engine. @@ -2158,7 +2158,7 @@ the port @var{number} defaults to 6666. When specified as "disabled", this service is not activated. @end deffn -@deffn {Command} telnet_port [number] +@deffn {Command} {telnet_port} [number] Specify or query the port on which to listen for incoming telnet connections. This port is intended for interaction with one human through TCL commands. @@ -2177,7 +2177,7 @@ The ones listed here are static and global. @xref{targetevents,,Target Events}, about configuring target-specific event handling. @anchor{gdbbreakpointoverride} -@deffn {Command} gdb_breakpoint_override [@option{hard}|@option{soft}|@option{disable}] +@deffn {Command} {gdb_breakpoint_override} [@option{hard}|@option{soft}|@option{disable}] Force breakpoint type for gdb @command{break} commands. This option supports GDB GUIs which don't distinguish hard versus soft breakpoints, if the default OpenOCD and @@ -2220,7 +2220,7 @@ Set to @option{enable} to cause OpenOCD to send the target descriptions to gdb v The default behaviour is @option{enable}. @end deffn -@deffn {Command} gdb_save_tdesc +@deffn {Command} {gdb_save_tdesc} Saves the target description file to the local file system. The file name is @i{target_name}.xml. @@ -2265,7 +2265,7 @@ to the various active targets. There is a command to manage and monitor that polling, which is normally done in the background. -@deffn {Command} poll [@option{on}|@option{off}] +@deffn {Command} {poll} [@option{on}|@option{off}] Poll the current target for its current state. (Also, @pxref{targetcurstate,,target curstate}.) If that target is in debug mode, architecture @@ -3598,19 +3598,19 @@ When a board has a reset button connected to SRST line it will probably have hardware debouncing, implying you should use this. @end deffn -@deffn {Command} jtag_ntrst_assert_width milliseconds +@deffn {Command} {jtag_ntrst_assert_width} milliseconds Minimum amount of time (in milliseconds) OpenOCD should wait after asserting nTRST (active-low JTAG TAP reset) before allowing it to be deasserted. @end deffn -@deffn {Command} jtag_ntrst_delay milliseconds +@deffn {Command} {jtag_ntrst_delay} milliseconds How long (in milliseconds) OpenOCD should wait after deasserting nTRST (active-low JTAG TAP reset) before starting new JTAG operations. @end deffn @anchor{reset_config} -@deffn {Command} reset_config mode_flag ... +@deffn {Command} {reset_config} mode_flag ... This command displays or modifies the reset configuration of your combination of JTAG board and target in target configuration scripts. @@ -4446,7 +4446,7 @@ foreach t [target names] @{ @c yep, "target list" would have been better. @c plus maybe "target setdefault". -@deffn {Command} targets [name] +@deffn {Command} {targets} [name] @emph{Note: the name of this command is plural. Other target command names are singular.} @@ -8032,11 +8032,11 @@ port is 5555. @section Server Commands -@deffn {Command} exit +@deffn {Command} {exit} Exits the current telnet session. @end deffn -@deffn {Command} help [string] +@deffn {Command} {help} [string] With no parameters, prints help text for all commands. Otherwise, prints each helptext containing @var{string}. Not every command provides helptext. @@ -8047,7 +8047,7 @@ In most cases, no such restriction is listed; this indicates commands which are only available after the configuration stage has completed. @end deffn -@deffn {Command} sleep msec [@option{busy}] +@deffn {Command} {sleep} msec [@option{busy}] Wait for at least @var{msec} milliseconds before resuming. If @option{busy} is passed, busy-wait instead of sleeping. (This option is strongly discouraged.) @@ -8055,7 +8055,7 @@ Useful in connection with script files (@command{script} command and @command{target_name} configuration). @end deffn -@deffn {Command} shutdown [@option{error}] +@deffn {Command} {shutdown} [@option{error}] Close the OpenOCD server, disconnecting all clients (GDB, telnet, other). If option @option{error} is used, OpenOCD will return a non-zero exit code to the parent process. @@ -8075,7 +8075,7 @@ or its replacement will be automatically executed before OpenOCD exits. @end deffn @anchor{debuglevel} -@deffn {Command} debug_level [n] +@deffn {Command} {debug_level} [n] @cindex message level Display debug level. If @var{n} (from 0..4) is provided, then set it to that level. @@ -8091,7 +8091,7 @@ file (which is normally the server's standard output). @xref{Running}. @end deffn -@deffn {Command} echo [-n] message +@deffn {Command} {echo} [-n] message Logs a message at "user" priority. Output @var{message} to stdout. Option "-n" suppresses trailing newline. @@ -8100,16 +8100,16 @@ echo "Downloading kernel -- please wait" @end example @end deffn -@deffn {Command} log_output [filename | "default"] +@deffn {Command} {log_output} [filename | "default"] Redirect logging to @var{filename} or set it back to default output; the default log output channel is stderr. @end deffn -@deffn {Command} add_script_search_dir [directory] +@deffn {Command} {add_script_search_dir} [directory] Add @var{directory} to the file/script search path. @end deffn -@deffn {Command} bindto [@var{name}] +@deffn {Command} {bindto} [@var{name}] Specify hostname or IPv4 address on which to listen for incoming TCP/IP connections. By default, OpenOCD will listen on the loopback interface only. If your network environment is safe, @code{bindto @@ -8130,7 +8130,7 @@ various operations. The current target may be changed by using @command{targets} command with the name of the target which should become current. -@deffn {Command} reg [(number|name) [(value|'force')]] +@deffn {Command} {reg} [(number|name) [(value|'force')]] Access a single register by @var{number} or by its @var{name}. The target must generally be halted before access to CPU core registers is allowed. Depending on the hardware, some other @@ -8169,8 +8169,8 @@ Debug and trace infrastructure: @end example @end deffn -@deffn {Command} halt [ms] -@deffnx {Command} wait_halt [ms] +@deffn {Command} {halt} [ms] +@deffnx {Command} {wait_halt} [ms] The @command{halt} command first sends a halt request to the target, which @command{wait_halt} doesn't. Otherwise these behave the same: wait up to @var{ms} milliseconds, @@ -8204,19 +8204,19 @@ power consumption (because the CPU is needlessly clocked). @end deffn -@deffn {Command} resume [address] +@deffn {Command} {resume} [address] Resume the target at its current code position, or the optional @var{address} if it is provided. OpenOCD will wait 5 seconds for the target to resume. @end deffn -@deffn {Command} step [address] +@deffn {Command} {step} [address] Single-step the target at its current code position, or the optional @var{address} if it is provided. @end deffn @anchor{resetcommand} -@deffn {Command} reset +@deffn {Command} {reset} @deffnx {Command} {reset run} @deffnx {Command} {reset halt} @deffnx {Command} {reset init} @@ -8237,7 +8237,7 @@ The other options will not work on all systems. @end itemize @end deffn -@deffn {Command} soft_reset_halt +@deffn {Command} {soft_reset_halt} Requesting target halt and executing a soft reset. This is often used when a target cannot be reset and halted. The target, after reset is released begins to execute code. OpenOCD attempts to stop the CPU and @@ -8293,10 +8293,10 @@ Please use their TARGET object siblings to avoid making assumptions about what TAP is the current target, or about MMU configuration. @end enumerate -@deffn {Command} mdd [phys] addr [count] -@deffnx {Command} mdw [phys] addr [count] -@deffnx {Command} mdh [phys] addr [count] -@deffnx {Command} mdb [phys] addr [count] +@deffn {Command} {mdd} [phys] addr [count] +@deffnx {Command} {mdw} [phys] addr [count] +@deffnx {Command} {mdh} [phys] addr [count] +@deffnx {Command} {mdb} [phys] addr [count] Display contents of address @var{addr}, as 64-bit doublewords (@command{mdd}), 32-bit words (@command{mdw}), 16-bit halfwords (@command{mdh}), @@ -8310,10 +8310,10 @@ If @var{count} is specified, displays that many units. see the @code{mem2array} primitives.) @end deffn -@deffn {Command} mwd [phys] addr doubleword [count] -@deffnx {Command} mww [phys] addr word [count] -@deffnx {Command} mwh [phys] addr halfword [count] -@deffnx {Command} mwb [phys] addr byte [count] +@deffn {Command} {mwd} [phys] addr doubleword [count] +@deffnx {Command} {mww} [phys] addr word [count] +@deffnx {Command} {mwh} [phys] addr halfword [count] +@deffnx {Command} {mwb} [phys] addr byte [count] Writes the specified @var{doubleword} (64 bits), @var{word} (32 bits), @var{halfword} (16 bits), or @var{byte} (8-bit) value, at the specified address @var{addr}. @@ -11162,7 +11162,7 @@ type target_state state [state-name] type target_reset mode [reset-mode] @end verbatim -@deffn {Command} tcl_notifications [on/off] +@deffn {Command} {tcl_notifications} [on/off] Toggle output of target notifications to the current Tcl RPC server. Only available from the Tcl RPC server. Defaults to off. @@ -11181,7 +11181,7 @@ Target trace data is emitted as a Tcl associative array in the following format. type target_trace data [trace-data-hex-encoded] @end verbatim -@deffn {Command} tcl_trace [on/off] +@deffn {Command} {tcl_trace} [on/off] Toggle output of target trace data to the current Tcl RPC server. Only available from the Tcl RPC server. Defaults to off. commit 7c4458fe283bf01fb6bb7042c00d63ea781d6d15 Author: Antonio Borneo <bor...@gm...> Date: Tue Apr 6 23:24:49 2021 +0200 doc: [1/3] uniform the texinfo syntax for commands definition To avoid errors in the documentation, like the one fixed by change http://openocd.zylin.com/6134/ , use a uniform notation across the file so simple copy-paste will work. Both 'Command' and '{Command}' are in use, with the following statistics: 0 @deffnx {Command} 45 @deffn {Command} 31 @deffnx Command 382 @deffn Command While 'Command' is the most popular, prefer the version within curly-brackets that has to be used for multi-word definition like '{NAND Driver}', '{Config Command}', '{FPGA Driver}', ... Patch generated through: sed -i 's/^\(@deffn \)\(Command\)/\1{\2}/' doc/openocd.texi sed -i 's/^\(@deffnx \)\(Command\)/\1{\2}/' doc/openocd.texi Change-Id: If692bbf7e546c5287f466a6aa6940d42b3d4655d Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/6150 Reviewed-by: Yasushi SHOJI <ya...@sp...> Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index e39ff86f3..247938fae 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2265,7 +2265,7 @@ to the various active targets. There is a command to manage and monitor that polling, which is normally done in the background. -@deffn Command poll [@option{on}|@option{off}] +@deffn {Command} poll [@option{on}|@option{off}] Poll the current target for its current state. (Also, @pxref{targetcurstate,,target curstate}.) If that target is in debug mode, architecture @@ -2339,11 +2339,11 @@ Use the adapter driver @var{name} to connect to the target. @end deffn -@deffn Command {adapter list} +@deffn {Command} {adapter list} List the debug adapter drivers that have been built into the running copy of OpenOCD. @end deffn -@deffn Command {adapter transports} transport_name+ +@deffn {Command} {adapter transports} transport_name+ Specifies the transports supported by this debug adapter. The adapter driver builds-in similar knowledge; use this only when external configuration (such as jumpering) changes what @@ -2352,12 +2352,12 @@ the hardware can support. -@deffn Command {adapter name} +@deffn {Command} {adapter name} Returns the name of the debug adapter driver being used. @end deffn @anchor{adapter_usb_location} -@deffn Command {adapter usb location} [<bus>-<port>[.<port>]...] +@deffn {Command} {adapter usb location} [<bus>-<port>[.<port>]...] Displays or specifies the physical USB port of the adapter to use. The path roots at @var{bus} and walks down the physical ports, with each @var{port} option specifying a deeper level in the bus topology, the last @@ -2393,7 +2393,7 @@ Optionally sets that option first. Olimex ARM-JTAG-EW USB adapter This has one driver-specific command: -@deffn Command {armjtagew_info} +@deffn {Command} {armjtagew_info} Logs some status @end deffn @end deffn @@ -2992,7 +2992,7 @@ When using PPDEV to access the parallel port, use the number of the parallel por you may encounter a problem. @end deffn -@deffn Command {parport_toggling_time} [nanoseconds] +@deffn {Command} {parport_toggling_time} [nanoseconds] Displays how many nanoseconds the hardware needs to toggle TCK; the parport driver uses this value to obey the @command{adapter speed} configuration. @@ -3283,12 +3283,12 @@ As noted earlier, depending on the version of OpenOCD you use, and the debug adapter you are using, several transports may be available to communicate with debug targets (or perhaps to program flash memory). -@deffn Command {transport list} +@deffn {Command} {transport list} displays the names of the transports supported by this version of OpenOCD. @end deffn -@deffn Command {transport select} @option{transport_name} +@deffn {Command} {transport select} @option{transport_name} Select which of the supported transports to use in this OpenOCD session. When invoked with @option{transport_name}, attempts to select the named @@ -3335,12 +3335,12 @@ driver} (in which case the command is @command{transport select hla_swd}) or @ref{st_link_dap_interface,the st-link interface driver} (in which case the command is @command{transport select dapdirect_swd}). -@deffn Command {swd newdap} ... +@deffn {Command} {swd newdap} ... Declares a single DAP which uses SWD transport. Parameters are currently the same as "jtag newtap" but this is expected to change. @end deffn -@deffn Command {swd wcr trn prescale} +@deffn {Command} {swd wcr trn prescale} Updates TRN (turnaround delay) and prescaling.fields of the Wire Control Register (WCR). No parameters: displays current settings. @@ -3415,7 +3415,7 @@ may not be the fastest solution. instead of @command{adapter speed}, but only for (ARM) cores and boards which support adaptive clocking. -@deffn Command {adapter speed} max_speed_kHz +@deffn {Command} {adapter speed} max_speed_kHz A non-zero speed is in KHZ. Hence: 3000 is 3mhz. JTAG interfaces usually support a limited number of speeds. The speed actually used won't be faster @@ -3585,13 +3585,13 @@ needing to cope with both architecture and board specific constraints. @section Commands for Handling Resets -@deffn Command {adapter srst pulse_width} milliseconds +@deffn {Command} {adapter srst pulse_width} milliseconds Minimum amount of time (in milliseconds) OpenOCD should wait after asserting nSRST (active-low system reset) before allowing it to be deasserted. @end deffn -@deffn Command {adapter srst delay} milliseconds +@deffn {Command} {adapter srst delay} milliseconds How long (in milliseconds) OpenOCD should wait after deasserting nSRST (active-low system reset) before starting new JTAG operations. When a board has a reset button connected to SRST line it will @@ -3768,7 +3768,7 @@ This is done by calling @command{jtag arp_init} (or @command{jtag arp_init-reset}). @end deffn -@deffn Command {jtag arp_init} +@deffn {Command} {jtag arp_init} This validates the scan chain using just the four standard JTAG signals (TMS, TCK, TDI, TDO). It starts by issuing a JTAG-only reset. @@ -3781,7 +3781,7 @@ If these tests all pass, TAP @code{setup} events are issued to all TAPs with handlers for that event. @end deffn -@deffn Command {jtag arp_init-reset} +@deffn {Command} {jtag arp_init-reset} This uses TRST and SRST to try resetting everything on the JTAG scan chain (and anything else connected to SRST). @@ -3889,7 +3889,7 @@ Actual config files typically use a variable such as @code{$_CHIPNAME} instead of literals like @option{str912}, to support more than one chip of each type. @xref{Config File Guidelines}. -@deffn Command {jtag names} +@deffn {Command} {jtag names} Returns the names of all current TAPs in the scan chain. Use @command{jtag cget} or @command{jtag tapisenabled} to examine attributes and state of each TAP. @@ -3900,7 +3900,7 @@ foreach t [jtag names] @{ @end example @end deffn -@deffn Command {scan_chain} +@deffn {Command} {scan_chain} Displays the TAPs in the scan chain configuration, and their status. The set of TAPs listed by this command is fixed by @@ -3934,7 +3934,7 @@ and underscores are OK; while others (including dots!) are not. @section TAP Declaration Commands @c shouldn't this be(come) a {Config Command}? -@deffn Command {jtag newtap} chipname tapname configparams... +@deffn {Command} {jtag newtap} chipname tapname configparams... Declares a new TAP with the dotted name @var{chipname}.@var{tapname}, and configured according to the various @var{configparams}. @@ -4026,12 +4026,12 @@ devices do not set the ack bit until sometime later. @section Other TAP commands -@deffn Command {jtag cget} dotted.name @option{-idcode} +@deffn {Command} {jtag cget} dotted.name @option{-idcode} Get the value of the IDCODE found in hardware. @end deffn -@deffn Command {jtag cget} dotted.name @option{-event} event_name -@deffnx Command {jtag configure} dotted.name @option{-event} event_name handler +@deffn {Command} {jtag cget} dotted.name @option{-event} event_name +@deffnx {Command} {jtag configure} dotted.name @option{-event} event_name handler At this writing this TAP attribute mechanism is limited and used mostly for event handling. (It is not a direct analogue of the @code{cget}/@code{configure} @@ -4152,7 +4152,7 @@ uses quotes to evaluate @code{$CHIP} when the event is configured. Using brackets @{ @} would cause it to be evaluated later, at runtime, when it might have a different value. -@deffn Command {jtag tapdisable} dotted.name +@deffn {Command} {jtag tapdisable} dotted.name If necessary, disables the tap by sending it a @option{tap-disable} event. Returns the string "1" if the tap @@ -4160,7 +4160,7 @@ specified by @var{dotted.name} is enabled, and "0" if it is disabled. @end deffn -@deffn Command {jtag tapenable} dotted.name +@deffn {Command} {jtag tapenable} dotted.name If necessary, enables the tap by sending it a @option{tap-enable} event. Returns the string "1" if the tap @@ -4168,7 +4168,7 @@ specified by @var{dotted.name} is enabled, and "0" if it is disabled. @end deffn -@deffn Command {jtag tapisenabled} dotted.name +@deffn {Command} {jtag tapisenabled} dotted.name Returns the string "1" if the tap specified by @var{dotted.name} is enabled, and "0" if it is disabled. @@ -4260,7 +4260,7 @@ instead of "@option{-chain-position} @var{dotted.name}" when the target is creat The @command{dap} command group supports the following sub-commands: -@deffn Command {dap create} dap_name @option{-chain-position} dotted.name configparams... +@deffn {Command} {dap create} dap_name @option{-chain-position} dotted.name configparams... Declare a DAP instance named @var{dap_name} linked to the JTAG tap @var{dotted.name}. This also creates a new command (@command{dap_name}) which is used for various purposes including additional configuration. @@ -4277,17 +4277,17 @@ devices do not set the ack bit until sometime later. @end itemize @end deffn -@deffn Command {dap names} +@deffn {Command} {dap names} This command returns a list of all registered DAP objects. It it useful mainly for TCL scripting. @end deffn -@deffn Command {dap info} [num] +@deffn {Command} {dap info} [num] Displays the ROM table for MEM-AP @var{num}, defaulting to the currently selected AP of the currently selected target. @end deffn -@deffn Command {dap init} +@deffn {Command} {dap init} Initialize all registered DAPs. This command is used internally during initialization. It can be issued at any time after the initialization, too. @@ -4295,27 +4295,27 @@ initialization, too. The following commands exist as subcommands of DAP instances: -@deffn Command {$dap_name info} [num] +@deffn {Command} {$dap_name info} [num] Displays the ROM table for MEM-AP @var{num}, defaulting to the currently selected AP. @end deffn -@deffn Command {$dap_name apid} [num] +@deffn {Command} {$dap_name apid} [num] Displays ID register from AP @var{num}, defaulting to the currently selected AP. @end deffn @anchor{DAP subcommand apreg} -@deffn Command {$dap_name apreg} ap_num reg [value] +@deffn {Command} {$dap_name apreg} ap_num reg [value] Displays content of a register @var{reg} from AP @var{ap_num} or set a new value @var{value}. @var{reg} is byte address of a word register, 0, 4, 8 ... 0xfc. @end deffn -@deffn Command {$dap_name apsel} [num] +@deffn {Command} {$dap_name apsel} [num] Select AP @var{num}, defaulting to 0. @end deffn -@deffn Command {$dap_name dpreg} reg [value] +@deffn {Command} {$dap_name dpreg} reg [value] Displays the content of DP register at address @var{reg}, or set it to a new value @var{value}. @@ -4327,18 +4327,18 @@ In case of JTAG it only assumes values 0, 4, 8 and 0xc. background activity by OpenOCD while you are operating at such low-level. @end deffn -@deffn Command {$dap_name baseaddr} [num] +@deffn {Command} {$dap_name baseaddr} [num] Displays debug base address from MEM-AP @var{num}, defaulting to the currently selected AP. @end deffn -@deffn Command {$dap_name memaccess} [value] +@deffn {Command} {$dap_name memaccess} [value] Displays the number of extra tck cycles in the JTAG idle to use for MEM-AP memory bus access [0-255], giving additional time to respond to reads. If @var{value} is defined, first assigns that. @end deffn -@deffn Command {$dap_name apcsw} [value [mask]] +@deffn {Command} {$dap_name apcsw} [value [mask]] Displays or changes CSW bit pattern for MEM-AP transfers. At the begin of each memory access the CSW pattern is extended (bitwise or-ed) @@ -4381,7 +4381,7 @@ xxx.dap apcsw default @end example @end deffn -@deffn Command {$dap_name ti_be_32_quirks} [@option{enable}] +@deffn {Command} {$dap_name ti_be_32_quirks} [@option{enable}] Set/get quirks mode for TI TMS450/TMS570 processors Disabled by default @end deffn @@ -4430,11 +4430,11 @@ are examples; and there are many more. Several commands let you examine the list of targets: -@deffn Command {target current} +@deffn {Command} {target current} Returns the name of the current target. @end deffn -@deffn Command {target names} +@deffn {Command} {target names} Lists the names of all current targets in the list. @example foreach t [target names] @{ @@ -4446,7 +4446,7 @@ foreach t [target names] @{ @c yep, "target list" would have been better. @c plus maybe "target setdefault". -@deffn Command targets [name] +@deffn {Command} targets [name] @emph{Note: the name of this command is plural. Other target command names are singular.} @@ -4477,7 +4477,7 @@ It's easy to see what target types are supported, since there's a command to list them. @anchor{targettypes} -@deffn Command {target types} +@deffn {Command} {target types} Lists all supported target types. At this writing, the supported CPU types are: @@ -4612,7 +4612,7 @@ That may be needed to let you write the boot loader into flash, in order to ``de-brick'' your board; or to load programs into external DDR memory without having run the boot loader. -@deffn Command {target create} target_name type configparams... +@deffn {Command} {target create} target_name type configparams... This command creates a GDB debug target that refers to a specific JTAG tap. It enters that target into a list, and creates a new command (@command{@var{target_name}}) which is used for various @@ -4637,7 +4637,7 @@ You @emph{must} set the @code{-chain-position @var{dotted.name}} or @end itemize @end deffn -@deffn Command {$target_name configure} configparams... +@deffn {Command} {$target_name configure} configparams... The options accepted by this command may also be specified as parameters to @command{target create}. Their values can later be queried one at a time by @@ -4760,18 +4760,18 @@ omap3530.cpu mww 0x5555 123 The commands supported by OpenOCD target objects are: -@deffn Command {$target_name arp_examine} @option{allow-defer} -@deffnx Command {$target_name arp_halt} -@deffnx Command {$target_name arp_poll} -@deffnx Command {$target_name arp_reset} -@deffnx Command {$target_name arp_waitstate} +@deffn {Command} {$target_name arp_examine} @option{allow-defer} +@deffnx {Command} {$target_name arp_halt} +@deffnx {Command} {$target_name arp_poll} +@deffnx {Command} {$target_name arp_reset} +@deffnx {Command} {$target_name arp_waitstate} Internal OpenOCD scripts (most notably @file{startup.tcl}) use these to deal with specific reset cases. They are not otherwise documented here. @end deffn -@deffn Command {$target_name array2mem} arrayname width address count -@deffnx Command {$target_name mem2array} arrayname width address count +@deffn {Command} {$target_name array2mem} arrayname width address count +@deffnx {Command} {$target_name mem2array} arrayname width address count These provide an efficient script-oriented interface to memory. The @code{array2mem} primitive writes bytes, halfwords, or words; while @code{mem2array} reads them. @@ -4793,7 +4793,7 @@ and neither store nor return those values. @end itemize @end deffn -@deffn Command {$target_name cget} queryparm +@deffn {Command} {$target_name cget} queryparm Each configuration parameter accepted by @command{$target_name configure} can be individually queried, to return its current value. @@ -4826,7 +4826,7 @@ foreach name [target names] @{ @end deffn @anchor{targetcurstate} -@deffn Command {$target_name curstate} +@deffn {Command} {$target_name curstate} Displays the current target state: @code{debug-running}, @code{halted}, @@ -4835,22 +4835,22 @@ Displays the current target state: (Also, @pxref{eventpolling,,Event Polling}.) @end deffn -@deffn Command {$target_name eventlist} +@deffn {Command} {$target_name eventlist} Displays a table listing all event handlers currently associated with this target. @xref{targetevents,,Target Events}. @end deffn -@deffn Command {$target_name invoke-event} event_name +@deffn {Command} {$target_name invoke-event} event_name Invokes the handler for the event named @var{event_name}. (This is primarily intended for use by OpenOCD framework code, for example by the reset code in @file{startup.tcl}.) @end deffn -@deffn Command {$target_name mdd} [phys] addr [count] -@deffnx Command {$target_name mdw} [phys] addr [count] -@deffnx Command {$target_name mdh} [phys] addr [count] -@deffnx Command {$target_name mdb} [phys] addr [count] +@deffn {Command} {$target_name mdd} [phys] addr [count] +@deffnx {Command} {$target_name mdw} [phys] addr [count] +@deffnx {Command} {$target_name mdh} [phys] addr [count] +@deffnx {Command} {$target_name mdb} [phys] addr [count] Display contents of address @var{addr}, as 64-bit doublewords (@command{mdd}), 32-bit words (@command{mdw}), 16-bit halfwords (@command{mdh}), @@ -4864,10 +4864,10 @@ If @var{count} is specified, displays that many units. see the @code{mem2array} primitives.) @end deffn -@deffn Command {$target_name mwd} [phys] addr doubleword [count] -@deffnx Command {$target_name mww} [phys] addr word [count] -@deffnx Command {$target_name mwh} [phys] addr halfword [count] -@deffnx Command {$target_name mwb} [phys] addr byte [count] +@deffn {Command} {$target_name mwd} [phys] addr doubleword [count] +@deffnx {Command} {$target_name mww} [phys] addr word [count] +@deffnx {Command} {$target_name mwh} [phys] addr halfword [count] +@deffnx {Command} {$target_name mwb} [phys] addr byte [count] Writes the specified @var{doubleword} (64 bits), @var{word} (32 bits), @var{halfword} (16 bits), or @var{byte} (8-bit) value, at the specified address @var{addr}. @@ -5105,20 +5105,20 @@ Use it in board specific configuration files, not interactively. @end deffn @comment less confusing would be: "flash list" (like "nand list") -@deffn Command {flash banks} +@deffn {Command} {flash banks} Prints a one-line summary of each device that was declared using @command{flash bank}, numbered from zero. Note that this is the @emph{plural} form; the @emph{singular} form is a very different command. @end deffn -@deffn Command {flash list} +@deffn {Command} {flash list} Retrieves a list of associative arrays for each device that was declared using @command{flash bank}, numbered from zero. This returned list can be manipulated easily from within scripts. @end deffn -@deffn Command {flash probe} num +@deffn {Command} {flash probe} num Identify the flash, or validate the parameters of the configured flash. Operation depends on the flash type. The @var{num} parameter is a value shown by @command{flash banks}. @@ -5180,7 +5180,7 @@ Examples include CFI flash such as ``Intel Advanced Bootblock flash'', and AT91SAM7 on-chip flash. @xref{flashprotect,,flash protect}. -@deffn Command {flash erase_sector} num first last +@deffn {Command} {flash erase_sector} num first last Erase sectors in bank @var{num}, starting at sector @var{first} up to and including @var{last}. Sector numbering starts at 0. @@ -5189,7 +5189,7 @@ specifies "to the end of the flash bank". The @var{num} parameter is a value shown by @command{flash banks}. @end deffn -@deffn Command {flash erase_address} [@option{pad}] [@option{unlock}] address length +@deffn {Command} {flash erase_address} [@option{pad}] [@option{unlock}] address length Erase sectors starting at @var{address} for @var{length} bytes. Unless @option{pad} is specified, @math{address} must begin a flash sector, and @math{address + length - 1} must end a sector. @@ -5203,10 +5203,10 @@ If @option{unlock} is specified, then the flash is unprotected before erase starts. @end deffn -@deffn Command {flash filld} address double-word length -@deffnx Command {flash fillw} address word length -@deffnx Command {flash fillh} address halfword length -@deffnx Command {flash fillb} address byte length +@deffn {Command} {flash filld} address double-word length +@deffnx {Command} {flash fillw} address word length +@deffnx {Command} {flash fillh} address halfword length +@deffnx {Command} {flash fillb} address byte length Fills flash memory with the specified @var{double-word} (64 bits), @var{word} (32 bits), @var{halfword} (16 bits), or @var{byte} (8-bit) pattern, starting at @var{address} and continuing @@ -5220,9 +5220,9 @@ each block, and the specified length must stay within that bank. @end deffn @comment no current checks for errors if fill blocks touch multiple banks! -@deffn Command {flash mdw} addr [count] -@deffnx... [truncated message content] |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-18 14:32:12
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via eb6a5faf6ac8aa1791ada64e95768ff4ed29084c (commit) from 0f06d943366154963c6f5eb70f52e70f64fe5c71 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit eb6a5faf6ac8aa1791ada64e95768ff4ed29084c Author: Yasushi SHOJI <ya...@sp...> Date: Tue Apr 6 18:51:57 2021 +0900 doc: Group adapter sub-commands The commit 5280eb618a8cab46 fixed all `adapter_khz` and `adapter_nsrst_*` commands in the doc but missed grouping them. This let the commands `adapter speed`, `adapter srst pulse_width`, and `adapter srst delay` not indexed. Tell texinfo about adapter sub-commands by grouping them in one. Change-Id: Ida53c4f5cfe28827320c145c8d501d53e831623c Signed-off-by: Yasushi SHOJI <ya...@sp...> Reviewed-on: http://openocd.zylin.com/6134 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 6b74243b8..e39ff86f3 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -3415,7 +3415,7 @@ may not be the fastest solution. instead of @command{adapter speed}, but only for (ARM) cores and boards which support adaptive clocking. -@deffn {Command} adapter speed max_speed_kHz +@deffn Command {adapter speed} max_speed_kHz A non-zero speed is in KHZ. Hence: 3000 is 3mhz. JTAG interfaces usually support a limited number of speeds. The speed actually used won't be faster @@ -3585,13 +3585,13 @@ needing to cope with both architecture and board specific constraints. @section Commands for Handling Resets -@deffn {Command} adapter srst pulse_width milliseconds +@deffn Command {adapter srst pulse_width} milliseconds Minimum amount of time (in milliseconds) OpenOCD should wait after asserting nSRST (active-low system reset) before allowing it to be deasserted. @end deffn -@deffn {Command} adapter srst delay milliseconds +@deffn Command {adapter srst delay} milliseconds How long (in milliseconds) OpenOCD should wait after deasserting nSRST (active-low system reset) before starting new JTAG operations. When a board has a reset button connected to SRST line it will ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-11 20:35:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 0f06d943366154963c6f5eb70f52e70f64fe5c71 (commit) from 651b861d5d5f1e361faee37a10c7d7ce03aa6afa (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0f06d943366154963c6f5eb70f52e70f64fe5c71 Author: Antonio Borneo <bor...@gm...> Date: Sun Dec 20 21:13:58 2020 +0100 mem_ap: allow GDB connections The target mem_ap is a convenient way to access buses, memory and peripherals behind an ARM AP. The current implementation provides only access through OpenOCD commands, because GDB remote protocol has to interact with a CPU and has to operate on CPU states and registers. Using GDB to access the memory is welcome, because GDB can resolve the symbol's address from an ELF file and can nicely display the content of complex struct and data types. Extend mem_ap target with the bare minimal support for a remote GDB connection, by emulating a fake basic ARM core. It means that only a GDB that has support for ARM can be used (either 'aarch64', 'arm' or 'multiarch' GDB). This is not seen as a big limitation, because the mem_ap target is mainly used on ARM based devices. Add a minimalist register description for the fake CPU. Fill the field 'debug_reason' as expected by GDB server. Call the target halted event to reply to GDB halt requests. For backward compatibility, don't open the GDB port by default. If needed, it has to be specified at 'target create' or 'configure' with the flag '-gdb-port'. Change-Id: I5a1b7adb749746516f5d4ffc6193c47b70132364 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/6034 Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 2cba45ecd..6b74243b8 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -4509,7 +4509,13 @@ The current implementation supports eSi-32xx cores. @item @code{hla_target} -- a Cortex-M alternative to work with HL adapters like ST-Link. @item @code{ls1_sap} -- this is the SAP on NXP LS102x CPUs, allowing access to physical memory addresses independently of CPU cores. -@item @code{mem_ap} -- this is an ARM debug infrastructure Access Port without a CPU, through which bus read and write cycles can be generated; it may be useful for working with non-CPU hardware behind an AP or during development of support for new CPUs. +@item @code{mem_ap} -- this is an ARM debug infrastructure Access Port without +a CPU, through which bus read and write cycles can be generated; it may be +useful for working with non-CPU hardware behind an AP or during development of +support for new CPUs. +It's possible to connect a GDB client to this target (the GDB port has to be +specified, @xref{gdbportoverride,,option -gdb-port}), and a fake ARM core will +be emulated to comply to GDB remote protocol. @item @code{mips_m4k} -- a MIPS core. @item @code{mips_mips64} -- a MIPS64 core. @item @code{nds32_v2} -- this is an Andes NDS32 v2 core. diff --git a/src/target/mem_ap.c b/src/target/mem_ap.c index 7ed41c63c..89c0c02c0 100644 --- a/src/target/mem_ap.c +++ b/src/target/mem_ap.c @@ -20,6 +20,7 @@ #include "target_type.h" #include "arm.h" #include "arm_adi_v5.h" +#include "register.h" #include <jtag/jtag.h> @@ -55,6 +56,9 @@ static int mem_ap_target_create(struct target *target, Jim_Interp *interp) target->arch_info = mem_ap; + if (!target->gdb_port_override) + target->gdb_port_override = strdup("disabled"); + return ERROR_OK; } @@ -62,6 +66,7 @@ static int mem_ap_init_target(struct command_context *cmd_ctx, struct target *ta { LOG_DEBUG("%s", __func__); target->state = TARGET_UNKNOWN; + target->debug_reason = DBG_REASON_UNDEFINED; return ERROR_OK; } @@ -82,8 +87,10 @@ static int mem_ap_arch_state(struct target *target) static int mem_ap_poll(struct target *target) { - if (target->state == TARGET_UNKNOWN) + if (target->state == TARGET_UNKNOWN) { target->state = TARGET_RUNNING; + target->debug_reason = DBG_REASON_NOTHALTED; + } return ERROR_OK; } @@ -92,6 +99,8 @@ static int mem_ap_halt(struct target *target) { LOG_DEBUG("%s", __func__); target->state = TARGET_HALTED; + target->debug_reason = DBG_REASON_DBGRQ; + target_call_event_callbacks(target, TARGET_EVENT_HALTED); return ERROR_OK; } @@ -100,6 +109,7 @@ static int mem_ap_resume(struct target *target, int current, target_addr_t addre { LOG_DEBUG("%s", __func__); target->state = TARGET_RUNNING; + target->debug_reason = DBG_REASON_NOTHALTED; return ERROR_OK; } @@ -108,12 +118,15 @@ static int mem_ap_step(struct target *target, int current, target_addr_t address { LOG_DEBUG("%s", __func__); target->state = TARGET_HALTED; + target->debug_reason = DBG_REASON_DBGRQ; + target_call_event_callbacks(target, TARGET_EVENT_HALTED); return ERROR_OK; } static int mem_ap_assert_reset(struct target *target) { target->state = TARGET_RESET; + target->debug_reason = DBG_REASON_UNDEFINED; LOG_DEBUG("%s", __func__); return ERROR_OK; @@ -127,6 +140,7 @@ static int mem_ap_examine(struct target *target) mem_ap->ap = dap_ap(mem_ap->arm.dap, mem_ap->ap_num); target_set_examined(target); target->state = TARGET_UNKNOWN; + target->debug_reason = DBG_REASON_UNDEFINED; return mem_ap_init(mem_ap->ap); } @@ -135,15 +149,85 @@ static int mem_ap_examine(struct target *target) static int mem_ap_deassert_reset(struct target *target) { - if (target->reset_halt) + if (target->reset_halt) { target->state = TARGET_HALTED; - else + target->debug_reason = DBG_REASON_DBGRQ; + target_call_event_callbacks(target, TARGET_EVENT_HALTED); + } else { target->state = TARGET_RUNNING; + target->debug_reason = DBG_REASON_NOTHALTED; + } LOG_DEBUG("%s", __func__); return ERROR_OK; } +static int mem_ap_reg_get(struct reg *reg) +{ + return ERROR_OK; +} + +static int mem_ap_reg_set(struct reg *reg, uint8_t *buf) +{ + return ERROR_OK; +} + +static struct reg_arch_type mem_ap_reg_arch_type = { + .get = mem_ap_reg_get, + .set = mem_ap_reg_set, +}; + +const char *mem_ap_get_gdb_arch(struct target *target) +{ + return "arm"; +} + +/* + * Dummy ARM register emulation: + * reg[0..15]: 32 bits, r0~r12, sp, lr, pc + * reg[16..23]: 96 bits, f0~f7 + * reg[24]: 32 bits, fps + * reg[25]: 32 bits, cpsr + * + * Set 'exist' only to reg[0..15], so initial response to GDB is correct + */ +#define NUM_REGS 26 +#define MAX_REG_SIZE 96 +#define REG_EXIST(n) ((n) < 16) +#define REG_SIZE(n) ((((n) >= 16) && ((n) < 24)) ? 96 : 32) + +struct mem_ap_alloc_reg_list { + /* reg_list must be the first field */ + struct reg *reg_list[NUM_REGS]; + struct reg regs[NUM_REGS]; + uint8_t regs_value[MAX_REG_SIZE / 8]; +}; + +static int mem_ap_get_gdb_reg_list(struct target *target, struct reg **reg_list[], + int *reg_list_size, enum target_register_class reg_class) +{ + struct mem_ap_alloc_reg_list *mem_ap_alloc = calloc(1, sizeof(struct mem_ap_alloc_reg_list)); + if (!mem_ap_alloc) { + LOG_ERROR("Out of memory"); + return ERROR_FAIL; + } + + *reg_list = mem_ap_alloc->reg_list; + *reg_list_size = NUM_REGS; + struct reg *regs = mem_ap_alloc->regs; + + for (int i = 0; i < NUM_REGS; i++) { + regs[i].number = i; + regs[i].value = mem_ap_alloc->regs_value; + regs[i].size = REG_SIZE(i); + regs[i].exist = REG_EXIST(i); + regs[i].type = &mem_ap_reg_arch_type; + (*reg_list)[i] = ®s[i]; + } + + return ERROR_OK; +} + static int mem_ap_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer) { @@ -192,6 +276,9 @@ struct target_type mem_ap_target = { .assert_reset = mem_ap_assert_reset, .deassert_reset = mem_ap_deassert_reset, + .get_gdb_arch = mem_ap_get_gdb_arch, + .get_gdb_reg_list = mem_ap_get_gdb_reg_list, + .read_memory = mem_ap_read_memory, .write_memory = mem_ap_write_memory, }; ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 8 ++++- src/target/mem_ap.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 97 insertions(+), 4 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-11 20:29:37
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 651b861d5d5f1e361faee37a10c7d7ce03aa6afa (commit) from 0ec9018040c2fd77807d80225b34e2fc7fb23e82 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 651b861d5d5f1e361faee37a10c7d7ce03aa6afa Author: Liming Sun <ls...@me...> Date: Fri Nov 9 16:17:25 2018 -0500 target/aarch64: Add watchpoint support There are some breakpoint/watchpoint related code in armv8_dpm.c, but seems not working for aarch64. Target aarch64 has its own breakpoint implementation in aarch64.c. This commit follows the same logic to add watchpoint support for target aarch64. This commit also increases the size of stop_reason[] in function gdb_signal_reply() since the old size is too small to fit in a 64-bit address, such as ffff8000115e6980. Change-Id: I907dc0e648130e36b434220f570c37d0e8eb5ce1 Signed-off-by: Liming Sun <ls...@me...> Signed-off-by: Daniel Goehring <dgo...@os...> Reviewed-on: http://openocd.zylin.com/4761 Tested-by: jenkins Reviewed-by: Liming Sun <li...@nv...> Reviewed-by: Kevin Burke <ke...@os...> Reviewed-by: Matthias Welwarsky <mat...@we...> Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index fc58971a7..002b5873b 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -728,7 +728,7 @@ static void gdb_signal_reply(struct target *target, struct connection *connectio { struct gdb_connection *gdb_connection = connection->priv; char sig_reply[65]; - char stop_reason[20]; + char stop_reason[32]; char current_thread[25]; int sig_reply_len; int signal_var; diff --git a/src/target/aarch64.c b/src/target/aarch64.c index e45803040..d6b12cd59 100644 --- a/src/target/aarch64.c +++ b/src/target/aarch64.c @@ -1651,7 +1651,6 @@ static int aarch64_add_hybrid_breakpoint(struct target *target, return aarch64_set_hybrid_breakpoint(target, breakpoint); /* ??? */ } - static int aarch64_remove_breakpoint(struct target *target, struct breakpoint *breakpoint) { struct aarch64_common *aarch64 = target_to_aarch64(target); @@ -1673,6 +1672,207 @@ static int aarch64_remove_breakpoint(struct target *target, struct breakpoint *b return ERROR_OK; } +/* Setup hardware Watchpoint Register Pair */ +static int aarch64_set_watchpoint(struct target *target, + struct watchpoint *watchpoint) +{ + int retval; + int wp_i = 0; + uint32_t control, offset, length; + struct aarch64_common *aarch64 = target_to_aarch64(target); + struct armv8_common *armv8 = &aarch64->armv8_common; + struct aarch64_brp *wp_list = aarch64->wp_list; + + if (watchpoint->set) { + LOG_WARNING("watchpoint already set"); + return ERROR_OK; + } + + while (wp_list[wp_i].used && (wp_i < aarch64->wp_num)) + wp_i++; + if (wp_i >= aarch64->wp_num) { + LOG_ERROR("ERROR Can not find free Watchpoint Register Pair"); + return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; + } + + control = (1 << 0) /* enable */ + | (3 << 1) /* both user and privileged access */ + | (1 << 13); /* higher mode control */ + + switch (watchpoint->rw) { + case WPT_READ: + control |= 1 << 3; + break; + case WPT_WRITE: + control |= 2 << 3; + break; + case WPT_ACCESS: + control |= 3 << 3; + break; + } + + /* Match up to 8 bytes. */ + offset = watchpoint->address & 7; + length = watchpoint->length; + if (offset + length > sizeof(uint64_t)) { + length = sizeof(uint64_t) - offset; + LOG_WARNING("Adjust watchpoint match inside 8-byte boundary"); + } + for (; length > 0; offset++, length--) + control |= (1 << offset) << 5; + + wp_list[wp_i].value = watchpoint->address & 0xFFFFFFFFFFFFFFF8ULL; + wp_list[wp_i].control = control; + + retval = aarch64_dap_write_memap_register_u32(target, armv8->debug_base + + CPUV8_DBG_WVR_BASE + 16 * wp_list[wp_i].BRPn, + (uint32_t)(wp_list[wp_i].value & 0xFFFFFFFF)); + if (retval != ERROR_OK) + return retval; + retval = aarch64_dap_write_memap_register_u32(target, armv8->debug_base + + CPUV8_DBG_WVR_BASE + 4 + 16 * wp_list[wp_i].BRPn, + (uint32_t)(wp_list[wp_i].value >> 32)); + if (retval != ERROR_OK) + return retval; + + retval = aarch64_dap_write_memap_register_u32(target, armv8->debug_base + + CPUV8_DBG_WCR_BASE + 16 * wp_list[wp_i].BRPn, + control); + if (retval != ERROR_OK) + return retval; + LOG_DEBUG("wp %i control 0x%0" PRIx32 " value 0x%" TARGET_PRIxADDR, wp_i, + wp_list[wp_i].control, wp_list[wp_i].value); + + /* Ensure that halting debug mode is enable */ + retval = aarch64_set_dscr_bits(target, DSCR_HDE, DSCR_HDE); + if (retval != ERROR_OK) { + LOG_DEBUG("Failed to set DSCR.HDE"); + return retval; + } + + wp_list[wp_i].used = 1; + watchpoint->set = wp_i + 1; + + return ERROR_OK; +} + +/* Clear hardware Watchpoint Register Pair */ +static int aarch64_unset_watchpoint(struct target *target, + struct watchpoint *watchpoint) +{ + int retval, wp_i; + struct aarch64_common *aarch64 = target_to_aarch64(target); + struct armv8_common *armv8 = &aarch64->armv8_common; + struct aarch64_brp *wp_list = aarch64->wp_list; + + if (!watchpoint->set) { + LOG_WARNING("watchpoint not set"); + return ERROR_OK; + } + + wp_i = watchpoint->set - 1; + if ((wp_i < 0) || (wp_i >= aarch64->wp_num)) { + LOG_DEBUG("Invalid WP number in watchpoint"); + return ERROR_OK; + } + LOG_DEBUG("rwp %i control 0x%0" PRIx32 " value 0x%0" PRIx64, wp_i, + wp_list[wp_i].control, wp_list[wp_i].value); + wp_list[wp_i].used = 0; + wp_list[wp_i].value = 0; + wp_list[wp_i].control = 0; + retval = aarch64_dap_write_memap_register_u32(target, armv8->debug_base + + CPUV8_DBG_WCR_BASE + 16 * wp_list[wp_i].BRPn, + wp_list[wp_i].control); + if (retval != ERROR_OK) + return retval; + retval = aarch64_dap_write_memap_register_u32(target, armv8->debug_base + + CPUV8_DBG_WVR_BASE + 16 * wp_list[wp_i].BRPn, + wp_list[wp_i].value); + if (retval != ERROR_OK) + return retval; + + retval = aarch64_dap_write_memap_register_u32(target, armv8->debug_base + + CPUV8_DBG_WVR_BASE + 4 + 16 * wp_list[wp_i].BRPn, + (uint32_t)wp_list[wp_i].value); + if (retval != ERROR_OK) + return retval; + watchpoint->set = 0; + + return ERROR_OK; +} + +static int aarch64_add_watchpoint(struct target *target, + struct watchpoint *watchpoint) +{ + int retval; + struct aarch64_common *aarch64 = target_to_aarch64(target); + + if (aarch64->wp_num_available < 1) { + LOG_INFO("no hardware watchpoint available"); + return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; + } + + retval = aarch64_set_watchpoint(target, watchpoint); + if (retval == ERROR_OK) + aarch64->wp_num_available--; + + return retval; +} + +static int aarch64_remove_watchpoint(struct target *target, + struct watchpoint *watchpoint) +{ + struct aarch64_common *aarch64 = target_to_aarch64(target); + + if (watchpoint->set) { + aarch64_unset_watchpoint(target, watchpoint); + aarch64->wp_num_available++; + } + + return ERROR_OK; +} + +/** + * find out which watchpoint hits + * get exception address and compare the address to watchpoints + */ +int aarch64_hit_watchpoint(struct target *target, + struct watchpoint **hit_watchpoint) +{ + if (target->debug_reason != DBG_REASON_WATCHPOINT) + return ERROR_FAIL; + + struct armv8_common *armv8 = target_to_armv8(target); + + uint64_t exception_address; + struct watchpoint *wp; + + exception_address = armv8->dpm.wp_pc; + + if (exception_address == 0xFFFFFFFF) + return ERROR_FAIL; + + /**********************************************************/ + /* see if a watchpoint address matches a value read from */ + /* the EDWAR register. Testing shows that on some ARM CPUs*/ + /* the EDWAR value needs to have 8 added to it so we add */ + /* that check as well not sure if that is a core bug) */ + /**********************************************************/ + for (exception_address = armv8->dpm.wp_pc; exception_address <= (armv8->dpm.wp_pc + 8); + exception_address += 8) { + for (wp = target->watchpoints; wp; wp = wp->next) { + if ((exception_address >= wp->address) && (exception_address < (wp->address + wp->length))) { + *hit_watchpoint = wp; + if (exception_address != armv8->dpm.wp_pc) + LOG_DEBUG("watchpoint hit required EDWAR to be increased by 8"); + return ERROR_OK; + } + } + } + + return ERROR_FAIL; +} + /* * Cortex-A8 Reset functions */ @@ -2461,7 +2661,20 @@ static int aarch64_examine_first(struct target *target) aarch64->brp_list[i].BRPn = i; } - LOG_DEBUG("Configured %i hw breakpoints", aarch64->brp_num); + /* Setup Watchpoint Register Pairs */ + aarch64->wp_num = (uint32_t)((debug >> 20) & 0x0F) + 1; + aarch64->wp_num_available = aarch64->wp_num; + aarch64->wp_list = calloc(aarch64->wp_num, sizeof(struct aarch64_brp)); + for (i = 0; i < aarch64->wp_num; i++) { + aarch64->wp_list[i].used = 0; + aarch64->wp_list[i].type = BRP_NORMAL; + aarch64->wp_list[i].value = 0; + aarch64->wp_list[i].control = 0; + aarch64->wp_list[i].BRPn = i; + } + + LOG_DEBUG("Configured %i hw breakpoints, %i watchpoints", + aarch64->brp_num, aarch64->wp_num); target->state = TARGET_UNKNOWN; target->debug_reason = DBG_REASON_NOTHALTED; @@ -2977,8 +3190,9 @@ struct target_type aarch64_target = { .add_context_breakpoint = aarch64_add_context_breakpoint, .add_hybrid_breakpoint = aarch64_add_hybrid_breakpoint, .remove_breakpoint = aarch64_remove_breakpoint, - .add_watchpoint = NULL, - .remove_watchpoint = NULL, + .add_watchpoint = aarch64_add_watchpoint, + .remove_watchpoint = aarch64_remove_watchpoint, + .hit_watchpoint = aarch64_hit_watchpoint, .commands = aarch64_command_handlers, .target_create = aarch64_target_create, diff --git a/src/target/aarch64.h b/src/target/aarch64.h index d7886a3d7..7c0ddf868 100644 --- a/src/target/aarch64.h +++ b/src/target/aarch64.h @@ -62,6 +62,11 @@ struct aarch64_common { int brp_num_available; struct aarch64_brp *brp_list; + /* Watchpoint register pairs */ + int wp_num; + int wp_num_available; + struct aarch64_brp *wp_list; + struct armv8_common armv8_common; enum aarch64_isrmasking_mode isrmasking_mode; diff --git a/src/target/armv8_dpm.c b/src/target/armv8_dpm.c index 1e88a445f..e7d0f864e 100644 --- a/src/target/armv8_dpm.c +++ b/src/target/armv8_dpm.c @@ -1465,8 +1465,10 @@ int armv8_dpm_setup(struct arm_dpm *dpm) } /* watchpoint setup */ - target->type->add_watchpoint = dpmv8_add_watchpoint; - target->type->remove_watchpoint = dpmv8_remove_watchpoint; + if (!target->type->add_watchpoint) { + target->type->add_watchpoint = dpmv8_add_watchpoint; + target->type->remove_watchpoint = dpmv8_remove_watchpoint; + } /* FIXME add vector catch support */ ----------------------------------------------------------------------- Summary of changes: src/server/gdb_server.c | 2 +- src/target/aarch64.c | 222 +++++++++++++++++++++++++++++++++++++++++++++++- src/target/aarch64.h | 5 ++ src/target/armv8_dpm.c | 6 +- 4 files changed, 228 insertions(+), 7 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: OpenOCD-Gerrit <ope...@us...> - 2021-04-11 20:28:45
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 0ec9018040c2fd77807d80225b34e2fc7fb23e82 (commit) via 134d7d5a5876a53a10ecb2eeac8d193bdddcea81 (commit) from 96aaa77f72a721f058f3863f270c2ba3d8d68871 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0ec9018040c2fd77807d80225b34e2fc7fb23e82 Author: Marc Schink <de...@za...> Date: Mon Apr 5 15:40:35 2021 +0200 doc/manual/style: Fix comments The comments currently used are not rendered. Change-Id: I3fcfb6aee4dea9c4f9186a7aec70d382a1abd634 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: http://openocd.zylin.com/6133 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/doc/manual/style.txt b/doc/manual/style.txt index c3fcfd782..755709fb0 100644 --- a/doc/manual/style.txt +++ b/doc/manual/style.txt @@ -114,9 +114,9 @@ pthreads require modest and predictable stack usage. - static inline functions should be preferred over macros: @code -/** do NOT define macro-like functions like this... */ +/* do NOT define macro-like functions like this... */ #define CUBE(x) ((x) * (x) * (x)) -/** instead, define the same expression using a C99 inline function */ +/* instead, define the same expression using a C99 inline function */ static inline int cube(int x) { return x * x * x; } @endcode - Functions should be declared static unless required by other modules commit 134d7d5a5876a53a10ecb2eeac8d193bdddcea81 Author: Marc Schink <de...@za...> Date: Fri Apr 2 11:17:00 2021 +0200 doc/manual/style: Do not use 'Yoda conditions' For more details, see: https://en.wikipedia.org/wiki/Yoda_conditions https://sektorvanskijlen.wordpress.com/2019/05/16/conditional-inversion-very-harmful-myth/ Change-Id: If1a8a5f1d0fd345b7cc0c7b5dee6d0d47f9d7fc2 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: http://openocd.zylin.com/6132 Reviewed-by: Tarek BOCHKATI <tar...@gm...> Tested-by: jenkins Reviewed-by: Oleksij Rempel <li...@re...> Reviewed-by: Antonio Borneo <bor...@gm...> Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/doc/manual/style.txt b/doc/manual/style.txt index dad3bb440..c3fcfd782 100644 --- a/doc/manual/style.txt +++ b/doc/manual/style.txt @@ -135,13 +135,13 @@ should write statements like the following: @code // separate statements should be preferred result = foo(); -if (ERROR_OK != result) +if (result != ERROR_OK) ... @endcode More directly, do @b not combine these kinds of statements: @code // Combined statements should be avoided -if (ERROR_OK != (result = foo())) +if ((result = foo()) != ERROR_OK) return result; @endcode ----------------------------------------------------------------------- Summary of changes: doc/manual/style.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) hooks/post-receive -- Main OpenOCD repository |