From 8edfdb02ed1fd73568ef9e9522634e65791dbd69 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 1 Sep 2024 14:45:36 +0200 Subject: [PATCH 01/44] rtos: chibios: fix version display The field 'struct chibios_chdebug::ch_version' is 16 bits wide, so using le_to_h_u32() and be_to_h_u32() overflows in the following fields of the struct. Restrict the endianness conversion to 16 bits and use the target endianness dependent target_buffer_get_u16(). Convert the 'struct chibios_chdebug::ch_version' to an array of uint8_t. Change-Id: Iaa80e9cb1a65c27512919398b8ffbf14e5c240cd Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8473 Tested-by: jenkins --- src/rtos/chibios.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/rtos/chibios.c b/src/rtos/chibios.c index c1e4e8419..f4ee33a49 100644 --- a/src/rtos/chibios.c +++ b/src/rtos/chibios.c @@ -31,7 +31,7 @@ struct chibios_chdebug { char ch_identifier[4]; /**< @brief Always set to "main". */ uint8_t ch_zero; /**< @brief Must be zero. */ uint8_t ch_size; /**< @brief Size of this structure. */ - uint16_t ch_version; /**< @brief Encoded ChibiOS/RT version. */ + uint8_t ch_version[2]; /**< @brief Encoded ChibiOS/RT version. */ uint8_t ch_ptrsize; /**< @brief Size of a pointer. */ uint8_t ch_timesize; /**< @brief Size of a @p systime_t. */ uint8_t ch_threadsize; /**< @brief Size of a @p Thread struct. */ @@ -171,13 +171,7 @@ static int chibios_update_memory_signature(struct rtos *rtos) " expected. Assuming compatibility..."); } - /* Convert endianness of version field */ - const uint8_t *versiontarget = (const uint8_t *) - &signature->ch_version; - signature->ch_version = rtos->target->endianness == TARGET_LITTLE_ENDIAN ? - le_to_h_u32(versiontarget) : be_to_h_u32(versiontarget); - - const uint16_t ch_version = signature->ch_version; + const uint16_t ch_version = target_buffer_get_u16(rtos->target, signature->ch_version); LOG_INFO("Successfully loaded memory map of ChibiOS/RT target " "running version %i.%i.%i", GET_CH_KERNEL_MAJOR(ch_version), GET_CH_KERNEL_MINOR(ch_version), GET_CH_KERNEL_PATCH(ch_version)); From 017e61feb44b71ac013ae4c7f2cfa3e7ca3323ae Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 2 Apr 2023 20:47:41 +0200 Subject: [PATCH 02/44] HACKING: add info on ignoring check-patch checks Due to checkpatch internal state machine, the field 'Checkpatch-ignore:' must be in the commit message before the 'Signed-off-by:' line. Report it in the documentation and add that multiple 'Checkpatch-ignore:' lines are allowed. Change-Id: I770cdc4cb5b33bcf63c860c154ab3cbd4785ad20 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/7572 Tested-by: jenkins --- HACKING | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/HACKING b/HACKING index 74cbe02e7..9e8cd357f 100644 --- a/HACKING +++ b/HACKING @@ -287,6 +287,13 @@ Only for exceptional cases, it is allowed to submit patches to Gerrit with the special field 'Checkpatch-ignore:' in the commit message. This field will cause checkpatch to ignore the error types listed in the field, only for the patch itself. +For errors in the commit message, the special field has to be put in +the commit message before the line that produces the error. +The special field must be added before the 'Signed-off-by:' +line, otherwise it is ignored. +To ignore multiple errors, either add multiple lines with the special +field or add multiple error types, separated by space or commas, in a +single line. The error type is printed by checkpatch on failure. For example the names of Windows APIs mix lower and upper case chars, in violation of OpenOCD coding style, triggering a 'CAMELCASE' error: From bd93b83f1b0625cc8c70aae46a1b0d13c41c53dc Mon Sep 17 00:00:00 2001 From: Parshintsev Anatoly Date: Tue, 10 Sep 2024 06:53:17 +0300 Subject: [PATCH 03/44] jtag: update constant names to follow code style guidelines Change-Id: Ib081433c67f3be0e5be0b39469680bcce079e0cc Signed-off-by: Parshintsev Anatoly Reviewed-on: https://review.openocd.org/c/openocd/+/8485 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/jtag/drivers/cmsis_dap.c | 8 ++++---- src/jtag/drivers/jtag_vpi.c | 4 ++-- src/jtag/drivers/xds110.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index a6dcfcd3d..4ba6b51be 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -563,7 +563,7 @@ static int cmsis_dap_cmd_dap_delay(uint16_t delay_us) static int cmsis_dap_metacmd_targetsel(uint32_t instance_id) { uint8_t *command = cmsis_dap_handle->command; - const uint32_t SEQ_RD = 0x80, SEQ_WR = 0x00; + 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 @@ -579,14 +579,14 @@ static int cmsis_dap_metacmd_targetsel(uint32_t instance_id) command[idx++] = 3; /* sequence count */ /* sequence 0: packet request for TARGETSEL */ - command[idx++] = SEQ_WR | 8; + 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; + command[idx++] = seq_rd | 5; /* sequence 2: WDATA plus parity */ - command[idx++] = SEQ_WR | (32 + 1); + command[idx++] = seq_wr | (32 + 1); h_u32_to_le(command + idx, instance_id); idx += 4; command[idx++] = parity_u32(instance_id); diff --git a/src/jtag/drivers/jtag_vpi.c b/src/jtag/drivers/jtag_vpi.c index a19060c2a..15b2679bb 100644 --- a/src/jtag/drivers/jtag_vpi.c +++ b/src/jtag/drivers/jtag_vpi.c @@ -461,14 +461,14 @@ static int jtag_vpi_stableclocks(unsigned int num_cycles) unsigned int cycles_remain = num_cycles; int nb_bits; int retval; - const unsigned int CYCLES_ONE_BATCH = sizeof(tms_bits) * 8; + const unsigned int cycles_one_batch = sizeof(tms_bits) * 8; /* use TMS=1 in TAP RESET state, TMS=0 in all other stable states */ memset(&tms_bits, (tap_get_state() == TAP_RESET) ? 0xff : 0x00, sizeof(tms_bits)); /* send the TMS bits */ while (cycles_remain > 0) { - nb_bits = (cycles_remain < CYCLES_ONE_BATCH) ? cycles_remain : CYCLES_ONE_BATCH; + nb_bits = (cycles_remain < cycles_one_batch) ? cycles_remain : cycles_one_batch; retval = jtag_vpi_tms_seq(tms_bits, nb_bits); if (retval != ERROR_OK) return retval; diff --git a/src/jtag/drivers/xds110.c b/src/jtag/drivers/xds110.c index f25208774..6e12b9a79 100644 --- a/src/jtag/drivers/xds110.c +++ b/src/jtag/drivers/xds110.c @@ -1887,7 +1887,7 @@ static int xds110_speed(int speed) } else { - const double XDS110_TCK_PULSE_INCREMENT = 66.0; + const double xds110_tck_pulse_increment = 66.0; freq_to_use = speed * 1000; /* Hz */ delay_count = 0; @@ -1908,7 +1908,7 @@ static int xds110_speed(int speed) double current_value = max_freq_pulse_duration; while (current_value < freq_to_pulse_width_in_ns) { - current_value += XDS110_TCK_PULSE_INCREMENT; + current_value += xds110_tck_pulse_increment; ++delay_count; } @@ -1919,9 +1919,9 @@ static int xds110_speed(int speed) if (delay_count) { double diff_freq_1 = freq_to_use - (one_giga / (max_freq_pulse_duration + - (XDS110_TCK_PULSE_INCREMENT * delay_count))); + (xds110_tck_pulse_increment * delay_count))); double diff_freq_2 = (one_giga / (max_freq_pulse_duration + - (XDS110_TCK_PULSE_INCREMENT * (delay_count - 1)))) - + (xds110_tck_pulse_increment * (delay_count - 1)))) - freq_to_use; /* One less count value yields a better match */ From ab3156213108138f9130defdfde7276d1e4e6afb Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sat, 21 Sep 2024 10:07:52 +0200 Subject: [PATCH 04/44] jep106: update to revision JEP106BK Sep 2024 Change-Id: Ica84e22b8d2da152cec39fc569c8333677c19490 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8501 Tested-by: jenkins --- src/helper/jep106.inc | 67 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/src/helper/jep106.inc b/src/helper/jep106.inc index b74cda85f..53d0355c1 100644 --- a/src/helper/jep106.inc +++ b/src/helper/jep106.inc @@ -8,7 +8,7 @@ * identification code list, please visit the JEDEC website at www.jedec.org . */ -/* This file is aligned to revision JEP106BJ.01 July 2024. */ +/* This file is aligned to revision JEP106BK September 2024. */ [0][0x01 - 1] = "AMD", [0][0x02 - 1] = "AMI", @@ -177,7 +177,7 @@ [1][0x27 - 1] = "Cabletron", [1][0x28 - 1] = "STEC (Silicon Tech)", [1][0x29 - 1] = "Vanguard", -[1][0x2a - 1] = "Hagiwara Sys-Com", +[1][0x2a - 1] = "Hagiwara Solutions Co Ltd", [1][0x2b - 1] = "Vantis", [1][0x2c - 1] = "Celestica", [1][0x2d - 1] = "Century", @@ -1373,7 +1373,7 @@ [10][0x65 - 1] = "Esperanto Technologies", [10][0x66 - 1] = "JinSheng Electronic (Shenzhen) Co Ltd", [10][0x67 - 1] = "Shenzhen Shi Bolunshuai Technology", -[10][0x68 - 1] = "Shanghai Rui Zuan Information Tech", +[10][0x68 - 1] = "Shanghai Rui Xuan Information Tech", [10][0x69 - 1] = "Fraunhofer IIS", [10][0x6a - 1] = "Kandou Bus SA", [10][0x6b - 1] = "Acer", @@ -1653,9 +1653,9 @@ [13][0x03 - 1] = "Shenzhen Feisrike Technology Co Ltd", [13][0x04 - 1] = "Shenzhen Sunhome Electronics Co Ltd", [13][0x05 - 1] = "Global Mixed-mode Technology Inc", -[13][0x06 - 1] = "Shenzhen Weien Electronics Co. Ltd.", +[13][0x06 - 1] = "Shenzhen Weien Electronics Co Ltd.", [13][0x07 - 1] = "Shenzhen Cooyes Technology Co Ltd", -[13][0x08 - 1] = "Keymos Electronics Co., Limited", +[13][0x08 - 1] = "ShenZhen ChaoYing ZhiNeng Technology", [13][0x09 - 1] = "E-Rockic Technology Company Limited", [13][0x0a - 1] = "Aerospace Science Memory Shenzhen", [13][0x0b - 1] = "Shenzhen Quanji Technology Co Ltd", @@ -1898,7 +1898,7 @@ [14][0x7a - 1] = "Cornelis Networks Inc", [14][0x7b - 1] = "WingSemi Technologies Co Ltd", [14][0x7c - 1] = "ForwardEdge ASIC", -[14][0x7d - 1] = "Beijing Future Imprint Technology Co Ltd", +[14][0x7d - 1] = "Beijing Future Signet Technology Co Ltd", [14][0x7e - 1] = "Fine Made Microelectronics Group Co Ltd", [15][0x01 - 1] = "Changxin Memory Technology (Shanghai)", [15][0x02 - 1] = "Synconv", @@ -1919,7 +1919,7 @@ [15][0x11 - 1] = "Guangzhou Beimu Technology Co., Ltd", [15][0x12 - 1] = "Rays Semiconductor Nanjing Co Ltd", [15][0x13 - 1] = "Milli-Centi Intelligence Technology Jiangsu", -[15][0x14 - 1] = "Zilia Technologioes", +[15][0x14 - 1] = "Zilia Technologies", [15][0x15 - 1] = "Incore Semiconductors", [15][0x16 - 1] = "Kinetic Technologies", [15][0x17 - 1] = "Nanjing Houmo Technology Co Ltd", @@ -1963,4 +1963,57 @@ [15][0x3d - 1] = "Shenzhen Titan Micro Electronics Co Ltd", [15][0x3e - 1] = "Shenzhen Macroflash Technology Co Ltd", [15][0x3f - 1] = "Advantech Group", +[15][0x40 - 1] = "Shenzhen Xingjiachen Electronics Co Ltd", +[15][0x41 - 1] = "CHUQI", +[15][0x42 - 1] = "Dongguan Liesun Trading Co Ltd", +[15][0x43 - 1] = "Shenzhen Miuman Technology Co Ltd", +[15][0x44 - 1] = "Shenzhen Techwinsemi Technology Twsc", +[15][0x45 - 1] = "Encharge AI Inc", +[15][0x46 - 1] = "Shenzhen Zhenchuang Electronics Co Ltd", +[15][0x47 - 1] = "Giant Chip Co. Ltd", +[15][0x48 - 1] = "Shenzhen Runner Semiconductor Co Ltd", +[15][0x49 - 1] = "Scalinx", +[15][0x4a - 1] = "Shenzhen Lanqi Electronics Co Ltd", +[15][0x4b - 1] = "CoreComm Technology Co Ltd", +[15][0x4c - 1] = "DLI Memory", +[15][0x4d - 1] = "Shenzhen Fidat Technology Co Ltd", +[15][0x4e - 1] = "Hubei Yangtze Mason Semiconductor Tech", +[15][0x4f - 1] = "Flastor", +[15][0x50 - 1] = "PIRATEMAN", +[15][0x51 - 1] = "Barrie Technologies Co Ltd", +[15][0x52 - 1] = "Dynacard Co Ltd", +[15][0x53 - 1] = "Rivian Automotive", +[15][0x54 - 1] = "Shenzhen Fidat Technology Co Ltd", +[15][0x55 - 1] = "Zhejang Weiming Semiconductor Co Ltd", +[15][0x56 - 1] = "Shenzhen Xinhua Micro Technology Co Ltd", +[15][0x57 - 1] = "Duvonn Electronic Technology Co Ltd", +[15][0x58 - 1] = "Shenzhen Xinchang Technology Co Ltd", +[15][0x59 - 1] = "Leidos", +[15][0x5a - 1] = "Keepixo", +[15][0x5b - 1] = "Applied Brain Research Inc", +[15][0x5c - 1] = "Maxio Technology (Hangzhou) Co Ltd", +[15][0x5d - 1] = "HK DCHIP Technology Limited", +[15][0x5e - 1] = "Hitachi-LG Data Storage", +[15][0x5f - 1] = "Shenzhen Huadian Communication Co Ltd", +[15][0x60 - 1] = "Achieve Memory Technology (Suzhou) Co", +[15][0x61 - 1] = "Shenzhen Think Future Semiconductor Co", +[15][0x62 - 1] = "Innosilicon", +[15][0x63 - 1] = "Shenzhen Weilida Technology Co Ltd", +[15][0x64 - 1] = "Agrade Storage (Shenzhen) Co Ltd", +[15][0x65 - 1] = "Shenzhen Worldshine Data Technology Co", +[15][0x66 - 1] = "Mindgrove Technologies", +[15][0x67 - 1] = "BYD Semiconductor Co Ltd", +[15][0x68 - 1] = "Chipsine Semiconductor (Suzhou) Co Ltd", +[15][0x69 - 1] = "Shen Zhen Shi Xun He Shi Ji Dian Zi You", +[15][0x6a - 1] = "Shenzhen Jindacheng Computer Co Ltd", +[15][0x6b - 1] = "Shenzhen Baina Haichuan Technology Co", +[15][0x6c - 1] = "Shanghai Hengshi Electronic Technology", +[15][0x6d - 1] = "Beijing Boyu Tuxian Technology Co Ltd", +[15][0x6e - 1] = "China Chips Star Semiconductor Co Ltd", +[15][0x6f - 1] = "Shenzhen Shenghuacan Technology Co", +[15][0x70 - 1] = "Kinara Inc", +[15][0x71 - 1] = "TRASNA Semiconductor", +[15][0x72 - 1] = "KEYSOM", +[15][0x73 - 1] = "Shenzhen YYF Info Tech Co Ltd", +[15][0x74 - 1] = "Sharetronics Data Technology Co Ltd", /* EOF */ From 00ee9b09d9112a09e9780ace560bd8b353661658 Mon Sep 17 00:00:00 2001 From: Walter Ji Date: Thu, 22 Feb 2024 17:06:53 +0800 Subject: [PATCH 05/44] target/mips32: add dsp access support for gdb Change order of dsp register name array and removed hi0 and lo0 to comply with gdb definition of dsp in mips-dsp.xml, the regs name array is now mapping corresponding dsp accumulator names onto `mips32_regs` and `core_regs` instead of mapping to instr arrays in dsp functions. feature now requires a place to store cached dsp registers. Add dsp registers to reg_list for gdb to access them. Add dsp module enable detection to avoid DSP Disabled exception while reading dsp accumulators. Add dsp register reading procedure in `mips32_pracc_read_regs` and writing procedure in `mips32_pracc_write_regs`. Change-Id: Iacc335da030ab85989922c81aac7925b3dc17459 Signed-off-by: Walter Ji Reviewed-on: https://review.openocd.org/c/openocd/+/8476 Tested-by: jenkins Reviewed-by: Antonio Borneo Reviewed-by: Oleksij Rempel --- src/target/mips32.c | 102 +++++++++++++++++++++++++++----------- src/target/mips32.h | 11 +++- src/target/mips32_pracc.c | 83 +++++++++++++++++++++++++++++-- 3 files changed, 163 insertions(+), 33 deletions(-) diff --git a/src/target/mips32.c b/src/target/mips32.c index 81faab72d..af52ffca0 100644 --- a/src/target/mips32.c +++ b/src/target/mips32.c @@ -31,7 +31,7 @@ static const char *mips_isa_strings[] = { /* * GDB registers - * based on gdb-7.6.2/gdb/features/mips-{fpu,cp0,cpu}.xml + * based on gdb-7.6.2/gdb/features/mips-{fpu,cp0,cpu,dsp}.xml */ static const struct { unsigned id; @@ -156,6 +156,22 @@ static const struct { "org.gnu.gdb.mips.cpu", 0 }, { MIPS32_REGLIST_C0_GUESTCTL1_INDEX, "guestCtl1", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cp0", 0 }, + + { MIPS32_REGLIST_DSP_INDEX + 0, "hi1", REG_TYPE_INT, NULL, + "org.gnu.gdb.mips.dsp", 0 }, + { MIPS32_REGLIST_DSP_INDEX + 1, "lo1", REG_TYPE_INT, NULL, + "org.gnu.gdb.mips.dsp", 0 }, + { MIPS32_REGLIST_DSP_INDEX + 2, "hi2", REG_TYPE_INT, NULL, + "org.gnu.gdb.mips.dsp", 0 }, + { MIPS32_REGLIST_DSP_INDEX + 3, "lo2", REG_TYPE_INT, NULL, + "org.gnu.gdb.mips.dsp", 0 }, + { MIPS32_REGLIST_DSP_INDEX + 4, "hi3", REG_TYPE_INT, NULL, + "org.gnu.gdb.mips.dsp", 0 }, + { MIPS32_REGLIST_DSP_INDEX + 5, "lo3", REG_TYPE_INT, NULL, + "org.gnu.gdb.mips.dsp", 0 }, + + { MIPS32_REGLIST_DSP_DSPCTL_INDEX, "dspctl", REG_TYPE_INT, NULL, + "org.gnu.gdb.mips.dsp", 0 }, }; #define MIPS32_NUM_REGS ARRAY_SIZE(mips32_regs) @@ -211,13 +227,11 @@ static const struct { static const struct { const char *name; } mips32_dsp_regs[MIPS32NUMDSPREGS] = { - { "hi0"}, { "hi1"}, - { "hi2"}, - { "hi3"}, - { "lo0"}, { "lo1"}, + { "hi2"}, { "lo2"}, + { "hi3"}, { "lo3"}, { "control"}, }; @@ -328,7 +342,12 @@ static int mips32_read_core_reg(struct target *target, unsigned int num) if (num >= MIPS32_NUM_REGS) return ERROR_COMMAND_SYNTAX_ERROR; - if (num >= MIPS32_REGLIST_C0_INDEX) { + if (num >= MIPS32_REGLIST_DSP_INDEX) { + /* DSP */ + cnum = num - MIPS32_REGLIST_DSP_INDEX; + reg_value = mips32->core_regs.dsp[cnum]; + buf_set_u32(mips32->core_cache->reg_list[num].value, 0, 32, reg_value); + } else if (num >= MIPS32_REGLIST_C0_INDEX) { /* CP0 */ cnum = num - MIPS32_REGLIST_C0_INDEX; reg_value = mips32->core_regs.cp0[cnum]; @@ -371,7 +390,12 @@ static int mips32_write_core_reg(struct target *target, unsigned int num) if (num >= MIPS32_NUM_REGS) return ERROR_COMMAND_SYNTAX_ERROR; - if (num >= MIPS32_REGLIST_C0_INDEX) { + if (num >= MIPS32_REGLIST_DSP_INDEX) { + /* DSP */ + cnum = num - MIPS32_REGLIST_DSP_INDEX; + reg_value = buf_get_u32(mips32->core_cache->reg_list[num].value, 0, 32); + mips32->core_regs.dsp[cnum] = (uint32_t)reg_value; + } else if (num >= MIPS32_REGLIST_C0_INDEX) { /* CP0 */ cnum = num - MIPS32_REGLIST_C0_INDEX; reg_value = buf_get_u32(mips32->core_cache->reg_list[num].value, 0, 32); @@ -1026,10 +1050,20 @@ int mips32_cpu_probe(struct target *target) /* reads dsp implementation info from CP0 Config3 register {DSPP, DSPREV}*/ static void mips32_read_config_dsp(struct mips32_common *mips32, struct mips_ejtag *ejtag_info) { - uint32_t dsp_present = ((ejtag_info->config[3] & MIPS32_CONFIG3_DSPP_MASK) >> MIPS32_CONFIG3_DSPP_SHIFT); + uint32_t retval, status_value, dsp_present; + bool dsp_enabled; + + retval = mips32_cp0_read(ejtag_info, &status_value, MIPS32_C0_STATUS, 0); + if (retval != ERROR_OK) { + LOG_ERROR("Failed to read cp0 status register"); + return; + } + + dsp_present = ((ejtag_info->config[3] & MIPS32_CONFIG3_DSPP_MASK) >> MIPS32_CONFIG3_DSPP_SHIFT); + dsp_enabled = (status_value & BIT(MIPS32_CP0_STATUS_MX_SHIFT)) != 0; if (dsp_present) { mips32->dsp_imp = ((ejtag_info->config[3] & MIPS32_CONFIG3_DSPREV_MASK) >> MIPS32_CONFIG3_DSPREV_SHIFT) + 1; - LOG_USER("DSP implemented: %s, rev %d", "yes", mips32->dsp_imp); + LOG_USER("DSP implemented: rev %d, %s", mips32->dsp_imp, dsp_enabled ? "enabled" : "disabled"); } else { LOG_USER("DSP implemented: %s", "no"); } @@ -1747,13 +1781,11 @@ static int mips32_pracc_read_dsp_reg(struct mips_ejtag *ejtag_info, uint32_t *va }; uint32_t dsp_read_code[] = { - MIPS32_MFHI(isa, t0), /* mfhi t0 ($ac0) - OPCODE - 0x00004010 */ MIPS32_DSP_MFHI(t0, 1), /* mfhi t0,$ac1 - OPCODE - 0x00204010 */ - MIPS32_DSP_MFHI(t0, 2), /* mfhi t0,$ac2 - OPCODE - 0x00404010 */ - MIPS32_DSP_MFHI(t0, 3), /* mfhi t0,$ac3 - OPCODE - 0x00604010*/ - MIPS32_MFLO(isa, t0), /* mflo t0 ($ac0) - OPCODE - 0x00004012 */ MIPS32_DSP_MFLO(t0, 1), /* mflo t0,$ac1 - OPCODE - 0x00204012 */ + MIPS32_DSP_MFHI(t0, 2), /* mfhi t0,$ac2 - OPCODE - 0x00404010 */ MIPS32_DSP_MFLO(t0, 2), /* mflo t0,$ac2 - OPCODE - 0x00404012 */ + MIPS32_DSP_MFHI(t0, 3), /* mfhi t0,$ac3 - OPCODE - 0x00604010*/ MIPS32_DSP_MFLO(t0, 3), /* mflo t0,$ac3 - OPCODE - 0x00604012 */ MIPS32_DSP_RDDSP(t0, 0x3F), /* rddsp t0, 0x3f (DSPCtl) - OPCODE - 0x7c3f44b8 */ }; @@ -1824,13 +1856,11 @@ static int mips32_pracc_write_dsp_reg(struct mips_ejtag *ejtag_info, uint32_t va }; uint32_t dsp_write_code[] = { - MIPS32_MTHI(isa, t0), /* mthi t0 ($ac0) - OPCODE - 0x01000011 */ MIPS32_DSP_MTHI(t0, 1), /* mthi t0, $ac1 - OPCODE - 0x01000811 */ - MIPS32_DSP_MTHI(t0, 2), /* mthi t0, $ac2 - OPCODE - 0x01001011 */ - MIPS32_DSP_MTHI(t0, 3), /* mthi t0, $ac3 - OPCODE - 0x01001811 */ - MIPS32_MTLO(isa, t0), /* mtlo t0 ($ac0) - OPCODE - 0x01000013 */ MIPS32_DSP_MTLO(t0, 1), /* mtlo t0, $ac1 - OPCODE - 0x01000813 */ + MIPS32_DSP_MTHI(t0, 2), /* mthi t0, $ac2 - OPCODE - 0x01001011 */ MIPS32_DSP_MTLO(t0, 2), /* mtlo t0, $ac2 - OPCODE - 0x01001013 */ + MIPS32_DSP_MTHI(t0, 3), /* mthi t0, $ac3 - OPCODE - 0x01001811 */ MIPS32_DSP_MTLO(t0, 3), /* mtlo t0, $ac3 - OPCODE - 0x01001813 */ MIPS32_DSP_WRDSP(t0, 0x1F), /* wrdsp t0, 0x1f (DSPCtl) - OPCODE - 0x7d00fcf8*/ }; @@ -2107,15 +2137,18 @@ static int mips32_dsp_find_register_by_name(const char *reg_name) * * @return ERROR_OK on success; error code on failure. */ -static int mips32_dsp_get_all_regs(struct command_invocation *cmd, struct mips_ejtag *ejtag_info) +static int mips32_dsp_get_all_regs(struct command_invocation *cmd, struct mips32_common *mips32) { uint32_t value = 0; + struct mips_ejtag *ejtag_info = &mips32->ejtag_info; for (int i = 0; i < MIPS32NUMDSPREGS; i++) { int retval = mips32_pracc_read_dsp_reg(ejtag_info, &value, i); if (retval != ERROR_OK) { command_print(CMD, "couldn't access reg %s", mips32_dsp_regs[i].name); return retval; } + mips32->core_regs.dsp[i] = value; + mips32->core_cache->reg_list[MIPS32_REGLIST_DSP_INDEX + i].dirty = 1; command_print(CMD, "%*s: 0x%8.8x", 7, mips32_dsp_regs[i].name, value); } return ERROR_OK; @@ -2132,20 +2165,28 @@ static int mips32_dsp_get_all_regs(struct command_invocation *cmd, struct mips_e * * @return ERROR_OK on success; error code on failure. */ -static int mips32_dsp_get_register(struct command_invocation *cmd, struct mips_ejtag *ejtag_info) +static int mips32_dsp_get_register(struct command_invocation *cmd, struct mips32_common *mips32) { uint32_t value = 0; int index = mips32_dsp_find_register_by_name(CMD_ARGV[0]); + struct mips_ejtag *ejtag_info = &mips32->ejtag_info; if (index == MIPS32NUMDSPREGS) { command_print(CMD, "ERROR: register '%s' not found", CMD_ARGV[0]); return ERROR_COMMAND_SYNTAX_ERROR; } int retval = mips32_pracc_read_dsp_reg(ejtag_info, &value, index); - if (retval != ERROR_OK) + if (retval != ERROR_OK) { command_print(CMD, "ERROR: Could not access dsp register %s", CMD_ARGV[0]); - else - command_print(CMD, "0x%8.8x", value); + return retval; + } + + command_print(CMD, "0x%8.8x", value); + + if (mips32->core_regs.dsp[index] != value) { + mips32->core_regs.dsp[index] = value; + mips32->core_cache->reg_list[MIPS32_REGLIST_DSP_INDEX + index].dirty = 1; + } return retval; } @@ -2162,9 +2203,10 @@ static int mips32_dsp_get_register(struct command_invocation *cmd, struct mips_e * * @return ERROR_OK on success; error code on failure. */ -static int mips32_dsp_set_register(struct command_invocation *cmd, struct mips_ejtag *ejtag_info) +static int mips32_dsp_set_register(struct command_invocation *cmd, struct mips32_common *mips32) { uint32_t value; + struct mips_ejtag *ejtag_info = &mips32->ejtag_info; int index = mips32_dsp_find_register_by_name(CMD_ARGV[0]); if (index == MIPS32NUMDSPREGS) { command_print(CMD, "ERROR: register '%s' not found", CMD_ARGV[0]); @@ -2174,8 +2216,13 @@ static int mips32_dsp_set_register(struct command_invocation *cmd, struct mips_e COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); int retval = mips32_pracc_write_dsp_reg(ejtag_info, value, index); - if (retval != ERROR_OK) + if (retval != ERROR_OK) { command_print(CMD, "Error: could not write to dsp register %s", CMD_ARGV[0]); + return retval; + } + + mips32->core_regs.dsp[index] = value; + mips32->core_cache->reg_list[MIPS32_REGLIST_DSP_INDEX + index].dirty = 1; return retval; } @@ -2193,7 +2240,6 @@ COMMAND_HANDLER(mips32_handle_dsp_command) int retval, tmp; struct target *target = get_current_target(CMD_CTX); struct mips32_common *mips32 = target_to_mips32(target); - struct mips_ejtag *ejtag_info = &mips32->ejtag_info; retval = mips32_verify_pointer(CMD, mips32); if (retval != ERROR_OK) @@ -2217,10 +2263,10 @@ COMMAND_HANDLER(mips32_handle_dsp_command) switch (CMD_ARGC) { case 0: - retval = mips32_dsp_get_all_regs(CMD, ejtag_info); + retval = mips32_dsp_get_all_regs(CMD, mips32); break; case 1: - retval = mips32_dsp_get_register(CMD, ejtag_info); + retval = mips32_dsp_get_register(CMD, mips32); break; case 2: tmp = *CMD_ARGV[0]; @@ -2228,7 +2274,7 @@ COMMAND_HANDLER(mips32_handle_dsp_command) command_print(CMD, "Error: invalid dsp command format"); retval = ERROR_COMMAND_ARGUMENT_INVALID; } else { - retval = mips32_dsp_set_register(CMD, ejtag_info); + retval = mips32_dsp_set_register(CMD, mips32); } break; default: diff --git a/src/target/mips32.h b/src/target/mips32.h index a557f3117..3d919e7dd 100644 --- a/src/target/mips32.h +++ b/src/target/mips32.h @@ -69,7 +69,7 @@ #define MIPS32_SCAN_DELAY_LEGACY_MODE 2000000 -#define MIPS32NUMDSPREGS 9 +#define MIPS32NUMDSPREGS 7 /* Bit Mask indicating CP0 register supported by this core */ #define MIPS_CP0_MK4 0x0001 @@ -78,6 +78,7 @@ #define MIPS_CP0_IAPTIV 0x0008 /* CP0 Status register fields */ +#define MIPS32_CP0_STATUS_MX_SHIFT 24 #define MIPS32_CP0_STATUS_FR_SHIFT 26 #define MIPS32_CP0_STATUS_CU1_SHIFT 29 @@ -211,6 +212,7 @@ static const struct mips32_cp0 { enum { MIPS32_PC = 37, MIPS32_FIR = 71, + MIPS32_DSPCTL = 78, MIPS32NUMCOREREGS }; @@ -220,11 +222,13 @@ enum { #define MIPS32_REG_FP_COUNT 32 #define MIPS32_REG_FPC_COUNT 2 #define MIPS32_REG_C0_COUNT 5 +#define MIPS32_REG_DSP_COUNT 7 #define MIPS32_REGLIST_GP_INDEX 0 #define MIPS32_REGLIST_FP_INDEX (MIPS32_REGLIST_GP_INDEX + MIPS32_REG_GP_COUNT) #define MIPS32_REGLIST_FPC_INDEX (MIPS32_REGLIST_FP_INDEX + MIPS32_REG_FP_COUNT) #define MIPS32_REGLIST_C0_INDEX (MIPS32_REGLIST_FPC_INDEX + MIPS32_REG_FPC_COUNT) +#define MIPS32_REGLIST_DSP_INDEX (MIPS32_REGLIST_C0_INDEX + MIPS32_REG_C0_COUNT) #define MIPS32_REGLIST_C0_STATUS_INDEX (MIPS32_REGLIST_C0_INDEX + 0) #define MIPS32_REGLIST_C0_BADVADDR_INDEX (MIPS32_REGLIST_C0_INDEX + 1) @@ -238,6 +242,10 @@ enum { #define MIPS32_REG_C0_PC_INDEX 3 #define MIPS32_REG_C0_GUESTCTL1_INDEX 4 +#define MIPS32_REGLIST_DSP_DSPCTL_INDEX (MIPS32_REGLIST_DSP_INDEX + 6) + +#define MIPS32_REG_DSP_DSPCTL_INDEX 6 + enum mips32_isa_mode { MIPS32_ISA_MIPS32 = 0, MIPS32_ISA_MIPS16E = 1, @@ -377,6 +385,7 @@ struct mips32_core_regs { uint64_t fpr[MIPS32_REG_FP_COUNT]; uint32_t fpcr[MIPS32_REG_FPC_COUNT]; uint32_t cp0[MIPS32_REG_C0_COUNT]; + uint32_t dsp[MIPS32_REG_DSP_COUNT]; }; struct mips32_common { diff --git a/src/target/mips32_pracc.c b/src/target/mips32_pracc.c index aaf3875fb..018d8424e 100644 --- a/src/target/mips32_pracc.c +++ b/src/target/mips32_pracc.c @@ -878,6 +878,7 @@ int mips32_pracc_write_regs(struct mips32_common *mips32) uint32_t *c0rs = mips32->core_regs.cp0; bool fpu_in_64bit = ((c0rs[0] & BIT(MIPS32_CP0_STATUS_FR_SHIFT)) != 0); bool fp_enabled = ((c0rs[0] & BIT(MIPS32_CP0_STATUS_CU1_SHIFT)) != 0); + bool dsp_enabled = ((c0rs[0] & BIT(MIPS32_CP0_STATUS_MX_SHIFT)) != 0); uint32_t rel = (ejtag_info->config[0] & MIPS32_CONFIG0_AR_MASK) >> MIPS32_CONFIG0_AR_SHIFT; pracc_queue_init(&ctx); @@ -943,6 +944,34 @@ int mips32_pracc_write_regs(struct mips32_common *mips32) pracc_add(&ctx, 0, MIPS32_EHB(ctx.isa)); } + /* Store DSP Accumulators */ + if (mips32->dsp_imp && dsp_enabled) { + /* Struct of mips32_dsp_regs: {ac{hi, lo}1-3, dspctl} */ + uint32_t *dspr = mips32->core_regs.dsp; + size_t dsp_regs = ARRAY_SIZE(mips32->core_regs.dsp); + + /* Starts from ac1, core_regs.dsp contains dspctl register, therefore - 1 */ + for (size_t index = 0; index != ((dsp_regs - 1) / 2); index++) { + /* Every accumulator have 2 registers, hi and lo, and core_regs.dsp stores ac[1~3] */ + /* reads hi[ac] from core_regs array */ + pracc_add_li32(&ctx, 2, dspr[index * 2], 0); + /* reads lo[ac] from core_regs array */ + pracc_add_li32(&ctx, 3, dspr[(index * 2) + 1], 0); + + /* Write to accumulator 1~3 and index starts from 0, therefore ac = index + 1 */ + size_t ac = index + 1; + pracc_add(&ctx, 0, MIPS32_DSP_MTHI(2, ac)); + pracc_add(&ctx, 0, MIPS32_DSP_MTLO(3, ac)); + } + + /* DSPCTL is the last element of register store */ + pracc_add_li32(&ctx, 2, dspr[6], 0); + pracc_add(&ctx, 0, MIPS32_DSP_WRDSP(2, 0x1F)); + + if (rel > MIPS32_RELEASE_1) + pracc_add(&ctx, 0, MIPS32_EHB(ctx.isa)); + } + /* load registers 2 to 31 with li32, optimize */ for (int i = 2; i < 32; i++) pracc_add_li32(&ctx, i, gprs[i], 1); @@ -1064,14 +1093,16 @@ int mips32_pracc_read_regs(struct mips32_common *mips32) unsigned int offset_cp0 = ((uint8_t *)&core_regs->cp0[0]) - (uint8_t *)core_regs; unsigned int offset_fpr = ((uint8_t *)&core_regs->fpr[0]) - (uint8_t *)core_regs; unsigned int offset_fpcr = ((uint8_t *)&core_regs->fpcr[0]) - (uint8_t *)core_regs; - bool fp_enabled; + unsigned int offset_dsp = ((uint8_t *)&core_regs->dsp[0]) - (uint8_t *)core_regs; + bool fp_enabled, dsp_enabled; /* - * This procedure has to be in 2 distinctive steps, because we can - * only know whether FP is enabled after reading CP0. + * This procedure has to be in 3 distinctive steps, because we can + * only know whether FP and DSP are enabled after reading CP0. * - * Step 1: Read everything except CP1 stuff + * Step 1: Read everything except CP1 and DSP stuff * Step 2: Read CP1 stuff if FP is implemented + * Step 3: Read DSP registers if dsp is implemented */ pracc_queue_init(&ctx); @@ -1149,6 +1180,50 @@ int mips32_pracc_read_regs(struct mips32_common *mips32) pracc_queue_free(&ctx); } + + dsp_enabled = (mips32->core_regs.cp0[MIPS32_REG_C0_STATUS_INDEX] & BIT(MIPS32_CP0_STATUS_MX_SHIFT)) != 0; + if (mips32->dsp_imp && dsp_enabled) { + pracc_queue_init(&ctx); + + mips32_pracc_store_regs_set_base_addr(&ctx); + + /* Struct of mips32_dsp_regs[7]: {ac{hi, lo}1-3, dspctl} */ + size_t dsp_regs = ARRAY_SIZE(mips32->core_regs.dsp); + /* Starts from ac1, core_regs.dsp have dspctl register, therefore - 1 */ + for (size_t index = 0; index != ((dsp_regs - 1) / 2); index++) { + /* Every accumulator have 2 registers, hi&lo, and core_regs.dsp stores ac[1~3] */ + /* Reads offset of hi[ac] from core_regs array */ + size_t offset_hi = offset_dsp + ((index * 2) * sizeof(uint32_t)); + /* Reads offset of lo[ac] from core_regs array */ + size_t offset_lo = offset_dsp + (((index * 2) + 1) * sizeof(uint32_t)); + + /* DSP Ac registers starts from 1 and index starts from 0, therefore ac = index + 1 */ + size_t ac = index + 1; + pracc_add(&ctx, 0, MIPS32_DSP_MFHI(8, ac)); + pracc_add(&ctx, MIPS32_PRACC_PARAM_OUT + offset_hi, + MIPS32_SW(ctx.isa, 8, PRACC_OUT_OFFSET + offset_hi, 1)); + pracc_add(&ctx, 0, MIPS32_DSP_MFLO(8, ac)); + pracc_add(&ctx, MIPS32_PRACC_PARAM_OUT + offset_lo, + MIPS32_SW(ctx.isa, 8, PRACC_OUT_OFFSET + offset_lo, 1)); + } + + /* DSPCTL is the last element of register store */ + pracc_add(&ctx, 0, MIPS32_DSP_RDDSP(8, 0x3F)); + pracc_add(&ctx, MIPS32_PRACC_PARAM_OUT + offset_dsp + ((dsp_regs - 1) * sizeof(uint32_t)), + MIPS32_SW(ctx.isa, 8, + PRACC_OUT_OFFSET + offset_dsp + ((dsp_regs - 1) * sizeof(uint32_t)), 1)); + + mips32_pracc_store_regs_restore(&ctx); + + /* jump to start */ + pracc_add(&ctx, 0, MIPS32_B(ctx.isa, NEG16((ctx.code_count + 1) << ctx.isa))); + /* load $15 in DeSave */ + pracc_add(&ctx, 0, MIPS32_MTC0(ctx.isa, 15, 31, 0)); + + ctx.retval = mips32_pracc_queue_exec(ejtag_info, &ctx, (uint32_t *)&mips32->core_regs, 1); + + pracc_queue_free(&ctx); + } return ctx.retval; } From 8750beeb44fb532612ea70dfdd1e794320810a0c Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sat, 21 Sep 2024 11:11:36 +0200 Subject: [PATCH 06/44] tcl: update to new syntax of telnet command Commit ad216136180e ("server/telnet: Restructure commands") modifies the syntax. sed -i 's/telnet_port/telnet port/' Change-Id: If1ad34a1ec54824dbc124acd36a894862276a34f Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8502 Reviewed-by: zapb Tested-by: jenkins --- tcl/interface/vdebug.cfg | 2 +- tcl/target/u8500.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tcl/interface/vdebug.cfg b/tcl/interface/vdebug.cfg index 9097c33da..63a595506 100644 --- a/tcl/interface/vdebug.cfg +++ b/tcl/interface/vdebug.cfg @@ -23,7 +23,7 @@ vdebug server $_VDEBUGHOST:$_VDEBUGPORT # example config listen on all interfaces, disable tcl/telnet server bindto 0.0.0.0 #gdb port 3333 -#telnet_port disabled +#telnet port disabled tcl port disabled # transaction batching: 0 - no batching, 1 - (default) wr, 2 - rw diff --git a/tcl/target/u8500.cfg b/tcl/target/u8500.cfg index b87d2613a..1fdc11fe3 100644 --- a/tcl/target/u8500.cfg +++ b/tcl/target/u8500.cfg @@ -143,7 +143,7 @@ proc enable_apetap {} { } tcl port 5555 -telnet_port 4444 +telnet port 4444 gdb port 3333 if { [info exists CHIPNAME] } { From bf1cf4afbb22d3c617186856c6638f4bb2d2d23b Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 8 Sep 2024 23:11:45 +0200 Subject: [PATCH 07/44] openocd: fix conversion string for stdint values Detected while converting 'unsigned' to 'unsigned int'. Use the correct conversion string for stdint values. Change-Id: I99f3dff4c64dfd7acf2bddb130b56e9ebe1e6c60 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8477 Tested-by: jenkins --- src/flash/nand/at91sam9.c | 5 ++--- src/flash/nand/lpc3180.c | 3 +-- src/flash/nand/lpc32xx.c | 3 +-- src/flash/nor/at91sam3.c | 10 +++++----- src/flash/nor/at91sam4.c | 10 +++++----- src/flash/nor/cfi.c | 3 +-- src/flash/nor/max32xxx.c | 4 ++-- src/flash/nor/stellaris.c | 4 ++-- src/flash/nor/tms470.c | 4 ++-- src/jtag/core.c | 5 ++--- src/jtag/tcl.c | 9 +++------ src/target/arm11.c | 15 ++++++--------- src/target/arm11_dbgtap.c | 25 ++++++++++--------------- src/target/arm_disassembler.c | 15 +++++++-------- src/target/arm_dpm.c | 10 ++++------ src/target/armv4_5.c | 2 +- src/target/armv8.c | 2 +- src/target/armv8_dpm.c | 5 ++--- src/target/cortex_a.c | 5 ++--- src/target/cortex_m.c | 10 ++++------ src/target/dsp563xx.c | 10 +++++----- src/target/etm.c | 7 +++---- src/target/target.c | 10 +++++----- src/target/x86_32_common.c | 4 ++-- 24 files changed, 78 insertions(+), 102 deletions(-) diff --git a/src/flash/nand/at91sam9.c b/src/flash/nand/at91sam9.c index bfbba67c4..9c8d5e2a3 100644 --- a/src/flash/nand/at91sam9.c +++ b/src/flash/nand/at91sam9.c @@ -389,9 +389,8 @@ static int at91sam9_read_page(struct nand_device *nand, uint32_t page, uint32_t bit = parity & 0x0F; data[word] ^= (0x1) << bit; - LOG_INFO("Data word %d, bit %d corrected.", - (unsigned) word, - (unsigned) bit); + LOG_INFO("Data word %" PRIu32 ", bit %" PRIu32 " corrected.", + word, bit); } } diff --git a/src/flash/nand/lpc3180.c b/src/flash/nand/lpc3180.c index c1af1d737..8e660a068 100644 --- a/src/flash/nand/lpc3180.c +++ b/src/flash/nand/lpc3180.c @@ -890,8 +890,7 @@ static int lpc3180_read_page(struct nand_device *nand, if (mlc_isr & 0x8) { if (mlc_isr & 0x40) { - LOG_ERROR("uncorrectable error detected: 0x%2.2x", - (unsigned)mlc_isr); + LOG_ERROR("uncorrectable error detected: 0x%2.2" PRIx32, mlc_isr); free(page_buffer); free(oob_buffer); return ERROR_NAND_OPERATION_FAILED; diff --git a/src/flash/nand/lpc32xx.c b/src/flash/nand/lpc32xx.c index 1fdae9fe5..89a00a9e3 100644 --- a/src/flash/nand/lpc32xx.c +++ b/src/flash/nand/lpc32xx.c @@ -1386,8 +1386,7 @@ static int lpc32xx_read_page_mlc(struct nand_device *nand, uint32_t page, if (mlc_isr & 0x8) { if (mlc_isr & 0x40) { - LOG_ERROR("uncorrectable error detected: " - "0x%2.2x", (unsigned)mlc_isr); + LOG_ERROR("uncorrectable error detected: 0x%2.2" PRIx32, mlc_isr); return ERROR_NAND_OPERATION_FAILED; } diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c index b1cb8f110..8e8497eb0 100644 --- a/src/flash/nor/at91sam3.c +++ b/src/flash/nor/at91sam3.c @@ -2051,7 +2051,7 @@ do_retry: case AT91C_EFC_FCMD_CLB: n = (private->size_bytes / private->page_size); if (argument >= n) - LOG_ERROR("*BUG*: Embedded flash has only %u pages", (unsigned)(n)); + LOG_ERROR("*BUG*: Embedded flash has only %" PRIu32 " pages", n); break; case AT91C_EFC_FCMD_SFB: @@ -2867,8 +2867,8 @@ static int sam3_read_this_reg(struct sam3_chip *chip, uint32_t *goes_here) r = target_read_u32(chip->target, reg->address, goes_here); if (r != ERROR_OK) { - LOG_ERROR("Cannot read SAM3 register: %s @ 0x%08x, Err: %d", - reg->name, (unsigned)(reg->address), r); + LOG_ERROR("Cannot read SAM3 register: %s @ 0x%08" PRIx32 ", Err: %d", + reg->name, reg->address, r); } return r; } @@ -2883,8 +2883,8 @@ static int sam3_read_all_regs(struct sam3_chip *chip) r = sam3_read_this_reg(chip, sam3_get_reg_ptr(&(chip->cfg), reg)); if (r != ERROR_OK) { - LOG_ERROR("Cannot read SAM3 register: %s @ 0x%08x, Error: %d", - reg->name, ((unsigned)(reg->address)), r); + LOG_ERROR("Cannot read SAM3 register: %s @ 0x%08" PRIx32 ", Error: %d", + reg->name, reg->address, r); return r; } reg++; diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c index 62127530f..31ae35ccd 100644 --- a/src/flash/nor/at91sam4.c +++ b/src/flash/nor/at91sam4.c @@ -1501,7 +1501,7 @@ do_retry: case AT91C_EFC_FCMD_CLB: n = (private->size_bytes / private->page_size); if (argument >= n) - LOG_ERROR("*BUG*: Embedded flash has only %u pages", (unsigned)(n)); + LOG_ERROR("*BUG*: Embedded flash has only %" PRIu32 " pages", n); break; case AT91C_EFC_FCMD_SFB: @@ -2374,8 +2374,8 @@ static int sam4_read_this_reg(struct sam4_chip *chip, uint32_t *goes_here) r = target_read_u32(chip->target, reg->address, goes_here); if (r != ERROR_OK) { - LOG_ERROR("Cannot read SAM4 register: %s @ 0x%08x, Err: %d", - reg->name, (unsigned)(reg->address), r); + LOG_ERROR("Cannot read SAM4 register: %s @ 0x%08" PRIx32 ", Err: %d", + reg->name, reg->address, r); } return r; } @@ -2390,8 +2390,8 @@ static int sam4_read_all_regs(struct sam4_chip *chip) r = sam4_read_this_reg(chip, sam4_get_reg_ptr(&(chip->cfg), reg)); if (r != ERROR_OK) { - LOG_ERROR("Cannot read SAM4 register: %s @ 0x%08x, Error: %d", - reg->name, ((unsigned)(reg->address)), r); + LOG_ERROR("Cannot read SAM4 register: %s @ 0x%08" PRIx32 ", Error: %d", + reg->name, reg->address, r); return r; } reg++; diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c index 78bc91e7d..96bd7353f 100644 --- a/src/flash/nor/cfi.c +++ b/src/flash/nor/cfi.c @@ -2219,8 +2219,7 @@ static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, u uint8_t current_word[CFI_MAX_BUS_WIDTH]; int retval; - LOG_DEBUG("reading buffer of %i byte at 0x%8.8x", - (int)count, (unsigned)offset); + LOG_DEBUG("reading buffer of %" PRIi32 " byte at 0x%8.8" PRIx32, count, offset); if (bank->target->state != TARGET_HALTED) { LOG_ERROR("Target not halted"); diff --git a/src/flash/nor/max32xxx.c b/src/flash/nor/max32xxx.c index 59a14af8b..052a42d23 100644 --- a/src/flash/nor/max32xxx.c +++ b/src/flash/nor/max32xxx.c @@ -388,8 +388,8 @@ static int max32xxx_write_block(struct flash_bank *bank, const uint8_t *buffer, return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; } - LOG_DEBUG("retry target_alloc_working_area(%s, size=%u)", - target_name(target), (unsigned) buffer_size); + LOG_DEBUG("retry target_alloc_working_area(%s, size=%" PRIu32 ")", + target_name(target), buffer_size); } target_write_buffer(target, write_algorithm->address, sizeof(write_code), diff --git a/src/flash/nor/stellaris.c b/src/flash/nor/stellaris.c index eab6244d4..25bc5507a 100644 --- a/src/flash/nor/stellaris.c +++ b/src/flash/nor/stellaris.c @@ -1056,8 +1056,8 @@ static int stellaris_write_block(struct flash_bank *bank, target_free_working_area(target, write_algorithm); return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; } - LOG_DEBUG("retry target_alloc_working_area(%s, size=%u)", - target_name(target), (unsigned) buffer_size); + LOG_DEBUG("retry target_alloc_working_area(%s, size=%" PRIu32 ")", + target_name(target), buffer_size); } target_write_buffer(target, write_algorithm->address, diff --git a/src/flash/nor/tms470.c b/src/flash/nor/tms470.c index e01d2df0a..6e0ea5b95 100644 --- a/src/flash/nor/tms470.c +++ b/src/flash/nor/tms470.c @@ -239,8 +239,8 @@ static int tms470_read_part_info(struct flash_bank *bank) break; default: - LOG_WARNING("Could not identify part 0x%02x as a member of the TMS470 family.", - (unsigned)part_number); + LOG_WARNING("Could not identify part 0x%02" PRIx32 " as a member of the TMS470 family.", + part_number); return ERROR_FLASH_OPERATION_FAILED; } diff --git a/src/jtag/core.c b/src/jtag/core.c index a6f38a19d..6515d7160 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -1473,10 +1473,9 @@ void jtag_tap_init(struct jtag_tap *tap) jtag_tap_add(tap); LOG_DEBUG("Created Tap: %s @ abs position %u, " - "irlen %u, capture: 0x%x mask: 0x%x", tap->dotted_name, + "irlen %u, capture: 0x%" PRIx32 " mask: 0x%" PRIx32, tap->dotted_name, tap->abs_chain_position, tap->ir_length, - (unsigned) tap->ir_capture_value, - (unsigned) tap->ir_capture_mask); + tap->ir_capture_value, tap->ir_capture_mask); } void jtag_tap_free(struct jtag_tap *tap) diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 624b4e4c2..e2b3b45a6 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -803,10 +803,8 @@ COMMAND_HANDLER(handle_scan_chain_command) while (tap) { uint32_t expected, expected_mask, ii; - snprintf(expected_id, sizeof(expected_id), "0x%08x", - (unsigned)((tap->expected_ids_cnt > 0) - ? tap->expected_ids[0] - : 0)); + snprintf(expected_id, sizeof(expected_id), "0x%08" PRIx32, + (tap->expected_ids_cnt > 0) ? tap->expected_ids[0] : 0); if (tap->ignore_version) expected_id[2] = '*'; @@ -825,8 +823,7 @@ COMMAND_HANDLER(handle_scan_chain_command) (unsigned int)(expected_mask)); for (ii = 1; ii < tap->expected_ids_cnt; ii++) { - snprintf(expected_id, sizeof(expected_id), "0x%08x", - (unsigned) tap->expected_ids[ii]); + snprintf(expected_id, sizeof(expected_id), "0x%08" PRIx32, tap->expected_ids[ii]); if (tap->ignore_version) expected_id[2] = '*'; diff --git a/src/target/arm11.c b/src/target/arm11.c index 50aaa86f1..43790c737 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -43,7 +43,7 @@ static int arm11_check_init(struct arm11_common *arm11) CHECK_RETVAL(arm11_read_dscr(arm11)); if (!(arm11->dscr & DSCR_HALT_DBG_MODE)) { - LOG_DEBUG("DSCR %08x", (unsigned) arm11->dscr); + LOG_DEBUG("DSCR %08" PRIx32, arm11->dscr); LOG_DEBUG("Bringing target into debug mode"); arm11->dscr |= DSCR_HALT_DBG_MODE; @@ -241,8 +241,7 @@ static int arm11_leave_debug_state(struct arm11_common *arm11, bool bpwp) registers hold data that was written by one side (CPU or JTAG) and not read out by the other side. */ - LOG_ERROR("wDTR/rDTR inconsistent (DSCR %08x)", - (unsigned) arm11->dscr); + LOG_ERROR("wDTR/rDTR inconsistent (DSCR %08" PRIx32 ")", arm11->dscr); return ERROR_FAIL; } } @@ -516,7 +515,7 @@ static int arm11_resume(struct target *target, int current, while (1) { CHECK_RETVAL(arm11_read_dscr(arm11)); - LOG_DEBUG("DSCR %08x", (unsigned) arm11->dscr); + LOG_DEBUG("DSCR %08" PRIx32, arm11->dscr); if (arm11->dscr & DSCR_CORE_RESTARTED) break; @@ -662,7 +661,7 @@ static int arm11_step(struct target *target, int current, | DSCR_CORE_HALTED; CHECK_RETVAL(arm11_read_dscr(arm11)); - LOG_DEBUG("DSCR %08x e", (unsigned) arm11->dscr); + LOG_DEBUG("DSCR %08" PRIx32 " e", arm11->dscr); if ((arm11->dscr & mask) == mask) break; @@ -1012,10 +1011,8 @@ static int arm11_write_memory_inner(struct target *target, return retval; if (address + size * count != r0) { - LOG_ERROR("Data transfer failed. Expected end " - "address 0x%08x, got 0x%08x", - (unsigned) (address + size * count), - (unsigned) r0); + LOG_ERROR("Data transfer failed. Expected end address 0x%08" PRIx32 ", got 0x%08" PRIx32, + address + size * count, r0); if (burst) LOG_ERROR( diff --git a/src/target/arm11_dbgtap.c b/src/target/arm11_dbgtap.c index b670bd7f7..b66f88618 100644 --- a/src/target/arm11_dbgtap.c +++ b/src/target/arm11_dbgtap.c @@ -242,7 +242,7 @@ int arm11_add_debug_scan_n(struct arm11_common *arm11, static void arm11_add_debug_inst(struct arm11_common *arm11, uint32_t inst, uint8_t *flag, tap_state_t state) { - JTAG_DEBUG("INST <= 0x%08x", (unsigned) inst); + JTAG_DEBUG("INST <= 0x%08" PRIx32, inst); struct scan_field itr[2]; @@ -282,9 +282,7 @@ int arm11_read_dscr(struct arm11_common *arm11) CHECK_RETVAL(jtag_execute_queue()); if (arm11->dscr != dscr) - JTAG_DEBUG("DSCR = %08x (OLD %08x)", - (unsigned) dscr, - (unsigned) arm11->dscr); + JTAG_DEBUG("DSCR = %08" PRIx32 " (OLD %08" PRIx32 ")", dscr, arm11->dscr); arm11->dscr = dscr; @@ -317,9 +315,7 @@ int arm11_write_dscr(struct arm11_common *arm11, uint32_t dscr) CHECK_RETVAL(jtag_execute_queue()); - JTAG_DEBUG("DSCR <= %08x (OLD %08x)", - (unsigned) dscr, - (unsigned) arm11->dscr); + JTAG_DEBUG("DSCR <= %08" PRIx32 " (OLD %08" PRIx32 ")", dscr, arm11->dscr); arm11->dscr = dscr; @@ -509,8 +505,8 @@ int arm11_run_instr_data_to_core(struct arm11_common *arm11, CHECK_RETVAL(jtag_execute_queue()); - JTAG_DEBUG("DTR _data %08x ready %d n_retry %d", - (unsigned) _data, ready, n_retry); + JTAG_DEBUG("DTR _data %08" PRIx32 " ready %d n_retry %d", + _data, ready, n_retry); int64_t then = 0; @@ -754,8 +750,8 @@ int arm11_run_instr_data_from_core(struct arm11_common *arm11, CHECK_RETVAL(jtag_execute_queue()); - JTAG_DEBUG("DTR _data %08x ready %d n_retry %d", - (unsigned) _data, ready, n_retry); + JTAG_DEBUG("DTR _data %08" PRIx32 " ready %d n_retry %d", + _data, ready, n_retry); int64_t then = 0; @@ -878,9 +874,8 @@ int arm11_sc7_run(struct arm11_common *arm11, struct arm11_sc7_action *actions, /* Timeout here so we don't get stuck. */ int i_n = 0; while (1) { - JTAG_DEBUG("SC7 <= c%-3d Data %08x %s", - (unsigned) address_out, - (unsigned) data_out, + JTAG_DEBUG("SC7 <= c%-3" PRIu8 " Data %08" PRIx32 " %s", + address_out, data_out, n_rw ? "write" : "read"); arm11_add_dr_scan_vc(arm11->arm.target->tap, ARRAY_SIZE(chain7_fields), @@ -908,7 +903,7 @@ int arm11_sc7_run(struct arm11_common *arm11, struct arm11_sc7_action *actions, } if (!n_rw) - JTAG_DEBUG("SC7 => Data %08x", (unsigned) data_in); + JTAG_DEBUG("SC7 => Data %08" PRIx32, data_in); if (i > 0) { if (actions[i - 1].address != address_in) diff --git a/src/target/arm_disassembler.c b/src/target/arm_disassembler.c index 749274f36..5c52ad899 100644 --- a/src/target/arm_disassembler.c +++ b/src/target/arm_disassembler.c @@ -266,18 +266,18 @@ static int evaluate_srs(uint32_t opcode, case 0x08400000: snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 - "\tSRS%s\tSP%s, #%d", + "\tSRS%s\tSP%s, #%" PRIu32, address, opcode, mode, wback, - (unsigned)(opcode & 0x1f)); + opcode & 0x1f); break; case 0x08100000: snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 - "\tRFE%s\tr%d%s", + "\tRFE%s\tr%" PRIu32 "%s", address, opcode, mode, - (unsigned)((opcode >> 16) & 0xf), wback); + (opcode >> 16) & 0xf, wback); break; default: return evaluate_unknown(opcode, address, instruction); @@ -842,7 +842,7 @@ static int evaluate_media(uint32_t opcode, uint32_t address, /* halfword pack */ if ((opcode & 0x01f00020) == 0x00800000) { char *type, *shift; - unsigned imm = (unsigned) (opcode >> 7) & 0x1f; + unsigned int imm = (opcode >> 7) & 0x1f; if (opcode & (1 << 6)) { type = "TB"; @@ -865,7 +865,7 @@ static int evaluate_media(uint32_t opcode, uint32_t address, /* word saturate */ if ((opcode & 0x01a00020) == 0x00a00000) { char *shift; - unsigned imm = (unsigned) (opcode >> 7) & 0x1f; + unsigned int imm = (opcode >> 7) & 0x1f; if (opcode & (1 << 6)) { shift = "ASR"; @@ -2046,8 +2046,7 @@ int arm_evaluate_opcode(uint32_t opcode, uint32_t address, return evaluate_cdp_mcr_mrc(opcode, address, instruction); } - LOG_ERROR("ARM: should never reach this point (opcode=%08x)", - (unsigned) opcode); + LOG_ERROR("ARM: should never reach this point (opcode=%08" PRIx32 ")", opcode); return -1; } diff --git a/src/target/arm_dpm.c b/src/target/arm_dpm.c index 9f3a444af..94e91ad6c 100644 --- a/src/target/arm_dpm.c +++ b/src/target/arm_dpm.c @@ -198,8 +198,7 @@ static int dpm_read_reg_u64(struct arm_dpm *dpm, struct reg *r, unsigned regnum) buf_set_u32(r->value + 4, 0, 32, value_r1); r->valid = true; r->dirty = false; - LOG_DEBUG("READ: %s, %8.8x, %8.8x", r->name, - (unsigned) value_r0, (unsigned) value_r1); + LOG_DEBUG("READ: %s, %8.8" PRIx32 ", %8.8" PRIx32, r->name, value_r0, value_r1); } return retval; @@ -266,7 +265,7 @@ int arm_dpm_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum) buf_set_u32(r->value, 0, 32, value); r->valid = true; r->dirty = false; - LOG_DEBUG("READ: %s, %8.8x", r->name, (unsigned) value); + LOG_DEBUG("READ: %s, %8.8" PRIx32, r->name, value); } return retval; @@ -302,8 +301,7 @@ static int dpm_write_reg_u64(struct arm_dpm *dpm, struct reg *r, unsigned regnum if (retval == ERROR_OK) { r->dirty = false; - LOG_DEBUG("WRITE: %s, %8.8x, %8.8x", r->name, - (unsigned) value_r0, (unsigned) value_r1); + LOG_DEBUG("WRITE: %s, %8.8" PRIx32 ", %8.8" PRIx32, r->name, value_r0, value_r1); } return retval; @@ -351,7 +349,7 @@ static int dpm_write_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum) if (retval == ERROR_OK) { r->dirty = false; - LOG_DEBUG("WRITE: %s, %8.8x", r->name, (unsigned) value); + LOG_DEBUG("WRITE: %s, %8.8" PRIx32, r->name, value); } return retval; diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 1886d5e1f..ae89762e1 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -482,7 +482,7 @@ void arm_set_cpsr(struct arm *arm, uint32_t cpsr) } arm->core_state = state; - LOG_DEBUG("set CPSR %#8.8x: %s mode, %s state", (unsigned) cpsr, + LOG_DEBUG("set CPSR %#8.8" PRIx32 ": %s mode, %s state", cpsr, arm_mode_name(mode), arm_state_strings[arm->core_state]); } diff --git a/src/target/armv8.c b/src/target/armv8.c index b54ef13d3..3e0ea0b75 100644 --- a/src/target/armv8.c +++ b/src/target/armv8.c @@ -961,7 +961,7 @@ void armv8_set_cpsr(struct arm *arm, uint32_t cpsr) arm->core_state = state; arm->core_mode = mode; - LOG_DEBUG("set CPSR %#8.8x: %s mode, %s state", (unsigned) cpsr, + LOG_DEBUG("set CPSR %#8.8" PRIx32 ": %s mode, %s state", cpsr, armv8_mode_name(arm->core_mode), armv8_state_strings[arm->core_state]); } diff --git a/src/target/armv8_dpm.c b/src/target/armv8_dpm.c index 271bd91c3..bcecedc9d 100644 --- a/src/target/armv8_dpm.c +++ b/src/target/armv8_dpm.c @@ -441,8 +441,7 @@ static int dpmv8_bpwp_enable(struct arm_dpm *dpm, unsigned index_t, vr += 16 * index_t; cr += 16 * index_t; - LOG_DEBUG("A8: bpwp enable, vr %08x cr %08x", - (unsigned) vr, (unsigned) cr); + LOG_DEBUG("A8: bpwp enable, vr %08" PRIx32 " cr %08" PRIx32, vr, cr); retval = mem_ap_write_atomic_u32(armv8->debug_ap, vr, addr); if (retval != ERROR_OK) @@ -469,7 +468,7 @@ static int dpmv8_bpwp_disable(struct arm_dpm *dpm, unsigned index_t) } cr += 16 * index_t; - LOG_DEBUG("A: bpwp disable, cr %08x", (unsigned) cr); + LOG_DEBUG("A: bpwp disable, cr %08" PRIx32, cr); /* clear control register */ return mem_ap_write_atomic_u32(armv8->debug_ap, cr, 0); diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c index 2de77c960..498a9cd16 100644 --- a/src/target/cortex_a.c +++ b/src/target/cortex_a.c @@ -595,8 +595,7 @@ static int cortex_a_bpwp_enable(struct arm_dpm *dpm, unsigned index_t, vr += 4 * index_t; cr += 4 * index_t; - LOG_DEBUG("A: bpwp enable, vr %08x cr %08x", - (unsigned) vr, (unsigned) cr); + LOG_DEBUG("A: bpwp enable, vr %08" PRIx32 " cr %08" PRIx32, vr, cr); retval = mem_ap_write_atomic_u32(a->armv7a_common.debug_ap, vr, addr); @@ -625,7 +624,7 @@ static int cortex_a_bpwp_disable(struct arm_dpm *dpm, unsigned index_t) } cr += 4 * index_t; - LOG_DEBUG("A: bpwp disable, cr %08x", (unsigned) cr); + LOG_DEBUG("A: bpwp disable, cr %08" PRIx32, cr); /* clear control register */ return mem_ap_write_atomic_u32(a->armv7a_common.debug_ap, cr, 0); diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 3b95b648e..698a6868c 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -2081,11 +2081,9 @@ static int cortex_m_set_watchpoint(struct target *target, struct watchpoint *wat target_write_u32(target, comparator->dwt_comparator_address + 8, comparator->function); - LOG_TARGET_DEBUG(target, "Watchpoint (ID %d) DWT%d 0x%08x 0x%x 0x%05x", + LOG_TARGET_DEBUG(target, "Watchpoint (ID %d) DWT%d 0x%08" PRIx32 " 0x%" PRIx32 " 0x%05" PRIx32, watchpoint->unique_id, dwt_num, - (unsigned) comparator->comp, - (unsigned) comparator->mask, - (unsigned) comparator->function); + comparator->comp, comparator->mask, comparator->function); return ERROR_OK; } @@ -2102,9 +2100,9 @@ static int cortex_m_unset_watchpoint(struct target *target, struct watchpoint *w unsigned int dwt_num = watchpoint->number; - LOG_TARGET_DEBUG(target, "Watchpoint (ID %d) DWT%u address: 0x%08x clear", + LOG_TARGET_DEBUG(target, "Watchpoint (ID %d) DWT%u address: " TARGET_ADDR_FMT " clear", watchpoint->unique_id, dwt_num, - (unsigned) watchpoint->address); + watchpoint->address); if (dwt_num >= cortex_m->dwt_num_comp) { LOG_TARGET_DEBUG(target, "Invalid DWT Comparator number in watchpoint"); diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c index 80cca1ed5..687821c5d 100644 --- a/src/target/dsp563xx.c +++ b/src/target/dsp563xx.c @@ -1135,7 +1135,7 @@ static int dsp563xx_resume(struct target *target, current = 0; } - LOG_DEBUG("%s %08X %08X", __func__, current, (unsigned) address); + LOG_DEBUG("%s %08X %08" TARGET_PRIXADDR, __func__, current, address); err = dsp563xx_restore_context(target); if (err != ERROR_OK) @@ -1199,7 +1199,7 @@ static int dsp563xx_step_ex(struct target *target, current = 0; } - LOG_DEBUG("%s %08X %08X", __func__, current, (unsigned) address); + LOG_DEBUG("%s %08X %08" PRIX32, __func__, current, address); err = dsp563xx_jtag_debug_request(target); if (err != ERROR_OK) @@ -1260,15 +1260,15 @@ static int dsp563xx_step_ex(struct target *target, err = dsp563xx_once_reg_read(target->tap, 1, DSP563XX_ONCE_OPABFR, &dr_in); if (err != ERROR_OK) return err; - LOG_DEBUG("fetch: %08X", (unsigned) dr_in&0x00ffffff); + LOG_DEBUG("fetch: %08" PRIX32, dr_in & 0x00ffffff); err = dsp563xx_once_reg_read(target->tap, 1, DSP563XX_ONCE_OPABDR, &dr_in); if (err != ERROR_OK) return err; - LOG_DEBUG("decode: %08X", (unsigned) dr_in&0x00ffffff); + LOG_DEBUG("decode: %08" PRIX32, dr_in & 0x00ffffff); err = dsp563xx_once_reg_read(target->tap, 1, DSP563XX_ONCE_OPABEX, &dr_in); if (err != ERROR_OK) return err; - LOG_DEBUG("execute: %08X", (unsigned) dr_in&0x00ffffff); + LOG_DEBUG("execute: %08" PRIX32, dr_in & 0x00ffffff); /* reset trace mode */ err = dsp563xx_once_reg_write(target->tap, 1, DSP563XX_ONCE_OSCR, 0x000000); diff --git a/src/target/etm.c b/src/target/etm.c index d083017f7..d8f2a2faa 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -320,9 +320,8 @@ struct reg_cache *etm_build_reg_cache(struct target *target, etm_reg_add(0x20, jtag_info, reg_cache, arch_info, etm_core + 1, 1); etm_get_reg(reg_list + 1); - etm_ctx->id = buf_get_u32( - arch_info[1].value, 0, 32); - LOG_DEBUG("ETM ID: %08x", (unsigned) etm_ctx->id); + etm_ctx->id = buf_get_u32(arch_info[1].value, 0, 32); + LOG_DEBUG("ETM ID: %08" PRIx32, etm_ctx->id); bcd_vers = 0x10 + (((etm_ctx->id) >> 4) & 0xff); } else { @@ -1495,7 +1494,7 @@ COMMAND_HANDLER(handle_etm_info_command) etm_get_reg(etm_sys_config_reg); config = buf_get_u32(etm_sys_config_reg->value, 0, 32); - LOG_DEBUG("ETM SYS CONFIG %08x", (unsigned) config); + LOG_DEBUG("ETM SYS CONFIG %08" PRIx32, config); max_port_size = config & 0x7; if (etm->bcd_vers >= 0x30) diff --git a/src/target/target.c b/src/target/target.c index 9d1d2f550..c3a4ed6d2 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -3851,11 +3851,11 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver for (t = 0; t < buf_cnt; t++) { if (data[t] != buffer[t]) { command_print(CMD, - "diff %d address 0x%08x. Was 0x%02x instead of 0x%02x", - diffs, - (unsigned)(t + image.sections[i].base_address), - data[t], - buffer[t]); + "diff %d address " TARGET_ADDR_FMT ". Was 0x%02" PRIx8 " instead of 0x%02" PRIx8, + diffs, + t + image.sections[i].base_address, + data[t], + buffer[t]); if (diffs++ >= 127) { command_print(CMD, "More than 128 errors, the rest are not printed."); free(data); diff --git a/src/target/x86_32_common.c b/src/target/x86_32_common.c index ecaf52b3a..666bb07bf 100644 --- a/src/target/x86_32_common.c +++ b/src/target/x86_32_common.c @@ -1360,8 +1360,8 @@ static void handle_iod_output(struct command_invocation *cmd, if (i % line_modulo == 0) { output_len += snprintf(output + output_len, sizeof(output) - output_len, - "0x%8.8x: ", - (unsigned)(address + (i*size))); + "0x%8.8" PRIx32 ": ", + address + (i * size)); } uint32_t value = 0; From 50586c9a063de2475ec12c4858dccfa8d5545221 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 8 Sep 2024 21:44:32 +0200 Subject: [PATCH 08/44] target: use 'unsigned int' for smp group Change the type to 'struct target::smp' and to the initialization variable 'smp_group'. Change-Id: I5f5a30a796aaf4e0014a38e81abdf4fb4afbdf48 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8478 Reviewed-by: zapb Tested-by: jenkins --- src/target/target.c | 2 +- src/target/target.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/target.c b/src/target/target.c index c3a4ed6d2..281bbbd40 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -6007,7 +6007,7 @@ static int get_target_with_common_rtos_type(struct command_invocation *cmd, COMMAND_HANDLER(handle_target_smp) { - static int smp_group = 1; + static unsigned int smp_group = 1; if (CMD_ARGC == 0) { LOG_DEBUG("Empty SMP target"); diff --git a/src/target/target.h b/src/target/target.h index d3077f571..ecc8a9032 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -184,7 +184,7 @@ struct target { bool rtos_auto_detect; /* A flag that indicates that the RTOS has been specified as "auto" * and must be detected when symbols are offered */ struct backoff_timer backoff; - int smp; /* Unique non-zero number for each SMP group */ + unsigned int smp; /* Unique non-zero number for each SMP group */ struct list_head *smp_targets; /* list all targets in this smp group/cluster * The head of the list is shared between the * cluster, thus here there is a pointer */ From 2ad48b78d4a19921f57a8cb7a4994b534c047b95 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 8 Sep 2024 21:15:53 +0200 Subject: [PATCH 09/44] flash: convert 'unsigned' to 'unsigned int' Conversion done with checkpatch --fix-inplace -types UNSPECIFIED_INT Ignore the cast as they could be better addressed. Fix only minor additional checkpatch issue (spacing and line length). Change-Id: Id808747855a02052f3738e2d232bff4dd99b27f1 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8479 Tested-by: jenkins Reviewed-by: zapb --- src/flash/common.c | 6 ++-- src/flash/common.h | 2 +- src/flash/nand/arm_io.c | 6 ++-- src/flash/nand/arm_io.h | 2 +- src/flash/nand/at91sam9.c | 8 ++--- src/flash/nand/core.c | 8 ++--- src/flash/nand/core.h | 2 +- src/flash/nand/davinci.c | 2 +- src/flash/nand/driver.c | 4 +-- src/flash/nand/fileio.c | 4 +-- src/flash/nand/lpc3180.c | 2 +- src/flash/nand/lpc32xx.c | 2 +- src/flash/nor/aducm360.c | 2 +- src/flash/nor/at91sam3.c | 68 +++++++++++++++++++------------------- src/flash/nor/at91sam4.c | 68 +++++++++++++++++++------------------- src/flash/nor/at91samd.c | 4 +-- src/flash/nor/ath79.c | 2 +- src/flash/nor/atsame5.c | 4 +-- src/flash/nor/atsamv.c | 28 ++++++++-------- src/flash/nor/cfi.c | 2 +- src/flash/nor/cfi.h | 8 ++--- src/flash/nor/core.c | 6 ++-- src/flash/nor/core.h | 2 +- src/flash/nor/drivers.c | 2 +- src/flash/nor/fespi.c | 2 +- src/flash/nor/fm4.c | 4 +-- src/flash/nor/kinetis.c | 36 ++++++++++---------- src/flash/nor/kinetis_ke.c | 6 ++-- src/flash/nor/max32xxx.c | 8 ++--- src/flash/nor/psoc5lp.c | 24 +++++++------- src/flash/nor/sim3x.c | 6 ++-- src/flash/nor/stellaris.c | 6 ++-- src/flash/nor/tcl.c | 8 ++--- src/flash/nor/tms470.c | 6 ++-- src/flash/nor/xmc1xxx.c | 6 ++-- 35 files changed, 178 insertions(+), 178 deletions(-) diff --git a/src/flash/common.c b/src/flash/common.c index ebd9396eb..9f40a3a6f 100644 --- a/src/flash/common.c +++ b/src/flash/common.c @@ -11,14 +11,14 @@ #include "common.h" #include -unsigned get_flash_name_index(const char *name) +unsigned int get_flash_name_index(const char *name) { const char *name_index = strrchr(name, '.'); if (!name_index) return 0; if (name_index[1] < '0' || name_index[1] > '9') return ~0U; - unsigned requested; + unsigned int requested; int retval = parse_uint(name_index + 1, &requested); /* detect parsing error by forcing past end of bank list */ return (retval == ERROR_OK) ? requested : ~0U; @@ -26,7 +26,7 @@ unsigned get_flash_name_index(const char *name) bool flash_driver_name_matches(const char *name, const char *expected) { - unsigned blen = strlen(name); + unsigned int blen = strlen(name); /* only match up to the length of the driver name... */ if (strncmp(name, expected, blen) != 0) return false; diff --git a/src/flash/common.h b/src/flash/common.h index 15aea5b81..6ceaa8d3c 100644 --- a/src/flash/common.h +++ b/src/flash/common.h @@ -17,7 +17,7 @@ * name provides a suffix but it does not parse as an unsigned integer, * the routine returns ~0U. This will prevent further matching. */ -unsigned get_flash_name_index(const char *name); +unsigned int get_flash_name_index(const char *name); /** * Attempt to match the @c expected name with the @c name of a driver. * @param name The name of the driver (from the bank's device structure). diff --git a/src/flash/nand/arm_io.c b/src/flash/nand/arm_io.c index 80bd0cf25..dd012e161 100644 --- a/src/flash/nand/arm_io.c +++ b/src/flash/nand/arm_io.c @@ -31,12 +31,12 @@ * @return Success or failure of the operation */ static int arm_code_to_working_area(struct target *target, - const uint32_t *code, unsigned code_size, - unsigned additional, struct working_area **area) + const uint32_t *code, unsigned int code_size, + unsigned int additional, struct working_area **area) { uint8_t code_buf[code_size]; int retval; - unsigned size = code_size + additional; + unsigned int size = code_size + additional; /* REVISIT this assumes size doesn't ever change. * That's usually correct; but there are boards with diff --git a/src/flash/nand/arm_io.h b/src/flash/nand/arm_io.h index 10f0e661c..760dc7e6f 100644 --- a/src/flash/nand/arm_io.h +++ b/src/flash/nand/arm_io.h @@ -27,7 +27,7 @@ struct arm_nand_data { struct working_area *copy_area; /** The chunk size is the page size or ECC chunk. */ - unsigned chunk_size; + unsigned int chunk_size; /** Where data is read from or written to. */ uint32_t data; diff --git a/src/flash/nand/at91sam9.c b/src/flash/nand/at91sam9.c index 9c8d5e2a3..41cb07bc9 100644 --- a/src/flash/nand/at91sam9.c +++ b/src/flash/nand/at91sam9.c @@ -532,7 +532,7 @@ COMMAND_HANDLER(handle_at91sam9_cle_command) { struct nand_device *nand = NULL; struct at91sam9_nand *info = NULL; - unsigned num, address_line; + unsigned int num, address_line; if (CMD_ARGC != 2) { command_print(CMD, "incorrect number of arguments for 'at91sam9 cle' command"); @@ -562,7 +562,7 @@ COMMAND_HANDLER(handle_at91sam9_ale_command) { struct nand_device *nand = NULL; struct at91sam9_nand *info = NULL; - unsigned num, address_line; + unsigned int num, address_line; if (CMD_ARGC != 2) return ERROR_COMMAND_SYNTAX_ERROR; @@ -590,7 +590,7 @@ COMMAND_HANDLER(handle_at91sam9_rdy_busy_command) { struct nand_device *nand = NULL; struct at91sam9_nand *info = NULL; - unsigned num, base_pioc, pin_num; + unsigned int num, base_pioc, pin_num; if (CMD_ARGC != 3) return ERROR_COMMAND_SYNTAX_ERROR; @@ -621,7 +621,7 @@ COMMAND_HANDLER(handle_at91sam9_ce_command) { struct nand_device *nand = NULL; struct at91sam9_nand *info = NULL; - unsigned num, base_pioc, pin_num; + unsigned int num, base_pioc, pin_num; if (CMD_ARGC != 3) return ERROR_COMMAND_SYNTAX_ERROR; diff --git a/src/flash/nand/core.c b/src/flash/nand/core.c index 37e1d12e0..c5430aeb0 100644 --- a/src/flash/nand/core.c +++ b/src/flash/nand/core.c @@ -165,8 +165,8 @@ static struct nand_ecclayout nand_oob_8 = { */ static struct nand_device *get_nand_device_by_name(const char *name) { - unsigned requested = get_flash_name_index(name); - unsigned found = 0; + unsigned int requested = get_flash_name_index(name); + unsigned int found = 0; struct nand_device *nand; for (nand = nand_devices; nand; nand = nand->next) { @@ -194,7 +194,7 @@ struct nand_device *get_nand_device_by_num(int num) return NULL; } -COMMAND_HELPER(nand_command_get_device, unsigned name_index, +COMMAND_HELPER(nand_command_get_device, unsigned int name_index, struct nand_device **nand) { const char *str = CMD_ARGV[name_index]; @@ -202,7 +202,7 @@ COMMAND_HELPER(nand_command_get_device, unsigned name_index, if (*nand) return ERROR_OK; - unsigned num; + unsigned int num; COMMAND_PARSE_NUMBER(uint, str, num); *nand = get_nand_device_by_num(num); if (!*nand) { diff --git a/src/flash/nand/core.h b/src/flash/nand/core.h index 137298cbc..4286e1183 100644 --- a/src/flash/nand/core.h +++ b/src/flash/nand/core.h @@ -209,7 +209,7 @@ int nand_correct_data(struct nand_device *nand, u_char *dat, int nand_register_commands(struct command_context *cmd_ctx); /** helper for parsing a nand device command argument string */ -COMMAND_HELPER(nand_command_get_device, unsigned name_index, +COMMAND_HELPER(nand_command_get_device, unsigned int name_index, struct nand_device **nand); diff --git a/src/flash/nand/davinci.c b/src/flash/nand/davinci.c index b7169feeb..17040fe17 100644 --- a/src/flash/nand/davinci.c +++ b/src/flash/nand/davinci.c @@ -379,7 +379,7 @@ static int davinci_writepage_tail(struct nand_device *nand, static int davinci_write_page_ecc1(struct nand_device *nand, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size) { - unsigned oob_offset; + unsigned int oob_offset; struct davinci_nand *info = nand->controller_priv; struct target *target = nand->target; const uint32_t fcr_addr = info->aemif + NANDFCR; diff --git a/src/flash/nand/driver.c b/src/flash/nand/driver.c index ce79e1382..5d99102c8 100644 --- a/src/flash/nand/driver.c +++ b/src/flash/nand/driver.c @@ -33,7 +33,7 @@ static struct nand_flash_controller *nand_flash_controllers[] = { struct nand_flash_controller *nand_driver_find_by_name(const char *name) { - for (unsigned i = 0; nand_flash_controllers[i]; i++) { + for (unsigned int i = 0; nand_flash_controllers[i]; i++) { struct nand_flash_controller *controller = nand_flash_controllers[i]; if (strcmp(name, controller->name) == 0) return controller; @@ -42,7 +42,7 @@ struct nand_flash_controller *nand_driver_find_by_name(const char *name) } int nand_driver_walk(nand_driver_walker_t f, void *x) { - for (unsigned i = 0; nand_flash_controllers[i]; i++) { + for (unsigned int i = 0; nand_flash_controllers[i]; i++) { int retval = (*f)(nand_flash_controllers[i], x); if (retval != ERROR_OK) return retval; diff --git a/src/flash/nand/fileio.c b/src/flash/nand/fileio.c index ca618b375..613ae3cb3 100644 --- a/src/flash/nand/fileio.c +++ b/src/flash/nand/fileio.c @@ -107,7 +107,7 @@ COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, { nand_fileio_init(state); - unsigned minargs = need_size ? 4 : 3; + unsigned int minargs = need_size ? 4 : 3; if (minargs > CMD_ARGC) return ERROR_COMMAND_SYNTAX_ERROR; @@ -131,7 +131,7 @@ COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, } if (minargs < CMD_ARGC) { - for (unsigned i = minargs; i < CMD_ARGC; i++) { + for (unsigned int i = minargs; i < CMD_ARGC; i++) { if (!strcmp(CMD_ARGV[i], "oob_raw")) state->oob_format |= NAND_OOB_RAW; else if (!strcmp(CMD_ARGV[i], "oob_only")) diff --git a/src/flash/nand/lpc3180.c b/src/flash/nand/lpc3180.c index 8e660a068..d221c34d9 100644 --- a/src/flash/nand/lpc3180.c +++ b/src/flash/nand/lpc3180.c @@ -1274,7 +1274,7 @@ COMMAND_HANDLER(handle_lpc3180_select_command) if ((CMD_ARGC < 1) || (CMD_ARGC > 3)) return ERROR_COMMAND_SYNTAX_ERROR; - unsigned num; + unsigned int num; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num); struct nand_device *nand = get_nand_device_by_num(num); if (!nand) { diff --git a/src/flash/nand/lpc32xx.c b/src/flash/nand/lpc32xx.c index 89a00a9e3..c67f2aa30 100644 --- a/src/flash/nand/lpc32xx.c +++ b/src/flash/nand/lpc32xx.c @@ -1742,7 +1742,7 @@ COMMAND_HANDLER(handle_lpc32xx_select_command) if ((CMD_ARGC < 1) || (CMD_ARGC > 3)) return ERROR_COMMAND_SYNTAX_ERROR; - unsigned num; + unsigned int num; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num); struct nand_device *nand = get_nand_device_by_num(num); if (!nand) { diff --git a/src/flash/nor/aducm360.c b/src/flash/nor/aducm360.c index ce9bf2445..aa573acde 100644 --- a/src/flash/nor/aducm360.c +++ b/src/flash/nor/aducm360.c @@ -79,7 +79,7 @@ static int aducm360_build_sector_list(struct flash_bank *bank) /* sector size is 512 */ bank->num_sectors = bank->size / FLASH_SECTOR_SIZE; bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors); - for (unsigned i = 0; i < bank->num_sectors; ++i) { + for (unsigned int i = 0; i < bank->num_sectors; ++i) { bank->sectors[i].offset = offset; bank->sectors[i].size = FLASH_SECTOR_SIZE; offset += bank->sectors[i].size; diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c index 8e8497eb0..b86a18da7 100644 --- a/src/flash/nor/at91sam3.c +++ b/src/flash/nor/at91sam3.c @@ -154,15 +154,15 @@ struct sam3_bank_private { struct sam3_chip *chip; /* so we can find the original bank pointer */ struct flash_bank *bank; - unsigned bank_number; + unsigned int bank_number; uint32_t controller_address; uint32_t base_address; uint32_t flash_wait_states; bool present; - unsigned size_bytes; - unsigned nsectors; - unsigned sector_size; - unsigned page_size; + unsigned int size_bytes; + unsigned int nsectors; + unsigned int sector_size; + unsigned int page_size; }; struct sam3_chip_details { @@ -176,12 +176,12 @@ struct sam3_chip_details { uint32_t chipid_cidr; const char *name; - unsigned n_gpnvms; + unsigned int n_gpnvms; #define SAM3_N_NVM_BITS 3 - unsigned gpnvm[SAM3_N_NVM_BITS]; - unsigned total_flash_size; - unsigned total_sram_size; - unsigned n_banks; + unsigned int gpnvm[SAM3_N_NVM_BITS]; + unsigned int total_flash_size; + unsigned int total_sram_size; + unsigned int n_banks; #define SAM3_MAX_FLASH_BANKS 2 /* these are "initialized" from the global const data */ struct sam3_bank_private bank[SAM3_MAX_FLASH_BANKS]; @@ -2029,7 +2029,7 @@ static int efc_get_result(struct sam3_bank_private *private, uint32_t *v) } static int efc_start_command(struct sam3_bank_private *private, - unsigned command, unsigned argument) + unsigned int command, unsigned int argument) { uint32_t n, v; int r; @@ -2124,8 +2124,8 @@ do_retry: * @param status - put command status bits here */ static int efc_perform_command(struct sam3_bank_private *private, - unsigned command, - unsigned argument, + unsigned int command, + unsigned int argument, uint32_t *status) { @@ -2220,7 +2220,7 @@ static int flashd_erase_entire_bank(struct sam3_bank_private *private) * @param puthere - result stored here. */ /* ------------------------------------------------------------------------------ */ -static int flashd_get_gpnvm(struct sam3_bank_private *private, unsigned gpnvm, unsigned *puthere) +static int flashd_get_gpnvm(struct sam3_bank_private *private, unsigned int gpnvm, unsigned int *puthere) { uint32_t v; int r; @@ -2261,10 +2261,10 @@ static int flashd_get_gpnvm(struct sam3_bank_private *private, unsigned gpnvm, u * @param gpnvm GPNVM index. * @returns 0 if successful; otherwise returns an error code. */ -static int flashd_clr_gpnvm(struct sam3_bank_private *private, unsigned gpnvm) +static int flashd_clr_gpnvm(struct sam3_bank_private *private, unsigned int gpnvm) { int r; - unsigned v; + unsigned int v; LOG_DEBUG("Here"); if (private->bank_number != 0) { @@ -2293,10 +2293,10 @@ static int flashd_clr_gpnvm(struct sam3_bank_private *private, unsigned gpnvm) * @param private info about the bank * @param gpnvm GPNVM index. */ -static int flashd_set_gpnvm(struct sam3_bank_private *private, unsigned gpnvm) +static int flashd_set_gpnvm(struct sam3_bank_private *private, unsigned int gpnvm) { int r; - unsigned v; + unsigned int v; if (private->bank_number != 0) { LOG_ERROR("GPNVM only works with Bank0"); @@ -2346,8 +2346,8 @@ static int flashd_get_lock_bits(struct sam3_bank_private *private, uint32_t *v) */ static int flashd_unlock(struct sam3_bank_private *private, - unsigned start_sector, - unsigned end_sector) + unsigned int start_sector, + unsigned int end_sector) { int r; uint32_t status; @@ -2376,8 +2376,8 @@ static int flashd_unlock(struct sam3_bank_private *private, * @param end_sector - last sector (inclusive) to lock */ static int flashd_lock(struct sam3_bank_private *private, - unsigned start_sector, - unsigned end_sector) + unsigned int start_sector, + unsigned int end_sector) { uint32_t status; uint32_t pg; @@ -2405,8 +2405,8 @@ static int flashd_lock(struct sam3_bank_private *private, static uint32_t sam3_reg_fieldname(struct sam3_chip *chip, const char *regname, uint32_t value, - unsigned shift, - unsigned width) + unsigned int shift, + unsigned int width) { uint32_t v; int hwidth, dwidth; @@ -2491,7 +2491,7 @@ static const char *const sramsize[] = { }; -static const struct archnames { unsigned value; const char *name; } archnames[] = { +static const struct archnames { unsigned int value; const char *name; } archnames[] = { { 0x19, "AT91SAM9xx Series" }, { 0x29, "AT91SAM9XExx Series" }, { 0x34, "AT91x34 Series" }, @@ -2951,7 +2951,7 @@ static int sam3_protect_check(struct flash_bank *bank) { int r; uint32_t v = 0; - unsigned x; + unsigned int x; struct sam3_bank_private *private; LOG_DEBUG("Begin"); @@ -3071,7 +3071,7 @@ static int sam3_get_details(struct sam3_bank_private *private) const struct sam3_chip_details *details; struct sam3_chip *chip; struct flash_bank *saved_banks[SAM3_MAX_FLASH_BANKS]; - unsigned x; + unsigned int x; LOG_DEBUG("Begin"); details = all_sam3_details; @@ -3264,7 +3264,7 @@ static int sam3_protect(struct flash_bank *bank, int set, unsigned int first, } -static int sam3_page_read(struct sam3_bank_private *private, unsigned pagenum, uint8_t *buf) +static int sam3_page_read(struct sam3_bank_private *private, unsigned int pagenum, uint8_t *buf) { uint32_t adr; int r; @@ -3283,7 +3283,7 @@ static int sam3_page_read(struct sam3_bank_private *private, unsigned pagenum, u return r; } -static int sam3_page_write(struct sam3_bank_private *private, unsigned pagenum, const uint8_t *buf) +static int sam3_page_write(struct sam3_bank_private *private, unsigned int pagenum, const uint8_t *buf) { uint32_t adr; uint32_t status; @@ -3347,10 +3347,10 @@ static int sam3_write(struct flash_bank *bank, uint32_t count) { int n; - unsigned page_cur; - unsigned page_end; + unsigned int page_cur; + unsigned int page_end; int r; - unsigned page_offset; + unsigned int page_offset; struct sam3_bank_private *private; uint8_t *pagebuffer; @@ -3497,7 +3497,7 @@ COMMAND_HANDLER(sam3_handle_info_command) if (!chip) return ERROR_OK; - unsigned x; + unsigned int x; int r; /* bank0 must exist before we can do anything */ @@ -3549,7 +3549,7 @@ need_define: COMMAND_HANDLER(sam3_handle_gpnvm_command) { - unsigned x, v; + unsigned int x, v; int r, who; struct sam3_chip *chip; diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c index 31ae35ccd..26a803784 100644 --- a/src/flash/nor/at91sam4.c +++ b/src/flash/nor/at91sam4.c @@ -134,15 +134,15 @@ struct sam4_bank_private { struct sam4_chip *chip; /* so we can find the original bank pointer */ struct flash_bank *bank; - unsigned bank_number; + unsigned int bank_number; uint32_t controller_address; uint32_t base_address; uint32_t flash_wait_states; bool present; - unsigned size_bytes; - unsigned nsectors; - unsigned sector_size; - unsigned page_size; + unsigned int size_bytes; + unsigned int nsectors; + unsigned int sector_size; + unsigned int page_size; }; struct sam4_chip_details { @@ -156,12 +156,12 @@ struct sam4_chip_details { uint32_t chipid_cidr; const char *name; - unsigned n_gpnvms; + unsigned int n_gpnvms; #define SAM4_N_NVM_BITS 3 - unsigned gpnvm[SAM4_N_NVM_BITS]; - unsigned total_flash_size; - unsigned total_sram_size; - unsigned n_banks; + unsigned int gpnvm[SAM4_N_NVM_BITS]; + unsigned int total_flash_size; + unsigned int total_sram_size; + unsigned int n_banks; #define SAM4_MAX_FLASH_BANKS 2 /* these are "initialized" from the global const data */ struct sam4_bank_private bank[SAM4_MAX_FLASH_BANKS]; @@ -1479,7 +1479,7 @@ static int efc_get_result(struct sam4_bank_private *private, uint32_t *v) } static int efc_start_command(struct sam4_bank_private *private, - unsigned command, unsigned argument) + unsigned int command, unsigned int argument) { uint32_t n, v; int r; @@ -1574,8 +1574,8 @@ do_retry: * @param status - put command status bits here */ static int efc_perform_command(struct sam4_bank_private *private, - unsigned command, - unsigned argument, + unsigned int command, + unsigned int argument, uint32_t *status) { @@ -1716,7 +1716,7 @@ static int flashd_erase_pages(struct sam4_bank_private *private, * @param puthere - result stored here. */ /* ------------------------------------------------------------------------------ */ -static int flashd_get_gpnvm(struct sam4_bank_private *private, unsigned gpnvm, unsigned *puthere) +static int flashd_get_gpnvm(struct sam4_bank_private *private, unsigned int gpnvm, unsigned int *puthere) { uint32_t v; int r; @@ -1757,10 +1757,10 @@ static int flashd_get_gpnvm(struct sam4_bank_private *private, unsigned gpnvm, u * @param gpnvm GPNVM index. * @returns 0 if successful; otherwise returns an error code. */ -static int flashd_clr_gpnvm(struct sam4_bank_private *private, unsigned gpnvm) +static int flashd_clr_gpnvm(struct sam4_bank_private *private, unsigned int gpnvm) { int r; - unsigned v; + unsigned int v; LOG_DEBUG("Here"); if (private->bank_number != 0) { @@ -1789,10 +1789,10 @@ static int flashd_clr_gpnvm(struct sam4_bank_private *private, unsigned gpnvm) * @param private info about the bank * @param gpnvm GPNVM index. */ -static int flashd_set_gpnvm(struct sam4_bank_private *private, unsigned gpnvm) +static int flashd_set_gpnvm(struct sam4_bank_private *private, unsigned int gpnvm) { int r; - unsigned v; + unsigned int v; if (private->bank_number != 0) { LOG_ERROR("GPNVM only works with Bank0"); @@ -1846,8 +1846,8 @@ static int flashd_get_lock_bits(struct sam4_bank_private *private, uint32_t *v) */ static int flashd_unlock(struct sam4_bank_private *private, - unsigned start_sector, - unsigned end_sector) + unsigned int start_sector, + unsigned int end_sector) { int r; uint32_t status; @@ -1876,8 +1876,8 @@ static int flashd_unlock(struct sam4_bank_private *private, * @param end_sector - last sector (inclusive) to lock */ static int flashd_lock(struct sam4_bank_private *private, - unsigned start_sector, - unsigned end_sector) + unsigned int start_sector, + unsigned int end_sector) { uint32_t status; uint32_t pg; @@ -1905,8 +1905,8 @@ static int flashd_lock(struct sam4_bank_private *private, static uint32_t sam4_reg_fieldname(struct sam4_chip *chip, const char *regname, uint32_t value, - unsigned shift, - unsigned width) + unsigned int shift, + unsigned int width) { uint32_t v; int hwidth, dwidth; @@ -1991,7 +1991,7 @@ static const char *const sramsize[] = { }; -static const struct archnames { unsigned value; const char *name; } archnames[] = { +static const struct archnames { unsigned int value; const char *name; } archnames[] = { { 0x19, "AT91SAM9xx Series" }, { 0x29, "AT91SAM9XExx Series" }, { 0x34, "AT91x34 Series" }, @@ -2444,7 +2444,7 @@ static int sam4_protect_check(struct flash_bank *bank) { int r; uint32_t v[4] = {0}; - unsigned x; + unsigned int x; struct sam4_bank_private *private; LOG_DEBUG("Begin"); @@ -2557,7 +2557,7 @@ static int sam4_get_details(struct sam4_bank_private *private) const struct sam4_chip_details *details; struct sam4_chip *chip; struct flash_bank *saved_banks[SAM4_MAX_FLASH_BANKS]; - unsigned x; + unsigned int x; LOG_DEBUG("Begin"); details = all_sam4_details; @@ -2796,7 +2796,7 @@ static int sam4_protect(struct flash_bank *bank, int set, unsigned int first, } -static int sam4_page_read(struct sam4_bank_private *private, unsigned pagenum, uint8_t *buf) +static int sam4_page_read(struct sam4_bank_private *private, unsigned int pagenum, uint8_t *buf) { uint32_t adr; int r; @@ -2841,7 +2841,7 @@ static int sam4_set_wait(struct sam4_bank_private *private) return r; } -static int sam4_page_write(struct sam4_bank_private *private, unsigned pagenum, const uint8_t *buf) +static int sam4_page_write(struct sam4_bank_private *private, unsigned int pagenum, const uint8_t *buf) { uint32_t adr; uint32_t status; @@ -2891,10 +2891,10 @@ static int sam4_write(struct flash_bank *bank, uint32_t count) { int n; - unsigned page_cur; - unsigned page_end; + unsigned int page_cur; + unsigned int page_end; int r; - unsigned page_offset; + unsigned int page_offset; struct sam4_bank_private *private; uint8_t *pagebuffer; @@ -3045,7 +3045,7 @@ COMMAND_HANDLER(sam4_handle_info_command) if (!chip) return ERROR_OK; - unsigned x; + unsigned int x; int r; /* bank0 must exist before we can do anything */ @@ -3097,7 +3097,7 @@ need_define: COMMAND_HANDLER(sam4_handle_gpnvm_command) { - unsigned x, v; + unsigned int x, v; int r, who; struct sam4_chip *chip; diff --git a/src/flash/nor/at91samd.c b/src/flash/nor/at91samd.c index 36298f19d..0f7b0bb30 100644 --- a/src/flash/nor/at91samd.c +++ b/src/flash/nor/at91samd.c @@ -365,7 +365,7 @@ static const struct samd_family *samd_find_family(uint32_t id) uint8_t family = SAMD_GET_FAMILY(id); uint8_t series = SAMD_GET_SERIES(id); - for (unsigned i = 0; i < ARRAY_SIZE(samd_families); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(samd_families); i++) { if (samd_families[i].processor == processor && samd_families[i].series == series && samd_families[i].family == family) @@ -387,7 +387,7 @@ static const struct samd_part *samd_find_part(uint32_t id) if (!family) return NULL; - for (unsigned i = 0; i < family->num_parts; i++) { + for (unsigned int i = 0; i < family->num_parts; i++) { if (family->parts[i].id == devsel) return &family->parts[i]; } diff --git a/src/flash/nor/ath79.c b/src/flash/nor/ath79.c index 1d1ec02b3..7ce42b2da 100644 --- a/src/flash/nor/ath79.c +++ b/src/flash/nor/ath79.c @@ -513,7 +513,7 @@ static int ath79_erase(struct flash_bank *bank, unsigned int first, if (ath79_info->dev->erase_cmd == 0x00) return ERROR_FLASH_OPER_UNSUPPORTED; - for (unsigned sector = first; sector <= last; sector++) { + for (unsigned int sector = first; sector <= last; sector++) { if (bank->sectors[sector].is_protected) { LOG_ERROR("Flash sector %u protected", sector); return ERROR_FAIL; diff --git a/src/flash/nor/atsame5.c b/src/flash/nor/atsame5.c index a6ac9060a..f34958fdb 100644 --- a/src/flash/nor/atsame5.c +++ b/src/flash/nor/atsame5.c @@ -224,7 +224,7 @@ static const struct samd_family *samd_find_family(uint32_t id) uint8_t family = SAMD_GET_FAMILY(id); uint8_t series = SAMD_GET_SERIES(id); - for (unsigned i = 0; i < ARRAY_SIZE(samd_families); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(samd_families); i++) { if (samd_families[i].processor == processor && samd_families[i].series == series && samd_families[i].family == family) @@ -246,7 +246,7 @@ static const struct samd_part *samd_find_part(uint32_t id) if (!family) return NULL; - for (unsigned i = 0; i < family->num_parts; i++) { + for (unsigned int i = 0; i < family->num_parts; i++) { if (family->parts[i].id == devsel) return &family->parts[i]; } diff --git a/src/flash/nor/atsamv.c b/src/flash/nor/atsamv.c index 24c432cba..d6d8938b6 100644 --- a/src/flash/nor/atsamv.c +++ b/src/flash/nor/atsamv.c @@ -55,8 +55,8 @@ struct samv_flash_bank { bool probed; - unsigned size_bytes; - unsigned gpnvm[SAMV_NUM_GPNVM_BITS]; + unsigned int size_bytes; + unsigned int gpnvm[SAMV_NUM_GPNVM_BITS]; }; /* The actual sector size of the SAMV7 flash memory is 128K bytes. @@ -82,7 +82,7 @@ static int samv_efc_get_result(struct target *target, uint32_t *v) } static int samv_efc_start_command(struct target *target, - unsigned command, unsigned argument) + unsigned int command, unsigned int argument) { uint32_t v; samv_efc_get_status(target, &v); @@ -100,7 +100,7 @@ static int samv_efc_start_command(struct target *target, } static int samv_efc_perform_command(struct target *target, - unsigned command, unsigned argument, uint32_t *status) + unsigned int command, unsigned int argument, uint32_t *status) { int r; uint32_t v; @@ -166,7 +166,7 @@ static int samv_erase_pages(struct target *target, first_page | erase_pages, status); } -static int samv_get_gpnvm(struct target *target, unsigned gpnvm, unsigned *out) +static int samv_get_gpnvm(struct target *target, unsigned int gpnvm, unsigned int *out) { uint32_t v; int r; @@ -190,10 +190,10 @@ static int samv_get_gpnvm(struct target *target, unsigned gpnvm, unsigned *out) return r; } -static int samv_clear_gpnvm(struct target *target, unsigned gpnvm) +static int samv_clear_gpnvm(struct target *target, unsigned int gpnvm) { int r; - unsigned v; + unsigned int v; if (gpnvm >= SAMV_NUM_GPNVM_BITS) { LOG_ERROR("invalid gpnvm %d, max: %d", gpnvm, SAMV_NUM_GPNVM_BITS); @@ -209,10 +209,10 @@ static int samv_clear_gpnvm(struct target *target, unsigned gpnvm) return r; } -static int samv_set_gpnvm(struct target *target, unsigned gpnvm) +static int samv_set_gpnvm(struct target *target, unsigned int gpnvm) { int r; - unsigned v; + unsigned int v; if (gpnvm >= SAMV_NUM_GPNVM_BITS) { LOG_ERROR("invalid gpnvm %d, max: %d", gpnvm, SAMV_NUM_GPNVM_BITS); return ERROR_FAIL; @@ -231,7 +231,7 @@ static int samv_set_gpnvm(struct target *target, unsigned gpnvm) } static int samv_flash_unlock(struct target *target, - unsigned start_sector, unsigned end_sector) + unsigned int start_sector, unsigned int end_sector) { int r; uint32_t status; @@ -251,7 +251,7 @@ static int samv_flash_unlock(struct target *target, } static int samv_flash_lock(struct target *target, - unsigned start_sector, unsigned end_sector) + unsigned int start_sector, unsigned int end_sector) { uint32_t status; uint32_t pg; @@ -419,7 +419,7 @@ static int samv_protect(struct flash_bank *bank, int set, unsigned int first, } static int samv_page_read(struct target *target, - unsigned page_num, uint8_t *buf) + unsigned int page_num, uint8_t *buf) { uint32_t addr = SAMV_FLASH_BASE + page_num * SAMV_PAGE_SIZE; int r = target_read_memory(target, addr, 4, SAMV_PAGE_SIZE / 4, buf); @@ -430,7 +430,7 @@ static int samv_page_read(struct target *target, } static int samv_page_write(struct target *target, - unsigned pagenum, const uint8_t *buf) + unsigned int pagenum, const uint8_t *buf) { uint32_t status; const uint32_t addr = SAMV_FLASH_BASE + pagenum * SAMV_PAGE_SIZE; @@ -618,7 +618,7 @@ COMMAND_HANDLER(samv_handle_gpnvm_command) return ERROR_COMMAND_SYNTAX_ERROR; } - unsigned v = 0; + unsigned int v = 0; if (!strcmp("show", CMD_ARGV[0])) { if (who == -1) { showall: diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c index 96bd7353f..2a15e4913 100644 --- a/src/flash/nor/cfi.c +++ b/src/flash/nor/cfi.c @@ -806,7 +806,7 @@ int cfi_flash_bank_cmd(struct flash_bank *bank, unsigned int argc, const char ** } bank->driver_priv = cfi_info; - for (unsigned i = 6; i < argc; i++) { + for (unsigned int i = 6; i < argc; i++) { if (strcmp(argv[i], "x16_as_x8") == 0) cfi_info->x16_as_x8 = true; else if (strcmp(argv[i], "data_swap") == 0) diff --git a/src/flash/nor/cfi.h b/src/flash/nor/cfi.h index ec7f47403..3a76d98ef 100644 --- a/src/flash/nor/cfi.h +++ b/src/flash/nor/cfi.h @@ -58,10 +58,10 @@ struct cfi_flash_bank { void *alt_ext; /* calculated timeouts */ - unsigned word_write_timeout; - unsigned buf_write_timeout; - unsigned block_erase_timeout; - unsigned chip_erase_timeout; + unsigned int word_write_timeout; + unsigned int buf_write_timeout; + unsigned int block_erase_timeout; + unsigned int chip_erase_timeout; /* memory accessors */ int (*write_mem)(struct flash_bank *bank, target_addr_t addr, diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c index 5e6c97152..5c4f2acca 100644 --- a/src/flash/nor/core.c +++ b/src/flash/nor/core.c @@ -164,7 +164,7 @@ int default_flash_verify(struct flash_bank *bank, void flash_bank_add(struct flash_bank *bank) { /* put flash bank in linked list */ - unsigned bank_num = 0; + unsigned int bank_num = 0; if (flash_banks) { /* find last flash bank */ struct flash_bank *p = flash_banks; @@ -242,8 +242,8 @@ void flash_free_all_banks(void) struct flash_bank *get_flash_bank_by_name_noprobe(const char *name) { - unsigned requested = get_flash_name_index(name); - unsigned found = 0; + unsigned int requested = get_flash_name_index(name); + unsigned int found = 0; struct flash_bank *bank; for (bank = flash_banks; bank; bank = bank->next) { diff --git a/src/flash/nor/core.h b/src/flash/nor/core.h index ff175a132..f8cf5e269 100644 --- a/src/flash/nor/core.h +++ b/src/flash/nor/core.h @@ -250,7 +250,7 @@ int get_flash_bank_by_num(unsigned int num, struct flash_bank **bank); * @param bank On output, contains a pointer to the bank or NULL. * @returns ERROR_OK on success, or an error indicating the problem. */ -COMMAND_HELPER(flash_command_get_bank, unsigned name_index, +COMMAND_HELPER(flash_command_get_bank, unsigned int name_index, struct flash_bank **bank); /** * Retrieves @a bank from a command argument, reporting errors parsing diff --git a/src/flash/nor/drivers.c b/src/flash/nor/drivers.c index 34359889a..dd9995ecb 100644 --- a/src/flash/nor/drivers.c +++ b/src/flash/nor/drivers.c @@ -91,7 +91,7 @@ static const struct flash_driver * const flash_drivers[] = { const struct flash_driver *flash_driver_find_by_name(const char *name) { - for (unsigned i = 0; flash_drivers[i]; i++) { + for (unsigned int i = 0; flash_drivers[i]; i++) { if (strcmp(name, flash_drivers[i]->name) == 0) return flash_drivers[i]; } diff --git a/src/flash/nor/fespi.c b/src/flash/nor/fespi.c index 9191764a9..6c4e8a928 100644 --- a/src/flash/nor/fespi.c +++ b/src/flash/nor/fespi.c @@ -531,7 +531,7 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer, bin_size = sizeof(riscv64_bin); } - unsigned data_wa_size = 0; + unsigned int data_wa_size = 0; if (target_alloc_working_area(target, bin_size, &algorithm_wa) == ERROR_OK) { retval = target_write_buffer(target, algorithm_wa->address, bin_size, bin); diff --git a/src/flash/nor/fm4.c b/src/flash/nor/fm4.c index 979ae84d0..2db79ef50 100644 --- a/src/flash/nor/fm4.c +++ b/src/flash/nor/fm4.c @@ -107,7 +107,7 @@ static int fm4_flash_erase(struct flash_bank *bank, unsigned int first, struct working_area *workarea; struct reg_param reg_params[4]; struct armv7m_algorithm armv7m_algo; - unsigned i; + unsigned int i; int retval; const uint8_t erase_sector_code[] = { #include "../../../contrib/loaders/flash/fm4/erase.inc" @@ -207,7 +207,7 @@ static int fm4_flash_write(struct flash_bank *bank, const uint8_t *buffer, struct armv7m_algorithm armv7m_algo; uint32_t halfword_count = DIV_ROUND_UP(byte_count, 2); uint32_t result; - unsigned i; + unsigned int i; int retval, retval2 = ERROR_OK; const uint8_t write_block_code[] = { #include "../../../contrib/loaders/flash/fm4/write.inc" diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c index 2d0a75334..2f88b9c1f 100644 --- a/src/flash/nor/kinetis.c +++ b/src/flash/nor/kinetis.c @@ -256,7 +256,7 @@ struct kinetis_flash_bank { struct kinetis_chip *k_chip; bool probed; - unsigned bank_number; /* bank number in particular chip */ + unsigned int bank_number; /* bank number in particular chip */ struct flash_bank *bank; uint32_t sector_size; @@ -285,9 +285,9 @@ struct kinetis_chip { uint32_t fcfg2_maxaddr0_shifted; uint32_t fcfg2_maxaddr1_shifted; - unsigned num_pflash_blocks, num_nvm_blocks; - unsigned pflash_sector_size, nvm_sector_size; - unsigned max_flash_prog_size; + unsigned int num_pflash_blocks, num_nvm_blocks; + unsigned int pflash_sector_size, nvm_sector_size; + unsigned int max_flash_prog_size; uint32_t pflash_base; uint32_t pflash_size; @@ -337,7 +337,7 @@ struct kinetis_chip { char name[40]; - unsigned num_banks; + unsigned int num_banks; struct kinetis_flash_bank banks[KINETIS_MAX_BANKS]; }; @@ -425,7 +425,7 @@ static int kinetis_probe_chip_s32k(struct kinetis_chip *k_chip); static int kinetis_auto_probe(struct flash_bank *bank); -static int kinetis_mdm_write_register(struct adiv5_dap *dap, unsigned reg, uint32_t value) +static int kinetis_mdm_write_register(struct adiv5_dap *dap, unsigned int reg, uint32_t value) { LOG_DEBUG("MDM_REG[0x%02x] <- %08" PRIX32, reg, value); @@ -453,7 +453,7 @@ static int kinetis_mdm_write_register(struct adiv5_dap *dap, unsigned reg, uint3 return ERROR_OK; } -static int kinetis_mdm_read_register(struct adiv5_dap *dap, unsigned reg, uint32_t *result) +static int kinetis_mdm_read_register(struct adiv5_dap *dap, unsigned int reg, uint32_t *result) { struct adiv5_ap *ap = dap_get_ap(dap, MDM_AP); if (!ap) { @@ -479,7 +479,7 @@ static int kinetis_mdm_read_register(struct adiv5_dap *dap, unsigned reg, uint32 return ERROR_OK; } -static int kinetis_mdm_poll_register(struct adiv5_dap *dap, unsigned reg, +static int kinetis_mdm_poll_register(struct adiv5_dap *dap, unsigned int reg, uint32_t mask, uint32_t value, uint32_t timeout_ms) { uint32_t val; @@ -977,7 +977,7 @@ static void kinetis_free_driver_priv(struct flash_bank *bank) static int kinetis_create_missing_banks(struct kinetis_chip *k_chip) { - unsigned num_blocks; + unsigned int num_blocks; struct kinetis_flash_bank *k_bank; struct flash_bank *bank; char base_name[69], name[87], num[11]; @@ -1463,7 +1463,7 @@ static int kinetis_fill_fcf(struct flash_bank *bank, uint8_t *fcf) uint32_t fprot = 0xffffffff; uint8_t fsec = 0xfe; /* set MCU unsecure */ uint8_t fdprot = 0xff; - unsigned num_blocks; + unsigned int num_blocks; uint32_t pflash_bit; uint8_t dflash_bit; struct flash_bank *bank_iter; @@ -2269,12 +2269,12 @@ static int kinetis_probe_chip(struct kinetis_chip *k_chip) uint32_t ee_size = 0; uint32_t pflash_size_k, nvm_size_k, dflash_size_k; uint32_t pflash_size_m; - unsigned num_blocks = 0; - unsigned maxaddr_shift = 13; + unsigned int num_blocks = 0; + unsigned int maxaddr_shift = 13; struct target *target = k_chip->target; - unsigned familyid = 0, subfamid = 0; - unsigned cpu_mhz = 120; + unsigned int familyid = 0, subfamid = 0; + unsigned int cpu_mhz = 120; bool use_nvm_marking = false; char flash_marking[12], nvm_marking[2]; char name[40]; @@ -2895,7 +2895,7 @@ static int kinetis_probe(struct flash_bank *bank) { int result; uint8_t fcfg2_maxaddr0, fcfg2_pflsh, fcfg2_maxaddr1; - unsigned num_blocks, first_nvm_bank; + unsigned int num_blocks, first_nvm_bank; uint32_t size_k; struct kinetis_flash_bank *k_bank = bank->driver_priv; struct kinetis_chip *k_chip; @@ -2940,7 +2940,7 @@ static int kinetis_probe(struct flash_bank *bank) } else if (k_bank->bank_number < num_blocks) { /* nvm, banks start at address 0x10000000 */ - unsigned nvm_ord = k_bank->bank_number - first_nvm_bank; + unsigned int nvm_ord = k_bank->bank_number - first_nvm_bank; uint32_t limit; k_bank->flash_class = FC_FLEX_NVM; @@ -3139,8 +3139,8 @@ static int kinetis_blank_check(struct flash_bank *bank) COMMAND_HANDLER(kinetis_nvm_partition) { int result; - unsigned bank_idx; - unsigned num_blocks, first_nvm_bank; + unsigned int bank_idx; + unsigned int num_blocks, first_nvm_bank; unsigned long par, log2 = 0, ee1 = 0, ee2 = 0; enum { SHOW_INFO, DF_SIZE, EEBKP_SIZE } sz_type = SHOW_INFO; bool enable; diff --git a/src/flash/nor/kinetis_ke.c b/src/flash/nor/kinetis_ke.c index c069f3ac8..e4dffa6d5 100644 --- a/src/flash/nor/kinetis_ke.c +++ b/src/flash/nor/kinetis_ke.c @@ -134,7 +134,7 @@ struct kinetis_ke_flash_bank { #define MDM_ACCESS_TIMEOUT 3000 /* iterations */ -static int kinetis_ke_mdm_write_register(struct adiv5_dap *dap, unsigned reg, uint32_t value) +static int kinetis_ke_mdm_write_register(struct adiv5_dap *dap, unsigned int reg, uint32_t value) { LOG_DEBUG("MDM_REG[0x%02x] <- %08" PRIX32, reg, value); @@ -161,7 +161,7 @@ static int kinetis_ke_mdm_write_register(struct adiv5_dap *dap, unsigned reg, ui return ERROR_OK; } -static int kinetis_ke_mdm_read_register(struct adiv5_dap *dap, unsigned reg, uint32_t *result) +static int kinetis_ke_mdm_read_register(struct adiv5_dap *dap, unsigned int reg, uint32_t *result) { struct adiv5_ap *ap = dap_get_ap(dap, 1); if (!ap) { @@ -187,7 +187,7 @@ static int kinetis_ke_mdm_read_register(struct adiv5_dap *dap, unsigned reg, uin return ERROR_OK; } -static int kinetis_ke_mdm_poll_register(struct adiv5_dap *dap, unsigned reg, uint32_t mask, uint32_t value) +static int kinetis_ke_mdm_poll_register(struct adiv5_dap *dap, unsigned int reg, uint32_t mask, uint32_t value) { uint32_t val; int retval; diff --git a/src/flash/nor/max32xxx.c b/src/flash/nor/max32xxx.c index 052a42d23..267fd4312 100644 --- a/src/flash/nor/max32xxx.c +++ b/src/flash/nor/max32xxx.c @@ -202,14 +202,14 @@ static int max32xxx_protect_check(struct flash_bank *bank) return ERROR_FLASH_BANK_NOT_PROBED; if (!info->max326xx) { - for (unsigned i = 0; i < bank->num_sectors; i++) + for (unsigned int i = 0; i < bank->num_sectors; i++) bank->sectors[i].is_protected = -1; return ERROR_FLASH_OPER_UNSUPPORTED; } /* Check the protection */ - for (unsigned i = 0; i < bank->num_sectors; i++) { + for (unsigned int i = 0; i < bank->num_sectors; i++) { if (i%32 == 0) target_read_u32(target, info->flc_base + FLSH_PROT + ((i/32)*4), &temp_reg); @@ -360,7 +360,7 @@ static int max32xxx_write_block(struct flash_bank *bank, const uint8_t *buffer, struct armv7m_algorithm armv7m_info; int retval = ERROR_OK; /* power of two, and multiple of word size */ - static const unsigned buf_min = 128; + static const unsigned int buf_min = 128; /* for small buffers it's faster not to download an algorithm */ if (wcount * 4 < buf_min) @@ -903,7 +903,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_check_command) } LOG_WARNING("s: a:
p:"); - for (unsigned i = 0; i < bank->num_sectors; i += 4) { + for (unsigned int i = 0; i < bank->num_sectors; i += 4) { LOG_WARNING("s:%03d a:0x%06x p:%d | s:%03d a:0x%06x p:%d | s:%03d a:0x%06x p:%d | s:%03d a:0x%06x p:%d", (i+0), (i+0)*info->sector_size, bank->sectors[(i+0)].is_protected, (i+1), (i+1)*info->sector_size, bank->sectors[(i+1)].is_protected, diff --git a/src/flash/nor/psoc5lp.c b/src/flash/nor/psoc5lp.c index 407efbcab..e8c901950 100644 --- a/src/flash/nor/psoc5lp.c +++ b/src/flash/nor/psoc5lp.c @@ -102,10 +102,10 @@ struct psoc5lp_device { uint32_t id; - unsigned fam; - unsigned speed_mhz; - unsigned flash_kb; - unsigned eeprom_kb; + unsigned int fam; + unsigned int speed_mhz; + unsigned int flash_kb; + unsigned int eeprom_kb; }; /* @@ -245,7 +245,7 @@ static int psoc5lp_find_device(struct target *target, const struct psoc5lp_device **device) { uint32_t device_id; - unsigned i; + unsigned int i; int retval; *device = NULL; @@ -381,9 +381,9 @@ static int psoc5lp_spc_load_byte(struct target *target, } static int psoc5lp_spc_load_row(struct target *target, - uint8_t array_id, const uint8_t *data, unsigned row_size) + uint8_t array_id, const uint8_t *data, unsigned int row_size) { - unsigned i; + unsigned int i; int retval; retval = psoc5lp_spc_write_opcode(target, SPC_LOAD_ROW); @@ -853,7 +853,7 @@ static int psoc5lp_eeprom_write(struct flash_bank *bank, { struct target *target = bank->target; uint8_t temp[2]; - unsigned row; + unsigned int row; int retval; if (offset % EEPROM_ROW_SIZE != 0) { @@ -1124,7 +1124,7 @@ static int psoc5lp_write(struct flash_bank *bank, const uint8_t *buffer, struct working_area *code_area, *even_row_area, *odd_row_area; uint32_t row_size; uint8_t temp[2], buf[12], ecc_bytes[ROW_ECC_SIZE]; - unsigned array_id, row; + unsigned int array_id, row; int i, retval; if (offset + byte_count > bank->size) { @@ -1183,7 +1183,7 @@ static int psoc5lp_write(struct flash_bank *bank, const uint8_t *buffer, row < ROWS_PER_BLOCK && byte_count > 0; row++) { bool even_row = (row % 2 == 0); struct working_area *data_area = even_row ? even_row_area : odd_row_area; - unsigned len = MIN(ROW_SIZE, byte_count); + unsigned int len = MIN(ROW_SIZE, byte_count); LOG_DEBUG("Writing load command for array %u row %u at " TARGET_ADDR_FMT, array_id, row, data_area->address); @@ -1307,8 +1307,8 @@ static int psoc5lp_protect_check(struct flash_bank *bank) { struct psoc5lp_flash_bank *psoc_bank = bank->driver_priv; uint8_t row_data[ROW_SIZE]; - const unsigned protection_bytes_per_sector = ROWS_PER_SECTOR * 2 / 8; - unsigned i, k, num_sectors; + const unsigned int protection_bytes_per_sector = ROWS_PER_SECTOR * 2 / 8; + unsigned int i, k, num_sectors; int retval; if (bank->target->state != TARGET_HALTED) { diff --git a/src/flash/nor/sim3x.c b/src/flash/nor/sim3x.c index 42550d06b..58d7913c2 100644 --- a/src/flash/nor/sim3x.c +++ b/src/flash/nor/sim3x.c @@ -859,7 +859,7 @@ static int sim3x_flash_info(struct flash_bank *bank, struct command_invocation * * reg 3:2 - register * reg 1:0 - no effect */ -static int ap_write_register(struct adiv5_dap *dap, unsigned reg, uint32_t value) +static int ap_write_register(struct adiv5_dap *dap, unsigned int reg, uint32_t value) { LOG_DEBUG("DAP_REG[0x%02x] <- %08" PRIX32, reg, value); @@ -886,7 +886,7 @@ static int ap_write_register(struct adiv5_dap *dap, unsigned reg, uint32_t value return ERROR_OK; } -static int ap_read_register(struct adiv5_dap *dap, unsigned reg, uint32_t *result) +static int ap_read_register(struct adiv5_dap *dap, unsigned int reg, uint32_t *result) { struct adiv5_ap *ap = dap_get_ap(dap, SIM3X_AP); if (!ap) { @@ -912,7 +912,7 @@ static int ap_read_register(struct adiv5_dap *dap, unsigned reg, uint32_t *resul return ERROR_OK; } -static int ap_poll_register(struct adiv5_dap *dap, unsigned reg, uint32_t mask, uint32_t value, int timeout) +static int ap_poll_register(struct adiv5_dap *dap, unsigned int reg, uint32_t mask, uint32_t value, int timeout) { uint32_t val; int retval; diff --git a/src/flash/nor/stellaris.c b/src/flash/nor/stellaris.c index 25bc5507a..1f53b2f35 100644 --- a/src/flash/nor/stellaris.c +++ b/src/flash/nor/stellaris.c @@ -530,7 +530,7 @@ static void stellaris_set_flash_timing(struct flash_bank *bank) target_write_u32(target, SCB_BASE | USECRL, usecrl); } -static const unsigned rcc_xtal[32] = { +static const unsigned int rcc_xtal[32] = { [0x00] = 1000000, /* no pll */ [0x01] = 1843200, /* no pll */ [0x02] = 2000000, /* no pll */ @@ -569,7 +569,7 @@ static void stellaris_read_clock_info(struct flash_bank *bank) struct stellaris_flash_bank *stellaris_info = bank->driver_priv; struct target *target = bank->target; uint32_t rcc, rcc2, pllcfg, sysdiv, usesysdiv, bypass, oscsrc; - unsigned xtal; + unsigned int xtal; unsigned long mainfreq; target_read_u32(target, SCB_BASE | RCC, &rcc); @@ -1029,7 +1029,7 @@ static int stellaris_write_block(struct flash_bank *bank, int retval = ERROR_OK; /* power of two, and multiple of word size */ - static const unsigned buf_min = 128; + static const unsigned int buf_min = 128; /* for small buffers it's faster not to download an algorithm */ if (wcount * 4 < buf_min) diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index 6ac932be7..e21620934 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -36,7 +36,7 @@ COMMAND_HELPER(flash_command_get_bank_probe_optional, unsigned int name_index, if (*bank) return ERROR_OK; - unsigned bank_num; + unsigned int bank_num; COMMAND_PARSE_NUMBER(uint, name, bank_num); if (do_probe) { @@ -48,7 +48,7 @@ COMMAND_HELPER(flash_command_get_bank_probe_optional, unsigned int name_index, } } -COMMAND_HELPER(flash_command_get_bank, unsigned name_index, +COMMAND_HELPER(flash_command_get_bank, unsigned int name_index, struct flash_bank **bank) { return CALL_COMMAND_HANDLER(flash_command_get_bank_probe_optional, @@ -518,7 +518,7 @@ COMMAND_HANDLER(handle_flash_fill_command) uint64_t pattern; uint32_t count; struct target *target = get_current_target(CMD_CTX); - unsigned i; + unsigned int i; uint32_t wordsize; int retval; @@ -1316,7 +1316,7 @@ COMMAND_HANDLER(handle_flash_banks_command) if (CMD_ARGC != 0) return ERROR_COMMAND_SYNTAX_ERROR; - unsigned n = 0; + unsigned int n = 0; for (struct flash_bank *p = flash_bank_list(); p; p = p->next, n++) { command_print(CMD, "#%d : %s (%s) at " TARGET_ADDR_FMT ", size 0x%8.8" PRIx32 ", " "buswidth %u, chipwidth %u", p->bank_number, diff --git a/src/flash/nor/tms470.c b/src/flash/nor/tms470.c index 6e0ea5b95..00ee77bb8 100644 --- a/src/flash/nor/tms470.c +++ b/src/flash/nor/tms470.c @@ -16,7 +16,7 @@ * ---------------------------------------------------------------------- */ struct tms470_flash_bank { - unsigned ordinal; + unsigned int ordinal; /* device identification register */ uint32_t device_ident_reg; @@ -391,7 +391,7 @@ static int tms470_try_flash_keys(struct target *target, const uint32_t *key_set) /* only perform the key match when 3VSTAT is clear */ target_read_u32(target, 0xFFE8BC0C, &fmmstat); if (!(fmmstat & 0x08)) { - unsigned i; + unsigned int i; uint32_t fmbptr, fmbac2, orig_fmregopt; target_write_u32(target, 0xFFE8BC04, fmmstat & ~0x07); @@ -455,7 +455,7 @@ static int tms470_unlock_flash(struct flash_bank *bank) { struct target *target = bank->target; const uint32_t *p_key_sets[5]; - unsigned i, key_set_count; + unsigned int i, key_set_count; if (keys_set) { key_set_count = 5; diff --git a/src/flash/nor/xmc1xxx.c b/src/flash/nor/xmc1xxx.c index 6e30fc125..4aa97a912 100644 --- a/src/flash/nor/xmc1xxx.c +++ b/src/flash/nor/xmc1xxx.c @@ -84,7 +84,7 @@ static int xmc1xxx_erase(struct flash_bank *bank, unsigned int first, struct working_area *workarea; struct reg_param reg_params[3]; struct armv7m_algorithm armv7m_algo; - unsigned i; + unsigned int i; int retval; const uint8_t erase_code[] = { #include "../../../contrib/loaders/flash/xmc1xxx/erase.inc" @@ -159,7 +159,7 @@ static int xmc1xxx_erase_check(struct flash_bank *bank) struct reg_param reg_params[3]; struct armv7m_algorithm armv7m_algo; uint16_t val; - unsigned i; + unsigned int i; int retval; const uint8_t erase_check_code[] = { #include "../../../contrib/loaders/flash/xmc1xxx/erase_check.inc" @@ -245,7 +245,7 @@ static int xmc1xxx_write(struct flash_bank *bank, const uint8_t *buffer, struct reg_param reg_params[4]; struct armv7m_algorithm armv7m_algo; uint32_t block_count = DIV_ROUND_UP(byte_count, NVM_BLOCK_SIZE); - unsigned i; + unsigned int i; int retval; const uint8_t write_code[] = { #include "../../../contrib/loaders/flash/xmc1xxx/write.inc" From e72733d59025b5d595bf955b227e95e5db7305c7 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 8 Sep 2024 21:20:48 +0200 Subject: [PATCH 10/44] target: convert 'unsigned' to 'unsigned int' Conversion done with checkpatch --fix-inplace -types UNSPECIFIED_INT Ignore the cast as they could be better addressed. Fix only minor additional checkpatch issue (spacing and line length). Use Checkpatch-ignore below for the function pointers in the file 'armv7a_cache_l2x.h' that do not assign the identifier names to the function arguments. Most of these struct are unused and should be fixed or dropped. Checkpatch-ignore: FUNCTION_ARGUMENTS Change-Id: I8f27e68eb3502e431c1ba801b362358105f9f2dc Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8480 Tested-by: jenkins Reviewed-by: zapb --- src/target/adi_v5_jtag.c | 10 +++--- src/target/adi_v5_swd.c | 10 +++--- src/target/arc.c | 4 +-- src/target/arm.h | 8 ++--- src/target/arm11.c | 2 +- src/target/arm11.h | 2 +- src/target/arm11_dbgtap.c | 10 +++--- src/target/arm9tdmi.c | 6 ++-- src/target/arm_adi_v5.h | 20 +++++------ src/target/arm_disassembler.c | 20 +++++------ src/target/arm_disassembler.h | 2 +- src/target/arm_dpm.c | 38 ++++++++++----------- src/target/arm_dpm.h | 14 ++++---- src/target/armv4_5.c | 22 ++++++------ src/target/armv7a_cache_l2x.h | 8 ++--- src/target/armv7m.c | 6 ++-- src/target/armv8.c | 22 ++++++------ src/target/armv8.h | 2 +- src/target/armv8_dpm.c | 28 +++++++-------- src/target/cortex_a.c | 4 +-- src/target/cortex_m.c | 14 ++++---- src/target/dsp563xx.c | 4 +-- src/target/dsp5680xx.c | 2 +- src/target/esirisc.c | 4 +-- src/target/esirisc_trace.c | 10 +++--- src/target/etb.h | 2 +- src/target/etm.c | 12 +++---- src/target/hla_target.c | 2 +- src/target/image.c | 4 +-- src/target/lakemont.c | 6 ++-- src/target/mips32.c | 4 +-- src/target/mips32_pracc.c | 6 ++-- src/target/mips32_pracc.h | 2 +- src/target/mips64.c | 10 +++--- src/target/mips64_pracc.c | 64 +++++++++++++++++------------------ src/target/mips64_pracc.h | 14 ++++---- src/target/mips_ejtag.c | 2 +- src/target/mips_ejtag.h | 2 +- src/target/register.h | 2 +- src/target/stm8.c | 2 +- src/target/target.c | 46 ++++++++++++------------- src/target/target.h | 6 ++-- src/target/target_type.h | 2 +- src/target/x86_32_common.c | 20 +++++------ src/target/xscale.c | 14 ++++---- 45 files changed, 248 insertions(+), 246 deletions(-) diff --git a/src/target/adi_v5_jtag.c b/src/target/adi_v5_jtag.c index 8d54a50fb..fee1a2485 100644 --- a/src/target/adi_v5_jtag.c +++ b/src/target/adi_v5_jtag.c @@ -736,7 +736,7 @@ static int jtag_send_sequence(struct adiv5_dap *dap, enum swd_special_seq seq) return retval; } -static int jtag_dp_q_read(struct adiv5_dap *dap, unsigned reg, +static int jtag_dp_q_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *data) { int retval = jtag_limit_queue_size(dap); @@ -749,7 +749,7 @@ static int jtag_dp_q_read(struct adiv5_dap *dap, unsigned reg, return retval; } -static int jtag_dp_q_write(struct adiv5_dap *dap, unsigned reg, +static int jtag_dp_q_write(struct adiv5_dap *dap, unsigned int reg, uint32_t data) { int retval = jtag_limit_queue_size(dap); @@ -763,7 +763,7 @@ static int jtag_dp_q_write(struct adiv5_dap *dap, unsigned reg, } /** Select the AP register bank */ -static int jtag_ap_q_bankselect(struct adiv5_ap *ap, unsigned reg) +static int jtag_ap_q_bankselect(struct adiv5_ap *ap, unsigned int reg) { int retval; struct adiv5_dap *dap = ap->dap; @@ -818,7 +818,7 @@ static int jtag_ap_q_bankselect(struct adiv5_ap *ap, unsigned reg) return ERROR_OK; } -static int jtag_ap_q_read(struct adiv5_ap *ap, unsigned reg, +static int jtag_ap_q_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data) { int retval = jtag_limit_queue_size(ap->dap); @@ -840,7 +840,7 @@ static int jtag_ap_q_read(struct adiv5_ap *ap, unsigned reg, return retval; } -static int jtag_ap_q_write(struct adiv5_ap *ap, unsigned reg, +static int jtag_ap_q_write(struct adiv5_ap *ap, unsigned int reg, uint32_t data) { int retval = jtag_limit_queue_size(ap->dap); diff --git a/src/target/adi_v5_swd.c b/src/target/adi_v5_swd.c index 123100588..dda1b0674 100644 --- a/src/target/adi_v5_swd.c +++ b/src/target/adi_v5_swd.c @@ -485,7 +485,7 @@ static int swd_queue_ap_abort(struct adiv5_dap *dap, uint8_t *ack) return check_sync(dap); } -static int swd_queue_dp_read(struct adiv5_dap *dap, unsigned reg, +static int swd_queue_dp_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *data) { int retval = swd_check_reconnect(dap); @@ -499,7 +499,7 @@ static int swd_queue_dp_read(struct adiv5_dap *dap, unsigned reg, return swd_queue_dp_read_inner(dap, reg, data); } -static int swd_queue_dp_write(struct adiv5_dap *dap, unsigned reg, +static int swd_queue_dp_write(struct adiv5_dap *dap, unsigned int reg, uint32_t data) { const struct swd_driver *swd = adiv5_dap_swd_driver(dap); @@ -517,7 +517,7 @@ static int swd_queue_dp_write(struct adiv5_dap *dap, unsigned reg, } /** Select the AP register bank */ -static int swd_queue_ap_bankselect(struct adiv5_ap *ap, unsigned reg) +static int swd_queue_ap_bankselect(struct adiv5_ap *ap, unsigned int reg) { int retval; struct adiv5_dap *dap = ap->dap; @@ -567,7 +567,7 @@ static int swd_queue_ap_bankselect(struct adiv5_ap *ap, unsigned reg) return ERROR_OK; } -static int swd_queue_ap_read(struct adiv5_ap *ap, unsigned reg, +static int swd_queue_ap_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data) { struct adiv5_dap *dap = ap->dap; @@ -592,7 +592,7 @@ static int swd_queue_ap_read(struct adiv5_ap *ap, unsigned reg, return check_sync(dap); } -static int swd_queue_ap_write(struct adiv5_ap *ap, unsigned reg, +static int swd_queue_ap_write(struct adiv5_ap *ap, unsigned int reg, uint32_t data) { struct adiv5_dap *dap = ap->dap; diff --git a/src/target/arc.c b/src/target/arc.c index 72e4d918d..28ce93947 100644 --- a/src/target/arc.c +++ b/src/target/arc.c @@ -516,7 +516,7 @@ static int arc_get_gdb_reg_list(struct target *target, struct reg **reg_list[], unsigned long i = 0; struct reg_cache *reg_cache = target->reg_cache; while (reg_cache) { - for (unsigned j = 0; j < reg_cache->num_regs; j++, i++) + for (unsigned int j = 0; j < reg_cache->num_regs; j++, i++) (*reg_list)[i] = ®_cache->reg_list[j]; reg_cache = reg_cache->next; } @@ -527,7 +527,7 @@ static int arc_get_gdb_reg_list(struct target *target, struct reg **reg_list[], unsigned long gdb_reg_number = 0; struct reg_cache *reg_cache = target->reg_cache; while (reg_cache) { - for (unsigned j = 0; + for (unsigned int j = 0; j < reg_cache->num_regs && gdb_reg_number <= arc->last_general_reg; j++) { if (reg_cache->reg_list[j].exist) { diff --git a/src/target/arm.h b/src/target/arm.h index 0de322a5a..79ec99d11 100644 --- a/src/target/arm.h +++ b/src/target/arm.h @@ -143,8 +143,8 @@ enum { ARM_VFP_V3_FPSCR, }; -const char *arm_mode_name(unsigned psr_mode); -bool is_arm_mode(unsigned psr_mode); +const char *arm_mode_name(unsigned int psr_mode); +bool is_arm_mode(unsigned int psr_mode); /** The PSR "T" and "J" bits define the mode of "classic ARM" cores. */ enum arm_state { @@ -325,7 +325,7 @@ int arm_blank_check_memory(struct target *target, struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value); void arm_set_cpsr(struct arm *arm, uint32_t cpsr); -struct reg *arm_reg_current(struct arm *arm, unsigned regnum); -struct reg *armv8_reg_current(struct arm *arm, unsigned regnum); +struct reg *arm_reg_current(struct arm *arm, unsigned int regnum); +struct reg *armv8_reg_current(struct arm *arm, unsigned int regnum); #endif /* OPENOCD_TARGET_ARM_H */ diff --git a/src/target/arm11.c b/src/target/arm11.c index 43790c737..c583a2ebd 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -478,7 +478,7 @@ static int arm11_resume(struct target *target, int current, /* activate all breakpoints */ if (true) { struct breakpoint *bp; - unsigned brp_num = 0; + unsigned int brp_num = 0; for (bp = target->breakpoints; bp; bp = bp->next) { struct arm11_sc7_action brp[2]; diff --git a/src/target/arm11.h b/src/target/arm11.h index 1f56f7bba..40a3f9024 100644 --- a/src/target/arm11.h +++ b/src/target/arm11.h @@ -39,7 +39,7 @@ struct arm11_common { /** Debug module state. */ struct arm_dpm dpm; struct arm11_sc7_action *bpwp_actions; - unsigned bpwp_n; + unsigned int bpwp_n; size_t brp; /**< Number of Breakpoint Register Pairs from DIDR */ size_t free_brps; /**< Number of breakpoints allocated */ diff --git a/src/target/arm11_dbgtap.c b/src/target/arm11_dbgtap.c index b66f88618..36325911a 100644 --- a/src/target/arm11_dbgtap.c +++ b/src/target/arm11_dbgtap.c @@ -567,8 +567,8 @@ static int arm11_run_instr_data_to_core_noack_inner(struct jtag_tap *tap, chain5_fields[2].in_value = NULL; uint8_t *readies; - unsigned readies_num = count; - unsigned bytes = sizeof(*readies)*readies_num; + unsigned int readies_num = count; + unsigned int bytes = sizeof(*readies) * readies_num; readies = malloc(bytes); if (!readies) { @@ -592,7 +592,7 @@ static int arm11_run_instr_data_to_core_noack_inner(struct jtag_tap *tap, int retval = jtag_execute_queue(); if (retval == ERROR_OK) { - unsigned error_count = 0; + unsigned int error_count = 0; for (size_t i = 0; i < readies_num; i++) { if (readies[i] != 1) @@ -1042,7 +1042,7 @@ static int arm11_dpm_instr_read_data_r0(struct arm_dpm *dpm, * and watchpoint operations instead of running them right away. Since we * pre-allocated our vector, we don't need to worry about space. */ -static int arm11_bpwp_enable(struct arm_dpm *dpm, unsigned index_t, +static int arm11_bpwp_enable(struct arm_dpm *dpm, unsigned int index_t, uint32_t addr, uint32_t control) { struct arm11_common *arm11 = dpm_to_arm11(dpm); @@ -1079,7 +1079,7 @@ static int arm11_bpwp_enable(struct arm_dpm *dpm, unsigned index_t, return ERROR_OK; } -static int arm11_bpwp_disable(struct arm_dpm *dpm, unsigned index_t) +static int arm11_bpwp_disable(struct arm_dpm *dpm, unsigned int index_t) { struct arm11_common *arm11 = dpm_to_arm11(dpm); struct arm11_sc7_action *action; diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c index 3bacfaefd..7e31306b6 100644 --- a/src/target/arm9tdmi.c +++ b/src/target/arm9tdmi.c @@ -821,9 +821,9 @@ COMMAND_HANDLER(handle_arm9tdmi_catch_vectors_command) else if (strcmp(CMD_ARGV[0], "none") == 0) { /* do nothing */ } else { - for (unsigned i = 0; i < CMD_ARGC; i++) { + for (unsigned int i = 0; i < CMD_ARGC; i++) { /* go through list of vectors */ - unsigned j; + unsigned int j; for (j = 0; arm9tdmi_vectors[j].name; j++) { if (strcmp(CMD_ARGV[i], arm9tdmi_vectors[j].name) == 0) { vector_catch_value |= arm9tdmi_vectors[j].value; @@ -850,7 +850,7 @@ COMMAND_HANDLER(handle_arm9tdmi_catch_vectors_command) } /* output current settings */ - for (unsigned i = 0; arm9tdmi_vectors[i].name; i++) { + for (unsigned int i = 0; arm9tdmi_vectors[i].name; i++) { command_print(CMD, "%s: %s", arm9tdmi_vectors[i].name, (vector_catch_value & arm9tdmi_vectors[i].value) ? "catch" : "don't catch"); diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index 92c3dbc3a..ebd2752bd 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -454,17 +454,17 @@ struct dap_ops { int (*send_sequence)(struct adiv5_dap *dap, enum swd_special_seq seq); /** DP register read. */ - int (*queue_dp_read)(struct adiv5_dap *dap, unsigned reg, + int (*queue_dp_read)(struct adiv5_dap *dap, unsigned int reg, uint32_t *data); /** DP register write. */ - int (*queue_dp_write)(struct adiv5_dap *dap, unsigned reg, + int (*queue_dp_write)(struct adiv5_dap *dap, unsigned int reg, uint32_t data); /** AP register read. */ - int (*queue_ap_read)(struct adiv5_ap *ap, unsigned reg, + int (*queue_ap_read)(struct adiv5_ap *ap, unsigned int reg, uint32_t *data); /** AP register write. */ - int (*queue_ap_write)(struct adiv5_ap *ap, unsigned reg, + int (*queue_ap_write)(struct adiv5_ap *ap, unsigned int reg, uint32_t data); /** AP operation abort. */ @@ -553,7 +553,7 @@ static inline int dap_send_sequence(struct adiv5_dap *dap, * @return ERROR_OK for success, else a fault code. */ static inline int dap_queue_dp_read(struct adiv5_dap *dap, - unsigned reg, uint32_t *data) + unsigned int reg, uint32_t *data) { assert(dap->ops); return dap->ops->queue_dp_read(dap, reg, data); @@ -571,7 +571,7 @@ static inline int dap_queue_dp_read(struct adiv5_dap *dap, * @return ERROR_OK for success, else a fault code. */ static inline int dap_queue_dp_write(struct adiv5_dap *dap, - unsigned reg, uint32_t data) + unsigned int reg, uint32_t data) { assert(dap->ops); return dap->ops->queue_dp_write(dap, reg, data); @@ -588,7 +588,7 @@ static inline int dap_queue_dp_write(struct adiv5_dap *dap, * @return ERROR_OK for success, else a fault code. */ static inline int dap_queue_ap_read(struct adiv5_ap *ap, - unsigned reg, uint32_t *data) + unsigned int reg, uint32_t *data) { assert(ap->dap->ops); if (ap->refcount == 0) { @@ -608,7 +608,7 @@ static inline int dap_queue_ap_read(struct adiv5_ap *ap, * @return ERROR_OK for success, else a fault code. */ static inline int dap_queue_ap_write(struct adiv5_ap *ap, - unsigned reg, uint32_t data) + unsigned int reg, uint32_t data) { assert(ap->dap->ops); if (ap->refcount == 0) { @@ -659,7 +659,7 @@ static inline int dap_sync(struct adiv5_dap *dap) return ERROR_OK; } -static inline int dap_dp_read_atomic(struct adiv5_dap *dap, unsigned reg, +static inline int dap_dp_read_atomic(struct adiv5_dap *dap, unsigned int reg, uint32_t *value) { int retval; @@ -671,7 +671,7 @@ static inline int dap_dp_read_atomic(struct adiv5_dap *dap, unsigned reg, return dap_run(dap); } -static inline int dap_dp_poll_register(struct adiv5_dap *dap, unsigned reg, +static inline int dap_dp_poll_register(struct adiv5_dap *dap, unsigned int reg, uint32_t mask, uint32_t value, int timeout) { assert(timeout > 0); diff --git a/src/target/arm_disassembler.c b/src/target/arm_disassembler.c index 5c52ad899..8619f8f82 100644 --- a/src/target/arm_disassembler.c +++ b/src/target/arm_disassembler.c @@ -114,7 +114,7 @@ static int evaluate_pld(uint32_t opcode, if ((opcode & 0x0d30f000) == 0x0510f000) { uint8_t rn; uint8_t u; - unsigned offset; + unsigned int offset; instruction->type = ARM_PLD; rn = (opcode & 0xf0000) >> 16; @@ -701,9 +701,9 @@ static int evaluate_load_store(uint32_t opcode, static int evaluate_extend(uint32_t opcode, uint32_t address, char *cp) { - unsigned rm = (opcode >> 0) & 0xf; - unsigned rd = (opcode >> 12) & 0xf; - unsigned rn = (opcode >> 16) & 0xf; + unsigned int rm = (opcode >> 0) & 0xf; + unsigned int rd = (opcode >> 12) & 0xf; + unsigned int rn = (opcode >> 16) & 0xf; char *type, *rot; switch ((opcode >> 24) & 0x3) { @@ -892,7 +892,7 @@ static int evaluate_media(uint32_t opcode, uint32_t address, /* multiplies */ if ((opcode & 0x01f00080) == 0x01000000) { - unsigned rn = (opcode >> 12) & 0xf; + unsigned int rn = (opcode >> 12) & 0xf; if (rn != 0xf) sprintf(cp, "SML%cD%s%s\tr%d, r%d, r%d, r%d", @@ -925,7 +925,7 @@ static int evaluate_media(uint32_t opcode, uint32_t address, return ERROR_OK; } if ((opcode & 0x01f00000) == 0x01500000) { - unsigned rn = (opcode >> 12) & 0xf; + unsigned int rn = (opcode >> 12) & 0xf; switch (opcode & 0xc0) { case 3: @@ -1001,8 +1001,8 @@ static int evaluate_media(uint32_t opcode, uint32_t address, return ERROR_OK; } if (mnemonic) { - unsigned rm = (opcode >> 0) & 0xf; - unsigned rd = (opcode >> 12) & 0xf; + unsigned int rm = (opcode >> 0) & 0xf; + unsigned int rd = (opcode >> 12) & 0xf; sprintf(cp, "%s%s\tr%d, r%d", mnemonic, COND(opcode), rm, rd); return ERROR_OK; @@ -2747,7 +2747,7 @@ static int evaluate_cond_branch_thumb(uint16_t opcode, static int evaluate_cb_thumb(uint16_t opcode, uint32_t address, struct arm_instruction *instruction) { - unsigned offset; + unsigned int offset; /* added in Thumb2 */ offset = (opcode >> 3) & 0x1f; @@ -2858,7 +2858,7 @@ static int evaluate_hint_thumb(uint16_t opcode, uint32_t address, static int evaluate_ifthen_thumb(uint16_t opcode, uint32_t address, struct arm_instruction *instruction) { - unsigned cond = (opcode >> 4) & 0x0f; + unsigned int cond = (opcode >> 4) & 0x0f; char *x = "", *y = "", *z = ""; if (opcode & 0x01) diff --git a/src/target/arm_disassembler.h b/src/target/arm_disassembler.h index 1be567475..8317da997 100644 --- a/src/target/arm_disassembler.h +++ b/src/target/arm_disassembler.h @@ -171,7 +171,7 @@ struct arm_instruction { uint32_t opcode; /* return value ... Thumb-2 sizes vary */ - unsigned instruction_size; + unsigned int instruction_size; union { struct arm_b_bl_bx_blx_instr b_bl_bx_blx; diff --git a/src/target/arm_dpm.c b/src/target/arm_dpm.c index 94e91ad6c..318d5afec 100644 --- a/src/target/arm_dpm.c +++ b/src/target/arm_dpm.c @@ -167,7 +167,7 @@ int arm_dpm_modeswitch(struct arm_dpm *dpm, enum arm_mode mode) } /* Read 64bit VFP registers */ -static int dpm_read_reg_u64(struct arm_dpm *dpm, struct reg *r, unsigned regnum) +static int dpm_read_reg_u64(struct arm_dpm *dpm, struct reg *r, unsigned int regnum) { int retval = ERROR_FAIL; uint32_t value_r0, value_r1; @@ -205,7 +205,7 @@ static int dpm_read_reg_u64(struct arm_dpm *dpm, struct reg *r, unsigned regnum) } /* just read the register -- rely on the core mode being right */ -int arm_dpm_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum) +int arm_dpm_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned int regnum) { uint32_t value; int retval; @@ -272,7 +272,7 @@ int arm_dpm_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum) } /* Write 64bit VFP registers */ -static int dpm_write_reg_u64(struct arm_dpm *dpm, struct reg *r, unsigned regnum) +static int dpm_write_reg_u64(struct arm_dpm *dpm, struct reg *r, unsigned int regnum) { int retval = ERROR_FAIL; uint32_t value_r0 = buf_get_u32(r->value, 0, 32); @@ -308,7 +308,7 @@ static int dpm_write_reg_u64(struct arm_dpm *dpm, struct reg *r, unsigned regnum } /* just write the register -- rely on the core mode being right */ -static int dpm_write_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum) +static int dpm_write_reg(struct arm_dpm *dpm, struct reg *r, unsigned int regnum) { int retval; uint32_t value = buf_get_u32(r->value, 0, 32); @@ -386,7 +386,7 @@ int arm_dpm_read_current_registers(struct arm_dpm *dpm) return retval; /* read R0 and R1 first (it's used for scratch), then CPSR */ - for (unsigned i = 0; i < 2; i++) { + for (unsigned int i = 0; i < 2; i++) { r = arm->core_cache->reg_list + i; if (!r->valid) { retval = arm_dpm_read_reg(dpm, r, i); @@ -404,7 +404,7 @@ int arm_dpm_read_current_registers(struct arm_dpm *dpm) arm_set_cpsr(arm, cpsr); /* REVISIT we can probably avoid reading R1..R14, saving time... */ - for (unsigned i = 2; i < 16; i++) { + for (unsigned int i = 2; i < 16; i++) { r = arm_reg_current(arm, i); if (r->valid) continue; @@ -501,7 +501,7 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp) * cope with the hand-crafted breakpoint code. */ if (arm->target->type->add_breakpoint == dpm_add_breakpoint) { - for (unsigned i = 0; i < dpm->nbp; i++) { + for (unsigned int i = 0; i < dpm->nbp; i++) { struct dpm_bp *dbp = dpm->dbp + i; struct breakpoint *bp = dbp->bp; @@ -513,7 +513,7 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp) } /* enable/disable watchpoints */ - for (unsigned i = 0; i < dpm->nwp; i++) { + for (unsigned int i = 0; i < dpm->nwp; i++) { struct dpm_wp *dwp = dpm->dwp + i; struct watchpoint *wp = dwp->wp; @@ -538,9 +538,9 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp) did_write = false; /* check everything except our scratch registers R0 and R1 */ - for (unsigned i = 2; i < cache->num_regs; i++) { + for (unsigned int i = 2; i < cache->num_regs; i++) { struct arm_reg *r; - unsigned regnum; + unsigned int regnum; /* also skip PC, CPSR, and non-dirty */ if (i == 15) @@ -625,7 +625,7 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp) arm->pc->dirty = false; /* flush R0 and R1 (our scratch registers) */ - for (unsigned i = 0; i < 2; i++) { + for (unsigned int i = 0; i < 2; i++) { retval = dpm_write_reg(dpm, &cache->reg_list[i], i); if (retval != ERROR_OK) goto done; @@ -643,7 +643,7 @@ done: * or MODE_ANY. */ static enum arm_mode dpm_mapmode(struct arm *arm, - unsigned num, enum arm_mode mode) + unsigned int num, enum arm_mode mode) { enum arm_mode amode = arm->core_mode; @@ -793,7 +793,7 @@ static int arm_dpm_full_context(struct target *target) * Pick some mode with unread registers and read them all. * Repeat until done. */ - for (unsigned i = 0; i < cache->num_regs; i++) { + for (unsigned int i = 0; i < cache->num_regs; i++) { struct arm_reg *r; if (!cache->reg_list[i].exist || cache->reg_list[i].valid) @@ -921,7 +921,7 @@ static int dpm_add_breakpoint(struct target *target, struct breakpoint *bp) if (bp->type == BKPT_SOFT) LOG_DEBUG("using HW bkpt, not SW..."); - for (unsigned i = 0; i < dpm->nbp; i++) { + for (unsigned int i = 0; i < dpm->nbp; i++) { if (!dpm->dbp[i].bp) { retval = dpm_bpwp_setup(dpm, &dpm->dbp[i].bpwp, bp->address, bp->length); @@ -940,7 +940,7 @@ static int dpm_remove_breakpoint(struct target *target, struct breakpoint *bp) struct arm_dpm *dpm = arm->dpm; int retval = ERROR_COMMAND_SYNTAX_ERROR; - for (unsigned i = 0; i < dpm->nbp; i++) { + for (unsigned int i = 0; i < dpm->nbp; i++) { if (dpm->dbp[i].bp == bp) { dpm->dbp[i].bp = NULL; dpm->dbp[i].bpwp.dirty = true; @@ -954,7 +954,7 @@ static int dpm_remove_breakpoint(struct target *target, struct breakpoint *bp) return retval; } -static int dpm_watchpoint_setup(struct arm_dpm *dpm, unsigned index_t, +static int dpm_watchpoint_setup(struct arm_dpm *dpm, unsigned int index_t, struct watchpoint *wp) { int retval; @@ -997,7 +997,7 @@ static int dpm_add_watchpoint(struct target *target, struct watchpoint *wp) int retval = ERROR_TARGET_RESOURCE_NOT_AVAILABLE; if (dpm->bpwp_enable) { - for (unsigned i = 0; i < dpm->nwp; i++) { + for (unsigned int i = 0; i < dpm->nwp; i++) { if (!dpm->dwp[i].wp) { retval = dpm_watchpoint_setup(dpm, i, wp); break; @@ -1014,7 +1014,7 @@ static int dpm_remove_watchpoint(struct target *target, struct watchpoint *wp) struct arm_dpm *dpm = arm->dpm; int retval = ERROR_COMMAND_SYNTAX_ERROR; - for (unsigned i = 0; i < dpm->nwp; i++) { + for (unsigned int i = 0; i < dpm->nwp; i++) { if (dpm->dwp[i].wp == wp) { dpm->dwp[i].wp = NULL; dpm->dwp[i].bpwp.dirty = true; @@ -1161,7 +1161,7 @@ int arm_dpm_initialize(struct arm_dpm *dpm) { /* Disable all breakpoints and watchpoints at startup. */ if (dpm->bpwp_disable) { - unsigned i; + unsigned int i; for (i = 0; i < dpm->nbp; i++) { dpm->dbp[i].bpwp.number = i; diff --git a/src/target/arm_dpm.h b/src/target/arm_dpm.h index 2da463111..16c801ea5 100644 --- a/src/target/arm_dpm.h +++ b/src/target/arm_dpm.h @@ -19,7 +19,7 @@ */ struct dpm_bpwp { - unsigned number; + unsigned int number; uint32_t address; uint32_t control; /* true if hardware state needs flushing */ @@ -109,7 +109,7 @@ struct arm_dpm { uint32_t opcode, uint64_t *data); struct reg *(*arm_reg_current)(struct arm *arm, - unsigned regnum); + unsigned int regnum); /* BREAKPOINT/WATCHPOINT SUPPORT */ @@ -119,7 +119,7 @@ struct arm_dpm { * must currently be disabled. Indices 0..15 are used for * breakpoints; indices 16..31 are for watchpoints. */ - int (*bpwp_enable)(struct arm_dpm *dpm, unsigned index_value, + int (*bpwp_enable)(struct arm_dpm *dpm, unsigned int index_value, uint32_t addr, uint32_t control); /** @@ -127,15 +127,15 @@ struct arm_dpm { * hardware control registers. Indices are the same ones * accepted by bpwp_enable(). */ - int (*bpwp_disable)(struct arm_dpm *dpm, unsigned index_value); + int (*bpwp_disable)(struct arm_dpm *dpm, unsigned int index_value); /* The breakpoint and watchpoint arrays are private to the * DPM infrastructure. There are nbp indices in the dbp * array. There are nwp indices in the dwp array. */ - unsigned nbp; - unsigned nwp; + unsigned int nbp; + unsigned int nwp; struct dpm_bp *dbp; struct dpm_wp *dwp; @@ -158,7 +158,7 @@ struct arm_dpm { int arm_dpm_setup(struct arm_dpm *dpm); int arm_dpm_initialize(struct arm_dpm *dpm); -int arm_dpm_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum); +int arm_dpm_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned int regnum); int arm_dpm_read_current_registers(struct arm_dpm *dpm); int arm_dpm_modeswitch(struct arm_dpm *dpm, enum arm_mode mode); diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index ae89762e1..c1836bc7a 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -168,9 +168,9 @@ static const struct { }; /** Map PSR mode bits to the name of an ARM processor operating mode. */ -const char *arm_mode_name(unsigned psr_mode) +const char *arm_mode_name(unsigned int psr_mode) { - for (unsigned i = 0; i < ARRAY_SIZE(arm_mode_data); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(arm_mode_data); i++) { if (arm_mode_data[i].psr == psr_mode) return arm_mode_data[i].name; } @@ -179,9 +179,9 @@ const char *arm_mode_name(unsigned psr_mode) } /** Return true iff the parameter denotes a valid ARM processor mode. */ -bool is_arm_mode(unsigned psr_mode) +bool is_arm_mode(unsigned int psr_mode) { - for (unsigned i = 0; i < ARRAY_SIZE(arm_mode_data); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(arm_mode_data); i++) { if (arm_mode_data[i].psr == psr_mode) return true; } @@ -272,8 +272,8 @@ static const struct { * CPSR -or- SPSR depending on whether 'mode' is MODE_ANY. * (Exception modes have both CPSR and SPSR registers ...) */ - unsigned cookie; - unsigned gdb_index; + unsigned int cookie; + unsigned int gdb_index; enum arm_mode mode; } arm_core_regs[] = { /* IMPORTANT: we guarantee that the first eight cached registers @@ -499,7 +499,7 @@ void arm_set_cpsr(struct arm *arm, uint32_t cpsr) * However, R8..R14, and SPSR (arm->spsr) *must* be mapped. * CPSR (arm->cpsr) is also not mapped. */ -struct reg *arm_reg_current(struct arm *arm, unsigned regnum) +struct reg *arm_reg_current(struct arm *arm, unsigned int regnum) { struct reg *r; @@ -840,7 +840,7 @@ COMMAND_HANDLER(handle_armv4_5_reg_command) regs = arm->core_cache->reg_list; - for (unsigned mode = 0; mode < ARRAY_SIZE(arm_mode_data); mode++) { + for (unsigned int mode = 0; mode < ARRAY_SIZE(arm_mode_data); mode++) { const char *name; char *sep = "\n"; char *shadow = ""; @@ -875,11 +875,11 @@ COMMAND_HANDLER(handle_armv4_5_reg_command) sep, name, shadow); /* display N rows of up to 4 registers each */ - for (unsigned i = 0; i < arm_mode_data[mode].n_indices; ) { + for (unsigned int i = 0; i < arm_mode_data[mode].n_indices; ) { char output[80]; int output_len = 0; - for (unsigned j = 0; j < 4; j++, i++) { + for (unsigned int j = 0; j < 4; j++, i++) { uint32_t value; struct reg *reg = regs; @@ -1750,7 +1750,7 @@ cleanup: static int arm_full_context(struct target *target) { struct arm *arm = target_to_arm(target); - unsigned num_regs = arm->core_cache->num_regs; + unsigned int num_regs = arm->core_cache->num_regs; struct reg *reg = arm->core_cache->reg_list; int retval = ERROR_OK; diff --git a/src/target/armv7a_cache_l2x.h b/src/target/armv7a_cache_l2x.h index d5f1a6f0e..ea726ec58 100644 --- a/src/target/armv7a_cache_l2x.h +++ b/src/target/armv7a_cache_l2x.h @@ -122,16 +122,16 @@ struct outer_cache_fns { void (*resume)(void); /* This is an ARM L2C thing */ - void (*write_sec)(unsigned long, unsigned); + void (*write_sec)(unsigned long, unsigned int); void (*configure)(const struct l2x0_regs *); }; struct l2c_init_data { const char *type; - unsigned way_size_0; - unsigned num_lock; + unsigned int way_size_0; + unsigned int num_lock; - void (*enable)(uint32_t, uint32_t, unsigned); + void (*enable)(uint32_t, uint32_t, unsigned int); void (*fixup)(uint32_t, uint32_t, struct outer_cache_fns *); void (*save)(uint32_t); void (*configure)(uint32_t); diff --git a/src/target/armv7m.c b/src/target/armv7m.c index d508af7bf..a403b25a9 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -74,9 +74,9 @@ const int armv7m_msp_reg_map[ARMV7M_NUM_CORE_REGS] = { * doesn't include basepri or faultmask registers. */ static const struct { - unsigned id; + unsigned int id; const char *name; - unsigned bits; + unsigned int bits; enum reg_type type; const char *group; const char *feature; @@ -530,7 +530,7 @@ int armv7m_start_algorithm(struct target *target, } /* Store all non-debug execution registers to armv7m_algorithm_info context */ - for (unsigned i = 0; i < armv7m->arm.core_cache->num_regs; i++) { + for (unsigned int i = 0; i < armv7m->arm.core_cache->num_regs; i++) { struct reg *reg = &armv7m->arm.core_cache->reg_list[i]; if (!reg->exist) continue; diff --git a/src/target/armv8.c b/src/target/armv8.c index 3e0ea0b75..3bf094275 100644 --- a/src/target/armv8.c +++ b/src/target/armv8.c @@ -36,7 +36,7 @@ static const char * const armv8_state_strings[] = { static const struct { const char *name; - unsigned psr; + unsigned int psr; } armv8_mode_data[] = { { .name = "USR", @@ -105,9 +105,9 @@ static const struct { }; /** Map PSR mode bits to the name of an ARM processor operating mode. */ -const char *armv8_mode_name(unsigned psr_mode) +const char *armv8_mode_name(unsigned int psr_mode) { - for (unsigned i = 0; i < ARRAY_SIZE(armv8_mode_data); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(armv8_mode_data); i++) { if (armv8_mode_data[i].psr == psr_mode) return armv8_mode_data[i].name; } @@ -683,7 +683,7 @@ static int armv8_read_reg_simdfp_aarch32(struct armv8_common *armv8, int regnum, struct arm_dpm *dpm = &armv8->dpm; struct reg *reg_r1 = dpm->arm->core_cache->reg_list + ARMV8_R1; uint32_t value_r0 = 0, value_r1 = 0; - unsigned num = (regnum - ARMV8_V0) << 1; + unsigned int num = (regnum - ARMV8_V0) << 1; switch (regnum) { case ARMV8_V0 ... ARMV8_V15: @@ -817,7 +817,7 @@ static int armv8_write_reg_simdfp_aarch32(struct armv8_common *armv8, int regnum struct arm_dpm *dpm = &armv8->dpm; struct reg *reg_r1 = dpm->arm->core_cache->reg_list + ARMV8_R1; uint32_t value_r0 = 0, value_r1 = 0; - unsigned num = (regnum - ARMV8_V0) << 1; + unsigned int num = (regnum - ARMV8_V0) << 1; switch (regnum) { case ARMV8_V0 ... ARMV8_V15: @@ -1506,9 +1506,9 @@ static struct reg_data_type aarch64_flags_cpsr[] = { }; static const struct { - unsigned id; + unsigned int id; const char *name; - unsigned bits; + unsigned int bits; enum arm_mode mode; enum reg_type type; const char *group; @@ -1611,10 +1611,10 @@ static const struct { }; static const struct { - unsigned id; - unsigned mapping; + unsigned int id; + unsigned int mapping; const char *name; - unsigned bits; + unsigned int bits; enum arm_mode mode; enum reg_type type; const char *group; @@ -1881,7 +1881,7 @@ struct reg_cache *armv8_build_reg_cache(struct target *target) return cache; } -struct reg *armv8_reg_current(struct arm *arm, unsigned regnum) +struct reg *armv8_reg_current(struct arm *arm, unsigned int regnum) { struct reg *r; diff --git a/src/target/armv8.h b/src/target/armv8.h index 156b5f8bb..349c8f002 100644 --- a/src/target/armv8.h +++ b/src/target/armv8.h @@ -329,7 +329,7 @@ static inline unsigned int armv8_curel_from_core_mode(enum arm_mode core_mode) } } -const char *armv8_mode_name(unsigned psr_mode); +const char *armv8_mode_name(unsigned int psr_mode); void armv8_select_reg_access(struct armv8_common *armv8, bool is_aarch64); int armv8_set_dbgreg_bits(struct armv8_common *armv8, unsigned int reg, unsigned long mask, unsigned long value); diff --git a/src/target/armv8_dpm.c b/src/target/armv8_dpm.c index bcecedc9d..22617fd0e 100644 --- a/src/target/armv8_dpm.c +++ b/src/target/armv8_dpm.c @@ -417,7 +417,7 @@ static int dpmv8_instr_read_data_r0_64(struct arm_dpm *dpm, } #if 0 -static int dpmv8_bpwp_enable(struct arm_dpm *dpm, unsigned index_t, +static int dpmv8_bpwp_enable(struct arm_dpm *dpm, unsigned int index_t, target_addr_t addr, uint32_t control) { struct armv8_common *armv8 = dpm->arm->arch_info; @@ -450,7 +450,7 @@ static int dpmv8_bpwp_enable(struct arm_dpm *dpm, unsigned index_t, } #endif -static int dpmv8_bpwp_disable(struct arm_dpm *dpm, unsigned index_t) +static int dpmv8_bpwp_disable(struct arm_dpm *dpm, unsigned int index_t) { struct armv8_common *armv8 = dpm->arm->arch_info; uint32_t cr; @@ -641,7 +641,7 @@ int armv8_dpm_modeswitch(struct arm_dpm *dpm, enum arm_mode mode) /* * Common register read, relies on armv8_select_reg_access() having been called. */ -static int dpmv8_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum) +static int dpmv8_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned int regnum) { struct armv8_common *armv8 = dpm->arm->arch_info; int retval = ERROR_FAIL; @@ -684,7 +684,7 @@ static int dpmv8_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum) /* * Common register write, relies on armv8_select_reg_access() having been called. */ -static int dpmv8_write_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum) +static int dpmv8_write_reg(struct arm_dpm *dpm, struct reg *r, unsigned int regnum) { struct armv8_common *armv8 = dpm->arm->arch_info; int retval = ERROR_FAIL; @@ -887,7 +887,7 @@ int armv8_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp) * cope with the hand-crafted breakpoint code. */ if (arm->target->type->add_breakpoint == dpmv8_add_breakpoint) { - for (unsigned i = 0; i < dpm->nbp; i++) { + for (unsigned int i = 0; i < dpm->nbp; i++) { struct dpm_bp *dbp = dpm->dbp + i; struct breakpoint *bp = dbp->bp; @@ -899,7 +899,7 @@ int armv8_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp) } /* enable/disable watchpoints */ - for (unsigned i = 0; i < dpm->nwp; i++) { + for (unsigned int i = 0; i < dpm->nwp; i++) { struct dpm_wp *dwp = dpm->dwp + i; struct watchpoint *wp = dwp->wp; @@ -919,7 +919,7 @@ int armv8_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp) goto done; /* check everything except our scratch register R0 */ - for (unsigned i = 1; i < cache->num_regs; i++) { + for (unsigned int i = 1; i < cache->num_regs; i++) { struct arm_reg *r; /* skip non-existent */ @@ -1047,7 +1047,7 @@ static int armv8_dpm_full_context(struct target *target) * Pick some mode with unread registers and read them all. * Repeat until done. */ - for (unsigned i = 0; i < cache->num_regs; i++) { + for (unsigned int i = 0; i < cache->num_regs; i++) { struct arm_reg *r; if (!cache->reg_list[i].exist || cache->reg_list[i].valid) @@ -1175,7 +1175,7 @@ static int dpmv8_add_breakpoint(struct target *target, struct breakpoint *bp) if (bp->type == BKPT_SOFT) LOG_DEBUG("using HW bkpt, not SW..."); - for (unsigned i = 0; i < dpm->nbp; i++) { + for (unsigned int i = 0; i < dpm->nbp; i++) { if (!dpm->dbp[i].bp) { retval = dpmv8_bpwp_setup(dpm, &dpm->dbp[i].bpwp, bp->address, bp->length); @@ -1194,7 +1194,7 @@ static int dpmv8_remove_breakpoint(struct target *target, struct breakpoint *bp) struct arm_dpm *dpm = arm->dpm; int retval = ERROR_COMMAND_SYNTAX_ERROR; - for (unsigned i = 0; i < dpm->nbp; i++) { + for (unsigned int i = 0; i < dpm->nbp; i++) { if (dpm->dbp[i].bp == bp) { dpm->dbp[i].bp = NULL; dpm->dbp[i].bpwp.dirty = true; @@ -1208,7 +1208,7 @@ static int dpmv8_remove_breakpoint(struct target *target, struct breakpoint *bp) return retval; } -static int dpmv8_watchpoint_setup(struct arm_dpm *dpm, unsigned index_t, +static int dpmv8_watchpoint_setup(struct arm_dpm *dpm, unsigned int index_t, struct watchpoint *wp) { int retval; @@ -1251,7 +1251,7 @@ static int dpmv8_add_watchpoint(struct target *target, struct watchpoint *wp) int retval = ERROR_TARGET_RESOURCE_NOT_AVAILABLE; if (dpm->bpwp_enable) { - for (unsigned i = 0; i < dpm->nwp; i++) { + for (unsigned int i = 0; i < dpm->nwp; i++) { if (!dpm->dwp[i].wp) { retval = dpmv8_watchpoint_setup(dpm, i, wp); break; @@ -1268,7 +1268,7 @@ static int dpmv8_remove_watchpoint(struct target *target, struct watchpoint *wp) struct arm_dpm *dpm = arm->dpm; int retval = ERROR_COMMAND_SYNTAX_ERROR; - for (unsigned i = 0; i < dpm->nwp; i++) { + for (unsigned int i = 0; i < dpm->nwp; i++) { if (dpm->dwp[i].wp == wp) { dpm->dwp[i].wp = NULL; dpm->dwp[i].bpwp.dirty = true; @@ -1484,7 +1484,7 @@ int armv8_dpm_initialize(struct arm_dpm *dpm) { /* Disable all breakpoints and watchpoints at startup. */ if (dpm->bpwp_disable) { - unsigned i; + unsigned int i; for (i = 0; i < dpm->nbp; i++) { dpm->dbp[i].bpwp.number = i; diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c index 498a9cd16..086aafe19 100644 --- a/src/target/cortex_a.c +++ b/src/target/cortex_a.c @@ -571,7 +571,7 @@ static int cortex_a_instr_read_data_r0_r1(struct arm_dpm *dpm, return retval; } -static int cortex_a_bpwp_enable(struct arm_dpm *dpm, unsigned index_t, +static int cortex_a_bpwp_enable(struct arm_dpm *dpm, unsigned int index_t, uint32_t addr, uint32_t control) { struct cortex_a_common *a = dpm_to_a(dpm); @@ -606,7 +606,7 @@ static int cortex_a_bpwp_enable(struct arm_dpm *dpm, unsigned index_t, return retval; } -static int cortex_a_bpwp_disable(struct arm_dpm *dpm, unsigned index_t) +static int cortex_a_bpwp_disable(struct arm_dpm *dpm, unsigned int index_t) { struct cortex_a_common *a = dpm_to_a(dpm); uint32_t cr; diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 698a6868c..880a83a18 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -898,7 +898,7 @@ static int cortex_m_debug_entry(struct target *target) arm->core_mode = ARM_MODE_HANDLER; arm->map = armv7m_msp_reg_map; } else { - unsigned control = buf_get_u32(arm->core_cache + unsigned int control = buf_get_u32(arm->core_cache ->reg_list[ARMV7M_CONTROL].value, 0, 3); /* is this thread privileged? */ @@ -2142,7 +2142,7 @@ int cortex_m_add_watchpoint(struct target *target, struct watchpoint *watchpoint } /* hardware allows address masks of up to 32K */ - unsigned mask; + unsigned int mask; for (mask = 0; mask < 16; mask++) { if ((1u << mask) == watchpoint->length) @@ -2378,7 +2378,7 @@ static int cortex_m_dwt_set_reg(struct reg *reg, uint8_t *buf) struct dwt_reg { uint32_t addr; const char *name; - unsigned size; + unsigned int size; }; static const struct dwt_reg dwt_base_regs[] = { @@ -2946,7 +2946,7 @@ COMMAND_HANDLER(handle_cortex_m_vector_catch_command) static const struct { char name[10]; - unsigned mask; + unsigned int mask; } vec_ids[] = { { "hard_err", VC_HARDERR, }, { "int_err", VC_INTERR, }, @@ -2972,7 +2972,7 @@ COMMAND_HANDLER(handle_cortex_m_vector_catch_command) return retval; if (CMD_ARGC > 0) { - unsigned catch = 0; + unsigned int catch = 0; if (CMD_ARGC == 1) { if (strcmp(CMD_ARGV[0], "all") == 0) { @@ -2984,7 +2984,7 @@ COMMAND_HANDLER(handle_cortex_m_vector_catch_command) goto write; } while (CMD_ARGC-- > 0) { - unsigned i; + unsigned int i; for (i = 0; i < ARRAY_SIZE(vec_ids); i++) { if (strcmp(CMD_ARGV[CMD_ARGC], vec_ids[i].name) != 0) continue; @@ -3017,7 +3017,7 @@ write: */ } - for (unsigned i = 0; i < ARRAY_SIZE(vec_ids); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(vec_ids); i++) { command_print(CMD, "%9s: %s", vec_ids[i].name, (demcr & vec_ids[i].mask) ? "catch" : "ignore"); } diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c index 687821c5d..953888de3 100644 --- a/src/target/dsp563xx.c +++ b/src/target/dsp563xx.c @@ -220,9 +220,9 @@ enum dsp563xx_reg_idx { }; static const struct { - unsigned id; + unsigned int id; const char *name; - unsigned bits; + unsigned int bits; /* effective addressing mode encoding */ uint8_t eame; uint32_t instr_mask; diff --git a/src/target/dsp5680xx.c b/src/target/dsp5680xx.c index c90bca3c1..8b3b1c49b 100644 --- a/src/target/dsp5680xx.c +++ b/src/target/dsp5680xx.c @@ -1172,7 +1172,7 @@ static int dsp5680xx_read(struct target *t, target_addr_t a, uint32_t size, dsp5680xx_context.flush = 0; int counter = FLUSH_COUNT_READ_WRITE; - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { if (--counter == 0) { dsp5680xx_context.flush = 1; counter = FLUSH_COUNT_READ_WRITE; diff --git a/src/target/esirisc.c b/src/target/esirisc.c index 14d34ff04..611141439 100644 --- a/src/target/esirisc.c +++ b/src/target/esirisc.c @@ -283,7 +283,7 @@ static int esirisc_save_context(struct target *target) LOG_DEBUG("-"); - for (unsigned i = 0; i < esirisc->reg_cache->num_regs; ++i) { + for (unsigned int i = 0; i < esirisc->reg_cache->num_regs; ++i) { struct reg *reg = esirisc->reg_cache->reg_list + i; struct esirisc_reg *reg_info = reg->arch_info; @@ -300,7 +300,7 @@ static int esirisc_restore_context(struct target *target) LOG_DEBUG("-"); - for (unsigned i = 0; i < esirisc->reg_cache->num_regs; ++i) { + for (unsigned int i = 0; i < esirisc->reg_cache->num_regs; ++i) { struct reg *reg = esirisc->reg_cache->reg_list + i; struct esirisc_reg *reg_info = reg->arch_info; diff --git a/src/target/esirisc_trace.c b/src/target/esirisc_trace.c index 376ea1db7..a70d9d74b 100644 --- a/src/target/esirisc_trace.c +++ b/src/target/esirisc_trace.c @@ -287,9 +287,9 @@ static int esirisc_trace_init(struct target *target) } static int esirisc_trace_buf_get_u32(uint8_t *buffer, uint32_t size, - unsigned *pos, unsigned count, uint32_t *value) + unsigned int *pos, unsigned int count, uint32_t *value) { - const unsigned num_bits = size * 8; + const unsigned int num_bits = size * 8; if (*pos+count > num_bits) return ERROR_FAIL; @@ -301,7 +301,7 @@ static int esirisc_trace_buf_get_u32(uint8_t *buffer, uint32_t size, } static int esirisc_trace_buf_get_pc(struct target *target, uint8_t *buffer, uint32_t size, - unsigned *pos, uint32_t *value) + unsigned int *pos, uint32_t *value) { struct esirisc_common *esirisc = target_to_esirisc(target); struct esirisc_trace *trace_info = &esirisc->trace_info; @@ -380,7 +380,7 @@ static int esirisc_trace_analyze_full(struct command_invocation *cmd, uint8_t *b const uint32_t num_bits = size * 8; int retval; - unsigned pos = 0; + unsigned int pos = 0; while (pos < num_bits) { uint32_t id; @@ -484,7 +484,7 @@ static int esirisc_trace_analyze_simple(struct command_invocation *cmd, uint8_t const uint32_t num_bits = size * 8; int retval; - unsigned pos = 0; + unsigned int pos = 0; while (pos < num_bits) { uint32_t pc; diff --git a/src/target/etb.h b/src/target/etb.h index fa75600ad..1d0c08b2c 100644 --- a/src/target/etb.h +++ b/src/target/etb.h @@ -32,7 +32,7 @@ struct etb { uint32_t ram_width; /** how much trace buffer to fill after trigger */ - unsigned trigger_percent; + unsigned int trigger_percent; }; struct etb_reg { diff --git a/src/target/etm.c b/src/target/etm.c index d8f2a2faa..53d5cb68c 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -220,10 +220,10 @@ static const struct reg_arch_type etm_scan6_type = { /* Look up register by ID ... most ETM instances only * support a subset of the possible registers. */ -static struct reg *etm_reg_lookup(struct etm_context *etm_ctx, unsigned id) +static struct reg *etm_reg_lookup(struct etm_context *etm_ctx, unsigned int id) { struct reg_cache *cache = etm_ctx->reg_cache; - unsigned i; + unsigned int i; for (i = 0; i < cache->num_regs; i++) { struct etm_reg *reg = cache->reg_list[i].arch_info; @@ -238,9 +238,9 @@ static struct reg *etm_reg_lookup(struct etm_context *etm_ctx, unsigned id) return NULL; } -static void etm_reg_add(unsigned bcd_vers, struct arm_jtag *jtag_info, +static void etm_reg_add(unsigned int bcd_vers, struct arm_jtag *jtag_info, struct reg_cache *cache, struct etm_reg *ereg, - const struct etm_reg_info *r, unsigned nreg) + const struct etm_reg_info *r, unsigned int nreg) { struct reg *reg = cache->reg_list; @@ -281,7 +281,7 @@ struct reg_cache *etm_build_reg_cache(struct target *target, struct reg_cache *reg_cache = malloc(sizeof(struct reg_cache)); struct reg *reg_list = NULL; struct etm_reg *arch_info = NULL; - unsigned bcd_vers, config; + unsigned int bcd_vers, config; /* the actual registers are kept in two arrays */ reg_list = calloc(128, sizeof(struct reg)); @@ -1590,7 +1590,7 @@ COMMAND_HANDLER(handle_etm_status_command) if (!reg) return ERROR_FAIL; if (etm_get_reg(reg) == ERROR_OK) { - unsigned s = buf_get_u32(reg->value, 0, reg->size); + unsigned int s = buf_get_u32(reg->value, 0, reg->size); command_print(CMD, "etm: %s%s%s%s", /* bit(1) == progbit */ diff --git a/src/target/hla_target.c b/src/target/hla_target.c index d6f2afb4e..6b0d2e95e 100644 --- a/src/target/hla_target.c +++ b/src/target/hla_target.c @@ -258,7 +258,7 @@ static int adapter_debug_entry(struct target *target) arm->core_mode = ARM_MODE_HANDLER; arm->map = armv7m_msp_reg_map; } else { - unsigned control = buf_get_u32(arm->core_cache + unsigned int control = buf_get_u32(arm->core_cache ->reg_list[ARMV7M_CONTROL].value, 0, 3); /* is this thread privileged? */ diff --git a/src/target/image.c b/src/target/image.c index 440fe17d1..e8ac066fd 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -195,7 +195,7 @@ static int image_ihex_buffer_complete_inner(struct image *image, } while (count-- > 0) { - unsigned value; + unsigned int value; sscanf(&lpsz_line[bytes_read], "%2x", &value); ihex->buffer[cooked_bytes] = (uint8_t)value; cal_checksum += (uint8_t)ihex->buffer[cooked_bytes]; @@ -864,7 +864,7 @@ static int image_mot_buffer_complete_inner(struct image *image, } while (count-- > 0) { - unsigned value; + unsigned int value; sscanf(&lpsz_line[bytes_read], "%2x", &value); mot->buffer[cooked_bytes] = (uint8_t)value; cal_checksum += (uint8_t)mot->buffer[cooked_bytes]; diff --git a/src/target/lakemont.c b/src/target/lakemont.c index 1fcd6426a..0340d0d0b 100644 --- a/src/target/lakemont.c +++ b/src/target/lakemont.c @@ -67,7 +67,7 @@ static const struct { const char *name; uint64_t op; uint8_t pm_idx; - unsigned bits; + unsigned int bits; enum reg_type type; const char *group; const char *feature; @@ -597,7 +597,7 @@ static int read_all_core_hw_regs(struct target *t) { int err; uint32_t regval; - unsigned i; + unsigned int i; struct x86_32_common *x86_32 = target_to_x86_32(t); for (i = 0; i < (x86_32->cache->num_regs); i++) { if (regs[i].pm_idx == NOT_AVAIL_REG) @@ -616,7 +616,7 @@ static int read_all_core_hw_regs(struct target *t) static int write_all_core_hw_regs(struct target *t) { int err; - unsigned i; + unsigned int i; struct x86_32_common *x86_32 = target_to_x86_32(t); for (i = 0; i < (x86_32->cache->num_regs); i++) { if (regs[i].pm_idx == NOT_AVAIL_REG) diff --git a/src/target/mips32.c b/src/target/mips32.c index af52ffca0..dd40558a1 100644 --- a/src/target/mips32.c +++ b/src/target/mips32.c @@ -34,7 +34,7 @@ static const char *mips_isa_strings[] = { * based on gdb-7.6.2/gdb/features/mips-{fpu,cp0,cpu,dsp}.xml */ static const struct { - unsigned id; + unsigned int id; const char *name; enum reg_type type; const char *group; @@ -1187,7 +1187,7 @@ int mips32_read_config_regs(struct target *target) mips32->isa_imp = MIPS32_MIPS16; LOG_USER("ISA implemented: %s%s", "MIPS32, MIPS16", buf); } else if (ejtag_info->config_regs >= 4) { /* config3 implemented */ - unsigned isa_imp = (ejtag_info->config[3] & MIPS32_CONFIG3_ISA_MASK) >> MIPS32_CONFIG3_ISA_SHIFT; + unsigned int isa_imp = (ejtag_info->config[3] & MIPS32_CONFIG3_ISA_MASK) >> MIPS32_CONFIG3_ISA_SHIFT; if (isa_imp == 1) { mips32->isa_imp = MMIPS32_ONLY; LOG_USER("ISA implemented: %s%s", "microMIPS32", buf); diff --git a/src/target/mips32_pracc.c b/src/target/mips32_pracc.c index 018d8424e..2d0bd641b 100644 --- a/src/target/mips32_pracc.c +++ b/src/target/mips32_pracc.c @@ -370,7 +370,7 @@ int mips32_pracc_queue_exec(struct mips_ejtag *ejtag_info, struct pracc_queue_in return ERROR_FAIL; } - unsigned num_clocks = + unsigned int num_clocks = ((uint64_t)(ejtag_info->scan_delay) * adapter_get_speed_khz() + 500000) / 1000000; uint32_t ejtag_ctrl = ejtag_info->ejtag_ctrl & ~EJTAG_CTRL_PRACC; @@ -1362,7 +1362,7 @@ int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_are pracc_swap16_array(ejtag_info, jmp_code, ARRAY_SIZE(jmp_code)); /* execute jump code, with no address check */ - for (unsigned i = 0; i < ARRAY_SIZE(jmp_code); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(jmp_code); i++) { int retval = wait_for_pracc_rw(ejtag_info); if (retval != ERROR_OK) return retval; @@ -1397,7 +1397,7 @@ int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_are mips_ejtag_set_instr(ejtag_info, EJTAG_INST_FASTDATA); mips_ejtag_fastdata_scan(ejtag_info, 1, &val); - unsigned num_clocks = 0; /* like in legacy code */ + unsigned int num_clocks = 0; /* like in legacy code */ if (ejtag_info->mode != 0) num_clocks = ((uint64_t)(ejtag_info->scan_delay) * adapter_get_speed_khz() + 500000) / 1000000; diff --git a/src/target/mips32_pracc.h b/src/target/mips32_pracc.h index f78f89153..a0244a695 100644 --- a/src/target/mips32_pracc.h +++ b/src/target/mips32_pracc.h @@ -45,7 +45,7 @@ struct pa_list { struct pracc_queue_info { struct mips_ejtag *ejtag_info; - unsigned isa; + unsigned int isa; int retval; int code_count; int store_count; diff --git a/src/target/mips64.c b/src/target/mips64.c index 48f4563dc..3d193a300 100644 --- a/src/target/mips64.c +++ b/src/target/mips64.c @@ -21,7 +21,7 @@ #include "mips64.h" static const struct { - unsigned id; + unsigned int id; const char *name; enum reg_type type; const char *group; @@ -332,8 +332,8 @@ int mips64_save_context(struct target *target) if (retval != ERROR_OK) return retval; - for (unsigned i = 0; i < MIPS64_NUM_REGS; i++) - retval = mips64->read_core_reg(target, i); + for (unsigned int i = 0; i < MIPS64_NUM_REGS; i++) + retval = mips64->read_core_reg(target, i); return retval; } @@ -343,7 +343,7 @@ int mips64_restore_context(struct target *target) struct mips64_common *mips64 = target->arch_info; struct mips_ejtag *ejtag_info = &mips64->ejtag_info; - for (unsigned i = 0; i < MIPS64_NUM_REGS; i++) { + for (unsigned int i = 0; i < MIPS64_NUM_REGS; i++) { if (mips64->core_cache->reg_list[i].dirty) mips64->write_core_reg(target, i); } @@ -379,7 +379,7 @@ int mips64_build_reg_cache(struct target *target) struct reg_cache **cache_p, *cache; struct mips64_core_reg *arch_info = NULL; struct reg *reg_list = NULL; - unsigned i; + unsigned int i; cache = calloc(1, sizeof(*cache)); if (!cache) { diff --git a/src/target/mips64_pracc.c b/src/target/mips64_pracc.c index b083f5ce8..8cfce32e3 100644 --- a/src/target/mips64_pracc.c +++ b/src/target/mips64_pracc.c @@ -27,13 +27,13 @@ struct mips64_pracc_context { uint64_t *local_iparam; - unsigned num_iparam; + unsigned int num_iparam; uint64_t *local_oparam; - unsigned num_oparam; + unsigned int num_oparam; const uint32_t *code; - unsigned code_len; + unsigned int code_len; uint64_t stack[STACK_DEPTH]; - unsigned stack_offset; + unsigned int stack_offset; struct mips_ejtag *ejtag_info; }; @@ -65,7 +65,7 @@ static int wait_for_pracc_rw(struct mips_ejtag *ejtag_info, uint32_t *ctrl) static int mips64_pracc_exec_read(struct mips64_pracc_context *ctx, uint64_t address) { struct mips_ejtag *ejtag_info = ctx->ejtag_info; - unsigned offset; + unsigned int offset; uint32_t ejtag_ctrl; uint64_t data; int rc; @@ -154,7 +154,7 @@ static int mips64_pracc_exec_write(struct mips64_pracc_context *ctx, uint64_t ad { uint32_t ejtag_ctrl; uint64_t data; - unsigned offset; + unsigned int offset; struct mips_ejtag *ejtag_info = ctx->ejtag_info; int rc; @@ -209,9 +209,9 @@ static int mips64_pracc_exec_write(struct mips64_pracc_context *ctx, uint64_t ad } int mips64_pracc_exec(struct mips_ejtag *ejtag_info, - unsigned code_len, const uint32_t *code, - unsigned num_param_in, uint64_t *param_in, - unsigned num_param_out, uint64_t *param_out) + unsigned int code_len, const uint32_t *code, + unsigned int num_param_in, uint64_t *param_in, + unsigned int num_param_out, uint64_t *param_out) { uint32_t ejtag_ctrl; uint64_t address = 0, address_prev = 0; @@ -219,7 +219,7 @@ int mips64_pracc_exec(struct mips_ejtag *ejtag_info, int retval; int pass = 0; bool first_time_call = true; - unsigned i; + unsigned int i; for (i = 0; i < code_len; i++) LOG_DEBUG("%08" PRIx32, code[i]); @@ -354,11 +354,11 @@ static int mips64_pracc_read_u64(struct mips_ejtag *ejtag_info, uint64_t addr, } static int mips64_pracc_read_mem64(struct mips_ejtag *ejtag_info, uint64_t addr, - unsigned count, uint64_t *buf) + unsigned int count, uint64_t *buf) { int retval = ERROR_OK; - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { retval = mips64_pracc_read_u64(ejtag_info, addr + 8*i, &buf[i]); if (retval != ERROR_OK) return retval; @@ -414,11 +414,11 @@ static int mips64_pracc_read_u32(struct mips_ejtag *ejtag_info, uint64_t addr, } static int mips64_pracc_read_mem32(struct mips_ejtag *ejtag_info, uint64_t addr, - unsigned count, uint32_t *buf) + unsigned int count, uint32_t *buf) { int retval = ERROR_OK; - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { retval = mips64_pracc_read_u32(ejtag_info, addr + 4 * i, &buf[i]); if (retval != ERROR_OK) return retval; @@ -474,11 +474,11 @@ static int mips64_pracc_read_u16(struct mips_ejtag *ejtag_info, uint64_t addr, } static int mips64_pracc_read_mem16(struct mips_ejtag *ejtag_info, uint64_t addr, - unsigned count, uint16_t *buf) + unsigned int count, uint16_t *buf) { int retval = ERROR_OK; - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { retval = mips64_pracc_read_u16(ejtag_info, addr + 2*i, &buf[i]); if (retval != ERROR_OK) return retval; @@ -534,11 +534,11 @@ static int mips64_pracc_read_u8(struct mips_ejtag *ejtag_info, uint64_t addr, } static int mips64_pracc_read_mem8(struct mips_ejtag *ejtag_info, uint64_t addr, - unsigned count, uint8_t *buf) + unsigned int count, uint8_t *buf) { int retval = ERROR_OK; - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { retval = mips64_pracc_read_u8(ejtag_info, addr + i, &buf[i]); if (retval != ERROR_OK) return retval; @@ -547,7 +547,7 @@ static int mips64_pracc_read_mem8(struct mips_ejtag *ejtag_info, uint64_t addr, } int mips64_pracc_read_mem(struct mips_ejtag *ejtag_info, uint64_t addr, - unsigned size, unsigned count, void *buf) + unsigned int size, unsigned int count, void *buf) { switch (size) { case 1: @@ -612,11 +612,11 @@ static int mips64_pracc_write_u64(struct mips_ejtag *ejtag_info, uint64_t addr, } static int mips64_pracc_write_mem64(struct mips_ejtag *ejtag_info, - uint64_t addr, unsigned count, uint64_t *buf) + uint64_t addr, unsigned int count, uint64_t *buf) { int retval = ERROR_OK; - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { retval = mips64_pracc_write_u64(ejtag_info, addr + 8 * i, &buf[i]); if (retval != ERROR_OK) return retval; @@ -674,11 +674,11 @@ static int mips64_pracc_write_u32(struct mips_ejtag *ejtag_info, uint64_t addr, } static int mips64_pracc_write_mem32(struct mips_ejtag *ejtag_info, uint64_t addr, - unsigned count, uint32_t *buf) + unsigned int count, uint32_t *buf) { int retval = ERROR_OK; - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { retval = mips64_pracc_write_u32(ejtag_info, addr + 4 * i, &buf[i]); if (retval != ERROR_OK) return retval; @@ -734,11 +734,11 @@ static int mips64_pracc_write_u16(struct mips_ejtag *ejtag_info, uint64_t addr, } static int mips64_pracc_write_mem16(struct mips_ejtag *ejtag_info, - uint64_t addr, unsigned count, uint16_t *buf) + uint64_t addr, unsigned int count, uint16_t *buf) { int retval = ERROR_OK; - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { retval = mips64_pracc_write_u16(ejtag_info, addr + 2 * i, &buf[i]); if (retval != ERROR_OK) return retval; @@ -795,11 +795,11 @@ static int mips64_pracc_write_u8(struct mips_ejtag *ejtag_info, uint64_t addr, } static int mips64_pracc_write_mem8(struct mips_ejtag *ejtag_info, - uint64_t addr, unsigned count, uint8_t *buf) + uint64_t addr, unsigned int count, uint8_t *buf) { int retval = ERROR_OK; - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { retval = mips64_pracc_write_u8(ejtag_info, addr + i, &buf[i]); if (retval != ERROR_OK) return retval; @@ -808,8 +808,8 @@ static int mips64_pracc_write_mem8(struct mips_ejtag *ejtag_info, } int mips64_pracc_write_mem(struct mips_ejtag *ejtag_info, - uint64_t addr, unsigned size, - unsigned count, void *buf) + uint64_t addr, unsigned int size, + unsigned int count, void *buf) { switch (size) { case 1: @@ -1270,7 +1270,7 @@ int mips64_pracc_read_regs(struct mips_ejtag *ejtag_info, uint64_t *regs) int mips64_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_area *source, bool write_t, uint64_t addr, - unsigned count, uint64_t *buf) + unsigned int count, uint64_t *buf) { uint32_t handler_code[] = { /* caution when editing, table is modified below */ @@ -1321,7 +1321,7 @@ int mips64_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, }; int retval; - unsigned i; + unsigned int i; uint32_t ejtag_ctrl, address32; uint64_t address, val; @@ -1385,7 +1385,7 @@ int mips64_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, mips64_ejtag_fastdata_scan(ejtag_info, 1, &val); /* like in legacy code */ - unsigned num_clocks = 0; + unsigned int num_clocks = 0; if (ejtag_info->mode != 0) num_clocks = ((uint64_t)(ejtag_info->scan_delay) * adapter_get_speed_khz() + 500000) / 1000000; LOG_DEBUG("num_clocks=%d", num_clocks); diff --git a/src/target/mips64_pracc.h b/src/target/mips64_pracc.h index 19d151946..2bdc856b9 100644 --- a/src/target/mips64_pracc.h +++ b/src/target/mips64_pracc.h @@ -40,20 +40,22 @@ #define MIPS64_PRACC_ADDR_STEP 4 #define MIPS64_PRACC_DATA_STEP 8 -int mips64_pracc_read_mem(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned size, unsigned count, void *buf); -int mips64_pracc_write_mem(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned size, unsigned count, void *buf); +int mips64_pracc_read_mem(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned int size, + unsigned int count, void *buf); +int mips64_pracc_write_mem(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned int size, + unsigned int count, void *buf); int mips64_pracc_read_regs(struct mips_ejtag *ejtag_info, uint64_t *regs); int mips64_pracc_write_regs(struct mips_ejtag *ejtag_info, uint64_t *regs); int mips64_pracc_exec(struct mips_ejtag *ejtag_info, - unsigned code_len, const uint32_t *code, - unsigned num_param_in, uint64_t *param_in, - unsigned num_param_out, uint64_t *param_out); + unsigned int code_len, const uint32_t *code, + unsigned int num_param_in, uint64_t *param_in, + unsigned int num_param_out, uint64_t *param_out); int mips64_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_area *source, bool write_t, uint64_t addr, - unsigned count, uint64_t *buf); + unsigned int count, uint64_t *buf); #endif /* OPENOCD_TARGET_MIPS64_PRACC_H */ diff --git a/src/target/mips_ejtag.c b/src/target/mips_ejtag.c index 389461cae..2ff4aa926 100644 --- a/src/target/mips_ejtag.c +++ b/src/target/mips_ejtag.c @@ -493,7 +493,7 @@ int mips64_ejtag_config_step(struct mips_ejtag *ejtag_info, bool enable_step) MIPS64_NOP, }; const uint32_t *code = enable_step ? code_enable : code_disable; - unsigned code_len = enable_step ? ARRAY_SIZE(code_enable) : + unsigned int code_len = enable_step ? ARRAY_SIZE(code_enable) : ARRAY_SIZE(code_disable); return mips64_pracc_exec(ejtag_info, diff --git a/src/target/mips_ejtag.h b/src/target/mips_ejtag.h index 7376e5141..30a46903f 100644 --- a/src/target/mips_ejtag.h +++ b/src/target/mips_ejtag.h @@ -214,7 +214,7 @@ struct mips_ejtag { uint32_t reg8; uint32_t reg9; - unsigned scan_delay; + unsigned int scan_delay; int mode; uint32_t pa_ctrl; uint32_t pa_addr; diff --git a/src/target/register.h b/src/target/register.h index 1e4f2e088..b9af401b4 100644 --- a/src/target/register.h +++ b/src/target/register.h @@ -145,7 +145,7 @@ struct reg_cache { const char *name; struct reg_cache *next; struct reg *reg_list; - unsigned num_regs; + unsigned int num_regs; }; struct reg_arch_type { diff --git a/src/target/stm8.c b/src/target/stm8.c index 227101b6f..2b3466dac 100644 --- a/src/target/stm8.c +++ b/src/target/stm8.c @@ -38,7 +38,7 @@ static int (*adapter_speed)(int speed); extern struct adapter_driver *adapter_driver; static const struct { - unsigned id; + unsigned int id; const char *name; const uint8_t bits; enum reg_type type; diff --git a/src/target/target.c b/src/target/target.c index 281bbbd40..56aa8b1e7 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1443,14 +1443,14 @@ int target_gdb_fileio_end(struct target *target, int retcode, int fileio_errno, target_addr_t target_address_max(struct target *target) { - unsigned bits = target_address_bits(target); + unsigned int bits = target_address_bits(target); if (sizeof(target_addr_t) * 8 == bits) return (target_addr_t) -1; else return (((target_addr_t) 1) << bits) - 1; } -unsigned target_address_bits(struct target *target) +unsigned int target_address_bits(struct target *target) { if (target->type->address_bits) return target->type->address_bits(target); @@ -3035,7 +3035,7 @@ COMMAND_HANDLER(handle_reg_command) unsigned int count = 0; while (cache) { - unsigned i; + unsigned int i; command_print(CMD, "===== %s", cache->name); @@ -3070,13 +3070,13 @@ COMMAND_HANDLER(handle_reg_command) /* access a single register by its ordinal number */ if ((CMD_ARGV[0][0] >= '0') && (CMD_ARGV[0][0] <= '9')) { - unsigned num; + unsigned int num; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num); struct reg_cache *cache = target->reg_cache; unsigned int count = 0; while (cache) { - unsigned i; + unsigned int i; for (i = 0; i < cache->num_regs; i++) { if (count++ == num) { reg = &cache->reg_list[i]; @@ -3194,7 +3194,7 @@ COMMAND_HANDLER(handle_wait_halt_command) if (CMD_ARGC > 1) return ERROR_COMMAND_SYNTAX_ERROR; - unsigned ms = DEFAULT_HALT_TIMEOUT; + unsigned int ms = DEFAULT_HALT_TIMEOUT; if (1 == CMD_ARGC) { int retval = parse_uint(CMD_ARGV[0], &ms); if (retval != ERROR_OK) @@ -3260,7 +3260,7 @@ COMMAND_HANDLER(handle_halt_command) return retval; if (CMD_ARGC == 1) { - unsigned wait_local; + unsigned int wait_local; retval = parse_uint(CMD_ARGV[0], &wait_local); if (retval != ERROR_OK) return ERROR_COMMAND_SYNTAX_ERROR; @@ -3344,14 +3344,14 @@ COMMAND_HANDLER(handle_step_command) } void target_handle_md_output(struct command_invocation *cmd, - struct target *target, target_addr_t address, unsigned size, - unsigned count, const uint8_t *buffer) + struct target *target, target_addr_t address, unsigned int size, + unsigned int count, const uint8_t *buffer) { - const unsigned line_bytecnt = 32; - unsigned line_modulo = line_bytecnt / size; + const unsigned int line_bytecnt = 32; + unsigned int line_modulo = line_bytecnt / size; char output[line_bytecnt * 4 + 1]; - unsigned output_len = 0; + unsigned int output_len = 0; const char *value_fmt; switch (size) { @@ -3373,7 +3373,7 @@ void target_handle_md_output(struct command_invocation *cmd, return; } - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { if (i % line_modulo == 0) { output_len += snprintf(output + output_len, sizeof(output) - output_len, @@ -3412,7 +3412,7 @@ COMMAND_HANDLER(handle_md_command) if (CMD_ARGC < 1) return ERROR_COMMAND_SYNTAX_ERROR; - unsigned size = 0; + unsigned int size = 0; switch (CMD_NAME[2]) { case 'd': size = 8; @@ -3445,7 +3445,7 @@ COMMAND_HANDLER(handle_md_command) target_addr_t address; COMMAND_PARSE_ADDRESS(CMD_ARGV[0], address); - unsigned count = 1; + unsigned int count = 1; if (CMD_ARGC == 2) COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], count); @@ -3471,22 +3471,22 @@ typedef int (*target_write_fn)(struct target *target, static int target_fill_mem(struct target *target, target_addr_t address, target_write_fn fn, - unsigned data_size, + unsigned int data_size, /* value */ uint64_t b, /* count */ - unsigned c) + unsigned int c) { /* We have to write in reasonably large chunks to be able * to fill large memory areas with any sane speed */ - const unsigned chunk_size = 16384; + const unsigned int chunk_size = 16384; uint8_t *target_buf = malloc(chunk_size * data_size); if (!target_buf) { LOG_ERROR("Out of memory"); return ERROR_FAIL; } - for (unsigned i = 0; i < chunk_size; i++) { + for (unsigned int i = 0; i < chunk_size; i++) { switch (data_size) { case 8: target_buffer_set_u64(target, target_buf + i * data_size, b); @@ -3507,8 +3507,8 @@ static int target_fill_mem(struct target *target, int retval = ERROR_OK; - for (unsigned x = 0; x < c; x += chunk_size) { - unsigned current; + for (unsigned int x = 0; x < c; x += chunk_size) { + unsigned int current; current = c - x; if (current > chunk_size) current = chunk_size; @@ -3550,12 +3550,12 @@ COMMAND_HANDLER(handle_mw_command) uint64_t value; COMMAND_PARSE_NUMBER(u64, CMD_ARGV[1], value); - unsigned count = 1; + unsigned int count = 1; if (CMD_ARGC == 3) COMMAND_PARSE_NUMBER(uint, CMD_ARGV[2], count); struct target *target = get_current_target(CMD_CTX); - unsigned wordsize; + unsigned int wordsize; switch (CMD_NAME[2]) { case 'd': wordsize = 8; diff --git a/src/target/target.h b/src/target/target.h index ecc8a9032..abd0b5825 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -685,7 +685,7 @@ target_addr_t target_address_max(struct target *target); * * This routine is a wrapper for target->type->address_bits. */ -unsigned target_address_bits(struct target *target); +unsigned int target_address_bits(struct target *target); /** * Return the number of data bits this target supports. @@ -778,8 +778,8 @@ int target_arch_state(struct target *target); void target_handle_event(struct target *t, enum target_event e); void target_handle_md_output(struct command_invocation *cmd, - struct target *target, target_addr_t address, unsigned size, - unsigned count, const uint8_t *buffer); + struct target *target, target_addr_t address, unsigned int size, + unsigned int count, const uint8_t *buffer); int target_profiling_default(struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds); diff --git a/src/target/target_type.h b/src/target/target_type.h index bc42c2d16..f35a59c5f 100644 --- a/src/target/target_type.h +++ b/src/target/target_type.h @@ -303,7 +303,7 @@ struct target_type { /* Return the number of address bits this target supports. This will * typically be 32 for 32-bit targets, and 64 for 64-bit targets. If not * implemented, it's assumed to be 32. */ - unsigned (*address_bits)(struct target *target); + unsigned int (*address_bits)(struct target *target); /* Return the number of system bus data bits this target supports. This * will typically be 32 for 32-bit targets, and 64 for 64-bit targets. If diff --git a/src/target/x86_32_common.c b/src/target/x86_32_common.c index 666bb07bf..2c60b9f7e 100644 --- a/src/target/x86_32_common.c +++ b/src/target/x86_32_common.c @@ -1330,14 +1330,14 @@ static int write_hw_reg_from_cache(struct target *t, int num) /* x86 32 commands */ static void handle_iod_output(struct command_invocation *cmd, - struct target *target, uint32_t address, unsigned size, - unsigned count, const uint8_t *buffer) + struct target *target, uint32_t address, unsigned int size, + unsigned int count, const uint8_t *buffer) { - const unsigned line_bytecnt = 32; - unsigned line_modulo = line_bytecnt / size; + const unsigned int line_bytecnt = 32; + unsigned int line_modulo = line_bytecnt / size; char output[line_bytecnt * 4 + 1]; - unsigned output_len = 0; + unsigned int output_len = 0; const char *value_fmt; switch (size) { @@ -1356,7 +1356,7 @@ static void handle_iod_output(struct command_invocation *cmd, return; } - for (unsigned i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { if (i % line_modulo == 0) { output_len += snprintf(output + output_len, sizeof(output) - output_len, @@ -1399,7 +1399,7 @@ COMMAND_HANDLER(handle_iod_command) return ERROR_COMMAND_SYNTAX_ERROR; } - unsigned size = 0; + unsigned int size = 0; switch (CMD_NAME[2]) { case 'w': size = 4; @@ -1413,7 +1413,7 @@ COMMAND_HANDLER(handle_iod_command) default: return ERROR_COMMAND_SYNTAX_ERROR; } - unsigned count = 1; + unsigned int count = 1; uint8_t *buffer = calloc(count, size); struct target *target = get_current_target(CMD_CTX); int retval = x86_32_common_read_io(target, address, size, buffer); @@ -1425,7 +1425,7 @@ COMMAND_HANDLER(handle_iod_command) static int target_fill_io(struct target *target, uint32_t address, - unsigned data_size, + unsigned int data_size, /* value */ uint32_t b) { @@ -1458,7 +1458,7 @@ COMMAND_HANDLER(handle_iow_command) COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); struct target *target = get_current_target(CMD_CTX); - unsigned wordsize; + unsigned int wordsize; switch (CMD_NAME[2]) { case 'w': wordsize = 4; diff --git a/src/target/xscale.c b/src/target/xscale.c index fbf43516d..155abaef1 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -840,7 +840,7 @@ static int xscale_debug_entry(struct target *target) struct arm *arm = &xscale->arm; uint32_t pc; uint32_t buffer[10]; - unsigned i; + unsigned int i; int retval; uint32_t moe; @@ -1515,7 +1515,7 @@ static int xscale_deassert_reset(struct target *target) */ { uint32_t address; - unsigned buf_cnt; + unsigned int buf_cnt; const uint8_t *buffer = xscale_debug_handler; int retval; @@ -1539,11 +1539,11 @@ static int xscale_deassert_reset(struct target *target) * coprocessors, trace data, etc. */ address = xscale->handler_address; - for (unsigned binary_size = sizeof(xscale_debug_handler); + for (unsigned int binary_size = sizeof(xscale_debug_handler); binary_size > 0; binary_size -= buf_cnt, buffer += buf_cnt) { uint32_t cache_line[8]; - unsigned i; + unsigned int i; buf_cnt = binary_size; if (buf_cnt > 32) @@ -3215,7 +3215,7 @@ COMMAND_HANDLER(xscale_handle_idcache_command) static const struct { char name[15]; - unsigned mask; + unsigned int mask; } vec_ids[] = { { "fiq", DCSR_TF, }, { "irq", DCSR_TI, }, @@ -3250,7 +3250,7 @@ COMMAND_HANDLER(xscale_handle_vector_catch_command) } } while (CMD_ARGC-- > 0) { - unsigned i; + unsigned int i; for (i = 0; i < ARRAY_SIZE(vec_ids); i++) { if (strcmp(CMD_ARGV[CMD_ARGC], vec_ids[i].name)) continue; @@ -3268,7 +3268,7 @@ COMMAND_HANDLER(xscale_handle_vector_catch_command) } dcsr_value = buf_get_u32(dcsr_reg->value, 0, 32); - for (unsigned i = 0; i < ARRAY_SIZE(vec_ids); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(vec_ids); i++) { command_print(CMD, "%15s: %s", vec_ids[i].name, (dcsr_value & vec_ids[i].mask) ? "catch" : "ignore"); } From a64dc23bf19fb4a7626fbda3c02693523ab5a75b Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 8 Sep 2024 21:21:35 +0200 Subject: [PATCH 11/44] jtag: convert 'unsigned' to 'unsigned int' Conversion done with checkpatch --fix-inplace -types UNSPECIFIED_INT Ignore the cast as they could be better addressed. Fix only minor additional checkpatch issue (spacing and line length). Change-Id: I2c1ef03bbc828112cc5bea89463cff9fc0c1e94f Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8481 Reviewed-by: zapb Tested-by: jenkins --- src/jtag/adapter.c | 12 ++-- src/jtag/core.c | 4 +- src/jtag/drivers/bitbang.c | 10 ++-- src/jtag/drivers/cmsis_dap.c | 4 +- src/jtag/drivers/driver.c | 2 +- src/jtag/drivers/ft232r.c | 10 ++-- src/jtag/drivers/ftdi.c | 12 ++-- src/jtag/drivers/jlink.c | 30 +++++----- src/jtag/drivers/jtag_vpi.c | 2 +- src/jtag/drivers/libusb_helper.c | 2 +- src/jtag/drivers/minidriver_imp.h | 2 +- src/jtag/drivers/mpsse.c | 58 +++++++++---------- src/jtag/drivers/mpsse.h | 18 +++--- src/jtag/drivers/stlink_usb.c | 2 +- .../usb_blaster/ublast2_access_libusb.c | 2 +- src/jtag/drivers/usb_blaster/ublast_access.h | 2 +- .../drivers/usb_blaster/ublast_access_ftdi.c | 2 +- src/jtag/drivers/usb_blaster/usb_blaster.c | 2 +- src/jtag/drivers/xlnx-pcie-xvc.c | 2 +- src/jtag/interface.c | 14 ++--- src/jtag/interface.h | 4 +- src/jtag/minidriver.h | 2 +- src/jtag/swd.h | 14 ++--- src/jtag/tcl.c | 8 +-- 24 files changed, 110 insertions(+), 110 deletions(-) diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index bbf1cb3d2..996a23f1f 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -401,7 +401,7 @@ COMMAND_HANDLER(adapter_transports_command) retval = allow_transports(CMD_CTX, (const char **)transports); if (retval != ERROR_OK) { - for (unsigned i = 0; transports[i]; i++) + for (unsigned int i = 0; transports[i]; i++) free(transports[i]); free(transports); } @@ -414,7 +414,7 @@ COMMAND_HANDLER(handle_adapter_list_command) return ERROR_COMMAND_SYNTAX_ERROR; command_print(CMD, "The following debug adapters are available:"); - for (unsigned i = 0; adapter_drivers[i]; i++) { + for (unsigned int i = 0; adapter_drivers[i]; i++) { const char *name = adapter_drivers[i]->name; command_print(CMD, "%u: %s", i + 1, name); } @@ -436,7 +436,7 @@ COMMAND_HANDLER(handle_adapter_driver_command) if (CMD_ARGC != 1 || CMD_ARGV[0][0] == '\0') return ERROR_COMMAND_SYNTAX_ERROR; - for (unsigned i = 0; adapter_drivers[i]; i++) { + for (unsigned int i = 0; adapter_drivers[i]; i++) { if (strcmp(CMD_ARGV[0], adapter_drivers[i]->name) != 0) continue; @@ -684,7 +684,7 @@ COMMAND_HANDLER(handle_adapter_srst_delay_command) if (CMD_ARGC > 1) return ERROR_COMMAND_SYNTAX_ERROR; if (CMD_ARGC == 1) { - unsigned delay; + unsigned int delay; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay); jtag_set_nsrst_delay(delay); @@ -698,7 +698,7 @@ COMMAND_HANDLER(handle_adapter_srst_pulse_width_command) if (CMD_ARGC > 1) return ERROR_COMMAND_SYNTAX_ERROR; if (CMD_ARGC == 1) { - unsigned width; + unsigned int width; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], width); jtag_set_nsrst_assert_width(width); @@ -714,7 +714,7 @@ COMMAND_HANDLER(handle_adapter_speed_command) int retval = ERROR_OK; if (CMD_ARGC == 1) { - unsigned khz = 0; + unsigned int khz = 0; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], khz); retval = adapter_config_khz(khz); diff --git a/src/jtag/core.c b/src/jtag/core.c index 6515d7160..907883f09 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -224,7 +224,7 @@ static void jtag_tap_add(struct jtag_tap *t) } /* returns a pointer to the n-th device in the scan chain */ -struct jtag_tap *jtag_tap_by_position(unsigned n) +struct jtag_tap *jtag_tap_by_position(unsigned int n) { struct jtag_tap *t = jtag_all_taps(); @@ -246,7 +246,7 @@ struct jtag_tap *jtag_tap_by_string(const char *s) } /* no tap found by name, so try to parse the name as a number */ - unsigned n; + unsigned int n; if (parse_uint(s, &n) != ERROR_OK) return NULL; diff --git a/src/jtag/drivers/bitbang.c b/src/jtag/drivers/bitbang.c index e41659263..17e01a233 100644 --- a/src/jtag/drivers/bitbang.c +++ b/src/jtag/drivers/bitbang.c @@ -92,13 +92,13 @@ static int bitbang_state_move(int skip) */ static int bitbang_execute_tms(struct jtag_command *cmd) { - unsigned num_bits = cmd->cmd.tms->num_bits; + unsigned int num_bits = cmd->cmd.tms->num_bits; const uint8_t *bits = cmd->cmd.tms->bits; LOG_DEBUG_IO("TMS: %u bits", num_bits); int tms = 0; - for (unsigned i = 0; i < num_bits; i++) { + for (unsigned int i = 0; i < num_bits; i++) { tms = ((bits[i/8] >> (i % 8)) & 1); if (bitbang_interface->write(0, tms, 0) != ERROR_OK) return ERROR_FAIL; @@ -193,10 +193,10 @@ static int bitbang_stableclocks(unsigned int num_cycles) } static int bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, - unsigned scan_size) + unsigned int scan_size) { tap_state_t saved_end_state = tap_get_end_state(); - unsigned bit_cnt; + unsigned int bit_cnt; if (!((!ir_scan && (tap_get_state() == TAP_DRSHIFT)) || @@ -254,7 +254,7 @@ static int bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, if (type != SCAN_OUT && bitbang_interface->buf_size && (buffered == bitbang_interface->buf_size || bit_cnt == scan_size - 1)) { - for (unsigned i = bit_cnt + 1 - buffered; i <= bit_cnt; i++) { + for (unsigned int i = bit_cnt + 1 - buffered; i <= bit_cnt; i++) { switch (bitbang_interface->read_sample()) { case BB_LOW: buffer[i/8] &= ~(1 << (i % 8)); diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index 4ba6b51be..2f776cb38 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -2153,7 +2153,7 @@ COMMAND_HANDLER(cmsis_dap_handle_cmd_command) { uint8_t *command = cmsis_dap_handle->command; - for (unsigned i = 0; i < CMD_ARGC; i++) + for (unsigned int i = 0; i < CMD_ARGC; i++) COMMAND_PARSE_NUMBER(u8, CMD_ARGV[i], command[i]); int retval = cmsis_dap_xfer(cmsis_dap_handle, CMD_ARGC); @@ -2185,7 +2185,7 @@ COMMAND_HANDLER(cmsis_dap_handle_vid_pid_command) CMD_ARGC -= 1; } - unsigned i; + unsigned int i; for (i = 0; i < CMD_ARGC; i += 2) { COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i], cmsis_dap_vid[i >> 1]); COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], cmsis_dap_pid[i >> 1]); diff --git a/src/jtag/drivers/driver.c b/src/jtag/drivers/driver.c index 2aad4a0c1..d52a345a0 100644 --- a/src/jtag/drivers/driver.c +++ b/src/jtag/drivers/driver.c @@ -234,7 +234,7 @@ int interface_jtag_add_tlr(void) return ERROR_OK; } -int interface_add_tms_seq(unsigned num_bits, const uint8_t *seq, enum tap_state state) +int interface_add_tms_seq(unsigned int num_bits, const uint8_t *seq, enum tap_state state) { struct jtag_command *cmd; diff --git a/src/jtag/drivers/ft232r.c b/src/jtag/drivers/ft232r.c index a4d072cd7..6dc130493 100644 --- a/src/jtag/drivers/ft232r.c +++ b/src/jtag/drivers/ft232r.c @@ -177,7 +177,7 @@ static void ft232r_increase_buf_size(size_t new_buf_size) */ static void ft232r_write(int tck, int tms, int tdi) { - unsigned out_value = (1<cmd.tms->num_bits; + unsigned int num_bits = cmd->cmd.tms->num_bits; const uint8_t *bits = cmd->cmd.tms->bits; LOG_DEBUG_IO("TMS: %u bits", num_bits); int tms = 0; - for (unsigned i = 0; i < num_bits; i++) { + for (unsigned int i = 0; i < num_bits; i++) { tms = ((bits[i/8] >> (i % 8)) & 1); ft232r_write(0, tms, 0); ft232r_write(1, tms, 0); diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c index 82117f12c..42ecda117 100644 --- a/src/jtag/drivers/ftdi.c +++ b/src/jtag/drivers/ftdi.c @@ -324,7 +324,7 @@ static void ftdi_execute_runtest(struct jtag_command *cmd) unsigned int i = cmd->cmd.runtest->num_cycles; while (i > 0) { /* there are no state transitions in this code, so omit state tracking */ - unsigned this_len = i > 7 ? 7 : i; + unsigned int this_len = i > 7 ? 7 : i; mpsse_clock_tms_cs_out(mpsse_ctx, &zero, 0, this_len, false, ftdi_jtag_mode); i -= this_len; } @@ -378,7 +378,7 @@ static void ftdi_execute_pathmove(struct jtag_command *cmd) tap_state_name(path[num_states-1])); int state_count = 0; - unsigned bit_count = 0; + unsigned int bit_count = 0; uint8_t tms_byte = 0; LOG_DEBUG_IO("-"); @@ -447,7 +447,7 @@ static void ftdi_execute_scan(struct jtag_command *cmd) ftdi_end_state(cmd->cmd.scan->end_state); struct scan_field *field = cmd->cmd.scan->fields; - unsigned scan_size = 0; + unsigned int scan_size = 0; for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) { scan_size += field->num_bits; @@ -584,7 +584,7 @@ static void ftdi_execute_stableclocks(struct jtag_command *cmd) * the correct level and remain there during the scan */ while (num_cycles > 0) { /* there are no state transitions in this code, so omit state tracking */ - unsigned this_len = num_cycles > 7 ? 7 : num_cycles; + unsigned int this_len = num_cycles > 7 ? 7 : num_cycles; mpsse_clock_tms_cs_out(mpsse_ctx, &tms, 0, this_len, false, ftdi_jtag_mode); num_cycles -= this_len; } @@ -750,7 +750,7 @@ COMMAND_HANDLER(ftdi_handle_layout_signal_command) uint16_t input_mask = 0; bool invert_oe = false; uint16_t oe_mask = 0; - for (unsigned i = 1; i < CMD_ARGC; i += 2) { + for (unsigned int i = 1; i < CMD_ARGC; i += 2) { if (strcmp("-data", CMD_ARGV[i]) == 0) { invert_data = false; COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], data_mask); @@ -879,7 +879,7 @@ COMMAND_HANDLER(ftdi_handle_vid_pid_command) CMD_ARGC -= 1; } - unsigned i; + unsigned int i; for (i = 0; i < CMD_ARGC; i += 2) { COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i], ftdi_vid[i >> 1]); COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], ftdi_pid[i >> 1]); diff --git a/src/jtag/drivers/jlink.c b/src/jtag/drivers/jlink.c index 1b2fb4e30..74660744a 100644 --- a/src/jtag/drivers/jlink.c +++ b/src/jtag/drivers/jlink.c @@ -104,10 +104,10 @@ static int jlink_flush(void); * @param in_offset A bit offset for TDO data. * @param length Amount of bits to transfer out and in. */ -static void jlink_clock_data(const uint8_t *out, unsigned out_offset, - const uint8_t *tms_out, unsigned tms_offset, - uint8_t *in, unsigned in_offset, - unsigned length); +static void jlink_clock_data(const uint8_t *out, unsigned int out_offset, + const uint8_t *tms_out, unsigned int tms_offset, + uint8_t *in, unsigned int in_offset, + unsigned int length); static enum tap_state jlink_last_state = TAP_RESET; static int queued_retval; @@ -179,7 +179,7 @@ static void jlink_execute_scan(struct jtag_command *cmd) jlink_end_state(cmd->cmd.scan->end_state); struct scan_field *field = cmd->cmd.scan->fields; - unsigned scan_size = 0; + unsigned int scan_size = 0; for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) { scan_size += field->num_bits; @@ -1962,7 +1962,7 @@ static void jlink_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_c /***************************************************************************/ /* J-Link tap functions */ -static unsigned tap_length; +static unsigned int tap_length; /* In SWD mode use tms buffer for direction control */ static uint8_t tms_buffer[JLINK_TAP_BUFFER_SIZE]; static uint8_t tdi_buffer[JLINK_TAP_BUFFER_SIZE]; @@ -1970,13 +1970,13 @@ static uint8_t tdo_buffer[JLINK_TAP_BUFFER_SIZE]; struct pending_scan_result { /** First bit position in tdo_buffer to read. */ - unsigned first; + unsigned int first; /** Number of bits to read. */ - unsigned length; + unsigned int length; /** Location to store the result */ void *buffer; /** Offset in the destination buffer */ - unsigned buffer_offset; + unsigned int buffer_offset; /** SWD command */ uint8_t swd_cmd; }; @@ -1994,13 +1994,13 @@ static void jlink_tap_init(void) memset(tdi_buffer, 0, sizeof(tdi_buffer)); } -static void jlink_clock_data(const uint8_t *out, unsigned out_offset, - const uint8_t *tms_out, unsigned tms_offset, - uint8_t *in, unsigned in_offset, - unsigned length) +static void jlink_clock_data(const uint8_t *out, unsigned int out_offset, + const uint8_t *tms_out, unsigned int tms_offset, + uint8_t *in, unsigned int in_offset, + unsigned int length) { do { - unsigned available_length = JLINK_TAP_BUFFER_SIZE - tap_length / 8; + unsigned int available_length = JLINK_TAP_BUFFER_SIZE - tap_length / 8; if (!available_length || (in && pending_scan_results_length == MAX_PENDING_SCAN_RESULTS)) { @@ -2012,7 +2012,7 @@ static void jlink_clock_data(const uint8_t *out, unsigned out_offset, struct pending_scan_result *pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length]; - unsigned scan_length = length > available_length ? + unsigned int scan_length = length > available_length ? available_length : length; if (out) diff --git a/src/jtag/drivers/jtag_vpi.c b/src/jtag/drivers/jtag_vpi.c index 15b2679bb..079bb1d0a 100644 --- a/src/jtag/drivers/jtag_vpi.c +++ b/src/jtag/drivers/jtag_vpi.c @@ -158,7 +158,7 @@ retry_write: static int jtag_vpi_receive_cmd(struct vpi_cmd *vpi) { - unsigned bytes_buffered = 0; + unsigned int bytes_buffered = 0; while (bytes_buffered < sizeof(struct vpi_cmd)) { int bytes_to_receive = sizeof(struct vpi_cmd) - bytes_buffered; int retval = read_socket(sockfd, ((char *)vpi) + bytes_buffered, bytes_to_receive); diff --git a/src/jtag/drivers/libusb_helper.c b/src/jtag/drivers/libusb_helper.c index 57ea8cd3f..ee90e78b3 100644 --- a/src/jtag/drivers/libusb_helper.c +++ b/src/jtag/drivers/libusb_helper.c @@ -53,7 +53,7 @@ static int jtag_libusb_error(int err) bool jtag_libusb_match_ids(struct libusb_device_descriptor *dev_desc, const uint16_t vids[], const uint16_t pids[]) { - for (unsigned i = 0; vids[i]; i++) { + for (unsigned int i = 0; vids[i]; i++) { if (dev_desc->idVendor == vids[i] && dev_desc->idProduct == pids[i]) { return true; diff --git a/src/jtag/drivers/minidriver_imp.h b/src/jtag/drivers/minidriver_imp.h index 7afb46345..b29b3c9cc 100644 --- a/src/jtag/drivers/minidriver_imp.h +++ b/src/jtag/drivers/minidriver_imp.h @@ -13,7 +13,7 @@ static inline void interface_jtag_add_scan_check_alloc(struct scan_field *field) { - unsigned num_bytes = DIV_ROUND_UP(field->num_bits, 8); + unsigned int num_bytes = DIV_ROUND_UP(field->num_bits, 8); field->in_value = cmd_queue_alloc(num_bytes); } diff --git a/src/jtag/drivers/mpsse.c b/src/jtag/drivers/mpsse.c index 3decddb0e..1ef9550a0 100644 --- a/src/jtag/drivers/mpsse.c +++ b/src/jtag/drivers/mpsse.c @@ -64,13 +64,13 @@ struct mpsse_ctx { uint8_t interface; enum ftdi_chip_type type; uint8_t *write_buffer; - unsigned write_size; - unsigned write_count; + unsigned int write_size; + unsigned int write_count; uint8_t *read_buffer; - unsigned read_size; - unsigned read_count; + unsigned int read_size; + unsigned int read_count; uint8_t *read_chunk; - unsigned read_chunk_size; + unsigned int read_chunk_size; struct bit_copy_queue read_queue; int retval; }; @@ -444,13 +444,13 @@ void mpsse_purge(struct mpsse_ctx *ctx) } } -static unsigned buffer_write_space(struct mpsse_ctx *ctx) +static unsigned int buffer_write_space(struct mpsse_ctx *ctx) { /* Reserve one byte for SEND_IMMEDIATE */ return ctx->write_size - ctx->write_count - 1; } -static unsigned buffer_read_space(struct mpsse_ctx *ctx) +static unsigned int buffer_read_space(struct mpsse_ctx *ctx) { return ctx->read_size - ctx->read_count; } @@ -462,8 +462,8 @@ static void buffer_write_byte(struct mpsse_ctx *ctx, uint8_t data) ctx->write_buffer[ctx->write_count++] = data; } -static unsigned buffer_write(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, - unsigned bit_count) +static unsigned int buffer_write(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, + unsigned int bit_count) { LOG_DEBUG_IO("%d bits", bit_count); assert(ctx->write_count + DIV_ROUND_UP(bit_count, 8) <= ctx->write_size); @@ -472,8 +472,8 @@ static unsigned buffer_write(struct mpsse_ctx *ctx, const uint8_t *out, unsigned return bit_count; } -static unsigned buffer_add_read(struct mpsse_ctx *ctx, uint8_t *in, unsigned in_offset, - unsigned bit_count, unsigned offset) +static unsigned int buffer_add_read(struct mpsse_ctx *ctx, uint8_t *in, unsigned int in_offset, + unsigned int bit_count, unsigned int offset) { LOG_DEBUG_IO("%d bits, offset %d", bit_count, offset); assert(ctx->read_count + DIV_ROUND_UP(bit_count, 8) <= ctx->read_size); @@ -483,20 +483,20 @@ static unsigned buffer_add_read(struct mpsse_ctx *ctx, uint8_t *in, unsigned in_ return bit_count; } -void mpsse_clock_data_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, - unsigned length, uint8_t mode) +void mpsse_clock_data_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, + unsigned int length, uint8_t mode) { mpsse_clock_data(ctx, out, out_offset, NULL, 0, length, mode); } -void mpsse_clock_data_in(struct mpsse_ctx *ctx, uint8_t *in, unsigned in_offset, unsigned length, +void mpsse_clock_data_in(struct mpsse_ctx *ctx, uint8_t *in, unsigned int in_offset, unsigned int length, uint8_t mode) { mpsse_clock_data(ctx, NULL, 0, in, in_offset, length, mode); } -void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, uint8_t *in, - unsigned in_offset, unsigned length, uint8_t mode) +void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, uint8_t *in, + unsigned int in_offset, unsigned int length, uint8_t mode) { /* TODO: Fix MSB first modes */ LOG_DEBUG_IO("%s%s %d bits", in ? "in" : "", out ? "out" : "", length); @@ -531,7 +531,7 @@ void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_of length = 0; } else { /* Byte transfer */ - unsigned this_bytes = length / 8; + unsigned int this_bytes = length / 8; /* MPSSE command limit */ if (this_bytes > 65536) this_bytes = 65536; @@ -558,7 +558,7 @@ void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_of this_bytes * 8, 0); if (!out && !in) - for (unsigned n = 0; n < this_bytes; n++) + for (unsigned int n = 0; n < this_bytes; n++) buffer_write_byte(ctx, 0x00); length -= this_bytes * 8; } @@ -566,14 +566,14 @@ void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_of } } -void mpsse_clock_tms_cs_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, - unsigned length, bool tdi, uint8_t mode) +void mpsse_clock_tms_cs_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, + unsigned int length, bool tdi, uint8_t mode) { mpsse_clock_tms_cs(ctx, out, out_offset, NULL, 0, length, tdi, mode); } -void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, uint8_t *in, - unsigned in_offset, unsigned length, bool tdi, uint8_t mode) +void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, uint8_t *in, + unsigned int in_offset, unsigned int length, bool tdi, uint8_t mode) { LOG_DEBUG_IO("%sout %d bits, tdi=%d", in ? "in" : "", length, tdi); assert(out); @@ -593,7 +593,7 @@ void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_ ctx->retval = mpsse_flush(ctx); /* Byte transfer */ - unsigned this_bits = length; + unsigned int this_bits = length; /* MPSSE command limit */ /* NOTE: there's a report of an FT2232 bug in this area, where shifting * exactly 7 bits can make problems with TMS signaling for the last @@ -783,7 +783,7 @@ int mpsse_set_frequency(struct mpsse_ctx *ctx, int frequency) struct transfer_result { struct mpsse_ctx *ctx; bool done; - unsigned transferred; + unsigned int transferred; }; static LIBUSB_CALL void read_cb(struct libusb_transfer *transfer) @@ -791,16 +791,16 @@ static LIBUSB_CALL void read_cb(struct libusb_transfer *transfer) struct transfer_result *res = transfer->user_data; struct mpsse_ctx *ctx = res->ctx; - unsigned packet_size = ctx->max_packet_size; + unsigned int packet_size = ctx->max_packet_size; DEBUG_PRINT_BUF(transfer->buffer, transfer->actual_length); /* Strip the two status bytes sent at the beginning of each USB packet * while copying the chunk buffer to the read buffer */ - unsigned num_packets = DIV_ROUND_UP(transfer->actual_length, packet_size); - unsigned chunk_remains = transfer->actual_length; - for (unsigned i = 0; i < num_packets && chunk_remains > 2; i++) { - unsigned this_size = packet_size - 2; + unsigned int num_packets = DIV_ROUND_UP(transfer->actual_length, packet_size); + unsigned int chunk_remains = transfer->actual_length; + for (unsigned int i = 0; i < num_packets && chunk_remains > 2; i++) { + unsigned int this_size = packet_size - 2; if (this_size > chunk_remains - 2) this_size = chunk_remains - 2; if (this_size > ctx->read_count - res->transferred) diff --git a/src/jtag/drivers/mpsse.h b/src/jtag/drivers/mpsse.h index 737560d95..4a625d890 100644 --- a/src/jtag/drivers/mpsse.h +++ b/src/jtag/drivers/mpsse.h @@ -44,16 +44,16 @@ bool mpsse_is_high_speed(struct mpsse_ctx *ctx); /* Command queuing. These correspond to the MPSSE commands with the same names, but no need to care * about bit/byte transfer or data length limitation. Read data is guaranteed to be available only * after the following mpsse_flush(). */ -void mpsse_clock_data_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, - unsigned length, uint8_t mode); -void mpsse_clock_data_in(struct mpsse_ctx *ctx, uint8_t *in, unsigned in_offset, unsigned length, +void mpsse_clock_data_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, + unsigned int length, uint8_t mode); +void mpsse_clock_data_in(struct mpsse_ctx *ctx, uint8_t *in, unsigned int in_offset, unsigned int length, uint8_t mode); -void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, uint8_t *in, - unsigned in_offset, unsigned length, uint8_t mode); -void mpsse_clock_tms_cs_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, - unsigned length, bool tdi, uint8_t mode); -void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, uint8_t *in, - unsigned in_offset, unsigned length, bool tdi, uint8_t mode); +void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, uint8_t *in, + unsigned int in_offset, unsigned int length, uint8_t mode); +void mpsse_clock_tms_cs_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, + unsigned int length, bool tdi, uint8_t mode); +void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, uint8_t *in, + unsigned int in_offset, unsigned int length, bool tdi, uint8_t mode); void mpsse_set_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir); void mpsse_set_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir); void mpsse_read_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t *data); diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c index 8cf3b0c73..812a192c2 100644 --- a/src/jtag/drivers/stlink_usb.c +++ b/src/jtag/drivers/stlink_usb.c @@ -3740,7 +3740,7 @@ static int stlink_open(struct hl_interface_param *param, enum stlink_mode mode, h->st_mode = mode; - for (unsigned i = 0; param->vid[i]; i++) { + for (unsigned int i = 0; param->vid[i]; i++) { LOG_DEBUG("transport: %d vid: 0x%04x pid: 0x%04x serial: %s", h->st_mode, param->vid[i], param->pid[i], adapter_get_required_serial() ? adapter_get_required_serial() : ""); diff --git a/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c b/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c index de0d2d847..e790f3ae5 100644 --- a/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c +++ b/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c @@ -30,7 +30,7 @@ #define SECTION_BUFFERSIZE 16384 static int ublast2_libusb_read(struct ublast_lowlevel *low, uint8_t *buf, - unsigned size, uint32_t *bytes_read) + unsigned int size, uint32_t *bytes_read) { int ret, tmp = 0; diff --git a/src/jtag/drivers/usb_blaster/ublast_access.h b/src/jtag/drivers/usb_blaster/ublast_access.h index 3e138bd23..e9c926813 100644 --- a/src/jtag/drivers/usb_blaster/ublast_access.h +++ b/src/jtag/drivers/usb_blaster/ublast_access.h @@ -30,7 +30,7 @@ struct ublast_lowlevel { int (*write)(struct ublast_lowlevel *low, uint8_t *buf, int size, uint32_t *bytes_written); - int (*read)(struct ublast_lowlevel *low, uint8_t *buf, unsigned size, + int (*read)(struct ublast_lowlevel *low, uint8_t *buf, unsigned int size, uint32_t *bytes_read); int (*open)(struct ublast_lowlevel *low); int (*close)(struct ublast_lowlevel *low); diff --git a/src/jtag/drivers/usb_blaster/ublast_access_ftdi.c b/src/jtag/drivers/usb_blaster/ublast_access_ftdi.c index eb312ef4e..9647f2b82 100644 --- a/src/jtag/drivers/usb_blaster/ublast_access_ftdi.c +++ b/src/jtag/drivers/usb_blaster/ublast_access_ftdi.c @@ -28,7 +28,7 @@ static struct ftdi_context *ublast_getftdic(struct ublast_lowlevel *low) } static int ublast_ftdi_read(struct ublast_lowlevel *low, uint8_t *buf, - unsigned size, uint32_t *bytes_read) + unsigned int size, uint32_t *bytes_read) { int retval; int timeout = 100; diff --git a/src/jtag/drivers/usb_blaster/usb_blaster.c b/src/jtag/drivers/usb_blaster/usb_blaster.c index 53dd158f6..496466ca3 100644 --- a/src/jtag/drivers/usb_blaster/usb_blaster.c +++ b/src/jtag/drivers/usb_blaster/usb_blaster.c @@ -158,7 +158,7 @@ static char *hexdump(uint8_t *buf, unsigned int size) return str; } -static int ublast_buf_read(uint8_t *buf, unsigned size, uint32_t *bytes_read) +static int ublast_buf_read(uint8_t *buf, unsigned int size, uint32_t *bytes_read) { int ret = info.drv->read(info.drv, buf, size, bytes_read); char *str = hexdump(buf, *bytes_read); diff --git a/src/jtag/drivers/xlnx-pcie-xvc.c b/src/jtag/drivers/xlnx-pcie-xvc.c index b5c7e2fd6..d90a022cd 100644 --- a/src/jtag/drivers/xlnx-pcie-xvc.c +++ b/src/jtag/drivers/xlnx-pcie-xvc.c @@ -43,7 +43,7 @@ struct xlnx_pcie_xvc { int fd; - unsigned offset; + unsigned int offset; char *device; }; diff --git a/src/jtag/interface.c b/src/jtag/interface.c index 1230bb1b3..87d704db9 100644 --- a/src/jtag/interface.c +++ b/src/jtag/interface.c @@ -343,7 +343,7 @@ static const struct name_mapping { const char *tap_state_name(tap_state_t state) { - unsigned i; + unsigned int i; for (i = 0; i < ARRAY_SIZE(tap_name_mapping); i++) { if (tap_name_mapping[i].symbol == state) @@ -354,7 +354,7 @@ const char *tap_state_name(tap_state_t state) tap_state_t tap_state_by_name(const char *name) { - unsigned i; + unsigned int i; for (i = 0; i < ARRAY_SIZE(tap_name_mapping); i++) { /* be nice to the human */ @@ -376,11 +376,11 @@ tap_state_t jtag_debug_state_machine_(const void *tms_buf, const void *tdi_buf, { const uint8_t *tms_buffer; const uint8_t *tdi_buffer; - unsigned tap_bytes; - unsigned cur_byte; - unsigned cur_bit; + unsigned int tap_bytes; + unsigned int cur_byte; + unsigned int cur_bit; - unsigned tap_out_bits; + unsigned int tap_out_bits; char tms_str[33]; char tdi_str[33]; @@ -400,7 +400,7 @@ tap_state_t jtag_debug_state_machine_(const void *tms_buf, const void *tdi_buf, for (cur_byte = 0; cur_byte < tap_bytes; cur_byte++) { for (cur_bit = 0; cur_bit < 8; cur_bit++) { /* make sure we do not run off the end of the buffers */ - unsigned tap_bit = cur_byte * 8 + cur_bit; + unsigned int tap_bit = cur_byte * 8 + cur_bit; if (tap_bit == tap_bits) break; diff --git a/src/jtag/interface.h b/src/jtag/interface.h index 28c1458cb..b448851dc 100644 --- a/src/jtag/interface.h +++ b/src/jtag/interface.h @@ -159,7 +159,7 @@ tap_state_t jtag_debug_state_machine_(const void *tms_buf, const void *tdi_buf, * @returns the final TAP state; pass as @a start_tap_state in following call. */ static inline tap_state_t jtag_debug_state_machine(const void *tms_buf, - const void *tdi_buf, unsigned tap_len, tap_state_t start_tap_state) + const void *tdi_buf, unsigned int tap_len, tap_state_t start_tap_state) { if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) return jtag_debug_state_machine_(tms_buf, tdi_buf, tap_len, start_tap_state); @@ -183,7 +183,7 @@ struct jtag_interface { /** * Bit vector listing capabilities exposed by this driver. */ - unsigned supported; + unsigned int supported; #define DEBUG_CAP_TMS_SEQ (1 << 0) /** diff --git a/src/jtag/minidriver.h b/src/jtag/minidriver.h index 45b0bf619..1b1094dd5 100644 --- a/src/jtag/minidriver.h +++ b/src/jtag/minidriver.h @@ -54,7 +54,7 @@ int interface_jtag_add_tlr(void); int interface_jtag_add_pathmove(unsigned int num_states, const tap_state_t *path); int interface_jtag_add_runtest(unsigned int num_cycles, tap_state_t endstate); -int interface_add_tms_seq(unsigned num_bits, +int interface_add_tms_seq(unsigned int num_bits, const uint8_t *bits, enum tap_state state); /** diff --git a/src/jtag/swd.h b/src/jtag/swd.h index 5f626c1bf..3fe1365b5 100644 --- a/src/jtag/swd.h +++ b/src/jtag/swd.h @@ -101,7 +101,7 @@ static const uint8_t swd_seq_line_reset[] = { /* At least 2 idle (low) cycles */ 0x00, }; -static const unsigned swd_seq_line_reset_len = 64; +static const unsigned int swd_seq_line_reset_len = 64; /** * JTAG-to-SWD sequence. @@ -122,7 +122,7 @@ static const uint8_t swd_seq_jtag_to_swd[] = { /* At least 2 idle (low) cycles */ 0x00, }; -static const unsigned swd_seq_jtag_to_swd_len = 136; +static const unsigned int swd_seq_jtag_to_swd_len = 136; /** * SWD-to-JTAG sequence. @@ -141,7 +141,7 @@ static const uint8_t swd_seq_swd_to_jtag[] = { /* At least 5 TCK/SWCLK cycles with TMS/SWDIO high */ 0xff, }; -static const unsigned swd_seq_swd_to_jtag_len = 80; +static const unsigned int swd_seq_swd_to_jtag_len = 80; /** * SWD-to-dormant sequence. @@ -156,7 +156,7 @@ static const uint8_t swd_seq_swd_to_dormant[] = { /* Switching sequence from SWD to dormant */ 0xbc, 0xe3, }; -static const unsigned swd_seq_swd_to_dormant_len = 72; +static const unsigned int swd_seq_swd_to_dormant_len = 72; /** * Dormant-to-SWD sequence. @@ -187,7 +187,7 @@ static const uint8_t swd_seq_dormant_to_swd[] = { /* At least 2 idle (low) cycles */ 0x00, }; -static const unsigned swd_seq_dormant_to_swd_len = 224; +static const unsigned int swd_seq_dormant_to_swd_len = 224; /** * JTAG-to-dormant sequence. @@ -208,7 +208,7 @@ static const uint8_t swd_seq_jtag_to_dormant[] = { 0x77, /* ((0xbb >> 7) & GENMASK(0, 0)) | ((0xbb << 1) & GENMASK(7, 1)) */ 0x67, /* ((0xbb >> 7) & GENMASK(0, 0)) | ((0x33 << 1) & GENMASK(7, 1)) */ }; -static const unsigned swd_seq_jtag_to_dormant_len = 40; +static const unsigned int swd_seq_jtag_to_dormant_len = 40; /** * Dormant-to-JTAG sequence. @@ -241,7 +241,7 @@ static const uint8_t swd_seq_dormant_to_jtag[] = { /* put the TAP in Run/Test Idle */ 0x00, }; -static const unsigned swd_seq_dormant_to_jtag_len = 160; +static const unsigned int swd_seq_dormant_to_jtag_len = 160; struct swd_driver { /** diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index e2b3b45a6..790aedfc4 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -843,7 +843,7 @@ COMMAND_HANDLER(handle_jtag_ntrst_delay_command) if (CMD_ARGC > 1) return ERROR_COMMAND_SYNTAX_ERROR; if (CMD_ARGC == 1) { - unsigned delay; + unsigned int delay; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay); jtag_set_ntrst_delay(delay); @@ -857,7 +857,7 @@ COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command) if (CMD_ARGC > 1) return ERROR_COMMAND_SYNTAX_ERROR; if (CMD_ARGC == 1) { - unsigned delay; + unsigned int delay; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay); jtag_set_ntrst_assert_width(delay); @@ -873,7 +873,7 @@ COMMAND_HANDLER(handle_jtag_rclk_command) int retval = ERROR_OK; if (CMD_ARGC == 1) { - unsigned khz = 0; + unsigned int khz = 0; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], khz); retval = adapter_config_rclk(khz); @@ -899,7 +899,7 @@ COMMAND_HANDLER(handle_runtest_command) if (CMD_ARGC != 1) return ERROR_COMMAND_SYNTAX_ERROR; - unsigned num_clocks; + unsigned int num_clocks; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num_clocks); jtag_add_runtest(num_clocks, TAP_IDLE); From 436e6f1770e4da6ec5b52724cfb637e8916b535a Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 8 Sep 2024 21:22:40 +0200 Subject: [PATCH 12/44] openocd: convert 'unsigned' to 'unsigned int' Conversion done with checkpatch --fix-inplace -types UNSPECIFIED_INT Ignore the cast as they could be better addressed. Fix only minor additional checkpatch issue (spacing and line length). Change-Id: I4f936ffc4cedb153afa331cd293b08f4c913dc93 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8482 Tested-by: jenkins --- src/helper/binarybuffer.c | 48 +++++++++++++++++++-------------------- src/helper/binarybuffer.h | 48 +++++++++++++++++++-------------------- src/helper/command.c | 16 ++++++------- src/helper/command.h | 4 ++-- src/helper/log.c | 10 ++++---- src/helper/log.h | 10 ++++---- src/helper/replacements.h | 2 +- src/openocd.c | 2 +- src/rtos/hwthread.c | 2 +- src/svf/svf.c | 4 ++-- src/transport/transport.c | 8 +++---- src/xsvf/xsvf.c | 2 +- 12 files changed, 78 insertions(+), 78 deletions(-) diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index a7ca5af9d..6fba86a66 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -40,7 +40,7 @@ static const char hex_digits[] = { 'a', 'b', 'c', 'd', 'e', 'f' }; -void *buf_cpy(const void *from, void *_to, unsigned size) +void *buf_cpy(const void *from, void *_to, unsigned int size) { if (!from || !_to) return NULL; @@ -49,7 +49,7 @@ void *buf_cpy(const void *from, void *_to, unsigned size) memcpy(_to, from, DIV_ROUND_UP(size, 8)); /* mask out bits that don't belong to the buffer */ - unsigned trailing_bits = size % 8; + unsigned int trailing_bits = size % 8; if (trailing_bits) { uint8_t *to = _to; to[size / 8] &= (1 << trailing_bits) - 1; @@ -61,22 +61,22 @@ static bool buf_eq_masked(uint8_t a, uint8_t b, uint8_t m) { return (a & m) == (b & m); } -static bool buf_eq_trailing(uint8_t a, uint8_t b, uint8_t m, unsigned trailing) +static bool buf_eq_trailing(uint8_t a, uint8_t b, uint8_t m, unsigned int trailing) { uint8_t mask = (1 << trailing) - 1; return buf_eq_masked(a, b, mask & m); } -bool buf_eq(const void *_buf1, const void *_buf2, unsigned size) +bool buf_eq(const void *_buf1, const void *_buf2, unsigned int size) { if (!_buf1 || !_buf2) return _buf1 == _buf2; - unsigned last = size / 8; + unsigned int last = size / 8; if (memcmp(_buf1, _buf2, last) != 0) return false; - unsigned trailing = size % 8; + unsigned int trailing = size % 8; if (!trailing) return true; @@ -85,24 +85,24 @@ bool buf_eq(const void *_buf1, const void *_buf2, unsigned size) } bool buf_eq_mask(const void *_buf1, const void *_buf2, - const void *_mask, unsigned size) + const void *_mask, unsigned int size) { if (!_buf1 || !_buf2) return _buf1 == _buf2 && _buf1 == _mask; const uint8_t *buf1 = _buf1, *buf2 = _buf2, *mask = _mask; - unsigned last = size / 8; - for (unsigned i = 0; i < last; i++) { + unsigned int last = size / 8; + for (unsigned int i = 0; i < last; i++) { if (!buf_eq_masked(buf1[i], buf2[i], mask[i])) return false; } - unsigned trailing = size % 8; + unsigned int trailing = size % 8; if (!trailing) return true; return buf_eq_trailing(buf1[last], buf2[last], mask[last], trailing); } -void *buf_set_ones(void *_buf, unsigned size) +void *buf_set_ones(void *_buf, unsigned int size) { uint8_t *buf = _buf; if (!buf) @@ -110,19 +110,19 @@ void *buf_set_ones(void *_buf, unsigned size) memset(buf, 0xff, size / 8); - unsigned trailing_bits = size % 8; + unsigned int trailing_bits = size % 8; if (trailing_bits) buf[size / 8] = (1 << trailing_bits) - 1; return buf; } -void *buf_set_buf(const void *_src, unsigned src_start, - void *_dst, unsigned dst_start, unsigned len) +void *buf_set_buf(const void *_src, unsigned int src_start, + void *_dst, unsigned int dst_start, unsigned int len) { const uint8_t *src = _src; uint8_t *dst = _dst; - unsigned i, sb, db, sq, dq, lb, lq; + unsigned int i, sb, db, sq, dq, lb, lq; sb = src_start / 8; db = dst_start / 8; @@ -175,13 +175,13 @@ uint32_t flip_u32(uint32_t value, unsigned int num) return c; } -char *buf_to_hex_str(const void *_buf, unsigned buf_len) +char *buf_to_hex_str(const void *_buf, unsigned int buf_len) { - unsigned len_bytes = DIV_ROUND_UP(buf_len, 8); + unsigned int len_bytes = DIV_ROUND_UP(buf_len, 8); char *str = calloc(len_bytes * 2 + 1, 1); const uint8_t *buf = _buf; - for (unsigned i = 0; i < len_bytes; i++) { + for (unsigned int i = 0; i < len_bytes; i++) { uint8_t tmp = buf[len_bytes - i - 1]; if ((i == 0) && (buf_len % 8)) tmp &= (0xff >> (8 - (buf_len % 8))); @@ -289,8 +289,8 @@ void bit_copy_queue_init(struct bit_copy_queue *q) INIT_LIST_HEAD(&q->list); } -int bit_copy_queued(struct bit_copy_queue *q, uint8_t *dst, unsigned dst_offset, const uint8_t *src, - unsigned src_offset, unsigned bit_count) +int bit_copy_queued(struct bit_copy_queue *q, uint8_t *dst, unsigned int dst_offset, const uint8_t *src, + unsigned int src_offset, unsigned int bit_count) { struct bit_copy_queue_entry *qe = malloc(sizeof(*qe)); if (!qe) @@ -395,12 +395,12 @@ size_t hexify(char *hex, const uint8_t *bin, size_t count, size_t length) return i; } -void buffer_shr(void *_buf, unsigned buf_len, unsigned count) +void buffer_shr(void *_buf, unsigned int buf_len, unsigned int count) { - unsigned i; + unsigned int i; unsigned char *buf = _buf; - unsigned bytes_to_remove; - unsigned shift; + unsigned int bytes_to_remove; + unsigned int shift; bytes_to_remove = count / 8; shift = count - (bytes_to_remove * 8); diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index ed13b980f..99132798b 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -32,7 +32,7 @@ * @param value Up to 32 bits that will be copied to _buffer. */ static inline void buf_set_u32(uint8_t *_buffer, - unsigned first, unsigned num, uint32_t value) + unsigned int first, unsigned int num, uint32_t value) { assert(num >= 1 && num <= 32); uint8_t *buffer = _buffer; @@ -43,7 +43,7 @@ static inline void buf_set_u32(uint8_t *_buffer, buffer[1] = (value >> 8) & 0xff; buffer[0] = (value >> 0) & 0xff; } else { - for (unsigned i = first; i < first + num; i++) { + for (unsigned int i = first; i < first + num; i++) { if (((value >> (i - first)) & 1) == 1) buffer[i / 8] |= 1 << (i % 8); else @@ -63,7 +63,7 @@ static inline void buf_set_u32(uint8_t *_buffer, * @param value Up to 64 bits that will be copied to _buffer. */ static inline void buf_set_u64(uint8_t *_buffer, - unsigned first, unsigned num, uint64_t value) + unsigned int first, unsigned int num, uint64_t value) { assert(num >= 1 && num <= 64); uint8_t *buffer = _buffer; @@ -83,7 +83,7 @@ static inline void buf_set_u64(uint8_t *_buffer, buffer[1] = (value >> 8) & 0xff; buffer[0] = (value >> 0) & 0xff; } else { - for (unsigned i = first; i < first + num; i++) { + for (unsigned int i = first; i < first + num; i++) { if (((value >> (i - first)) & 1) == 1) buffer[i / 8] |= 1 << (i % 8); else @@ -102,7 +102,7 @@ static inline void buf_set_u64(uint8_t *_buffer, * @returns Up to 32-bits that were read from @c _buffer. */ static inline uint32_t buf_get_u32(const uint8_t *_buffer, - unsigned first, unsigned num) + unsigned int first, unsigned int num) { assert(num >= 1 && num <= 32); const uint8_t *buffer = _buffer; @@ -114,7 +114,7 @@ static inline uint32_t buf_get_u32(const uint8_t *_buffer, (((uint32_t)buffer[0]) << 0); } else { uint32_t result = 0; - for (unsigned i = first; i < first + num; i++) { + for (unsigned int i = first; i < first + num; i++) { if (((buffer[i / 8] >> (i % 8)) & 1) == 1) result |= 1U << (i - first); } @@ -132,7 +132,7 @@ static inline uint32_t buf_get_u32(const uint8_t *_buffer, * @returns Up to 64-bits that were read from @c _buffer. */ static inline uint64_t buf_get_u64(const uint8_t *_buffer, - unsigned first, unsigned num) + unsigned int first, unsigned int num) { assert(num >= 1 && num <= 64); const uint8_t *buffer = _buffer; @@ -153,7 +153,7 @@ static inline uint64_t buf_get_u64(const uint8_t *_buffer, (((uint64_t)buffer[0]) << 0)); } else { uint64_t result = 0; - for (unsigned i = first; i < first + num; i++) { + for (unsigned int i = first; i < first + num; i++) { if (((buffer[i / 8] >> (i % 8)) & 1) == 1) result = result | ((uint64_t)1 << (uint64_t)(i - first)); } @@ -170,11 +170,11 @@ static inline uint64_t buf_get_u64(const uint8_t *_buffer, * @param width The number of bits in value (2-32). * @returns A 32-bit word with @c value in reversed bit-order. */ -uint32_t flip_u32(uint32_t value, unsigned width); +uint32_t flip_u32(uint32_t value, unsigned int width); -bool buf_eq(const void *buf1, const void *buf2, unsigned size); +bool buf_eq(const void *buf1, const void *buf2, unsigned int size); bool buf_eq_mask(const void *buf1, const void *buf2, - const void *mask, unsigned size); + const void *mask, unsigned int size); /** * Copies @c size bits out of @c from and into @c to. Any extra @@ -183,7 +183,7 @@ bool buf_eq_mask(const void *buf1, const void *buf2, * @param to The buffer that will receive the copy of @c from. * @param size The number of bits to copy. */ -void *buf_cpy(const void *from, void *to, unsigned size); +void *buf_cpy(const void *from, void *to, unsigned int size); /** * Set the contents of @c buf with @c count bits, all set to 1. @@ -191,10 +191,10 @@ void *buf_cpy(const void *from, void *to, unsigned size); * @param size The number of bits. * @returns The original buffer (@c buf). */ -void *buf_set_ones(void *buf, unsigned size); +void *buf_set_ones(void *buf, unsigned int size); -void *buf_set_buf(const void *src, unsigned src_start, - void *dst, unsigned dst_start, unsigned len); +void *buf_set_buf(const void *src, unsigned int src_start, + void *dst, unsigned int dst_start, unsigned int len); /** * Parse an unsigned number (provided as a zero-terminated string) @@ -207,7 +207,7 @@ void *buf_set_buf(const void *src, unsigned src_start, */ int str_to_buf(const char *str, void *_buf, unsigned int buf_bitsize); -char *buf_to_hex_str(const void *buf, unsigned size); +char *buf_to_hex_str(const void *buf, unsigned int size); /* read a uint32_t from a buffer in target memory endianness */ static inline uint32_t fast_target_buffer_get_u32(const void *p, bool le) @@ -215,8 +215,8 @@ static inline uint32_t fast_target_buffer_get_u32(const void *p, bool le) return le ? le_to_h_u32(p) : be_to_h_u32(p); } -static inline void bit_copy(uint8_t *dst, unsigned dst_offset, const uint8_t *src, - unsigned src_offset, unsigned bit_count) +static inline void bit_copy(uint8_t *dst, unsigned int dst_offset, const uint8_t *src, + unsigned int src_offset, unsigned int bit_count) { buf_set_buf(src, src_offset, dst, dst_offset, bit_count); } @@ -227,16 +227,16 @@ struct bit_copy_queue { struct bit_copy_queue_entry { uint8_t *dst; - unsigned dst_offset; + unsigned int dst_offset; const uint8_t *src; - unsigned src_offset; - unsigned bit_count; + unsigned int src_offset; + unsigned int bit_count; struct list_head list; }; void bit_copy_queue_init(struct bit_copy_queue *q); -int bit_copy_queued(struct bit_copy_queue *q, uint8_t *dst, unsigned dst_offset, const uint8_t *src, - unsigned src_offset, unsigned bit_count); +int bit_copy_queued(struct bit_copy_queue *q, uint8_t *dst, unsigned int dst_offset, const uint8_t *src, + unsigned int src_offset, unsigned int bit_count); void bit_copy_execute(struct bit_copy_queue *q); void bit_copy_discard(struct bit_copy_queue *q); @@ -244,6 +244,6 @@ void bit_copy_discard(struct bit_copy_queue *q); * used in ti-icdi driver and gdb server */ size_t unhexify(uint8_t *bin, const char *hex, size_t count); size_t hexify(char *hex, const uint8_t *bin, size_t count, size_t out_maxlen); -void buffer_shr(void *_buf, unsigned buf_len, unsigned count); +void buffer_shr(void *_buf, unsigned int buf_len, unsigned int count); #endif /* OPENOCD_HELPER_BINARYBUFFER_H */ diff --git a/src/helper/command.c b/src/helper/command.c index 907869325..d90d34141 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -58,7 +58,7 @@ 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, +static void tcl_output(void *privData, const char *file, unsigned int line, const char *function, const char *string) { struct log_capture_state *state = privData; @@ -144,7 +144,7 @@ static void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * const return; char *dbg = alloc_printf("command -"); - for (unsigned i = 0; i < argc; i++) { + for (unsigned int i = 0; i < argc; i++) { const char *w = Jim_GetString(argv[i], NULL); char *t = alloc_printf("%s %s", dbg, w); free(dbg); @@ -288,7 +288,7 @@ int __register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, struct target *override_target) { int retval = ERROR_OK; - unsigned i; + unsigned int i; for (i = 0; cmds[i].name || cmds[i].chain; i++) { const struct command_registration *cr = cmds + i; @@ -323,7 +323,7 @@ int __register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, } } if (retval != ERROR_OK) { - for (unsigned j = 0; j < i; j++) + for (unsigned int j = 0; j < i; j++) unregister_command(cmd_ctx, cmd_prefix, cmds[j].name); } return retval; @@ -728,12 +728,12 @@ static COMMAND_HELPER(command_help_show_list, bool show_help, const char *cmd_ma #define HELP_LINE_WIDTH(_n) (int)(76 - (2 * _n)) -static void command_help_show_indent(unsigned n) +static void command_help_show_indent(unsigned int n) { - for (unsigned i = 0; i < n; i++) + for (unsigned int i = 0; i < n; i++) LOG_USER_N(" "); } -static void command_help_show_wrap(const char *str, unsigned n, unsigned n2) +static void command_help_show_wrap(const char *str, unsigned int n, unsigned int n2) { const char *cp = str, *last = str; while (*cp) { @@ -1317,7 +1317,7 @@ DEFINE_PARSE_NUM_TYPE(_llong, long long, strtoll, LLONG_MIN, LLONG_MAX) #define DEFINE_PARSE_ULONGLONG(name, type, min, max) \ DEFINE_PARSE_WRAPPER(name, type, min, max, unsigned long long, _ullong) -DEFINE_PARSE_ULONGLONG(_uint, unsigned, 0, UINT_MAX) +DEFINE_PARSE_ULONGLONG(_uint, unsigned int, 0, UINT_MAX) DEFINE_PARSE_ULONGLONG(_u64, uint64_t, 0, UINT64_MAX) DEFINE_PARSE_ULONGLONG(_u32, uint32_t, 0, UINT32_MAX) DEFINE_PARSE_ULONGLONG(_u16, uint16_t, 0, UINT16_MAX) diff --git a/src/helper/command.h b/src/helper/command.h index b224bd022..18fe56178 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -77,7 +77,7 @@ struct command_invocation { struct command_context *ctx; struct command *current; const char *name; - unsigned argc; + unsigned int argc; const char **argv; Jim_Obj * const *jimtcl_argv; Jim_Obj *output; @@ -414,7 +414,7 @@ int parse_llong(const char *str, long long *ul); #define DECLARE_PARSE_WRAPPER(name, type) \ int parse ## name(const char *str, type * ul) -DECLARE_PARSE_WRAPPER(_uint, unsigned); +DECLARE_PARSE_WRAPPER(_uint, unsigned int); DECLARE_PARSE_WRAPPER(_u64, uint64_t); DECLARE_PARSE_WRAPPER(_u32, uint32_t); DECLARE_PARSE_WRAPPER(_u16, uint16_t); diff --git a/src/helper/log.c b/src/helper/log.c index 471069ade..62ba4da4c 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -53,7 +53,7 @@ static const char * const log_strings[6] = { static int count; /* forward the log to the listeners */ -static void log_forward(const char *file, unsigned line, const char *function, const char *string) +static void log_forward(const char *file, unsigned int line, const char *function, const char *string) { struct log_callback *cb, *next; cb = log_callbacks; @@ -133,7 +133,7 @@ static void log_puts(enum log_levels level, void log_printf(enum log_levels level, const char *file, - unsigned line, + unsigned int line, const char *function, const char *format, ...) @@ -156,7 +156,7 @@ void log_printf(enum log_levels level, va_end(ap); } -void log_vprintf_lf(enum log_levels level, const char *file, unsigned line, +void log_vprintf_lf(enum log_levels level, const char *file, unsigned int line, const char *function, const char *format, va_list args) { char *tmp; @@ -182,7 +182,7 @@ void log_vprintf_lf(enum log_levels level, const char *file, unsigned line, void log_printf_lf(enum log_levels level, const char *file, - unsigned line, + unsigned int line, const char *function, const char *format, ...) @@ -505,7 +505,7 @@ void log_socket_error(const char *socket_desc) * Find the first non-printable character in the char buffer, return a pointer to it. * If no such character exists, return NULL. */ -char *find_nonprint_char(char *buf, unsigned buf_len) +char *find_nonprint_char(char *buf, unsigned int buf_len) { for (unsigned int i = 0; i < buf_len; i++) { if (!isprint(buf[i])) diff --git a/src/helper/log.h b/src/helper/log.h index d52c05f99..0f11cfa9a 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -48,12 +48,12 @@ enum log_levels { LOG_LVL_DEBUG_IO = 4, }; -void log_printf(enum log_levels level, const char *file, unsigned line, +void log_printf(enum log_levels level, const char *file, unsigned int line, const char *function, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))); -void log_vprintf_lf(enum log_levels level, const char *file, unsigned line, +void log_vprintf_lf(enum log_levels level, const char *file, unsigned int line, const char *function, const char *format, va_list args); -void log_printf_lf(enum log_levels level, const char *file, unsigned line, +void log_printf_lf(enum log_levels level, const char *file, unsigned int line, const char *function, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))); @@ -73,7 +73,7 @@ void busy_sleep(uint64_t ms); void log_socket_error(const char *socket_desc); -typedef void (*log_callback_fn)(void *priv, const char *file, unsigned line, +typedef void (*log_callback_fn)(void *priv, const char *file, unsigned int line, const char *function, const char *string); struct log_callback { @@ -89,7 +89,7 @@ char *alloc_vprintf(const char *fmt, va_list ap); char *alloc_printf(const char *fmt, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 2))); -char *find_nonprint_char(char *buf, unsigned buf_len); +char *find_nonprint_char(char *buf, unsigned int buf_len); extern int debug_level; diff --git a/src/helper/replacements.h b/src/helper/replacements.h index 6e30b628b..ecc0e5e95 100644 --- a/src/helper/replacements.h +++ b/src/helper/replacements.h @@ -111,7 +111,7 @@ size_t strnlen(const char *s, size_t maxlen); #ifndef HAVE_USLEEP #ifdef _WIN32 -static inline unsigned usleep(unsigned int usecs) +static inline unsigned int usleep(unsigned int usecs) { Sleep((usecs/1000)); return 0; diff --git a/src/openocd.c b/src/openocd.c index 54c5eb34f..7a5147050 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -258,7 +258,7 @@ static struct command_context *setup_command_handler(Jim_Interp *interp) &arm_tpiu_swo_register_commands, NULL }; - for (unsigned i = 0; command_registrants[i]; i++) { + for (unsigned int i = 0; command_registrants[i]; i++) { int retval = (*command_registrants[i])(cmd_ctx); if (retval != ERROR_OK) { command_done(cmd_ctx); diff --git a/src/rtos/hwthread.c b/src/rtos/hwthread.c index 4fe841902..65b89eb22 100644 --- a/src/rtos/hwthread.c +++ b/src/rtos/hwthread.c @@ -320,7 +320,7 @@ static int hwthread_get_thread_reg(struct rtos *rtos, int64_t thread_id, rtos_reg->number = reg->number; rtos_reg->size = reg->size; - unsigned bytes = (reg->size + 7) / 8; + unsigned int bytes = (reg->size + 7) / 8; assert(bytes <= sizeof(rtos_reg->value)); memcpy(rtos_reg->value, reg->value, bytes); diff --git a/src/svf/svf.c b/src/svf/svf.c index 470889948..9dd2463c0 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -245,7 +245,7 @@ static int svf_last_printed_percentage = -1; #define SVF_BUF_LOG(_lvl, _buf, _nbits, _desc) \ svf_hexbuf_print(LOG_LVL_##_lvl, __FILE__, __LINE__, __func__, _buf, _nbits, _desc) -static void svf_hexbuf_print(int dbg_lvl, const char *file, unsigned line, +static void svf_hexbuf_print(int dbg_lvl, const char *file, unsigned int line, const char *function, const uint8_t *buf, int bit_len, const char *desc) { @@ -316,7 +316,7 @@ static void svf_free_xxd_para(struct svf_xxr_para *para) int svf_add_statemove(tap_state_t state_to) { tap_state_t state_from = cmd_queue_cur_state; - unsigned index_var; + unsigned int index_var; /* when resetting, be paranoid and ignore current state */ if (state_to == TAP_RESET) { diff --git a/src/transport/transport.c b/src/transport/transport.c index bf306e731..c7293e7fd 100644 --- a/src/transport/transport.c +++ b/src/transport/transport.c @@ -176,8 +176,8 @@ struct transport *get_current_transport(void) COMMAND_HELPER(transport_list_parse, char ***vector) { char **argv; - unsigned n = CMD_ARGC; - unsigned j = 0; + unsigned int n = CMD_ARGC; + unsigned int j = 0; *vector = NULL; @@ -189,7 +189,7 @@ COMMAND_HELPER(transport_list_parse, char ***vector) if (!argv) return ERROR_FAIL; - for (unsigned i = 0; i < n; i++) { + for (unsigned int i = 0; i < n; i++) { struct transport *t; for (t = transport_list; t; t = t->next) { @@ -208,7 +208,7 @@ COMMAND_HELPER(transport_list_parse, char ***vector) return ERROR_OK; fail: - for (unsigned i = 0; i < n; i++) + for (unsigned int i = 0; i < n; i++) free(argv[i]); free(argv); return ERROR_FAIL; diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index 0266c2120..74a4dcfde 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -217,7 +217,7 @@ COMMAND_HANDLER(handle_xsvf_command) bool collecting_path = false; tap_state_t path[XSTATE_MAX_PATH]; - unsigned pathlen = 0; + unsigned int pathlen = 0; /* a flag telling whether to clock TCK during waits, * or simply sleep, controlled by virt2 From 39f024900e7e69d2695071267fb079afb5ad6635 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 16 Sep 2024 10:42:47 +0200 Subject: [PATCH 13/44] flash: stm32l4x: fix open brace style Checkpatch triggers the error ERROR:OPEN_BRACE: open brace '{' following function definitions go on the next line Fix it! Change-Id: I0ce4585a6507eca094b82cdabdecf6fdbe7923b1 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8491 Tested-by: jenkins Reviewed-by: zapb --- src/flash/nor/stm32l4x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c index 9235dd787..d66a83dd3 100644 --- a/src/flash/nor/stm32l4x.c +++ b/src/flash/nor/stm32l4x.c @@ -717,7 +717,8 @@ struct range { }; static void bitmap_to_ranges(unsigned long *bitmap, unsigned int nbits, - struct range *ranges, unsigned int *ranges_count) { + struct range *ranges, unsigned int *ranges_count) +{ *ranges_count = 0; bool last_bit = 0, cur_bit; for (unsigned int i = 0; i < nbits; i++) { From 537793bb245750f4af992a04547f856d1a99cbfc Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 16 Sep 2024 10:45:17 +0200 Subject: [PATCH 14/44] target: mem_ap: drop return from void function Checkpatch triggers the error ERROR:RETURN_VOID: void function return statements are not generally useful Fix it! Change-Id: I72d9fb8242d6a91c0aa481d5d023f0359c76a5ec Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8492 Tested-by: jenkins Reviewed-by: zapb --- src/target/mem_ap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/target/mem_ap.c b/src/target/mem_ap.c index 61a9475e6..411402077 100644 --- a/src/target/mem_ap.c +++ b/src/target/mem_ap.c @@ -75,7 +75,6 @@ static void mem_ap_deinit_target(struct target *target) free(target->private_config); free(target->arch_info); - return; } static int mem_ap_arch_state(struct target *target) From 4214fca4478404fff21110fd8ce5b4dc9ccfa72a Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 16 Sep 2024 11:31:37 +0200 Subject: [PATCH 15/44] OpenOCD: fix code alignment Fix checkpatch errors: ERROR:TABSTOP: Statements should start on a tabstop Change-Id: Ia771e7b7fa2cc4ef0be7f52b670525175555c8e4 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8493 Reviewed-by: zapb Tested-by: jenkins --- src/flash/nor/ocl.c | 2 +- src/jtag/drivers/buspirate.c | 16 ++++++++-------- src/jtag/hla/hla_interface.c | 2 +- src/target/mips32_pracc.c | 6 +++--- src/target/openrisc/or1k_du_adv.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/flash/nor/ocl.c b/src/flash/nor/ocl.c index e00c365ed..61af908f5 100644 --- a/src/flash/nor/ocl.c +++ b/src/flash/nor/ocl.c @@ -160,7 +160,7 @@ static int ocl_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t of retval = embeddedice_send(ocl->jtag_info, dcc_buffer, dcc_bufptr-dcc_buffer); if (retval != ERROR_OK) { free(dcc_buffer); - return retval; + return retval; } /* wait for response, fixed timeout of 1 s */ diff --git a/src/jtag/drivers/buspirate.c b/src/jtag/drivers/buspirate.c index b01a79644..6f8df5ada 100644 --- a/src/jtag/drivers/buspirate.c +++ b/src/jtag/drivers/buspirate.c @@ -1442,7 +1442,7 @@ static void buspirate_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_del data); switch (ack) { - case SWD_ACK_OK: + case SWD_ACK_OK: if (parity != parity_u32(data)) { LOG_DEBUG("Read data parity mismatch %x %x", parity, parity_u32(data)); queued_retval = ERROR_FAIL; @@ -1453,15 +1453,15 @@ static void buspirate_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_del if (cmd & SWD_CMD_APNDP) buspirate_swd_idle_clocks(ap_delay_clk); return; - case SWD_ACK_WAIT: + case SWD_ACK_WAIT: LOG_DEBUG("SWD_ACK_WAIT"); buspirate_swd_clear_sticky_errors(); return; - case SWD_ACK_FAULT: + case SWD_ACK_FAULT: LOG_DEBUG("SWD_ACK_FAULT"); queued_retval = ack; return; - default: + default: LOG_DEBUG("No valid acknowledge: ack=%d", ack); queued_retval = ack; return; @@ -1500,19 +1500,19 @@ static void buspirate_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_del value); switch (ack) { - case SWD_ACK_OK: + case SWD_ACK_OK: if (cmd & SWD_CMD_APNDP) buspirate_swd_idle_clocks(ap_delay_clk); return; - case SWD_ACK_WAIT: + case SWD_ACK_WAIT: LOG_DEBUG("SWD_ACK_WAIT"); buspirate_swd_clear_sticky_errors(); return; - case SWD_ACK_FAULT: + case SWD_ACK_FAULT: LOG_DEBUG("SWD_ACK_FAULT"); queued_retval = ack; return; - default: + default: LOG_DEBUG("No valid acknowledge: ack=%d", ack); queued_retval = ack; return; diff --git a/src/jtag/hla/hla_interface.c b/src/jtag/hla/hla_interface.c index c73f6c8d3..f284278dd 100644 --- a/src/jtag/hla/hla_interface.c +++ b/src/jtag/hla/hla_interface.c @@ -348,7 +348,7 @@ static const struct command_registration hl_interface_subcommand_handlers[] = { .help = "select which ST-Link backend to use", .usage = "usb | tcp [port]", }, - { + { .name = "command", .handler = &interface_handle_hla_command, .mode = COMMAND_EXEC, diff --git a/src/target/mips32_pracc.c b/src/target/mips32_pracc.c index 2d0bd641b..587e20d2b 100644 --- a/src/target/mips32_pracc.c +++ b/src/target/mips32_pracc.c @@ -212,7 +212,7 @@ static int mips32_pracc_exec(struct mips_ejtag *ejtag_info, struct pracc_queue_i store_pending--; } else { /* read/fetch access */ - if (!final_check) { /* executing function code */ + if (!final_check) { /* executing function code */ /* check address */ if (ejtag_info->pa_addr != (MIPS32_PRACC_TEXT + code_count * 4)) { LOG_DEBUG("reading at unexpected address %" PRIx32 ", expected %x", @@ -243,7 +243,7 @@ static int mips32_pracc_exec(struct mips_ejtag *ejtag_info, struct pracc_queue_i if (code_count == ctx->code_count) /* last instruction, start final check */ final_check = 1; - } else { /* final check after function code shifted out */ + } else { /* final check after function code shifted out */ /* check address */ if (ejtag_info->pa_addr == MIPS32_PRACC_TEXT) { if (!pass) { /* first pass through pracc text */ @@ -275,7 +275,7 @@ static int mips32_pracc_exec(struct mips_ejtag *ejtag_info, struct pracc_queue_i } instr = MIPS32_NOP; /* shift out NOPs instructions */ code_count++; - } + } /* Send instruction out */ mips_ejtag_set_instr(ejtag_info, EJTAG_INST_DATA); diff --git a/src/target/openrisc/or1k_du_adv.c b/src/target/openrisc/or1k_du_adv.c index e4003a213..f401ea9fb 100644 --- a/src/target/openrisc/or1k_du_adv.c +++ b/src/target/openrisc/or1k_du_adv.c @@ -362,7 +362,7 @@ static int adbg_ctrl_read(struct or1k_jtag *jtag_info, uint32_t regidx, default: LOG_ERROR("Illegal debug chain selected (%i) while doing control read", jtag_info->or1k_jtag_module_selected); - return ERROR_FAIL; + return ERROR_FAIL; } /* Zero MSB = op for module, not top-level debug unit */ From 39197cdb4ee8f7ed605308a07bac67b33fb4973f Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 16 Sep 2024 11:36:03 +0200 Subject: [PATCH 16/44] jtag: stlink_usb: drop comparison to NULL Fix checkpatch error: ERROR:COMPARISON_TO_NULL: Comparison to NULL could be written "handle" Change-Id: I0ac12ccfc5fce4dd41266f83eb4b973a4e6a314d Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8494 Reviewed-by: zapb Tested-by: jenkins --- src/jtag/drivers/stlink_usb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c index 812a192c2..0385e4d85 100644 --- a/src/jtag/drivers/stlink_usb.c +++ b/src/jtag/drivers/stlink_usb.c @@ -2754,7 +2754,7 @@ static int stlink_usb_read_mem32_noaddrinc(void *handle, uint8_t ap_num, uint32_ { struct stlink_usb_handle *h = handle; - assert(handle != NULL); + assert(handle); if (!(h->version.flags & STLINK_F_HAS_MEM_RD_NO_INC)) return ERROR_COMMAND_NOTFOUND; @@ -2796,7 +2796,7 @@ static int stlink_usb_write_mem32_noaddrinc(void *handle, uint8_t ap_num, uint32 { struct stlink_usb_handle *h = handle; - assert(handle != NULL); + assert(handle); if (!(h->version.flags & STLINK_F_HAS_MEM_WR_NO_INC)) return ERROR_COMMAND_NOTFOUND; @@ -3947,7 +3947,7 @@ static int stlink_usb_rw_misc_out(void *handle, uint32_t items, const uint8_t *b LOG_DEBUG_IO("%s(%" PRIu32 ")", __func__, items); - assert(handle != NULL); + assert(handle); if (!(h->version.flags & STLINK_F_HAS_RW_MISC)) return ERROR_COMMAND_NOTFOUND; @@ -3968,7 +3968,7 @@ static int stlink_usb_rw_misc_in(void *handle, uint32_t items, uint8_t *buffer) LOG_DEBUG_IO("%s(%" PRIu32 ")", __func__, items); - assert(handle != NULL); + assert(handle); if (!(h->version.flags & STLINK_F_HAS_RW_MISC)) return ERROR_COMMAND_NOTFOUND; From 66006d83b99843ab7c6ec19125e2fc20855a4c7c Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 16 Sep 2024 11:37:05 +0200 Subject: [PATCH 17/44] target: drop comparison to NULL Fix checkpatch error: ERROR:COMPARISON_TO_NULL: Comparison to NULL could be written "cmd_ctx" Change-Id: I3615fc427f8b160d44b6edbf7a066a086cab99bb Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8495 Tested-by: jenkins Reviewed-by: zapb --- src/target/target.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/target.c b/src/target/target.c index 56aa8b1e7..2be8b24b9 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -4596,7 +4596,7 @@ static int target_jim_write_memory(Jim_Interp *interp, int argc, } struct command_context *cmd_ctx = current_command_context(interp); - assert(cmd_ctx != NULL); + assert(cmd_ctx); struct target *target = get_current_target(cmd_ctx); const size_t buffersize = 4096; @@ -4739,7 +4739,7 @@ static int target_jim_get_reg(Jim_Interp *interp, int argc, return JIM_ERR; struct command_context *cmd_ctx = current_command_context(interp); - assert(cmd_ctx != NULL); + assert(cmd_ctx); const struct target *target = get_current_target(cmd_ctx); for (int i = 0; i < length; i++) { From 3ccf68cd0a8aa740565456317bae9d43618ef662 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 16 Sep 2024 11:55:20 +0200 Subject: [PATCH 18/44] OpenOCD: drop comparison with true/false Fix checkpatch errors: ERROR:BOOL_COMPARISON: Using comparison to true/false is error prone While there, - drop useless parenthesis, - drop unnecessary else after a return. Change-Id: I1234737b3e65bd10df5e938d1c36f9abaf02d348 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8496 Reviewed-by: zapb Tested-by: jenkins --- src/flash/nor/psoc6.c | 2 +- src/flash/nor/xcf.c | 62 +++++++++---------- src/jtag/drivers/ulink.c | 6 +- .../usb_blaster/ublast2_access_libusb.c | 2 +- src/rtos/hwthread.c | 4 +- src/rtos/rtos.c | 2 +- src/server/gdb_server.c | 8 +-- src/target/cortex_m.c | 2 +- src/target/target.c | 2 +- 9 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/flash/nor/psoc6.c b/src/flash/nor/psoc6.c index 47f3ac698..662910aa0 100644 --- a/src/flash/nor/psoc6.c +++ b/src/flash/nor/psoc6.c @@ -487,7 +487,7 @@ static int psoc6_get_info(struct flash_bank *bank, struct command_invocation *cm { struct psoc6_target_info *psoc6_info = bank->driver_priv; - if (psoc6_info->is_probed == false) + if (!psoc6_info->is_probed) return ERROR_FAIL; int hr = get_silicon_id(bank->target, &psoc6_info->silicon_id, &psoc6_info->protection); diff --git a/src/flash/nor/xcf.c b/src/flash/nor/xcf.c index 1d67b0943..4011fa42b 100644 --- a/src/flash/nor/xcf.c +++ b/src/flash/nor/xcf.c @@ -143,28 +143,27 @@ static int isc_enter(struct flash_bank *bank) struct xcf_status status = read_status(bank); - if (true == status.isc_mode) + if (status.isc_mode) return ERROR_OK; - else { - struct scan_field scan; - scan.check_mask = NULL; - scan.check_value = NULL; - scan.num_bits = 16; - scan.out_value = cmd_isc_enable; - scan.in_value = NULL; + struct scan_field scan; - jtag_add_ir_scan(bank->target->tap, &scan, TAP_IDLE); - jtag_execute_queue(); + scan.check_mask = NULL; + scan.check_value = NULL; + scan.num_bits = 16; + scan.out_value = cmd_isc_enable; + scan.in_value = NULL; - status = read_status(bank); - if (!status.isc_mode) { - LOG_ERROR("*** XCF: FAILED to enter ISC mode"); - return ERROR_FLASH_OPERATION_FAILED; - } + jtag_add_ir_scan(bank->target->tap, &scan, TAP_IDLE); + jtag_execute_queue(); - return ERROR_OK; + status = read_status(bank); + if (!status.isc_mode) { + LOG_ERROR("*** XCF: FAILED to enter ISC mode"); + return ERROR_FLASH_OPERATION_FAILED; } + + return ERROR_OK; } static int isc_leave(struct flash_bank *bank) @@ -174,27 +173,26 @@ static int isc_leave(struct flash_bank *bank) if (!status.isc_mode) return ERROR_OK; - else { - struct scan_field scan; - scan.check_mask = NULL; - scan.check_value = NULL; - scan.num_bits = 16; - scan.out_value = cmd_isc_disable; - scan.in_value = NULL; + struct scan_field scan; - jtag_add_ir_scan(bank->target->tap, &scan, TAP_IDLE); - jtag_execute_queue(); - alive_sleep(1); /* device needs 50 uS to leave ISC mode */ + scan.check_mask = NULL; + scan.check_value = NULL; + scan.num_bits = 16; + scan.out_value = cmd_isc_disable; + scan.in_value = NULL; - status = read_status(bank); - if (status.isc_mode) { - LOG_ERROR("*** XCF: FAILED to leave ISC mode"); - return ERROR_FLASH_OPERATION_FAILED; - } + jtag_add_ir_scan(bank->target->tap, &scan, TAP_IDLE); + jtag_execute_queue(); + alive_sleep(1); /* device needs 50 uS to leave ISC mode */ - return ERROR_OK; + status = read_status(bank); + if (status.isc_mode) { + LOG_ERROR("*** XCF: FAILED to leave ISC mode"); + return ERROR_FLASH_OPERATION_FAILED; } + + return ERROR_OK; } static int sector_state(uint8_t wrpt, int sector) diff --git a/src/jtag/drivers/ulink.c b/src/jtag/drivers/ulink.c index ad3bc6e37..3a248e388 100644 --- a/src/jtag/drivers/ulink.c +++ b/src/jtag/drivers/ulink.c @@ -606,7 +606,7 @@ static void ulink_clear_queue(struct ulink *device) /* IN payload MUST be freed ONLY if no other commands use the * payload_in_start buffer */ - if (current->free_payload_in_start == true) { + if (current->free_payload_in_start) { free(current->payload_in_start); current->payload_in_start = NULL; current->payload_in = NULL; @@ -1861,7 +1861,7 @@ static int ulink_post_process_queue(struct ulink *device) /* Check if a corresponding OpenOCD command is stored for this * OpenULINK command */ - if ((current->needs_postprocessing == true) && (openocd_cmd)) { + if (current->needs_postprocessing && openocd_cmd) { switch (openocd_cmd->type) { case JTAG_SCAN: ret = ulink_post_process_scan(current); @@ -2131,7 +2131,7 @@ static int ulink_init(void) download_firmware = true; } - if (download_firmware == true) { + if (download_firmware) { LOG_INFO("Loading OpenULINK firmware. This is reversible by power-cycling" " ULINK device."); ret = ulink_load_firmware_and_renumerate(&ulink_handle, diff --git a/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c b/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c index e790f3ae5..8f0ed96f3 100644 --- a/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c +++ b/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c @@ -215,7 +215,7 @@ static int ublast2_libusb_init(struct ublast_lowlevel *low) const uint16_t vids_renum[] = { low->ublast_vid, 0 }; const uint16_t pids_renum[] = { low->ublast_pid, 0 }; - if (renumeration == false) { + if (!renumeration) { if (jtag_libusb_open(vids_renum, pids_renum, NULL, &low->libusb_dev, NULL) != ERROR_OK) { LOG_ERROR("Altera USB-Blaster II not found"); return ERROR_FAIL; diff --git a/src/rtos/hwthread.c b/src/rtos/hwthread.c index 65b89eb22..1890a3d87 100644 --- a/src/rtos/hwthread.c +++ b/src/rtos/hwthread.c @@ -254,7 +254,7 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, int j = 0; for (int i = 0; i < reg_list_size; i++) { - if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden) + if (!reg_list[i] || !reg_list[i]->exist || reg_list[i]->hidden) continue; j++; } @@ -267,7 +267,7 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, j = 0; for (int i = 0; i < reg_list_size; i++) { - if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden) + if (!reg_list[i] || !reg_list[i]->exist || reg_list[i]->hidden) continue; if (!reg_list[i]->valid) { retval = reg_list[i]->type->get(reg_list[i]); diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c index 0df1182c0..54e31e426 100644 --- a/src/rtos/rtos.c +++ b/src/rtos/rtos.c @@ -389,7 +389,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa return ERROR_OK; } else if (strncmp(packet, "qSymbol", 7) == 0) { if (rtos_qsymbol(connection, packet, packet_size) == 1) { - if (target->rtos_auto_detect == true) { + if (target->rtos_auto_detect) { target->rtos_auto_detect = false; target->rtos->type->create(target); } diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 854c4dc65..c1e5e268f 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1262,7 +1262,7 @@ static int gdb_get_registers_packet(struct connection *connection, return gdb_error(connection, retval); for (i = 0; i < reg_list_size; i++) { - if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden) + if (!reg_list[i] || !reg_list[i]->exist || reg_list[i]->hidden) continue; reg_packet_size += DIV_ROUND_UP(reg_list[i]->size, 8) * 2; } @@ -1276,7 +1276,7 @@ static int gdb_get_registers_packet(struct connection *connection, reg_packet_p = reg_packet; for (i = 0; i < reg_list_size; i++) { - if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden) + if (!reg_list[i] || !reg_list[i]->exist || reg_list[i]->hidden) continue; retval = gdb_get_reg_value_as_str(target, reg_packet_p, reg_list[i]); if (retval != ERROR_OK && gdb_report_register_access_error) { @@ -2254,7 +2254,7 @@ static int get_reg_features_list(struct target *target, char const **feature_lis *feature_list = calloc(1, sizeof(char *)); for (int i = 0; i < reg_list_size; i++) { - if (reg_list[i]->exist == false || reg_list[i]->hidden) + if (!reg_list[i]->exist || reg_list[i]->hidden) continue; if (reg_list[i]->feature @@ -2464,7 +2464,7 @@ static int gdb_generate_target_description(struct target *target, char **tdesc_o int i; for (i = 0; i < reg_list_size; i++) { - if (reg_list[i]->exist == false || reg_list[i]->hidden) + if (!reg_list[i]->exist || reg_list[i]->hidden) continue; if (strcmp(reg_list[i]->feature->name, features[current_feature])) diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 880a83a18..bd0e8d886 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -1521,7 +1521,7 @@ static int cortex_m_step(struct target *target, int current, /* if no bkpt instruction is found at pc then we can perform * a normal step, otherwise we have to manually step over the bkpt * instruction - as such simulate a step */ - if (bkpt_inst_found == false) { + if (!bkpt_inst_found) { if (cortex_m->isrmasking_mode != CORTEX_M_ISRMASK_AUTO) { /* Automatic ISR masking mode off: Just step over the next * instruction, with interrupts on or off as appropriate. */ diff --git a/src/target/target.c b/src/target/target.c index 2be8b24b9..49611dfb4 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -3042,7 +3042,7 @@ COMMAND_HANDLER(handle_reg_command) for (i = 0, reg = cache->reg_list; i < cache->num_regs; i++, reg++, count++) { - if (reg->exist == false || reg->hidden) + if (!reg->exist || reg->hidden) continue; /* only print cached values if they are valid */ if (reg->valid) { From 8c23e6c1759be497c1328837fb49992d489b0719 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 16 Sep 2024 13:49:04 +0200 Subject: [PATCH 19/44] target: arm: drop casts commented-out The function dpm->finish() returns a value that is almost always ignored. Drop the commented-out cast /* (void) */ Change-Id: I7ff210a2693dd1877b7c7591705cdcd96a2c6125 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8498 Tested-by: jenkins Reviewed-by: zapb --- src/target/arm_dpm.c | 22 +++++++++++----------- src/target/armv7a.c | 2 +- src/target/armv8.c | 2 +- src/target/armv8_dpm.c | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/target/arm_dpm.c b/src/target/arm_dpm.c index 318d5afec..0b2db77c5 100644 --- a/src/target/arm_dpm.c +++ b/src/target/arm_dpm.c @@ -59,7 +59,7 @@ static int dpm_mrc(struct target *target, int cpnum, ARMV4_5_MRC(cpnum, op1, 0, crn, crm, op2), value); - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); return retval; } @@ -82,7 +82,7 @@ static int dpm_mrrc(struct target *target, int cpnum, ARMV5_T_MRRC(cpnum, op, 0, 1, crm), value); - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); return retval; } @@ -107,7 +107,7 @@ static int dpm_mcr(struct target *target, int cpnum, ARMV4_5_MCR(cpnum, op1, 0, crn, crm, op2), value); - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); return retval; } @@ -129,7 +129,7 @@ static int dpm_mcrr(struct target *target, int cpnum, retval = dpm->instr_write_data_r0_r1(dpm, ARMV5_T_MCRR(cpnum, op, 0, 1, crm), value); - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); return retval; } @@ -422,7 +422,7 @@ int arm_dpm_read_current_registers(struct arm_dpm *dpm) */ fail: - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); return retval; } @@ -632,7 +632,7 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp) cache->reg_list[i].dirty = false; } - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); done: return retval; } @@ -719,10 +719,10 @@ static int arm_dpm_read_core_reg(struct target *target, struct reg *r, /* always clean up, regardless of error */ if (mode != ARM_MODE_ANY) - /* (void) */ arm_dpm_modeswitch(dpm, ARM_MODE_ANY); + arm_dpm_modeswitch(dpm, ARM_MODE_ANY); fail: - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); return retval; } @@ -761,10 +761,10 @@ static int arm_dpm_write_core_reg(struct target *target, struct reg *r, /* always clean up, regardless of error */ if (mode != ARM_MODE_ANY) - /* (void) */ arm_dpm_modeswitch(dpm, ARM_MODE_ANY); + arm_dpm_modeswitch(dpm, ARM_MODE_ANY); fail: - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); return retval; } @@ -831,7 +831,7 @@ static int arm_dpm_full_context(struct target *target) } while (did_read); retval = arm_dpm_modeswitch(dpm, ARM_MODE_ANY); - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); done: return retval; } diff --git a/src/target/armv7a.c b/src/target/armv7a.c index dc3752e0b..e22d309a0 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -74,7 +74,7 @@ static void armv7a_show_fault_registers(struct target *target) ", IFAR: %8.8" PRIx32, ifsr, ifar); done: - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); } diff --git a/src/target/armv8.c b/src/target/armv8.c index 3bf094275..61d72741a 100644 --- a/src/target/armv8.c +++ b/src/target/armv8.c @@ -1010,7 +1010,7 @@ static void armv8_show_fault_registers32(struct armv8_common *armv8) ", IFAR: %8.8" PRIx32, ifsr, ifar); done: - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); } static __attribute__((unused)) void armv8_show_fault_registers(struct target *target) diff --git a/src/target/armv8_dpm.c b/src/target/armv8_dpm.c index 22617fd0e..d1cee8a10 100644 --- a/src/target/armv8_dpm.c +++ b/src/target/armv8_dpm.c @@ -500,7 +500,7 @@ static int dpmv8_mrc(struct target *target, int cpnum, ARMV4_5_MRC(cpnum, op1, 0, crn, crm, op2), value); - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); return retval; } @@ -525,7 +525,7 @@ static int dpmv8_mcr(struct target *target, int cpnum, ARMV4_5_MCR(cpnum, op1, 0, crn, crm, op2), value); - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); return retval; } @@ -991,7 +991,7 @@ static int armv8_dpm_read_core_reg(struct target *target, struct reg *r, goto fail; fail: - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); return retval; } @@ -1085,7 +1085,7 @@ static int armv8_dpm_full_context(struct target *target) } while (did_read); retval = armv8_dpm_modeswitch(dpm, ARM_MODE_ANY); - /* (void) */ dpm->finish(dpm); + dpm->finish(dpm); done: return retval; } From 595bb965b745371e07091c96ced478c8cd0b0d82 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 16 Sep 2024 10:58:37 +0200 Subject: [PATCH 20/44] jtag: bcm2835gpio: fix macro definition The macros trigger few errors with checkpatch: ERROR:MACRO_ARG_REUSE: Macro argument reuse 'g' - possible side-effects? ERROR:TRAILING_STATEMENTS: trailing statements should be on next line ERROR:SPACING: spaces preferred around (several cases) ERROR:SINGLE_STATEMENT_DO_WHILE_MACRO: Single statement macros should not use a do {} while (0) loop plus an empty line triggers ERROR:BRACES: Blank lines aren't necessary before a close brace '}' Fix them! Change-Id: I0690b68b511ed7f45a7e0909a0addd2822ba9fe8 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8499 Tested-by: jenkins Reviewed-by: Tomas Vanek --- src/jtag/drivers/bcm2835gpio.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/jtag/drivers/bcm2835gpio.c b/src/jtag/drivers/bcm2835gpio.c index ff10b0a78..b8d91bf38 100644 --- a/src/jtag/drivers/bcm2835gpio.c +++ b/src/jtag/drivers/bcm2835gpio.c @@ -31,16 +31,28 @@ static off_t bcm2835_peri_base = 0x20000000; #define BCM2835_GPIO_MODE_OUTPUT 1 /* GPIO setup macros */ -#define MODE_GPIO(g) (*(pio_base+((g)/10))>>(((g)%10)*3) & 7) -#define INP_GPIO(g) do { *(pio_base+((g)/10)) &= ~(7<<(((g)%10)*3)); } while (0) -#define SET_MODE_GPIO(g, m) do { /* clear the mode bits first, then set as necessary */ \ - INP_GPIO(g); \ - *(pio_base+((g)/10)) |= ((m)<<(((g)%10)*3)); } while (0) +#define MODE_GPIO(_g) ({ \ + typeof(_g) g = (_g); \ + *(pio_base + (g / 10)) >> ((g % 10) * 3) & 7; \ +}) + +#define INP_GPIO(_g) do { \ + typeof(_g) g1 = (_g); \ + *(pio_base + (g1 / 10)) &= ~(7 << ((g1 % 10) * 3)); \ +} while (0) + +#define SET_MODE_GPIO(_g, m) do { \ + typeof(_g) g = (_g); \ + /* clear the mode bits first, then set as necessary */ \ + INP_GPIO(g); \ + *(pio_base + (g / 10)) |= ((m) << ((g % 10) * 3)); \ +} while (0) + #define OUT_GPIO(g) SET_MODE_GPIO(g, BCM2835_GPIO_MODE_OUTPUT) -#define GPIO_SET (*(pio_base+7)) /* sets bits which are 1, ignores bits which are 0 */ -#define GPIO_CLR (*(pio_base+10)) /* clears bits which are 1, ignores bits which are 0 */ -#define GPIO_LEV (*(pio_base+13)) /* current level of the pin */ +#define GPIO_SET (*(pio_base + 7)) /* sets bits which are 1, ignores bits which are 0 */ +#define GPIO_CLR (*(pio_base + 10)) /* clears bits which are 1, ignores bits which are 0 */ +#define GPIO_LEV (*(pio_base + 13)) /* current level of the pin */ static int dev_mem_fd; static volatile uint32_t *pio_base = MAP_FAILED; @@ -175,7 +187,6 @@ static bb_value_t bcm2835gpio_read(void) unsigned int shift = adapter_gpio_config[ADAPTER_GPIO_IDX_TDO].gpio_num; uint32_t value = (GPIO_LEV >> shift) & 1; return value ^ (adapter_gpio_config[ADAPTER_GPIO_IDX_TDO].active_low ? BB_HIGH : BB_LOW); - } static int bcm2835gpio_write(int tck, int tms, int tdi) From 116e9553d12193faa08e668b3d9504ef995bd21f Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 22 Sep 2024 18:32:21 +0200 Subject: [PATCH 21/44] openocd: build: allow more socket connections on Windows Cross compiling OpenOCD for Windows forces the maximum number of open files (including sockets) to 64. See in include file psdk_inc/_fd_types.h: #ifndef FD_SETSIZE #define FD_SETSIZE 64 #endif This limit is far lower than the default value 1024 used by Linux. In pull request #644 [1] in risc-v fork it's reported that: - each socket server of OpenOCD (GDB, telnet, ...) uses one FD; - each active connection to a socket server uses another FD; - multi-core devices with 32 or more cores, each having a GDB connection, already saturates the 64 available FD at the 26th GDB connection. The patch [2] proposed and merged in risc-v fork adds the compile flag -DFD_SETSIZE=128 to all the host types. While this looks fine for Windows, it reduces the default value for Linux and other OS. Add the compile flag FD_SETSIZE only to cross compile for Windows. Link: [1] https://github.com/riscv-collab/riscv-openocd/pull/644 Link: [2] https://github.com/riscv-collab/riscv-openocd/pull/644/commits/1bab4cfbc4f4 Change-Id: Ie43a792ac11a5e63e0407b68e3f270efea0c87be Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8503 Tested-by: jenkins --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b7aed245e..07e06551f 100644 --- a/configure.ac +++ b/configure.ac @@ -435,7 +435,7 @@ AS_CASE([$host], # In case enable_buspirate=auto, make sure it will not be built. enable_buspirate=no - AC_SUBST([HOST_CPPFLAGS], [-D__USE_MINGW_ANSI_STDIO]) + AC_SUBST([HOST_CPPFLAGS], ["-D__USE_MINGW_ANSI_STDIO -DFD_SETSIZE=128"]) ], [*darwin*], [ is_darwin=yes From 73390332d203f02aa5b9798a7550191d55650d97 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Fri, 27 Sep 2024 22:36:52 +0200 Subject: [PATCH 22/44] openocd: fix build with jimtcl 0.83 In jimtcl 0.82, the include file jim.h included in turn stdio.h This made redundant to include the former in openocd source files. Since jimtcl 0.83, jim.h drops the include of stdio.h, causing openocd build to fail. Include stdio.h in the files that need it. Change-Id: Ic81c9b273d7520f4d2d8c32bc3e0a6bcfffb67ed Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8512 Reviewed-by: Jonathan McDowell Tested-by: jenkins --- src/helper/configuration.h | 1 + src/helper/jim-nvp.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/helper/configuration.h b/src/helper/configuration.h index 295ea591d..d646670eb 100644 --- a/src/helper/configuration.h +++ b/src/helper/configuration.h @@ -11,6 +11,7 @@ #ifndef OPENOCD_HELPER_CONFIGURATION_H #define OPENOCD_HELPER_CONFIGURATION_H +#include #include int parse_cmdline_args(struct command_context *cmd_ctx, diff --git a/src/helper/jim-nvp.c b/src/helper/jim-nvp.c index e1ab64ae5..cdd4d3429 100644 --- a/src/helper/jim-nvp.c +++ b/src/helper/jim-nvp.c @@ -21,6 +21,7 @@ #endif #include "jim-nvp.h" +#include #include int jim_get_nvp(Jim_Interp *interp, From 30c3d077f281876286a7aa37afbd411d4bd1667e Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Fri, 27 Sep 2024 22:40:06 +0200 Subject: [PATCH 23/44] jimtcl: update to version 0.83 New version tagged on 2024-08-28. Change-Id: Id0cf82a692469ccf794c9680c5d5ac09ea26e6da Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8513 Tested-by: jenkins --- jimtcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jimtcl b/jimtcl index 1933e5457..f16086617 160000 --- a/jimtcl +++ b/jimtcl @@ -1 +1 @@ -Subproject commit 1933e5457b9512d39ebbe11ed32578aada149f49 +Subproject commit f160866171457474f7c4d6ccda70f9b77524407e From edf2c82cf615af4926cc3536bbbafce2c55fe4e0 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Fri, 27 Sep 2024 09:49:52 +0200 Subject: [PATCH 24/44] helper/align.h: Fix macro IS_PWR_OF_2 Zero is not a power of two. All functions that use IS_PWR_OF_2 were checked and the edge case of IS_PWR_OF_2(0) does not occur anywhere at the moment. Therefore the fix is safe. Change-Id: I84d9f9c64c9a7df452ca6e99c2ee4169ccb2b0be Signed-off-by: Jan Matyas Fixes: 9544cd653df1 ("helper: add align.h") Reviewed-on: https://review.openocd.org/c/openocd/+/8511 Reviewed-by: Antonio Borneo Tested-by: jenkins --- src/helper/align.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/align.h b/src/helper/align.h index 935a6a3b2..d7170065e 100644 --- a/src/helper/align.h +++ b/src/helper/align.h @@ -24,7 +24,7 @@ #define IS_PWR_OF_2(x) \ ({ \ typeof(x) _x = (x); \ - _x == 0 || (_x & (_x - 1)) == 0; \ + _x != 0 && (_x & (_x - 1)) == 0; \ }) #endif /* OPENOCD_HELPER_ALIGN_H */ From bcf63ac56242b4060586761eb39b436e7fe2c1f7 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Tue, 8 Oct 2024 00:37:48 +0200 Subject: [PATCH 25/44] checkpatch: check SPDX in Makefile The firmware in contrib folder use Makefile for the build. Force checkpatch to check these Makefile for the SPDX. Change-Id: I815bf6df636c96a15f82c3d8a9de0c4f219303d2 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8520 Tested-by: jenkins --- tools/scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/scripts/checkpatch.pl b/tools/scripts/checkpatch.pl index 59a3eed12..01bd547ff 100755 --- a/tools/scripts/checkpatch.pl +++ b/tools/scripts/checkpatch.pl @@ -3728,7 +3728,7 @@ sub process { } elsif ($realfile =~ /\.rst$/) { $comment = '..'; # OpenOCD specific: Begin - } elsif ($realfile =~ /\.(am|cfg|tcl)$/) { + } elsif (($realfile =~ /\.(am|cfg|tcl)$/) || ($realfile =~ /\/Makefile$/)) { $comment = '#'; } elsif ($realfile =~ /\.(ld)$/) { $comment = '/*'; From 957eb741a0980408fe4d0682fccb99a183f90998 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 8 Sep 2024 21:23:28 +0200 Subject: [PATCH 26/44] target: riscv: convert 'unsigned' to 'unsigned int' Conversion done with checkpatch --fix-inplace -types UNSPECIFIED_INT Ignore the cast as they could be better addressed. Fix only minor additional checkpatch issue (spacing and line length). Change-Id: I11f10eddadc21e051c96eb3d4d4c0554a2cddd15 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8483 Tested-by: jenkins --- src/target/riscv/batch.c | 6 +- src/target/riscv/batch.h | 6 +- src/target/riscv/opcodes.h | 16 ++--- src/target/riscv/program.c | 2 +- src/target/riscv/riscv-011.c | 24 +++---- src/target/riscv/riscv-013.c | 128 +++++++++++++++++------------------ src/target/riscv/riscv.c | 32 ++++----- src/target/riscv/riscv.h | 28 ++++---- 8 files changed, 121 insertions(+), 121 deletions(-) diff --git a/src/target/riscv/batch.c b/src/target/riscv/batch.c index d4bdadf17..859e2275e 100644 --- a/src/target/riscv/batch.c +++ b/src/target/riscv/batch.c @@ -127,7 +127,7 @@ int riscv_batch_run(struct riscv_batch *batch) return ERROR_OK; } -void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned address, uint64_t data) +void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned int address, uint64_t data) { assert(batch->used_scans < batch->allocated_scans); struct scan_field *field = batch->fields + batch->used_scans; @@ -140,7 +140,7 @@ void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned address, uint batch->used_scans++; } -size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address) +size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned int address) { assert(batch->used_scans < batch->allocated_scans); struct scan_field *field = batch->fields + batch->used_scans; @@ -156,7 +156,7 @@ size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address) return batch->read_keys_used++; } -unsigned riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key) +unsigned int riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key) { assert(key < batch->read_keys_used); size_t index = batch->read_keys[key]; diff --git a/src/target/riscv/batch.h b/src/target/riscv/batch.h index 9c42ba81e..e5b94cc21 100644 --- a/src/target/riscv/batch.h +++ b/src/target/riscv/batch.h @@ -59,13 +59,13 @@ bool riscv_batch_full(struct riscv_batch *batch); int riscv_batch_run(struct riscv_batch *batch); /* Adds a DMI write to this batch. */ -void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned address, uint64_t data); +void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned int address, uint64_t data); /* DMI reads must be handled in two parts: the first one schedules a read and * provides a key, the second one actually obtains the result of the read - * status (op) and the actual data. */ -size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address); -unsigned riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key); +size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned int address); +unsigned int riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key); uint32_t riscv_batch_get_dmi_read_data(struct riscv_batch *batch, size_t key); /* Scans in a NOP. */ diff --git a/src/target/riscv/opcodes.h b/src/target/riscv/opcodes.h index 8faa154ba..7d17e6eea 100644 --- a/src/target/riscv/opcodes.h +++ b/src/target/riscv/opcodes.h @@ -191,26 +191,26 @@ static uint32_t fld(unsigned int dest, unsigned int base, uint16_t offset) return imm_i(offset) | inst_rs1(base) | inst_rd(dest) | MATCH_FLD; } -static uint32_t fmv_x_w(unsigned dest, unsigned src) __attribute__ ((unused)); -static uint32_t fmv_x_w(unsigned dest, unsigned src) +static uint32_t fmv_x_w(unsigned int dest, unsigned int src) __attribute__ ((unused)); +static uint32_t fmv_x_w(unsigned int dest, unsigned int src) { return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_X_W; } -static uint32_t fmv_x_d(unsigned dest, unsigned src) __attribute__ ((unused)); -static uint32_t fmv_x_d(unsigned dest, unsigned src) +static uint32_t fmv_x_d(unsigned int dest, unsigned int src) __attribute__ ((unused)); +static uint32_t fmv_x_d(unsigned int dest, unsigned int src) { return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_X_D; } -static uint32_t fmv_w_x(unsigned dest, unsigned src) __attribute__ ((unused)); -static uint32_t fmv_w_x(unsigned dest, unsigned src) +static uint32_t fmv_w_x(unsigned int dest, unsigned int src) __attribute__ ((unused)); +static uint32_t fmv_w_x(unsigned int dest, unsigned int src) { return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_W_X; } -static uint32_t fmv_d_x(unsigned dest, unsigned src) __attribute__ ((unused)); -static uint32_t fmv_d_x(unsigned dest, unsigned src) +static uint32_t fmv_d_x(unsigned int dest, unsigned int src) __attribute__ ((unused)); +static uint32_t fmv_d_x(unsigned int dest, unsigned int src) { return inst_rs1(src) | inst_rd(dest) | MATCH_FMV_D_X; } diff --git a/src/target/riscv/program.c b/src/target/riscv/program.c index 0976539b3..1014137f4 100644 --- a/src/target/riscv/program.c +++ b/src/target/riscv/program.c @@ -31,7 +31,7 @@ int riscv_program_init(struct riscv_program *p, struct target *target) int riscv_program_write(struct riscv_program *program) { - for (unsigned i = 0; i < program->instruction_count; ++i) { + for (unsigned int i = 0; i < program->instruction_count; ++i) { LOG_DEBUG("debug_buffer[%02x] = DASM(0x%08x)", i, program->debug_buffer[i]); if (riscv_write_debug_buffer(program->target, i, program->debug_buffer[i]) != ERROR_OK) diff --git a/src/target/riscv/riscv-011.c b/src/target/riscv/riscv-011.c index 565721c28..302ace869 100644 --- a/src/target/riscv/riscv-011.c +++ b/src/target/riscv/riscv-011.c @@ -474,7 +474,7 @@ static uint64_t dbus_read(struct target *target, uint16_t address) * While somewhat nonintuitive, this is an efficient way to get the data. */ - unsigned i = 0; + unsigned int i = 0; do { status = dbus_scan(target, &address_in, &value, DBUS_OP_READ, address, 0); if (status == DBUS_STATUS_BUSY) @@ -495,7 +495,7 @@ static uint64_t dbus_read(struct target *target, uint16_t address) static void dbus_write(struct target *target, uint16_t address, uint64_t value) { dbus_status_t status = DBUS_STATUS_BUSY; - unsigned i = 0; + unsigned int i = 0; while (status == DBUS_STATUS_BUSY && i++ < 256) { status = dbus_scan(target, NULL, NULL, DBUS_OP_WRITE, address, value); if (status == DBUS_STATUS_BUSY) @@ -656,13 +656,13 @@ static void scans_add_read(scans_t *scans, slot_t slot, bool set_interrupt) } static uint32_t scans_get_u32(scans_t *scans, unsigned int index, - unsigned first, unsigned num) + unsigned int first, unsigned int num) { return buf_get_u32(scans->in + scans->scan_size * index, first, num); } static uint64_t scans_get_u64(scans_t *scans, unsigned int index, - unsigned first, unsigned num) + unsigned int first, unsigned int num) { return buf_get_u64(scans->in + scans->scan_size * index, first, num); } @@ -699,7 +699,7 @@ static bits_t read_bits(struct target *target) }; do { - unsigned i = 0; + unsigned int i = 0; do { status = dbus_scan(target, &address_in, &value, DBUS_OP_READ, 0, 0); if (status == DBUS_STATUS_BUSY) { @@ -1296,7 +1296,7 @@ static int register_write(struct target *target, unsigned int number, int result = update_mstatus_actual(target); if (result != ERROR_OK) return result; - unsigned i = 0; + unsigned int i = 0; if ((info->mstatus_actual & MSTATUS_FS) == 0) { info->mstatus_actual = set_field(info->mstatus_actual, MSTATUS_FS, 1); cache_set_load(target, i++, S0, SLOT1); @@ -1352,7 +1352,7 @@ static int get_register(struct target *target, riscv_reg_t *value, int regid) int result = update_mstatus_actual(target); if (result != ERROR_OK) return result; - unsigned i = 0; + unsigned int i = 0; if ((info->mstatus_actual & MSTATUS_FS) == 0) { info->mstatus_actual = set_field(info->mstatus_actual, MSTATUS_FS, 1); cache_set_load(target, i++, S0, SLOT1); @@ -1538,7 +1538,7 @@ static int examine(struct target *target) /* 0x00000000 0x00000000:00000003 0x00000000:00000003:ffffffff:ffffffff */ cache_set32(target, 4, sw(S1, ZERO, DEBUG_RAM_START + 4)); cache_set_jump(target, 5); - for (unsigned i = 6; i < info->dramsize; i++) + for (unsigned int i = 6; i < info->dramsize; i++) cache_set32(target, i, i * 0x01020304); cache_write(target, 0, false); @@ -1569,7 +1569,7 @@ static int examine(struct target *target) LOG_DEBUG("Discovered XLEN is %d", riscv_xlen(target)); if (read_remote_csr(target, &r->misa, CSR_MISA) != ERROR_OK) { - const unsigned old_csr_misa = 0xf10; + const unsigned int old_csr_misa = 0xf10; LOG_WARNING("Failed to read misa at 0x%x; trying 0x%x.", CSR_MISA, old_csr_misa); if (read_remote_csr(target, &r->misa, old_csr_misa) != ERROR_OK) { @@ -1651,7 +1651,7 @@ static riscv_error_t handle_halt_routine(struct target *target) unsigned int dbus_busy = 0; unsigned int interrupt_set = 0; - unsigned result = 0; + unsigned int result = 0; uint64_t value = 0; reg_cache_set(target, 0, 0); /* The first scan result is the result from something old we don't care @@ -2016,7 +2016,7 @@ static int read_memory(struct target *target, target_addr_t address, cache_write(target, CACHE_NO_READ, false); riscv011_info_t *info = get_info(target); - const unsigned max_batch_size = 256; + const unsigned int max_batch_size = 256; scans_t *scans = scans_new(target, max_batch_size); if (!scans) return ERROR_FAIL; @@ -2174,7 +2174,7 @@ static int write_memory(struct target *target, target_addr_t address, if (setup_write_memory(target, size) != ERROR_OK) return ERROR_FAIL; - const unsigned max_batch_size = 256; + const unsigned int max_batch_size = 256; scans_t *scans = scans_new(target, max_batch_size); if (!scans) return ERROR_FAIL; diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index dbf9aad1d..16eced2d8 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -48,7 +48,7 @@ static int riscv013_on_step(struct target *target); static int riscv013_resume_prep(struct target *target); static bool riscv013_is_halted(struct target *target); static enum riscv_halt_reason riscv013_halt_reason(struct target *target); -static int riscv013_write_debug_buffer(struct target *target, unsigned index, +static int riscv013_write_debug_buffer(struct target *target, unsigned int index, riscv_insn_t d); static riscv_insn_t riscv013_read_debug_buffer(struct target *target, unsigned index); @@ -59,7 +59,7 @@ static int riscv013_dmi_write_u64_bits(struct target *target); static void riscv013_fill_dmi_nop_u64(struct target *target, char *buf); static int register_read(struct target *target, uint64_t *value, uint32_t number); static int register_read_direct(struct target *target, uint64_t *value, uint32_t number); -static int register_write_direct(struct target *target, unsigned number, +static int register_write_direct(struct target *target, unsigned int number, uint64_t value); static int read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer, uint32_t increment); @@ -156,13 +156,13 @@ typedef struct { typedef struct { /* The indexed used to address this hart in its DM. */ - unsigned index; + unsigned int index; /* Number of address bits in the dbus register. */ - unsigned abits; + unsigned int abits; /* Number of abstract command data registers. */ - unsigned datacount; + unsigned int datacount; /* Number of words in the Program Buffer. */ - unsigned progbufsize; + unsigned int progbufsize; /* We cache the read-only bits of sbcs here. */ uint32_t sbcs; @@ -209,7 +209,7 @@ typedef struct { int16_t dataaddr; /* The width of the hartsel field. */ - unsigned hartsellen; + unsigned int hartsellen; /* DM that provides access to this target. */ dm013_info_t *dm; @@ -290,10 +290,10 @@ static uint32_t set_hartsel(uint32_t initial, uint32_t index) return initial; } -static void decode_dmi(char *text, unsigned address, unsigned data) +static void decode_dmi(char *text, unsigned int address, unsigned int data) { static const struct { - unsigned address; + unsigned int address; uint64_t mask; const char *name; } description[] = { @@ -350,10 +350,10 @@ static void decode_dmi(char *text, unsigned address, unsigned data) }; text[0] = 0; - for (unsigned i = 0; i < ARRAY_SIZE(description); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(description); i++) { if (description[i].address == address) { uint64_t mask = description[i].mask; - unsigned value = get_field(data, mask); + unsigned int value = get_field(data, mask); if (value) { if (i > 0) *(text++) = ' '; @@ -468,7 +468,7 @@ static dmi_status_t dmi_scan(struct target *target, uint32_t *address_in, { riscv013_info_t *info = get_info(target); RISCV_INFO(r); - unsigned num_bits = info->abits + DTM_DMI_OP_LENGTH + DTM_DMI_DATA_LENGTH; + unsigned int num_bits = info->abits + DTM_DMI_OP_LENGTH + DTM_DMI_DATA_LENGTH; size_t num_bytes = (num_bits + 7) / 8; uint8_t in[num_bytes]; uint8_t out[num_bytes]; @@ -680,7 +680,7 @@ static int dmi_write_exec(struct target *target, uint32_t address, } static int dmstatus_read_timeout(struct target *target, uint32_t *dmstatus, - bool authenticated, unsigned timeout_sec) + bool authenticated, unsigned int timeout_sec) { int result = dmi_op_timeout(target, dmstatus, NULL, DMI_OP_READ, DM_DMSTATUS, 0, timeout_sec, false, true); @@ -717,7 +717,7 @@ static void increase_ac_busy_delay(struct target *target) info->ac_busy_delay); } -static uint32_t __attribute__((unused)) abstract_register_size(unsigned width) +static uint32_t __attribute__((unused)) abstract_register_size(unsigned int width) { switch (width) { case 32: @@ -807,12 +807,12 @@ static int execute_abstract_command(struct target *target, uint32_t command) return ERROR_OK; } -static riscv_reg_t read_abstract_arg(struct target *target, unsigned index, - unsigned size_bits) +static riscv_reg_t read_abstract_arg(struct target *target, unsigned int index, + unsigned int size_bits) { riscv_reg_t value = 0; uint32_t v; - unsigned offset = index * size_bits / 32; + unsigned int offset = index * size_bits / 32; switch (size_bits) { default: LOG_ERROR("Unsupported size: %d bits", size_bits); @@ -828,10 +828,10 @@ static riscv_reg_t read_abstract_arg(struct target *target, unsigned index, return value; } -static int write_abstract_arg(struct target *target, unsigned index, - riscv_reg_t value, unsigned size_bits) +static int write_abstract_arg(struct target *target, unsigned int index, + riscv_reg_t value, unsigned int size_bits) { - unsigned offset = index * size_bits / 32; + unsigned int offset = index * size_bits / 32; switch (size_bits) { default: LOG_ERROR("Unsupported size: %d bits", size_bits); @@ -849,7 +849,7 @@ static int write_abstract_arg(struct target *target, unsigned index, * @par size in bits */ static uint32_t access_register_command(struct target *target, uint32_t number, - unsigned size, uint32_t flags) + unsigned int size, uint32_t flags) { uint32_t command = set_field(0, DM_COMMAND_CMDTYPE, 0); switch (size) { @@ -891,7 +891,7 @@ static uint32_t access_register_command(struct target *target, uint32_t number, } static int register_read_abstract(struct target *target, uint64_t *value, - uint32_t number, unsigned size) + uint32_t number, unsigned int size) { RISCV013_INFO(info); @@ -929,7 +929,7 @@ static int register_read_abstract(struct target *target, uint64_t *value, } static int register_write_abstract(struct target *target, uint32_t number, - uint64_t value, unsigned size) + uint64_t value, unsigned int size) { RISCV013_INFO(info); @@ -968,7 +968,7 @@ static int register_write_abstract(struct target *target, uint32_t number, * Sets the AAMSIZE field of a memory access abstract command based on * the width (bits). */ -static uint32_t abstract_memory_size(unsigned width) +static uint32_t abstract_memory_size(unsigned int width) { switch (width) { case 8: @@ -991,7 +991,7 @@ static uint32_t abstract_memory_size(unsigned width) * Creates a memory access abstract command. */ static uint32_t access_memory_command(struct target *target, bool virtual, - unsigned width, bool postincrement, bool write) + unsigned int width, bool postincrement, bool write) { uint32_t command = set_field(0, AC_ACCESS_MEMORY_CMDTYPE, 2); command = set_field(command, AC_ACCESS_MEMORY_AAMVIRTUAL, virtual); @@ -1134,7 +1134,7 @@ typedef struct { static int scratch_reserve(struct target *target, scratch_mem_t *scratch, struct riscv_program *program, - unsigned size_bytes) + unsigned int size_bytes) { riscv_addr_t alignment = 1; while (alignment < size_bytes) @@ -1166,7 +1166,7 @@ static int scratch_reserve(struct target *target, return ERROR_FAIL; /* Allow for ebreak at the end of the program. */ - unsigned program_size = (program->instruction_count + 1) * 4; + unsigned int program_size = (program->instruction_count + 1) * 4; scratch->hart_address = (info->progbuf_address + program_size + alignment - 1) & ~(alignment - 1); if ((info->progbuf_writable == YNM_YES) && @@ -1271,7 +1271,7 @@ static int scratch_write64(struct target *target, scratch_mem_t *scratch, } /** Return register size in bits. */ -static unsigned register_size(struct target *target, unsigned number) +static unsigned int register_size(struct target *target, unsigned int number) { /* If reg_cache hasn't been initialized yet, make a guess. We need this for * when this function is called during examine(). */ @@ -1281,7 +1281,7 @@ static unsigned register_size(struct target *target, unsigned number) return riscv_xlen(target); } -static bool has_sufficient_progbuf(struct target *target, unsigned size) +static bool has_sufficient_progbuf(struct target *target, unsigned int size) { RISCV013_INFO(info); RISCV_INFO(r); @@ -1293,7 +1293,7 @@ static bool has_sufficient_progbuf(struct target *target, unsigned size) * Immediately write the new value to the requested register. This mechanism * bypasses any caches. */ -static int register_write_direct(struct target *target, unsigned number, +static int register_write_direct(struct target *target, unsigned int number, uint64_t value) { LOG_DEBUG("{%d} %s <- 0x%" PRIx64, riscv_current_hartid(target), @@ -1834,7 +1834,7 @@ static int riscv013_hart_count(struct target *target) } /* Try to find out the widest memory access size depending on the selected memory access methods. */ -static unsigned riscv013_data_bits(struct target *target) +static unsigned int riscv013_data_bits(struct target *target) { RISCV013_INFO(info); RISCV_INFO(r); @@ -1904,12 +1904,12 @@ static COMMAND_HELPER(riscv013_print_info, struct target *target) } static int prep_for_vector_access(struct target *target, uint64_t *vtype, - uint64_t *vl, unsigned *debug_vl) + uint64_t *vl, unsigned int *debug_vl) { RISCV_INFO(r); /* TODO: this continuous save/restore is terrible for performance. */ /* Write vtype and vl. */ - unsigned encoded_vsew; + unsigned int encoded_vsew; switch (riscv_xlen(target)) { case 32: encoded_vsew = 2; @@ -1965,12 +1965,12 @@ static int riscv013_get_register_buf(struct target *target, return ERROR_FAIL; uint64_t vtype, vl; - unsigned debug_vl; + unsigned int debug_vl; if (prep_for_vector_access(target, &vtype, &vl, &debug_vl) != ERROR_OK) return ERROR_FAIL; - unsigned vnum = regno - GDB_REGNO_V0; - unsigned xlen = riscv_xlen(target); + unsigned int vnum = regno - GDB_REGNO_V0; + unsigned int xlen = riscv_xlen(target); struct riscv_program program; riscv_program_init(&program, target); @@ -1978,7 +1978,7 @@ static int riscv013_get_register_buf(struct target *target, riscv_program_insert(&program, vslide1down_vx(vnum, vnum, S0, true)); int result = ERROR_OK; - for (unsigned i = 0; i < debug_vl; i++) { + for (unsigned int i = 0; i < debug_vl; i++) { /* Executing the program might result in an exception if there is some * issue with the vector implementation/instructions we're using. If that * happens, attempt to restore as usual. We may have clobbered the @@ -2024,18 +2024,18 @@ static int riscv013_set_register_buf(struct target *target, return ERROR_FAIL; uint64_t vtype, vl; - unsigned debug_vl; + unsigned int debug_vl; if (prep_for_vector_access(target, &vtype, &vl, &debug_vl) != ERROR_OK) return ERROR_FAIL; - unsigned vnum = regno - GDB_REGNO_V0; - unsigned xlen = riscv_xlen(target); + unsigned int vnum = regno - GDB_REGNO_V0; + unsigned int xlen = riscv_xlen(target); struct riscv_program program; riscv_program_init(&program, target); riscv_program_insert(&program, vslide1down_vx(vnum, vnum, S0, true)); int result = ERROR_OK; - for (unsigned i = 0; i < debug_vl; i++) { + for (unsigned int i = 0; i < debug_vl; i++) { if (register_write_direct(target, GDB_REGNO_S0, buf_get_u64(value, xlen * i, xlen)) != ERROR_OK) return ERROR_FAIL; @@ -2476,7 +2476,7 @@ static int execute_fence(struct target *target) } static void log_memory_access(target_addr_t address, uint64_t value, - unsigned size_bytes, bool read) + unsigned int size_bytes, bool read) { if (debug_level < LOG_LVL_DEBUG) return; @@ -2524,7 +2524,7 @@ static int read_memory_bus_word(struct target *target, target_addr_t address, static target_addr_t sb_read_address(struct target *target) { RISCV013_INFO(info); - unsigned sbasize = get_field(info->sbcs, DM_SBCS_SBASIZE); + unsigned int sbasize = get_field(info->sbcs, DM_SBCS_SBASIZE); target_addr_t address = 0; uint32_t v; if (sbasize > 32) { @@ -2717,7 +2717,7 @@ static int read_memory_bus_v1(struct target *target, target_addr_t address, for (uint32_t i = (next_address - address) / size; i < count - 1; i++) { for (int j = (size - 1) / 4; j >= 0; j--) { uint32_t value; - unsigned attempt = 0; + unsigned int attempt = 0; while (1) { if (attempt++ > 100) { LOG_ERROR("DMI keeps being busy in while reading memory just past " TARGET_ADDR_FMT, @@ -2745,7 +2745,7 @@ static int read_memory_bus_v1(struct target *target, target_addr_t address, uint32_t sbcs_read = 0; if (count > 1) { uint32_t value; - unsigned attempt = 0; + unsigned int attempt = 0; while (1) { if (attempt++ > 100) { LOG_ERROR("DMI keeps being busy in while reading memory just past " TARGET_ADDR_FMT, @@ -2793,7 +2793,7 @@ static int read_memory_bus_v1(struct target *target, target_addr_t address, continue; } - unsigned error = get_field(sbcs_read, DM_SBCS_SBERROR); + unsigned int error = get_field(sbcs_read, DM_SBCS_SBERROR); if (error == 0) { next_address = end_address; } else { @@ -2959,7 +2959,7 @@ static int read_memory_abstract(struct target *target, target_addr_t address, memset(buffer, 0, count * size); /* Convert the size (bytes) to width (bits) */ - unsigned width = size << 3; + unsigned int width = size << 3; /* Create the command (physical address, postincrement, read) */ uint32_t command = access_memory_command(target, false, width, use_aampostincrement, false); @@ -3035,7 +3035,7 @@ static int write_memory_abstract(struct target *target, target_addr_t address, size, address); /* Convert the size (bytes) to width (bits) */ - unsigned width = size << 3; + unsigned int width = size << 3; /* Create the command (physical address, postincrement, write) */ uint32_t command = access_memory_command(target, false, width, use_aampostincrement, true); @@ -3145,7 +3145,7 @@ static int read_memory_progbuf_inner(struct target *target, target_addr_t addres /* read_addr is the next address that the hart will read from, which is the * value in s0. */ - unsigned index = 2; + unsigned int index = 2; while (index < count) { riscv_addr_t read_addr = address + index * increment; LOG_DEBUG("i=%d, count=%d, read_addr=0x%" PRIx64, index, count, read_addr); @@ -3162,8 +3162,8 @@ static int read_memory_progbuf_inner(struct target *target, target_addr_t addres if (!batch) return ERROR_FAIL; - unsigned reads = 0; - for (unsigned j = index; j < count; j++) { + unsigned int reads = 0; + for (unsigned int j = index; j < count; j++) { if (size > 4) riscv_batch_add_dmi_read(batch, DM_DATA1); riscv_batch_add_dmi_read(batch, DM_DATA0); @@ -3186,8 +3186,8 @@ static int read_memory_progbuf_inner(struct target *target, target_addr_t addres return ERROR_FAIL; info->cmderr = get_field(abstractcs, DM_ABSTRACTCS_CMDERR); - unsigned next_index; - unsigned ignore_last = 0; + unsigned int next_index; + unsigned int ignore_last = 0; switch (info->cmderr) { case CMDERR_NONE: LOG_DEBUG("successful (partial?) memory read"); @@ -3256,9 +3256,9 @@ static int read_memory_progbuf_inner(struct target *target, target_addr_t addres /* Now read whatever we got out of the batch. */ dmi_status_t status = DMI_STATUS_SUCCESS; - unsigned read = 0; + unsigned int read = 0; assert(index >= 2); - for (unsigned j = index - 2; j < index + reads; j++) { + for (unsigned int j = index - 2; j < index + reads; j++) { assert(j < count); LOG_DEBUG("index=%d, reads=%d, next_index=%d, ignore_last=%d, j=%d", index, reads, next_index, ignore_last, j); @@ -3867,9 +3867,9 @@ static int write_memory_progbuf(struct target *target, target_addr_t address, goto error; /* To write another word, we put it in S1 and execute the program. */ - unsigned start = (cur_addr - address) / size; - for (unsigned i = start; i < count; ++i) { - unsigned offset = size*i; + unsigned int start = (cur_addr - address) / size; + for (unsigned int i = start; i < count; ++i) { + unsigned int offset = size * i; const uint8_t *t_buffer = buffer + offset; uint64_t value = buf_get_u64(t_buffer, 0, 8 * size); @@ -4160,18 +4160,18 @@ static int select_prepped_harts(struct target *target, bool *use_hasel) } assert(dm->hart_count); - unsigned hawindow_count = (dm->hart_count + 31) / 32; + unsigned int hawindow_count = (dm->hart_count + 31) / 32; uint32_t hawindow[hawindow_count]; memset(hawindow, 0, sizeof(uint32_t) * hawindow_count); target_list_t *entry; - unsigned total_selected = 0; + unsigned int total_selected = 0; list_for_each_entry(entry, &dm->target_list, list) { struct target *t = entry->target; struct riscv_info *r = riscv_info(t); riscv013_info_t *info = get_info(t); - unsigned index = info->index; + unsigned int index = info->index; LOG_DEBUG("index=%d, coreid=%d, prepped=%d", index, t->coreid, r->prepped); r->selected = r->prepped; if (r->prepped) { @@ -4188,7 +4188,7 @@ static int select_prepped_harts(struct target *target, bool *use_hasel) return ERROR_OK; } - for (unsigned i = 0; i < hawindow_count; i++) { + for (unsigned int i = 0; i < hawindow_count; i++) { if (dmi_write(target, DM_HAWINDOWSEL, i) != ERROR_OK) return ERROR_FAIL; if (dmi_write(target, DM_HAWINDOW, hawindow[i]) != ERROR_OK) @@ -4346,7 +4346,7 @@ static enum riscv_halt_reason riscv013_halt_reason(struct target *target) return RISCV_HALT_UNKNOWN; } -int riscv013_write_debug_buffer(struct target *target, unsigned index, riscv_insn_t data) +int riscv013_write_debug_buffer(struct target *target, unsigned int index, riscv_insn_t data) { dm013_info_t *dm = get_dm(target); if (!dm) @@ -4361,7 +4361,7 @@ int riscv013_write_debug_buffer(struct target *target, unsigned index, riscv_ins return ERROR_OK; } -riscv_insn_t riscv013_read_debug_buffer(struct target *target, unsigned index) +riscv_insn_t riscv013_read_debug_buffer(struct target *target, unsigned int index) { uint32_t value; dmi_read(target, &value, DM_PROGBUF0 + index); diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 511a3c6c3..99f40a739 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -476,7 +476,7 @@ static void riscv_free_registers(struct target *target) if (target->reg_cache->reg_list) { free(target->reg_cache->reg_list[0].arch_info); /* Free the ones we allocated separately. */ - for (unsigned i = GDB_REGNO_COUNT; i < target->reg_cache->num_regs; i++) + for (unsigned int i = GDB_REGNO_COUNT; i < target->reg_cache->num_regs; i++) free(target->reg_cache->reg_list[i].arch_info); for (unsigned int i = 0; i < target->reg_cache->num_regs; i++) free(target->reg_cache->reg_list[i].value); @@ -1583,7 +1583,7 @@ static int riscv_address_translate(struct target *target, if (result != ERROR_OK) return result; - unsigned xlen = riscv_xlen(target); + unsigned int xlen = riscv_xlen(target); mode = get_field(satp_value, RISCV_SATP_MODE(xlen)); switch (mode) { case SATP_MODE_SV32: @@ -1927,7 +1927,7 @@ static int riscv_run_algorithm(struct target *target, int num_mem_params, GDB_REGNO_PC, GDB_REGNO_MSTATUS, GDB_REGNO_MEPC, GDB_REGNO_MCAUSE, }; - for (unsigned i = 0; i < ARRAY_SIZE(regnums); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(regnums); i++) { enum gdb_regno regno = regnums[i]; riscv_reg_t reg_value; if (riscv_get_register(target, ®_value, regno) != ERROR_OK) @@ -2007,8 +2007,8 @@ static int riscv_checksum_memory(struct target *target, static const uint8_t *crc_code; - unsigned xlen = riscv_xlen(target); - unsigned crc_code_size; + unsigned int xlen = riscv_xlen(target); + unsigned int crc_code_size; if (xlen == 32) { crc_code = riscv32_crc_code; crc_code_size = sizeof(riscv32_crc_code); @@ -2187,8 +2187,8 @@ int riscv_openocd_poll(struct target *target) int halted_hart = -1; if (target->smp) { - unsigned should_remain_halted = 0; - unsigned should_resume = 0; + unsigned int should_remain_halted = 0; + unsigned int should_resume = 0; struct target_list *list; foreach_smp_target(list, target->smp_targets) { struct target *t = list->target; @@ -2436,8 +2436,8 @@ static int parse_ranges(struct list_head *ranges, const char *tcl_arg, const cha /* For backward compatibility, allow multiple parameters within one TCL argument, separated by ',' */ char *arg = strtok(args, ","); while (arg) { - unsigned low = 0; - unsigned high = 0; + unsigned int low = 0; + unsigned int high = 0; char *name = NULL; char *dash = strchr(arg, '-'); @@ -3055,7 +3055,7 @@ static const struct command_registration riscv_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static unsigned riscv_xlen_nonconst(struct target *target) +static unsigned int riscv_xlen_nonconst(struct target *target) { return riscv_xlen(target); } @@ -3194,7 +3194,7 @@ static int riscv_step_rtos_hart(struct target *target) bool riscv_supports_extension(struct target *target, char letter) { RISCV_INFO(r); - unsigned num; + unsigned int num; if (letter >= 'a' && letter <= 'z') num = letter - 'a'; else if (letter >= 'A' && letter <= 'Z') @@ -3204,7 +3204,7 @@ bool riscv_supports_extension(struct target *target, char letter) return r->misa & BIT(num); } -unsigned riscv_xlen(const struct target *target) +unsigned int riscv_xlen(const struct target *target) { RISCV_INFO(r); return r->xlen; @@ -3778,7 +3778,7 @@ static struct reg_arch_type riscv_reg_arch_type = { }; struct csr_info { - unsigned number; + unsigned int number; const char *name; }; @@ -3958,7 +3958,7 @@ int riscv_init_registers(struct target *target) }; /* encoding.h does not contain the registers in sorted order. */ qsort(csr_info, ARRAY_SIZE(csr_info), sizeof(*csr_info), cmp_csr_info); - unsigned csr_info_index = 0; + unsigned int csr_info_index = 0; int custom_within_range = 0; @@ -4213,7 +4213,7 @@ int riscv_init_registers(struct target *target) } else if (number >= GDB_REGNO_CSR0 && number <= GDB_REGNO_CSR4095) { r->group = "csr"; r->feature = &feature_csr; - unsigned csr_number = number - GDB_REGNO_CSR0; + unsigned int csr_number = number - GDB_REGNO_CSR0; while (csr_info[csr_info_index].number < csr_number && csr_info_index < ARRAY_SIZE(csr_info) - 1) { @@ -4376,7 +4376,7 @@ int riscv_init_registers(struct target *target) range_list_t *range = list_first_entry(&info->expose_custom, range_list_t, list); - unsigned custom_number = range->low + custom_within_range; + unsigned int custom_number = range->low + custom_within_range; r->group = "custom"; r->feature = &feature_custom; diff --git a/src/target/riscv/riscv.h b/src/target/riscv/riscv.h index aba0864e6..6cb2709de 100644 --- a/src/target/riscv/riscv.h +++ b/src/target/riscv/riscv.h @@ -61,7 +61,7 @@ enum riscv_halt_reason { typedef struct { struct target *target; - unsigned custom_number; + unsigned int custom_number; } riscv_reg_info_t; #define RISCV_SAMPLE_BUF_TIMESTAMP_BEFORE 0x80 @@ -90,7 +90,7 @@ typedef struct { struct riscv_info { unsigned int common_magic; - unsigned dtm_version; + unsigned int dtm_version; struct command_context *cmd_ctx; void *version_specific; @@ -159,9 +159,9 @@ struct riscv_info { int (*halt_go)(struct target *target); int (*on_step)(struct target *target); enum riscv_halt_reason (*halt_reason)(struct target *target); - int (*write_debug_buffer)(struct target *target, unsigned index, + int (*write_debug_buffer)(struct target *target, unsigned int index, riscv_insn_t d); - riscv_insn_t (*read_debug_buffer)(struct target *target, unsigned index); + riscv_insn_t (*read_debug_buffer)(struct target *target, unsigned int index); int (*execute_debug_buffer)(struct target *target); int (*dmi_write_u64_bits)(struct target *target); void (*fill_dmi_write_u64)(struct target *target, char *buf, int a, uint64_t d); @@ -184,7 +184,7 @@ struct riscv_info { /* How many harts are attached to the DM that this target is attached to? */ int (*hart_count)(struct target *target); - unsigned (*data_bits)(struct target *target); + unsigned int (*data_bits)(struct target *target); COMMAND_HELPER((*print_info), struct target *target); @@ -239,14 +239,14 @@ typedef struct { typedef struct { const char *name; int level; - unsigned va_bits; - unsigned pte_shift; - unsigned vpn_shift[PG_MAX_LEVEL]; - unsigned vpn_mask[PG_MAX_LEVEL]; - unsigned pte_ppn_shift[PG_MAX_LEVEL]; - unsigned pte_ppn_mask[PG_MAX_LEVEL]; - unsigned pa_ppn_shift[PG_MAX_LEVEL]; - unsigned pa_ppn_mask[PG_MAX_LEVEL]; + unsigned int va_bits; + unsigned int pte_shift; + unsigned int vpn_shift[PG_MAX_LEVEL]; + unsigned int vpn_mask[PG_MAX_LEVEL]; + unsigned int pte_ppn_shift[PG_MAX_LEVEL]; + unsigned int pte_ppn_mask[PG_MAX_LEVEL]; + unsigned int pa_ppn_shift[PG_MAX_LEVEL]; + unsigned int pa_ppn_mask[PG_MAX_LEVEL]; } virt2phys_info_t; /* Wall-clock timeout for a command/access. Settable via RISC-V Target commands.*/ @@ -307,7 +307,7 @@ int riscv_openocd_deassert_reset(struct target *target); bool riscv_supports_extension(struct target *target, char letter); /* Returns XLEN for the given (or current) hart. */ -unsigned riscv_xlen(const struct target *target); +unsigned int riscv_xlen(const struct target *target); int riscv_xlen_of_hart(const struct target *target); /* Sets the current hart, which is the hart that will actually be used when From fec3b224214e3784b0c00970d2421212402da880 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 8 Sep 2024 21:47:31 +0200 Subject: [PATCH 27/44] target: riscv: remove non-trivial 'unsigned' cast Change the prototype of riscv_batch_get_dmi_read_op(). Now that 'target->smp' is unsigned, drop the cast. Change-Id: I2a54268ed1e4bf0ea884b62cceb73f5c7451da78 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8484 Tested-by: jenkins --- src/target/riscv/batch.c | 4 ++-- src/target/riscv/batch.h | 2 +- src/target/riscv/riscv-013.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/target/riscv/batch.c b/src/target/riscv/batch.c index 859e2275e..e3f8ff3d4 100644 --- a/src/target/riscv/batch.c +++ b/src/target/riscv/batch.c @@ -156,14 +156,14 @@ size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned int address) return batch->read_keys_used++; } -unsigned int riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key) +uint32_t riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key) { assert(key < batch->read_keys_used); size_t index = batch->read_keys[key]; assert(index <= batch->used_scans); uint8_t *base = batch->data_in + DMI_SCAN_BUF_SIZE * index; /* extract "op" field from the DMI read result */ - return (unsigned)buf_get_u32(base, DTM_DMI_OP_OFFSET, DTM_DMI_OP_LENGTH); + return buf_get_u32(base, DTM_DMI_OP_OFFSET, DTM_DMI_OP_LENGTH); } uint32_t riscv_batch_get_dmi_read_data(struct riscv_batch *batch, size_t key) diff --git a/src/target/riscv/batch.h b/src/target/riscv/batch.h index e5b94cc21..537fa5923 100644 --- a/src/target/riscv/batch.h +++ b/src/target/riscv/batch.h @@ -65,7 +65,7 @@ void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned int address, * provides a key, the second one actually obtains the result of the read - * status (op) and the actual data. */ size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned int address); -unsigned int riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key); +uint32_t riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key); uint32_t riscv_batch_get_dmi_read_data(struct riscv_batch *batch, size_t key); /* Scans in a NOP. */ diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 16eced2d8..6c9ed317b 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1537,7 +1537,7 @@ static int set_haltgroup(struct target *target, bool *supported) uint32_t read; if (dmi_read(target, &read, DM_DMCS2) != ERROR_OK) return ERROR_FAIL; - *supported = get_field(read, DM_DMCS2_GROUP) == (unsigned)target->smp; + *supported = get_field(read, DM_DMCS2_GROUP) == target->smp; return ERROR_OK; } From 21a211d547406d2639ed02256f491ead93a22a20 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 6 Aug 2024 15:28:15 -0700 Subject: [PATCH 28/44] arm_adi_v5: Added Cortex-A55 debug unit identifier Add identifier of the Cortex-A55 debug unit. Change-Id: I67336094a5153a3187cccc32c0e38d78ae4af542 Signed-off-by: Florian Fainelli Reviewed-on: https://review.openocd.org/c/openocd/+/8430 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/target/arm_adi_v5.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c index 3a5afc605..eaaa209b9 100644 --- a/src/target/arm_adi_v5.c +++ b/src/target/arm_adi_v5.c @@ -1532,6 +1532,7 @@ static const struct dap_part_nums { { ARM_ID, 0xc17, "Cortex-R7 Debug", "(Debug Unit)", }, { ARM_ID, 0xd03, "Cortex-A53 Debug", "(Debug Unit)", }, { ARM_ID, 0xd04, "Cortex-A35 Debug", "(Debug Unit)", }, + { ARM_ID, 0xd05, "Cortex-A55 Debug", "(Debug Unit)", }, { ARM_ID, 0xd07, "Cortex-A57 Debug", "(Debug Unit)", }, { ARM_ID, 0xd08, "Cortex-A72 Debug", "(Debug Unit)", }, { ARM_ID, 0xd0b, "Cortex-A76 Debug", "(Debug Unit)", }, From 114ca19f64d8af5365ecf171cc2adc45a763a406 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Thu, 3 Oct 2024 09:59:24 +0200 Subject: [PATCH 29/44] gitignore: Start ignoring ".vscode" To help the developers who use Visual Studio Code IDE, ignore the ".vscode" folder in Git. This folder contains local configuration of the VSCode workspace. Change-Id: I1d54d8ce2bd0680f2fa1fb773bb33c786bdcc608 Signed-off-by: Jan Matyas Reviewed-on: https://review.openocd.org/c/openocd/+/8518 Reviewed-by: Antonio Borneo Tested-by: jenkins --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 103dad2c7..5de33077e 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,9 @@ patches .cproject .settings +# VSCode stuff +.vscode + # Emacs temp files *~ From d09ff476446a5403e556476b41a5a3c9bdf0a706 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Mon, 30 Sep 2024 14:55:58 +0200 Subject: [PATCH 30/44] gdb_server: Improve const correctness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On several packet-handling functions, add "const" to arguments that represent read-only packet buffers. For instance on GCC 13.2.0, this code: const char *some_packet = "..."; gdb_put_packet(conn, some_packet, strlen(some_packet)); would prior to the fix produce warning: passing argument 2 of ‘gdb_put_packet’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] Change-Id: Idb62f57d37ed323c39de38982e57afdd3882e280 Signed-off-by: Jan Matyas Reviewed-on: https://review.openocd.org/c/openocd/+/8517 Reviewed-by: Antonio Borneo Tested-by: jenkins --- src/helper/log.c | 2 +- src/helper/log.h | 2 +- src/server/gdb_server.c | 10 +++++----- src/server/gdb_server.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/helper/log.c b/src/helper/log.c index 62ba4da4c..9ad00ce62 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -505,7 +505,7 @@ void log_socket_error(const char *socket_desc) * Find the first non-printable character in the char buffer, return a pointer to it. * If no such character exists, return NULL. */ -char *find_nonprint_char(char *buf, unsigned int buf_len) +const char *find_nonprint_char(const char *buf, unsigned int buf_len) { for (unsigned int i = 0; i < buf_len; i++) { if (!isprint(buf[i])) diff --git a/src/helper/log.h b/src/helper/log.h index 0f11cfa9a..dc8df6fbb 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -89,7 +89,7 @@ char *alloc_vprintf(const char *fmt, va_list ap); char *alloc_printf(const char *fmt, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 2))); -char *find_nonprint_char(char *buf, unsigned int buf_len); +const char *find_nonprint_char(const char *buf, unsigned int buf_len); extern int debug_level; diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index c1e5e268f..579a388d2 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -335,7 +335,7 @@ static int gdb_putback_char(struct connection *connection, int last_char) /* The only way we can detect that the socket is closed is the first time * we write to it, we will fail. Subsequent write operations will * succeed. Shudder! */ -static int gdb_write(struct connection *connection, void *data, int len) +static int gdb_write(struct connection *connection, const void *data, int len) { struct gdb_connection *gdb_con = connection->priv; if (gdb_con->closed) { @@ -351,7 +351,7 @@ static int gdb_write(struct connection *connection, void *data, int len) return ERROR_SERVER_REMOTE_CLOSED; } -static void gdb_log_incoming_packet(struct connection *connection, char *packet) +static void gdb_log_incoming_packet(struct connection *connection, const char *packet) { if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) return; @@ -384,7 +384,7 @@ static void gdb_log_incoming_packet(struct connection *connection, char *packet) } } -static void gdb_log_outgoing_packet(struct connection *connection, char *packet_buf, +static void gdb_log_outgoing_packet(struct connection *connection, const char *packet_buf, unsigned int packet_len, unsigned char checksum) { if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) @@ -402,7 +402,7 @@ static void gdb_log_outgoing_packet(struct connection *connection, char *packet_ } static int gdb_put_packet_inner(struct connection *connection, - char *buffer, int len) + const char *buffer, int len) { int i; unsigned char my_checksum = 0; @@ -522,7 +522,7 @@ static int gdb_put_packet_inner(struct connection *connection, return ERROR_OK; } -int gdb_put_packet(struct connection *connection, char *buffer, int len) +int gdb_put_packet(struct connection *connection, const char *buffer, int len) { struct gdb_connection *gdb_con = connection->priv; gdb_con->busy = true; diff --git a/src/server/gdb_server.h b/src/server/gdb_server.h index 4288ceb87..1a626ebd9 100644 --- a/src/server/gdb_server.h +++ b/src/server/gdb_server.h @@ -28,7 +28,7 @@ int gdb_target_add_all(struct target *target); int gdb_register_commands(struct command_context *command_context); void gdb_service_free(void); -int gdb_put_packet(struct connection *connection, char *buffer, int len); +int gdb_put_packet(struct connection *connection, const char *buffer, int len); int gdb_get_actual_connections(void); From 7214c8be46f749f210e00d334c30883bd73cca03 Mon Sep 17 00:00:00 2001 From: "R. Diez" Date: Sat, 1 Jun 2024 21:20:31 +0200 Subject: [PATCH 31/44] configure: show adapter Xilinx XVC/PCIe in the configuration summary Adapter Xilinx XVC/PCIe was not appearing in the configuration summary because of the wrong variable name: build_xlnx_pcie_xvc instead of enable_xlnx_pcie_xvc. Also build this adapter automatically on Linux. Change-Id: I69ea92f550052b9ce55ce32597ac446a15a87388 Signed-off-by: R. Diez Reviewed-on: https://review.openocd.org/c/openocd/+/8312 Tested-by: jenkins Reviewed-by: R. Diez Reviewed-by: Antonio Borneo --- configure.ac | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 07e06551f..9355ffb93 100644 --- a/configure.ac +++ b/configure.ac @@ -104,12 +104,18 @@ AS_IF([test -x "$srcdir/guess-rev.sh"], [ AC_MSG_RESULT([$build_release]) # Adapter drivers -# 1st column -- configure option -# 2nd column -- description -# 3rd column -- symbol used for both config.h and automake +# 1st column -- Basename for the configure option generated with AC_ARG_ENABLE. +# For example, "buspirate" generates options "--enable-buspirate[=yes/no]" +# and "--disable-buspirate". +# 2nd column -- Description for the configure option. For example, "Bus Pirate" +# generates "Enable building support for the Bus Pirate (default is auto)". +# 3rd column -- Basename for the config.h and Automake symbols. +# For example, basename "BUS_PIRATE" generates "BUILD_BUS_PIRATE" with AC_DEFINE +# for config.h and "BUS_PIRATE" with AM_CONDITIONAL for Automake. m4_define([ADAPTER_ARG], [m4_argn([1], $1)]) m4_define([ADAPTER_DESC], [m4_argn([2], $1)]) m4_define([ADAPTER_SYM], [m4_argn([3], $1)]) +# AC_ARG_ENABLE uses prefix "enable_" to name the corresponding option variable. m4_define([ADAPTER_VAR], [enable_[]ADAPTER_ARG($1)]) m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])]) @@ -264,6 +270,7 @@ AC_ARG_ADAPTERS([ LIBFTDI_USB1_ADAPTERS LIBGPIOD_ADAPTERS, SERIAL_PORT_ADAPTERS, + PCIE_ADAPTERS, LIBJAYLINK_ADAPTERS ],[auto]) @@ -340,12 +347,10 @@ AC_ARG_ENABLE([sysfsgpio], AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]), [build_sysfsgpio=$enableval], [build_sysfsgpio=no]) -AC_ARG_ENABLE([xlnx_pcie_xvc], - AS_HELP_STRING([--enable-xlnx-pcie-xvc], [Enable building support for Xilinx XVC/PCIe.]), - [build_xlnx_pcie_xvc=$enableval], [build_xlnx_pcie_xvc=no]) - AS_CASE([$host_os], - [linux*], [], + [linux*], [ + is_linux=yes + ], [ AS_IF([test "x$build_sysfsgpio" = "xyes"], [ AC_MSG_ERROR([sysfsgpio is only available on linux]) @@ -355,10 +360,6 @@ AS_CASE([$host_os], AC_MSG_ERROR([linuxgpiod is only available on linux]) ]) - AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [ - AC_MSG_ERROR([xlnx_pcie_xvc is only available on linux]) - ]) - AS_CASE([$host_os], [freebsd*], [], [ AS_IF([test "x$build_rshim" = "xyes"], [ @@ -619,13 +620,6 @@ AS_IF([test "x$build_sysfsgpio" = "xyes"], [ AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.]) ]) -AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [ - build_xlnx_pcie_xvc=yes - AC_DEFINE([BUILD_XLNX_PCIE_XVC], [1], [1 if you want the Xilinx XVC/PCIe driver.]) -], [ - AC_DEFINE([BUILD_XLNX_PCIE_XVC], [0], [0 if you don't want Xilinx XVC/PCIe driver.]) -]) - PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [ use_libusb1=yes AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x]) @@ -687,11 +681,11 @@ PKG_CHECK_MODULES([LIBGPIOD], [libgpiod < 2.0], [ PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.2], [use_libjaylink=yes], [use_libjaylink=no]) -# Arg $1: The adapter name, used to derive option and variable names for the adapter. -# Arg $2: Whether the adapter can be enabled, for example, because -# its prerequisites are installed in the system. +# Arg $1: An array of adapter triplets, used to derive option and variable names for each adapter. +# Arg $2: Whether the adapters can be enabled, for example, because +# their prerequisites are installed in the system. # Arg $3: What prerequisites are missing, to be shown in an error message -# if the adapter was requested but cannot be enabled. +# if an adapter was requested but cannot be enabled. m4_define([PROCESS_ADAPTERS], [ m4_foreach([adapter], [$1], [ AS_IF([test $2], [ @@ -702,7 +696,7 @@ m4_define([PROCESS_ADAPTERS], [ ]) ], [ AS_IF([test "x$ADAPTER_VAR([adapter])" = "xyes"], [ - AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])]) + AC_MSG_ERROR([$3 is required for [adapter] ADAPTER_DESC([adapter]).]) ]) ADAPTER_VAR([adapter])=no AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).) @@ -718,6 +712,7 @@ PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi]) PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"], [libftdi and libusb-1.x]) PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [libgpiod]) PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libjaylink-0.2]) +PROCESS_ADAPTERS([PCIE_ADAPTERS], ["x$is_linux" = "xyes"], [Linux build]) PROCESS_ADAPTERS([DUMMY_ADAPTER], [true], [unused]) AS_IF([test "x$enable_linuxgpiod" != "xno"], [ @@ -774,7 +769,6 @@ AM_CONDITIONAL([GW16012], [test "x$build_gw16012" = "xyes"]) AM_CONDITIONAL([REMOTE_BITBANG], [test "x$build_remote_bitbang" = "xyes"]) AM_CONDITIONAL([BUSPIRATE], [test "x$enable_buspirate" != "xno"]) AM_CONDITIONAL([SYSFSGPIO], [test "x$build_sysfsgpio" = "xyes"]) -AM_CONDITIONAL([XLNX_PCIE_XVC], [test "x$build_xlnx_pcie_xvc" = "xyes"]) AM_CONDITIONAL([USE_LIBUSB1], [test "x$use_libusb1" = "xyes"]) AM_CONDITIONAL([IS_CYGWIN], [test "x$is_cygwin" = "xyes"]) AM_CONDITIONAL([IS_MINGW], [test "x$is_mingw" = "xyes"]) From 3ce0962f2c525595bcbd0bd5da73673e236fc42d Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 15 Jul 2024 11:56:36 +0200 Subject: [PATCH 32/44] target: cortex_m: fix polling for target kept under reset In multi-target SoC not all the targets are running simultaneously and some target could be powered off or kept under reset. Commit 4892e32294c6 ("target/cortex_m: allow poll quickly get out of TARGET_RESET state") does not considers the case of a target that is kept in reset and expects the target to change state from TARGET_RESET immediately. This causes OpenOCD to log continuously: Info : [stm32mp15x.cm4] external reset detected Info : [stm32mp15x.cm4] external reset detected Info : [stm32mp15x.cm4] external reset detected Read again dhcsr to detect the 'stable' reset status and quit, waiting for next poll to re-check the target's status. Change-Id: Ic66029b988404a1599bb99bc66d4a8845b8b02c6 Signed-off-by: Antonio Borneo Fixes: 4892e32294c6 ("target/cortex_m: allow poll quickly get out of TARGET_RESET state") Reviewed-on: https://review.openocd.org/c/openocd/+/8399 Reviewed-by: Tomas Vanek Tested-by: jenkins --- src/target/cortex_m.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index bd0e8d886..e78d2e29b 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -989,6 +989,18 @@ static int cortex_m_poll_one(struct target *target) * and keep it until the next poll to allow its detection */ return ERROR_OK; } + + /* refresh status bits */ + retval = cortex_m_read_dhcsr_atomic_sticky(target); + if (retval != ERROR_OK) + return retval; + + /* If still under reset, quit and re-check at next poll */ + if (cortex_m->dcb_dhcsr_cumulated_sticky & S_RESET_ST) { + cortex_m->dcb_dhcsr_cumulated_sticky &= ~S_RESET_ST; + return ERROR_OK; + } + /* S_RESET_ST was expected (in a reset command). Continue processing * to quickly get out of TARGET_RESET state */ } From 34ec5536c0ba3315bc5a841244bbf70141ccfbb4 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sat, 12 Oct 2024 11:48:05 +0200 Subject: [PATCH 33/44] stlink: deprecate HLA support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The STLink API that supports dap-direct is available from STLink firmware v2j24, published in early 2015. We can reasonably expect that any old STLink still in use today has got at least one firmware update during the last 10 years. Most of the board files in upstream OpenOCD still use the STLink in HLA mode. This limits the test coverage of the dap-direct code, which was introduced in OpenOCD v0.11.0. - Rename interface/stlink.cfg as interface/stlink-hla.cfg to still provide support for HLA, adding a deprecated message. - Rename interface/stlink-dap.cfg as interface/stlink.cfg to make dap-direct the default trasport. - Add a redirect file interface/stlink-dap.cfg for users that have out-of-tree custom board files. - Update all the board files to the new setup. - Remove STLink HLA mentions from the documentation, while adding a reference to interface/stlink-hla.cfg Checkpatch-ignore: LONG_LINE Change-Id: I99366bb03cd3b83f8f408514e657f30e59813063 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8523 Tested-by: jenkins Reviewed-by: Andrzej Sierżęga --- doc/openocd.texi | 20 +++++++------------- tcl/board/st_b-l475e-iot01a.cfg | 2 +- tcl/board/st_nucleo_8l152r8.cfg | 2 +- tcl/board/st_nucleo_8s208rb.cfg | 2 +- tcl/board/st_nucleo_f0.cfg | 2 +- tcl/board/st_nucleo_f103rb.cfg | 2 +- tcl/board/st_nucleo_f3.cfg | 2 +- tcl/board/st_nucleo_f4.cfg | 2 +- tcl/board/st_nucleo_f7.cfg | 2 +- tcl/board/st_nucleo_g0.cfg | 2 +- tcl/board/st_nucleo_g4.cfg | 2 +- tcl/board/st_nucleo_h743zi.cfg | 2 +- tcl/board/st_nucleo_h745zi.cfg | 2 +- tcl/board/st_nucleo_l073rz.cfg | 2 +- tcl/board/st_nucleo_l1.cfg | 2 +- tcl/board/st_nucleo_l4.cfg | 2 +- tcl/board/st_nucleo_l5.cfg | 2 +- tcl/board/st_nucleo_wb55.cfg | 2 +- tcl/board/stm320518_eval_stlink.cfg | 2 +- tcl/board/stm3220g_eval_stlink.cfg | 2 +- tcl/board/stm3241g_eval_stlink.cfg | 2 +- tcl/board/stm32429i_eval_stlink.cfg | 2 +- tcl/board/stm32439i_eval_stlink.cfg | 2 +- tcl/board/stm32f0discovery.cfg | 2 +- tcl/board/stm32f3discovery.cfg | 2 +- tcl/board/stm32f412g-disco.cfg | 2 +- tcl/board/stm32f413h-disco.cfg | 2 +- tcl/board/stm32f429disc1.cfg | 2 +- tcl/board/stm32f429discovery.cfg | 2 +- tcl/board/stm32f469discovery.cfg | 2 +- tcl/board/stm32f469i-disco.cfg | 2 +- tcl/board/stm32f4discovery.cfg | 2 +- tcl/board/stm32f723e-disco.cfg | 2 +- tcl/board/stm32f746g-disco.cfg | 2 +- tcl/board/stm32f769i-disco.cfg | 2 +- tcl/board/stm32f7discovery.cfg | 2 +- tcl/board/stm32h735g-disco.cfg | 2 +- tcl/board/stm32h745i-disco.cfg | 2 +- tcl/board/stm32h747i-disco.cfg | 2 +- tcl/board/stm32h750b-disco.cfg | 2 +- tcl/board/stm32h7b3i-disco.cfg | 2 +- tcl/board/stm32h7x3i_eval.cfg | 2 +- tcl/board/stm32l0discovery.cfg | 2 +- tcl/board/stm32l476g-disco.cfg | 2 +- tcl/board/stm32l496g-disco.cfg | 2 +- tcl/board/stm32l4discovery.cfg | 2 +- tcl/board/stm32l4p5g-disco.cfg | 2 +- tcl/board/stm32l4r9i-disco.cfg | 2 +- tcl/board/stm32ldiscovery.cfg | 2 +- tcl/board/stm32mp13x_dk.cfg | 2 +- tcl/board/stm32mp15x_dk2.cfg | 2 +- tcl/board/stm32vldiscovery.cfg | 2 +- tcl/interface/stlink-dap.cfg | 21 ++------------------- tcl/interface/stlink-hla.cfg | 21 +++++++++++++++++++++ tcl/interface/stlink.cfg | 22 +++++++++++++--------- 55 files changed, 94 insertions(+), 92 deletions(-) create mode 100644 tcl/interface/stlink-hla.cfg diff --git a/doc/openocd.texi b/doc/openocd.texi index 97396c7b7..9b5cfbb83 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2489,7 +2489,7 @@ This command is only available if your libusb1 is at least version 1.0.16. Specifies the @var{serial_string} of the adapter to use. If this command is not specified, serial strings are not checked. Only the following adapter drivers use the serial string from this command: -arm-jtag-ew, cmsis_dap, esp_usb_jtag, ft232r, ftdi, hla (stlink, ti-icdi), jlink, kitprog, opendus, +arm-jtag-ew, cmsis_dap, esp_usb_jtag, ft232r, ftdi, hla (ti-icdi), jlink, kitprog, opendus, openjtag, osbdm, presto, rlink, st-link, usb_blaster (ublast2), usbprog, vsllink, xds110. @end deffn @@ -3206,7 +3206,7 @@ version reported is V2.J21.S4. Currently Not Supported. @end deffn -@deffn {Config Command} {hla layout} (@option{stlink}|@option{icdi}|@option{nulink}) +@deffn {Config Command} {hla layout} (@option{icdi}|@option{nulink}) Specifies the adapter layout to use. @end deffn @@ -3214,15 +3214,6 @@ Specifies the adapter layout to use. Pairs of vendor IDs and product IDs of the device. @end deffn -@deffn {Config Command} {hla stlink_backend} (usb | tcp [port]) -@emph{ST-Link only:} Choose between 'exclusive' USB communication (the default backend) or -'shared' mode using ST-Link TCP server (the default port is 7184). - -@emph{Note:} ST-Link TCP server is a binary application provided by ST -available from @url{https://www.st.com/en/development-tools/st-link-server.html, -ST-LINK server software module}. -@end deffn - @deffn {Command} {hla command} command Execute a custom adapter-specific command. The @var{command} string is passed as is to the underlying adapter layout handler. @@ -3232,9 +3223,12 @@ passed as is to the underlying adapter layout handler. @anchor{st_link_dap_interface} @deffn {Interface Driver} {st-link} This is a driver that supports STMicroelectronics adapters ST-LINK/V2 -(from firmware V2J24), STLINK-V3 and STLINK-V3PWR, thanks to a new API that provides +(from 2015 firmware V2J24), STLINK-V3 and STLINK-V3PWR, thanks to a new API that provides directly access the arm ADIv5 DAP. +The older API that requires HLA transport is deprecated and will be dropped +from OpenOCD. In mean time it's still available by using @file{interface/stlink-hla.cfg}. + The new API provide access to multiple AP on the same DAP, but the maximum number of the AP port is limited by the specific firmware version (e.g. firmware V2J29 has 3 as maximum AP number, while V2J32 has 8). @@ -10677,7 +10671,7 @@ baud with our custom divisor to get 12MHz) @item OpenOCD invocation line: @example openocd -f interface/stlink.cfg \ --c "transport select hla_swd" \ +-c "transport select dapdirect_swd" \ -f target/stm32l1.cfg \ -c "stm32l1.tpiu configure -protocol uart" \ -c "stm32l1.tpiu configure -traceclk 24000000 -pin-freq 12000000" \ diff --git a/tcl/board/st_b-l475e-iot01a.cfg b/tcl/board/st_b-l475e-iot01a.cfg index e75c99d7a..3f3db125c 100644 --- a/tcl/board/st_b-l475e-iot01a.cfg +++ b/tcl/board/st_b-l475e-iot01a.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 96KB set WORKAREASIZE 0x18000 diff --git a/tcl/board/st_nucleo_8l152r8.cfg b/tcl/board/st_nucleo_8l152r8.cfg index 7cb8bcecd..681b5a243 100644 --- a/tcl/board/st_nucleo_8l152r8.cfg +++ b/tcl/board/st_nucleo_8l152r8.cfg @@ -3,7 +3,7 @@ # This is a ST NUCLEO 8L152R8 board with a single STM8L152R8T6 chip. # http://www.st.com/en/evaluation-tools/nucleo-8l152r8.html -source [find interface/stlink-dap.cfg] +source [find interface/stlink.cfg] transport select swim diff --git a/tcl/board/st_nucleo_8s208rb.cfg b/tcl/board/st_nucleo_8s208rb.cfg index 0d3c0c912..0f6bde215 100644 --- a/tcl/board/st_nucleo_8s208rb.cfg +++ b/tcl/board/st_nucleo_8s208rb.cfg @@ -3,7 +3,7 @@ # This is a ST NUCLEO 8S208RB board with a single STM8S208RBT6 chip. # https://www.st.com/en/evaluation-tools/nucleo-8s208rb.html -source [find interface/stlink-dap.cfg] +source [find interface/stlink.cfg] transport select swim diff --git a/tcl/board/st_nucleo_f0.cfg b/tcl/board/st_nucleo_f0.cfg index 31a95f59d..00c131fd6 100644 --- a/tcl/board/st_nucleo_f0.cfg +++ b/tcl/board/st_nucleo_f0.cfg @@ -10,7 +10,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32f0x.cfg] diff --git a/tcl/board/st_nucleo_f103rb.cfg b/tcl/board/st_nucleo_f103rb.cfg index 9815d4546..892bdda99 100644 --- a/tcl/board/st_nucleo_f103rb.cfg +++ b/tcl/board/st_nucleo_f103rb.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32f1x.cfg] diff --git a/tcl/board/st_nucleo_f3.cfg b/tcl/board/st_nucleo_f3.cfg index 883372494..38f49e3d5 100644 --- a/tcl/board/st_nucleo_f3.cfg +++ b/tcl/board/st_nucleo_f3.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32f3x.cfg] diff --git a/tcl/board/st_nucleo_f4.cfg b/tcl/board/st_nucleo_f4.cfg index a1908e403..7617a1758 100644 --- a/tcl/board/st_nucleo_f4.cfg +++ b/tcl/board/st_nucleo_f4.cfg @@ -8,7 +8,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32f4x.cfg] diff --git a/tcl/board/st_nucleo_f7.cfg b/tcl/board/st_nucleo_f7.cfg index 9c5b36ea4..41f8b2129 100644 --- a/tcl/board/st_nucleo_f7.cfg +++ b/tcl/board/st_nucleo_f7.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32f7x.cfg] diff --git a/tcl/board/st_nucleo_g0.cfg b/tcl/board/st_nucleo_g0.cfg index f8e67a043..f22a7e397 100644 --- a/tcl/board/st_nucleo_g0.cfg +++ b/tcl/board/st_nucleo_g0.cfg @@ -12,7 +12,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32g0x.cfg] diff --git a/tcl/board/st_nucleo_g4.cfg b/tcl/board/st_nucleo_g4.cfg index 8e583e77d..309f7a4c8 100644 --- a/tcl/board/st_nucleo_g4.cfg +++ b/tcl/board/st_nucleo_g4.cfg @@ -12,7 +12,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32g4x.cfg] diff --git a/tcl/board/st_nucleo_h743zi.cfg b/tcl/board/st_nucleo_h743zi.cfg index b857b00e0..be2d42fb8 100644 --- a/tcl/board/st_nucleo_h743zi.cfg +++ b/tcl/board/st_nucleo_h743zi.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32h7x_dual_bank.cfg] diff --git a/tcl/board/st_nucleo_h745zi.cfg b/tcl/board/st_nucleo_h745zi.cfg index ad563b7d3..84865f422 100644 --- a/tcl/board/st_nucleo_h745zi.cfg +++ b/tcl/board/st_nucleo_h745zi.cfg @@ -2,7 +2,7 @@ # This is an ST NUCLEO-H745ZI-Q board with single STM32H745ZITx chip. -source [find interface/stlink-dap.cfg] +source [find interface/stlink.cfg] transport select dapdirect_swd # STM32H745xx devices are dual core (Cortex-M7 and Cortex-M4) diff --git a/tcl/board/st_nucleo_l073rz.cfg b/tcl/board/st_nucleo_l073rz.cfg index 10fac5ef8..317c86e21 100644 --- a/tcl/board/st_nucleo_l073rz.cfg +++ b/tcl/board/st_nucleo_l073rz.cfg @@ -4,7 +4,7 @@ # http://www.st.com/en/evaluation-tools/nucleo-l073rz.html source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd set WORKAREASIZE 0x2000 diff --git a/tcl/board/st_nucleo_l1.cfg b/tcl/board/st_nucleo_l1.cfg index 50688d2b6..d7474d0fe 100644 --- a/tcl/board/st_nucleo_l1.cfg +++ b/tcl/board/st_nucleo_l1.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32l1x_dual_bank.cfg] diff --git a/tcl/board/st_nucleo_l4.cfg b/tcl/board/st_nucleo_l4.cfg index 8c63d8cbf..b0a75afe0 100644 --- a/tcl/board/st_nucleo_l4.cfg +++ b/tcl/board/st_nucleo_l4.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32l4x.cfg] diff --git a/tcl/board/st_nucleo_l5.cfg b/tcl/board/st_nucleo_l5.cfg index 6450f08b8..626914aa7 100644 --- a/tcl/board/st_nucleo_l5.cfg +++ b/tcl/board/st_nucleo_l5.cfg @@ -3,7 +3,7 @@ # This is for STM32L5 Nucleo Dev Boards. # http://www.st.com/en/evaluation-tools/stm32-mcu-nucleo.html -source [find interface/stlink-dap.cfg] +source [find interface/stlink.cfg] transport select dapdirect_swd diff --git a/tcl/board/st_nucleo_wb55.cfg b/tcl/board/st_nucleo_wb55.cfg index 29b7ec98d..ab7307c68 100644 --- a/tcl/board/st_nucleo_wb55.cfg +++ b/tcl/board/st_nucleo_wb55.cfg @@ -6,7 +6,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32wbx.cfg] diff --git a/tcl/board/stm320518_eval_stlink.cfg b/tcl/board/stm320518_eval_stlink.cfg index 153f7e5cb..997bb4af9 100644 --- a/tcl/board/stm320518_eval_stlink.cfg +++ b/tcl/board/stm320518_eval_stlink.cfg @@ -8,7 +8,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 8KB set WORKAREASIZE 0x2000 diff --git a/tcl/board/stm3220g_eval_stlink.cfg b/tcl/board/stm3220g_eval_stlink.cfg index d5296720c..4233d04f1 100644 --- a/tcl/board/stm3220g_eval_stlink.cfg +++ b/tcl/board/stm3220g_eval_stlink.cfg @@ -8,7 +8,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 128KB set WORKAREASIZE 0x20000 diff --git a/tcl/board/stm3241g_eval_stlink.cfg b/tcl/board/stm3241g_eval_stlink.cfg index d2d579077..3bccd2866 100644 --- a/tcl/board/stm3241g_eval_stlink.cfg +++ b/tcl/board/stm3241g_eval_stlink.cfg @@ -8,7 +8,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 128KB set WORKAREASIZE 0x20000 diff --git a/tcl/board/stm32429i_eval_stlink.cfg b/tcl/board/stm32429i_eval_stlink.cfg index be3c48226..7d04aa7f3 100644 --- a/tcl/board/stm32429i_eval_stlink.cfg +++ b/tcl/board/stm32429i_eval_stlink.cfg @@ -8,7 +8,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 128KB set WORKAREASIZE 0x20000 diff --git a/tcl/board/stm32439i_eval_stlink.cfg b/tcl/board/stm32439i_eval_stlink.cfg index 7a1a396fc..b9ea084df 100644 --- a/tcl/board/stm32439i_eval_stlink.cfg +++ b/tcl/board/stm32439i_eval_stlink.cfg @@ -8,7 +8,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 128KB set WORKAREASIZE 0x20000 diff --git a/tcl/board/stm32f0discovery.cfg b/tcl/board/stm32f0discovery.cfg index 60fb4a65e..398ecc103 100644 --- a/tcl/board/stm32f0discovery.cfg +++ b/tcl/board/stm32f0discovery.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd set WORKAREASIZE 0x2000 source [find target/stm32f0x.cfg] diff --git a/tcl/board/stm32f3discovery.cfg b/tcl/board/stm32f3discovery.cfg index f28e11f6a..73c349a6e 100644 --- a/tcl/board/stm32f3discovery.cfg +++ b/tcl/board/stm32f3discovery.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32f3x.cfg] diff --git a/tcl/board/stm32f412g-disco.cfg b/tcl/board/stm32f412g-disco.cfg index 757b25d75..30a9537f0 100644 --- a/tcl/board/stm32f412g-disco.cfg +++ b/tcl/board/stm32f412g-disco.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 128KB set WORKAREASIZE 0x20000 diff --git a/tcl/board/stm32f413h-disco.cfg b/tcl/board/stm32f413h-disco.cfg index 6abf49551..c82d0d434 100644 --- a/tcl/board/stm32f413h-disco.cfg +++ b/tcl/board/stm32f413h-disco.cfg @@ -10,7 +10,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 128KB set WORKAREASIZE 0x20000 diff --git a/tcl/board/stm32f429disc1.cfg b/tcl/board/stm32f429disc1.cfg index 657aa1986..0a8e7ef4e 100644 --- a/tcl/board/stm32f429disc1.cfg +++ b/tcl/board/stm32f429disc1.cfg @@ -7,7 +7,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32f4x.cfg] diff --git a/tcl/board/stm32f429discovery.cfg b/tcl/board/stm32f429discovery.cfg index d1b5f5a11..865602ab6 100644 --- a/tcl/board/stm32f429discovery.cfg +++ b/tcl/board/stm32f429discovery.cfg @@ -7,7 +7,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 128KB set WORKAREASIZE 0x20000 diff --git a/tcl/board/stm32f469discovery.cfg b/tcl/board/stm32f469discovery.cfg index cca25b7f0..c9acbbbd0 100644 --- a/tcl/board/stm32f469discovery.cfg +++ b/tcl/board/stm32f469discovery.cfg @@ -7,7 +7,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 128KB set WORKAREASIZE 0x20000 diff --git a/tcl/board/stm32f469i-disco.cfg b/tcl/board/stm32f469i-disco.cfg index 7ce57f6e7..63c42c64e 100644 --- a/tcl/board/stm32f469i-disco.cfg +++ b/tcl/board/stm32f469i-disco.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 128KB set WORKAREASIZE 0x20000 diff --git a/tcl/board/stm32f4discovery.cfg b/tcl/board/stm32f4discovery.cfg index 714f1e903..d96e2dbd3 100644 --- a/tcl/board/stm32f4discovery.cfg +++ b/tcl/board/stm32f4discovery.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 64KB set WORKAREASIZE 0x10000 diff --git a/tcl/board/stm32f723e-disco.cfg b/tcl/board/stm32f723e-disco.cfg index 2dee2f902..020795620 100644 --- a/tcl/board/stm32f723e-disco.cfg +++ b/tcl/board/stm32f723e-disco.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 128KB set WORKAREASIZE 0x20000 diff --git a/tcl/board/stm32f746g-disco.cfg b/tcl/board/stm32f746g-disco.cfg index fed1d8ec9..75ff4ec1e 100644 --- a/tcl/board/stm32f746g-disco.cfg +++ b/tcl/board/stm32f746g-disco.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 256KB set WORKAREASIZE 0x40000 diff --git a/tcl/board/stm32f769i-disco.cfg b/tcl/board/stm32f769i-disco.cfg index 2969bb927..cd6383a70 100644 --- a/tcl/board/stm32f769i-disco.cfg +++ b/tcl/board/stm32f769i-disco.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 256KB set WORKAREASIZE 0x40000 diff --git a/tcl/board/stm32f7discovery.cfg b/tcl/board/stm32f7discovery.cfg index 4cc22ea62..6fd6c64b3 100644 --- a/tcl/board/stm32f7discovery.cfg +++ b/tcl/board/stm32f7discovery.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK/V2-1 source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 256KB set WORKAREASIZE 0x40000 diff --git a/tcl/board/stm32h735g-disco.cfg b/tcl/board/stm32h735g-disco.cfg index 4097ae28b..327a36418 100644 --- a/tcl/board/stm32h735g-disco.cfg +++ b/tcl/board/stm32h735g-disco.cfg @@ -7,7 +7,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd set CHIPNAME stm32h735igk6 diff --git a/tcl/board/stm32h745i-disco.cfg b/tcl/board/stm32h745i-disco.cfg index 1c0bc6748..9da1daefc 100644 --- a/tcl/board/stm32h745i-disco.cfg +++ b/tcl/board/stm32h745i-disco.cfg @@ -7,7 +7,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd set CHIPNAME stm32h745xih6 diff --git a/tcl/board/stm32h747i-disco.cfg b/tcl/board/stm32h747i-disco.cfg index e0a348ef0..7f8eda8c4 100644 --- a/tcl/board/stm32h747i-disco.cfg +++ b/tcl/board/stm32h747i-disco.cfg @@ -7,7 +7,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd set CHIPNAME stm32h747xih6 diff --git a/tcl/board/stm32h750b-disco.cfg b/tcl/board/stm32h750b-disco.cfg index efb32b1df..8b254f21f 100644 --- a/tcl/board/stm32h750b-disco.cfg +++ b/tcl/board/stm32h750b-disco.cfg @@ -7,7 +7,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd set CHIPNAME stm32h750xbh6 diff --git a/tcl/board/stm32h7b3i-disco.cfg b/tcl/board/stm32h7b3i-disco.cfg index 58ad9f781..df0d0a6f2 100644 --- a/tcl/board/stm32h7b3i-disco.cfg +++ b/tcl/board/stm32h7b3i-disco.cfg @@ -7,7 +7,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd set CHIPNAME stm32h7b3lih6q diff --git a/tcl/board/stm32h7x3i_eval.cfg b/tcl/board/stm32h7x3i_eval.cfg index b9c4c74c2..508f10d5d 100644 --- a/tcl/board/stm32h7x3i_eval.cfg +++ b/tcl/board/stm32h7x3i_eval.cfg @@ -8,7 +8,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32h7x_dual_bank.cfg] diff --git a/tcl/board/stm32l0discovery.cfg b/tcl/board/stm32l0discovery.cfg index c711d9c8a..59aed3405 100644 --- a/tcl/board/stm32l0discovery.cfg +++ b/tcl/board/stm32l0discovery.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd set WORKAREASIZE 0x2000 source [find target/stm32l0.cfg] diff --git a/tcl/board/stm32l476g-disco.cfg b/tcl/board/stm32l476g-disco.cfg index a32d20fb3..fe33ffefb 100644 --- a/tcl/board/stm32l476g-disco.cfg +++ b/tcl/board/stm32l476g-disco.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 96KB set WORKAREASIZE 0x18000 diff --git a/tcl/board/stm32l496g-disco.cfg b/tcl/board/stm32l496g-disco.cfg index 1ba2299ca..823fa6e38 100644 --- a/tcl/board/stm32l496g-disco.cfg +++ b/tcl/board/stm32l496g-disco.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 96KB set WORKAREASIZE 0x18000 diff --git a/tcl/board/stm32l4discovery.cfg b/tcl/board/stm32l4discovery.cfg index f08955078..64a456b61 100644 --- a/tcl/board/stm32l4discovery.cfg +++ b/tcl/board/stm32l4discovery.cfg @@ -8,7 +8,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd source [find target/stm32l4x.cfg] diff --git a/tcl/board/stm32l4p5g-disco.cfg b/tcl/board/stm32l4p5g-disco.cfg index 20d781a1a..33bb9a766 100644 --- a/tcl/board/stm32l4p5g-disco.cfg +++ b/tcl/board/stm32l4p5g-disco.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 96KB set WORKAREASIZE 0x18000 diff --git a/tcl/board/stm32l4r9i-disco.cfg b/tcl/board/stm32l4r9i-disco.cfg index f364ad3d5..cbb86669f 100644 --- a/tcl/board/stm32l4r9i-disco.cfg +++ b/tcl/board/stm32l4r9i-disco.cfg @@ -6,7 +6,7 @@ # This is for using the onboard STLINK source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd # increase working area to 96KB set WORKAREASIZE 0x18000 diff --git a/tcl/board/stm32ldiscovery.cfg b/tcl/board/stm32ldiscovery.cfg index d760edaba..e39b52295 100644 --- a/tcl/board/stm32ldiscovery.cfg +++ b/tcl/board/stm32ldiscovery.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd set WORKAREASIZE 0x4000 source [find target/stm32l1.cfg] diff --git a/tcl/board/stm32mp13x_dk.cfg b/tcl/board/stm32mp13x_dk.cfg index 6328ddb4c..08377ca76 100644 --- a/tcl/board/stm32mp13x_dk.cfg +++ b/tcl/board/stm32mp13x_dk.cfg @@ -3,7 +3,7 @@ # board MB1635x # http://www.st.com/en/evaluation-tools/stm32mp135f-dk.html -source [find interface/stlink-dap.cfg] +source [find interface/stlink.cfg] transport select dapdirect_swd diff --git a/tcl/board/stm32mp15x_dk2.cfg b/tcl/board/stm32mp15x_dk2.cfg index 9503428d1..0e71e05ee 100644 --- a/tcl/board/stm32mp15x_dk2.cfg +++ b/tcl/board/stm32mp15x_dk2.cfg @@ -4,7 +4,7 @@ # http://www.st.com/en/evaluation-tools/stm32mp157a-dk1.html # http://www.st.com/en/evaluation-tools/stm32mp157c-dk2.html -source [find interface/stlink-dap.cfg] +source [find interface/stlink.cfg] transport select dapdirect_swd diff --git a/tcl/board/stm32vldiscovery.cfg b/tcl/board/stm32vldiscovery.cfg index 30e35b981..57852bfd4 100644 --- a/tcl/board/stm32vldiscovery.cfg +++ b/tcl/board/stm32vldiscovery.cfg @@ -5,7 +5,7 @@ source [find interface/stlink.cfg] -transport select hla_swd +transport select dapdirect_swd set WORKAREASIZE 0x2000 source [find target/stm32f1x.cfg] diff --git a/tcl/interface/stlink-dap.cfg b/tcl/interface/stlink-dap.cfg index 99c81c180..009fdb7e0 100644 --- a/tcl/interface/stlink-dap.cfg +++ b/tcl/interface/stlink-dap.cfg @@ -1,22 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-or-later -# -# STMicroelectronics ST-LINK/V1, ST-LINK/V2, ST-LINK/V2-1, STLINK-V3 in-circuit -# debugger/programmer -# -# This new interface driver creates a ST-Link wrapper for ARM-DAP named "dapdirect" -# Old ST-LINK/V1 and ST-LINK/V2 pre version V2J24 don't support "dapdirect" -# -# SWIM transport is natively supported -# +echo "WARNING: interface/stlink-dap.cfg is deprecated, please switch to interface/stlink.cfg" +source [find interface/stlink.cfg] -adapter driver st-link -st-link vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754 0x0483 0x3755 0x0483 0x3757 - -# transport select dapdirect_jtag -# transport select dapdirect_swd -# transport select swim - -# Optionally specify the serial number of usb device -# e.g. -# adapter serial "\xaa\xbc\x6e\x06\x50\x75\xff\x55\x17\x42\x19\x3f" diff --git a/tcl/interface/stlink-hla.cfg b/tcl/interface/stlink-hla.cfg new file mode 100644 index 000000000..5c4adb897 --- /dev/null +++ b/tcl/interface/stlink-hla.cfg @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# +# STMicroelectronics ST-LINK/V1, ST-LINK/V2, ST-LINK/V2-1, STLINK-V3 in-circuit +# debugger/programmer +# + +echo "DEPRECATED: OpenOCD support for ST-Link HLA transport will be dropped soon!" +echo "Consider updating your ST-Link firmware to a version >= V2J24 (2015)" + +adapter driver hla +hla layout stlink +hla device_desc "ST-LINK" +hla vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754 0x0483 0x3755 0x0483 0x3757 + +# Optionally specify the serial number of ST-LINK/V2 usb device. ST-LINK/V2 +# devices seem to have serial numbers with unreadable characters. ST-LINK/V2 +# firmware version >= V2.J21.S4 recommended to avoid issues with adapter serial +# number reset issues. +# eg. +# adapter serial "\xaa\xbc\x6e\x06\x50\x75\xff\x55\x17\x42\x19\x3f" diff --git a/tcl/interface/stlink.cfg b/tcl/interface/stlink.cfg index 9b7f1f9eb..99c81c180 100644 --- a/tcl/interface/stlink.cfg +++ b/tcl/interface/stlink.cfg @@ -4,15 +4,19 @@ # STMicroelectronics ST-LINK/V1, ST-LINK/V2, ST-LINK/V2-1, STLINK-V3 in-circuit # debugger/programmer # +# This new interface driver creates a ST-Link wrapper for ARM-DAP named "dapdirect" +# Old ST-LINK/V1 and ST-LINK/V2 pre version V2J24 don't support "dapdirect" +# +# SWIM transport is natively supported +# -adapter driver hla -hla layout stlink -hla device_desc "ST-LINK" -hla vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754 0x0483 0x3755 0x0483 0x3757 +adapter driver st-link +st-link vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754 0x0483 0x3755 0x0483 0x3757 -# Optionally specify the serial number of ST-LINK/V2 usb device. ST-LINK/V2 -# devices seem to have serial numbers with unreadable characters. ST-LINK/V2 -# firmware version >= V2.J21.S4 recommended to avoid issues with adapter serial -# number reset issues. -# eg. +# transport select dapdirect_jtag +# transport select dapdirect_swd +# transport select swim + +# Optionally specify the serial number of usb device +# e.g. # adapter serial "\xaa\xbc\x6e\x06\x50\x75\xff\x55\x17\x42\x19\x3f" From 134e56338d365319380092a7bc5becf82c6d47f2 Mon Sep 17 00:00:00 2001 From: Mark Zhuang Date: Fri, 25 Oct 2024 22:15:29 +0800 Subject: [PATCH 34/44] target: riscv: convert 'unsigned' to 'unsigned int' Change-Id: I10b9abf9e42389eb91b210b8c2f01219ca9068cd Signed-off-by: Mark Zhuang Reviewed-on: https://review.openocd.org/c/openocd/+/8366 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/target/riscv/riscv-013.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 6c9ed317b..658c1fd9d 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -50,8 +50,7 @@ static bool riscv013_is_halted(struct target *target); static enum riscv_halt_reason riscv013_halt_reason(struct target *target); static int riscv013_write_debug_buffer(struct target *target, unsigned int index, riscv_insn_t d); -static riscv_insn_t riscv013_read_debug_buffer(struct target *target, unsigned - index); +static riscv_insn_t riscv013_read_debug_buffer(struct target *target, unsigned int index); static int riscv013_execute_debug_buffer(struct target *target); static void riscv013_fill_dmi_write_u64(struct target *target, char *buf, int a, uint64_t d); static void riscv013_fill_dmi_read_u64(struct target *target, char *buf, int a); From 114ad468ca6be45e25cfc1a521f04f959cc76159 Mon Sep 17 00:00:00 2001 From: Mark Zhuang Date: Sat, 26 Oct 2024 10:42:03 +0800 Subject: [PATCH 35/44] server: convert 'unsigned' to 'unsigned int' Conversion done with checkpatch --fix-inplace -types UNSPECIFIED_INT Ignore the cast as they could be better addressed. Change-Id: Ib0cbd9388d61659f8d47c8f57c09baa6df123487 Signed-off-by: Mark Zhuang Reviewed-on: https://review.openocd.org/c/openocd/+/8369 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/server/gdb_server.c | 12 ++++++------ src/server/telnet_server.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 579a388d2..c572f392a 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -116,7 +116,7 @@ static int gdb_error(struct connection *connection, int retval); static char *gdb_port; static char *gdb_port_next; -static void gdb_log_callback(void *priv, const char *file, unsigned line, +static void gdb_log_callback(void *priv, const char *file, unsigned int line, const char *function, const char *string); static void gdb_sig_halted(struct connection *connection); @@ -360,7 +360,7 @@ static void gdb_log_incoming_packet(struct connection *connection, const char *p struct gdb_connection *gdb_connection = connection->priv; /* Avoid dumping non-printable characters to the terminal */ - const unsigned packet_len = strlen(packet); + const unsigned int packet_len = strlen(packet); const char *nonprint = find_nonprint_char(packet, packet_len); if (nonprint) { /* Does packet at least have a prefix that is printable? @@ -1203,7 +1203,7 @@ static void gdb_target_to_reg(struct target *target, int i; for (i = 0; i < str_len; i += 2) { - unsigned t; + unsigned int t; if (sscanf(tstr + i, "%02x", &t) != 1) { LOG_ERROR("BUG: unable to convert register value"); exit(-1); @@ -1948,8 +1948,8 @@ static int gdb_memory_map(struct connection *connection, compare_bank); for (unsigned int i = 0; i < target_flash_banks; i++) { - unsigned sector_size = 0; - unsigned group_len = 0; + unsigned int sector_size = 0; + unsigned int group_len = 0; p = banks[i]; @@ -3469,7 +3469,7 @@ static int gdb_fileio_response_packet(struct connection *connection, return ERROR_OK; } -static void gdb_log_callback(void *priv, const char *file, unsigned line, +static void gdb_log_callback(void *priv, const char *file, unsigned int line, const char *function, const char *string) { struct connection *connection = priv; diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index a596afef0..7818af2db 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -93,7 +93,7 @@ static int telnet_output(struct command_context *cmd_ctx, const char *line) return telnet_outputline(connection, line); } -static void telnet_log_callback(void *priv, const char *file, unsigned line, +static void telnet_log_callback(void *priv, const char *file, unsigned int line, const char *function, const char *string) { struct connection *connection = priv; From b95633b30c35058005f7d69578773944e32e98e5 Mon Sep 17 00:00:00 2001 From: Mark Zhuang Date: Sat, 26 Oct 2024 11:09:16 +0800 Subject: [PATCH 36/44] flash: convert 'unsigned' to 'unsigned int' Change-Id: I8e8da78385eed714524891b580e19a79cfb459d3 Signed-off-by: Mark Zhuang Reviewed-on: https://review.openocd.org/c/openocd/+/8370 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/flash/nand/mx3.h | 8 ++++---- src/flash/nand/mxc.h | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/flash/nand/mx3.h b/src/flash/nand/mx3.h index b272962b4..648cd86cc 100644 --- a/src/flash/nand/mx3.h +++ b/src/flash/nand/mx3.h @@ -86,10 +86,10 @@ enum mx_nf_finalize_action { }; struct mx3_nf_flags { - unsigned target_little_endian:1; - unsigned nand_readonly:1; - unsigned one_kb_sram:1; - unsigned hw_ecc_enabled:1; + unsigned int target_little_endian:1; + unsigned int nand_readonly:1; + unsigned int one_kb_sram:1; + unsigned int hw_ecc_enabled:1; }; struct mx3_nf_controller { diff --git a/src/flash/nand/mxc.h b/src/flash/nand/mxc.h index ae2c03a75..e9dc0a2f3 100644 --- a/src/flash/nand/mxc.h +++ b/src/flash/nand/mxc.h @@ -138,11 +138,11 @@ enum mxc_nf_finalize_action { }; struct mxc_nf_flags { - unsigned target_little_endian:1; - unsigned nand_readonly:1; - unsigned one_kb_sram:1; - unsigned hw_ecc_enabled:1; - unsigned biswap_enabled:1; + unsigned int target_little_endian:1; + unsigned int nand_readonly:1; + unsigned int one_kb_sram:1; + unsigned int hw_ecc_enabled:1; + unsigned int biswap_enabled:1; }; struct mxc_nf_controller { From 99f60d5e594278b876142a957090d8649d5e6c44 Mon Sep 17 00:00:00 2001 From: Mark Zhuang Date: Sat, 26 Oct 2024 10:15:00 +0800 Subject: [PATCH 37/44] jtag: convert 'unsigned' to 'unsigned int' Conversion done with checkpatch --fix-inplace -types UNSPECIFIED_INT Change-Id: I2c2d56aa98e89bcc6088a1bd51d70066d67d6dad Signed-off-by: Mark Zhuang Reviewed-on: https://review.openocd.org/c/openocd/+/8367 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/jtag/hla/hla_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jtag/hla/hla_interface.c b/src/jtag/hla/hla_interface.c index f284278dd..e826f7910 100644 --- a/src/jtag/hla/hla_interface.c +++ b/src/jtag/hla/hla_interface.c @@ -76,7 +76,7 @@ int hl_interface_init_target(struct target *t) if (res != ERROR_OK) return res; - unsigned ii, limit = t->tap->expected_ids_cnt; + unsigned int ii, limit = t->tap->expected_ids_cnt; int found = 0; for (ii = 0; ii < limit; ii++) { @@ -264,7 +264,7 @@ COMMAND_HANDLER(hl_interface_handle_vid_pid_command) return ERROR_COMMAND_SYNTAX_ERROR; } - unsigned i; + unsigned int i; for (i = 0; i < CMD_ARGC; i += 2) { COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i], hl_if.param.vid[i / 2]); COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], hl_if.param.pid[i / 2]); From f4d81cd4d49336f695b8d4b00aa0afdbc6ea22cd Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Fri, 30 Aug 2024 10:47:55 +0200 Subject: [PATCH 38/44] tcl/interface: Restructure parport config files Provide cable specific configuration files like for the FTDI interface. Depcrecate the old configuration files but keep them until the next release for compatibility reasons. Change-Id: I436bd60779a107120c9e1b1f0b8a69a39a240ad4 Signed-off-by: Marc Schink Reviewed-on: https://review.openocd.org/c/openocd/+/8514 Reviewed-by: Antonio Borneo Tested-by: jenkins --- tcl/interface/parport.cfg | 15 ++------------- tcl/interface/parport/dlc5.cfg | 17 +++++++++++++++++ tcl/interface/parport/wiggler.cfg | 21 +++++++++++++++++++++ tcl/interface/parport_dlc5.cfg | 11 ++--------- 4 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 tcl/interface/parport/dlc5.cfg create mode 100644 tcl/interface/parport/wiggler.cfg diff --git a/tcl/interface/parport.cfg b/tcl/interface/parport.cfg index b9fceeb85..8fb1c148b 100644 --- a/tcl/interface/parport.cfg +++ b/tcl/interface/parport.cfg @@ -5,17 +5,6 @@ # # Addresses: 0x378/LPT1 or 0x278/LPT2 ... # +echo "DEPRECATED: use interface/parport/wiggler.cfg instead of deprecated interface/parport.cfg" -if { [info exists PARPORTADDR] } { - set _PARPORTADDR $PARPORTADDR -} else { - if {$tcl_platform(platform) eq "windows"} { - set _PARPORTADDR 0x378 - } { - set _PARPORTADDR 0 - } -} - -adapter driver parport -parport port $_PARPORTADDR -parport cable wiggler +source [find interface/parport/wiggler.cfg] diff --git a/tcl/interface/parport/dlc5.cfg b/tcl/interface/parport/dlc5.cfg new file mode 100644 index 000000000..24acea7a9 --- /dev/null +++ b/tcl/interface/parport/dlc5.cfg @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# +# Xilinx Parallel Cable III 'DLC 5' (and various clones) +# +# http://www.xilinx.com/itp/xilinx4/data/docs/pac/appendixb.html +# + +if { [info exists PARPORTADDR] } { + set _PARPORTADDR $PARPORTADDR +} else { + set _PARPORTADDR 0 +} + +adapter driver parport +parport port $_PARPORTADDR +parport cable dlc5 diff --git a/tcl/interface/parport/wiggler.cfg b/tcl/interface/parport/wiggler.cfg new file mode 100644 index 000000000..b9fceeb85 --- /dev/null +++ b/tcl/interface/parport/wiggler.cfg @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# +# Parallel port wiggler (many clones available) on port 0x378 +# +# Addresses: 0x378/LPT1 or 0x278/LPT2 ... +# + +if { [info exists PARPORTADDR] } { + set _PARPORTADDR $PARPORTADDR +} else { + if {$tcl_platform(platform) eq "windows"} { + set _PARPORTADDR 0x378 + } { + set _PARPORTADDR 0 + } +} + +adapter driver parport +parport port $_PARPORTADDR +parport cable wiggler diff --git a/tcl/interface/parport_dlc5.cfg b/tcl/interface/parport_dlc5.cfg index 24acea7a9..83f3b56c4 100644 --- a/tcl/interface/parport_dlc5.cfg +++ b/tcl/interface/parport_dlc5.cfg @@ -5,13 +5,6 @@ # # http://www.xilinx.com/itp/xilinx4/data/docs/pac/appendixb.html # +echo "DEPRECATED: use interface/parport/dlc5.cfg instead of deprecated interface/parport_dlc5.cfg" -if { [info exists PARPORTADDR] } { - set _PARPORTADDR $PARPORTADDR -} else { - set _PARPORTADDR 0 -} - -adapter driver parport -parport port $_PARPORTADDR -parport cable dlc5 +source [find interface/parport/dlc5.cfg] From 337db329c9c30a58ffa08c01691f12dd95890cbb Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Fri, 30 Aug 2024 11:06:13 +0200 Subject: [PATCH 39/44] adapter/bitbang: Use 'bool' data type for blink() Change-Id: I187f8944ad5fd92f28cbd32e447f9ec1a97e16d6 Signed-off-by: Marc Schink Reviewed-on: https://review.openocd.org/c/openocd/+/8515 Reviewed-by: Antonio Borneo Tested-by: jenkins --- src/jtag/drivers/am335xgpio.c | 4 ++-- src/jtag/drivers/bcm2835gpio.c | 4 ++-- src/jtag/drivers/bitbang.c | 8 ++++---- src/jtag/drivers/bitbang.h | 2 +- src/jtag/drivers/dummy.c | 2 +- src/jtag/drivers/linuxgpiod.c | 4 ++-- src/jtag/drivers/parport.c | 8 ++++---- src/jtag/drivers/remote_bitbang.c | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/jtag/drivers/am335xgpio.c b/src/jtag/drivers/am335xgpio.c index cfe41c3be..9bb7ea7d1 100644 --- a/src/jtag/drivers/am335xgpio.c +++ b/src/jtag/drivers/am335xgpio.c @@ -275,10 +275,10 @@ static int am335xgpio_swdio_read(void) return get_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_SWDIO]); } -static int am335xgpio_blink(int on) +static int am335xgpio_blink(bool on) { if (is_gpio_config_valid(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED])) - set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on); + set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on ? 1 : 0); return ERROR_OK; } diff --git a/src/jtag/drivers/bcm2835gpio.c b/src/jtag/drivers/bcm2835gpio.c index b8d91bf38..2c2061dae 100644 --- a/src/jtag/drivers/bcm2835gpio.c +++ b/src/jtag/drivers/bcm2835gpio.c @@ -419,10 +419,10 @@ static void bcm2835gpio_munmap(void) } } -static int bcm2835gpio_blink(int on) +static int bcm2835gpio_blink(bool on) { if (is_gpio_config_valid(ADAPTER_GPIO_IDX_LED)) - set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on); + set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on ? 1 : 0); return ERROR_OK; } diff --git a/src/jtag/drivers/bitbang.c b/src/jtag/drivers/bitbang.c index 17e01a233..42234a6f7 100644 --- a/src/jtag/drivers/bitbang.c +++ b/src/jtag/drivers/bitbang.c @@ -309,7 +309,7 @@ int bitbang_execute_queue(struct jtag_command *cmd_queue) retval = ERROR_OK; if (bitbang_interface->blink) { - if (bitbang_interface->blink(1) != ERROR_OK) + if (bitbang_interface->blink(true) != ERROR_OK) return ERROR_FAIL; } @@ -377,7 +377,7 @@ int bitbang_execute_queue(struct jtag_command *cmd_queue) cmd = cmd->next; } if (bitbang_interface->blink) { - if (bitbang_interface->blink(0) != ERROR_OK) + if (bitbang_interface->blink(false) != ERROR_OK) return ERROR_FAIL; } @@ -396,7 +396,7 @@ static void bitbang_swd_exchange(bool rnw, uint8_t buf[], unsigned int offset, u { if (bitbang_interface->blink) { /* FIXME: we should manage errors */ - bitbang_interface->blink(1); + bitbang_interface->blink(true); } for (unsigned int i = offset; i < bit_cnt + offset; i++) { @@ -418,7 +418,7 @@ static void bitbang_swd_exchange(bool rnw, uint8_t buf[], unsigned int offset, u if (bitbang_interface->blink) { /* FIXME: we should manage errors */ - bitbang_interface->blink(0); + bitbang_interface->blink(false); } } diff --git a/src/jtag/drivers/bitbang.h b/src/jtag/drivers/bitbang.h index dc941796e..82405eb8a 100644 --- a/src/jtag/drivers/bitbang.h +++ b/src/jtag/drivers/bitbang.h @@ -45,7 +45,7 @@ struct bitbang_interface { int (*write)(int tck, int tms, int tdi); /** Blink led (optional). */ - int (*blink)(int on); + int (*blink)(bool on); /** Sample SWDIO and return the value. */ int (*swdio_read)(void); diff --git a/src/jtag/drivers/dummy.c b/src/jtag/drivers/dummy.c index 1b1e57392..4fe598fe3 100644 --- a/src/jtag/drivers/dummy.c +++ b/src/jtag/drivers/dummy.c @@ -72,7 +72,7 @@ static int dummy_reset(int trst, int srst) return ERROR_OK; } -static int dummy_led(int on) +static int dummy_led(bool on) { return ERROR_OK; } diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 1926ed9ae..fa14e42d6 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -178,14 +178,14 @@ static int linuxgpiod_swd_write(int swclk, int swdio) return ERROR_OK; } -static int linuxgpiod_blink(int on) +static int linuxgpiod_blink(bool on) { int retval; if (!is_gpio_config_valid(ADAPTER_GPIO_IDX_LED)) return ERROR_OK; - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_LED], on); + retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_LED], on ? 1 : 0); if (retval < 0) LOG_WARNING("Fail set led"); return retval; diff --git a/src/jtag/drivers/parport.c b/src/jtag/drivers/parport.c index d26a51048..d03d3b89c 100644 --- a/src/jtag/drivers/parport.c +++ b/src/jtag/drivers/parport.c @@ -183,8 +183,8 @@ static int parport_reset(int trst, int srst) return ERROR_OK; } -/* turn LED on parport adapter on (1) or off (0) */ -static int parport_led(int on) +/* turn LED on parport adapter on (true) or off (true) */ +static int parport_led(bool on) { if (on) dataport_value |= cable->LED_MASK; @@ -364,7 +364,7 @@ static int parport_init(void) return ERROR_FAIL; if (parport_write(0, 0, 0) != ERROR_OK) return ERROR_FAIL; - if (parport_led(1) != ERROR_OK) + if (parport_led(true) != ERROR_OK) return ERROR_FAIL; bitbang_interface = &parport_bitbang; @@ -374,7 +374,7 @@ static int parport_init(void) static int parport_quit(void) { - if (parport_led(0) != ERROR_OK) + if (parport_led(false) != ERROR_OK) return ERROR_FAIL; if (parport_exit) { diff --git a/src/jtag/drivers/remote_bitbang.c b/src/jtag/drivers/remote_bitbang.c index edd36f2e6..91a8532b7 100644 --- a/src/jtag/drivers/remote_bitbang.c +++ b/src/jtag/drivers/remote_bitbang.c @@ -251,7 +251,7 @@ static int remote_bitbang_sleep(unsigned int microseconds) return remote_bitbang_flush(); } -static int remote_bitbang_blink(int on) +static int remote_bitbang_blink(bool on) { char c = on ? 'B' : 'b'; return remote_bitbang_queue(c, FLUSH_SEND_BUF); From 3b261fb155dd9165c39fc848bd66aae2e5dea370 Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Fri, 30 Aug 2024 11:22:17 +0200 Subject: [PATCH 40/44] adapter/parport: Coding style changes Apply some coding style changes according to the C style guide. The patch is tested for regression with the 'wiggler' parallel port cable. Change-Id: I43774f596831d8c46f90f18893418178041a930b Signed-off-by: Marc Schink Reviewed-on: https://review.openocd.org/c/openocd/+/8516 Reviewed-by: Antonio Borneo Tested-by: jenkins --- src/jtag/drivers/parport.c | 130 ++++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 60 deletions(-) diff --git a/src/jtag/drivers/parport.c b/src/jtag/drivers/parport.c index d03d3b89c..bdd338895 100644 --- a/src/jtag/drivers/parport.c +++ b/src/jtag/drivers/parport.c @@ -45,21 +45,31 @@ #include #endif -/* parallel port cable description - */ +// Parallel port cable description. struct cable { const char *name; - uint8_t TDO_MASK; /* status port bit containing current TDO value */ - uint8_t TRST_MASK; /* data port bit for TRST */ - uint8_t TMS_MASK; /* data port bit for TMS */ - uint8_t TCK_MASK; /* data port bit for TCK */ - uint8_t TDI_MASK; /* data port bit for TDI */ - uint8_t SRST_MASK; /* data port bit for SRST */ - uint8_t OUTPUT_INVERT; /* data port bits that should be inverted */ - uint8_t INPUT_INVERT; /* status port that should be inverted */ - uint8_t PORT_INIT; /* initialize data port with this value */ - uint8_t PORT_EXIT; /* de-initialize data port with this value */ - uint8_t LED_MASK; /* data port bit for LED */ + // Status port bit containing current TDO value. + uint8_t tdo_mask; + // Data port bit for TRST. + uint8_t trst_mask; + // Data port bit for TMD. + uint8_t tms_mask; + // Data port bit for TCK. + uint8_t tck_mask; + // Data port bit for TDI. + uint8_t tdi_mask; + // Data port bit for SRST. + uint8_t srst_mask; + // Data port bits that should be inverted. + uint8_t output_invert; + // Status port that should be inverted. + uint8_t input_invert; + // Initialize data port with this value. + uint8_t port_init; + // De-initialize data port with this value. + uint8_t port_exit; + // Data port bit for LED. + uint8_t led_mask; }; static const struct cable cables[] = { @@ -87,15 +97,14 @@ static const struct cable cables[] = { { NULL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; -/* configuration */ +// Configuration variables. static char *parport_cable; static uint16_t parport_port; static bool parport_exit; static uint32_t parport_toggling_time_ns = 1000; static int wait_states; -/* interface variables - */ +// Interface variables. static const struct cable *cable; static uint8_t dataport_value; @@ -116,7 +125,7 @@ static bb_value_t parport_read(void) data = inb(statusport); #endif - if ((data ^ cable->INPUT_INVERT) & cable->TDO_MASK) + if ((data ^ cable->input_invert) & cable->tdo_mask) return BB_HIGH; else return BB_LOW; @@ -125,7 +134,7 @@ static bb_value_t parport_read(void) static inline void parport_write_data(void) { uint8_t output; - output = dataport_value ^ cable->OUTPUT_INVERT; + output = dataport_value ^ cable->output_invert; #if PARPORT_USE_PPDEV == 1 ioctl(device_handle, PPWDATA, &output); @@ -143,19 +152,19 @@ static int parport_write(int tck, int tms, int tdi) int i = wait_states + 1; if (tck) - dataport_value |= cable->TCK_MASK; + dataport_value |= cable->tck_mask; else - dataport_value &= ~cable->TCK_MASK; + dataport_value &= ~cable->tck_mask; if (tms) - dataport_value |= cable->TMS_MASK; + dataport_value |= cable->tms_mask; else - dataport_value &= ~cable->TMS_MASK; + dataport_value &= ~cable->tms_mask; if (tdi) - dataport_value |= cable->TDI_MASK; + dataport_value |= cable->tdi_mask; else - dataport_value &= ~cable->TDI_MASK; + dataport_value &= ~cable->tdi_mask; while (i-- > 0) parport_write_data(); @@ -163,33 +172,32 @@ static int parport_write(int tck, int tms, int tdi) return ERROR_OK; } -/* (1) assert or (0) deassert reset lines */ +// (1) assert or (0) deassert reset lines. static int parport_reset(int trst, int srst) { LOG_DEBUG("trst: %i, srst: %i", trst, srst); if (trst == 0) - dataport_value |= cable->TRST_MASK; + dataport_value |= cable->trst_mask; else if (trst == 1) - dataport_value &= ~cable->TRST_MASK; + dataport_value &= ~cable->trst_mask; if (srst == 0) - dataport_value |= cable->SRST_MASK; + dataport_value |= cable->srst_mask; else if (srst == 1) - dataport_value &= ~cable->SRST_MASK; + dataport_value &= ~cable->srst_mask; parport_write_data(); return ERROR_OK; } -/* turn LED on parport adapter on (true) or off (true) */ static int parport_led(bool on) { if (on) - dataport_value |= cable->LED_MASK; + dataport_value |= cable->led_mask; else - dataport_value &= ~cable->LED_MASK; + dataport_value &= ~cable->led_mask; parport_write_data(); @@ -204,7 +212,7 @@ static int parport_speed(int speed) static int parport_khz(int khz, int *jtag_speed) { - if (khz == 0) { + if (!khz) { LOG_DEBUG("RCLK not supported"); return ERROR_FAIL; } @@ -248,10 +256,10 @@ static int parport_get_giveio_access(void) #endif static struct bitbang_interface parport_bitbang = { - .read = &parport_read, - .write = &parport_write, - .blink = &parport_led, - }; + .read = &parport_read, + .write = &parport_write, + .blink = &parport_led, +}; static int parport_init(void) { @@ -268,7 +276,7 @@ static int parport_init(void) } while (cur_cable->name) { - if (strcmp(cur_cable->name, parport_cable) == 0) { + if (!strcmp(cur_cable->name, parport_cable)) { cable = cur_cable; break; } @@ -280,7 +288,7 @@ static int parport_init(void) return ERROR_JTAG_INIT_FAILED; } - dataport_value = cable->PORT_INIT; + dataport_value = cable->port_init; #if PARPORT_USE_PPDEV == 1 if (device_handle > 0) { @@ -332,7 +340,7 @@ static int parport_init(void) #endif /* not __FreeBSD__, __FreeBSD_kernel__ */ #else /* not PARPORT_USE_PPDEV */ - if (parport_port == 0) { + if (!parport_port) { parport_port = 0x378; LOG_WARNING("No parport port specified, using default '0x378' (LPT1)"); } @@ -351,7 +359,7 @@ static int parport_init(void) } LOG_DEBUG("...privileges granted"); - /* make sure parallel port is in right mode (clear tristate and interrupt */ + // Make sure parallel port is in right mode (clear tristate and interrupt. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) outb(parport_port + 2, 0x0); #else @@ -378,7 +386,7 @@ static int parport_quit(void) return ERROR_FAIL; if (parport_exit) { - dataport_value = cable->PORT_EXIT; + dataport_value = cable->port_exit; parport_write_data(); } @@ -388,13 +396,13 @@ static int parport_quit(void) return ERROR_OK; } -COMMAND_HANDLER(parport_handle_parport_port_command) +COMMAND_HANDLER(parport_handle_port_command) { if (CMD_ARGC == 1) { - /* only if the port wasn't overwritten by cmdline */ - if (parport_port == 0) + // Only if the port wasn't overwritten by cmdline. + if (!parport_port) { COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], parport_port); - else { + } else { LOG_ERROR("The parport port was already configured!"); return ERROR_FAIL; } @@ -405,14 +413,14 @@ COMMAND_HANDLER(parport_handle_parport_port_command) return ERROR_OK; } -COMMAND_HANDLER(parport_handle_parport_cable_command) +COMMAND_HANDLER(parport_handle_cable_command) { - if (CMD_ARGC == 0) + if (!CMD_ARGC) return ERROR_OK; - /* only if the cable name wasn't overwritten by cmdline */ + // Only if the cable name wasn't overwritten by cmdline. if (!parport_cable) { - /* REVISIT first verify that it's listed in cables[] ... */ + // TODO: REVISIT first verify that it's listed in cables[]. parport_cable = malloc(strlen(CMD_ARGV[0]) + sizeof(char)); if (!parport_cable) { LOG_ERROR("Out of memory"); @@ -421,7 +429,7 @@ COMMAND_HANDLER(parport_handle_parport_cable_command) strcpy(parport_cable, CMD_ARGV[0]); } - /* REVISIT it's probably worth returning the current value ... */ + // TODO: REVISIT it's probably worth returning the current value. return ERROR_OK; } @@ -436,7 +444,7 @@ COMMAND_HANDLER(parport_handle_write_on_exit_command) return ERROR_OK; } -COMMAND_HANDLER(parport_handle_parport_toggling_time_command) +COMMAND_HANDLER(parport_handle_toggling_time_command) { if (CMD_ARGC == 1) { uint32_t ns; @@ -445,7 +453,7 @@ COMMAND_HANDLER(parport_handle_parport_toggling_time_command) if (retval != ERROR_OK) return retval; - if (ns == 0) { + if (!ns) { LOG_ERROR("0 ns is not a valid parport toggling time"); return ERROR_FAIL; } @@ -453,9 +461,11 @@ COMMAND_HANDLER(parport_handle_parport_toggling_time_command) parport_toggling_time_ns = ns; retval = adapter_get_speed(&wait_states); if (retval != ERROR_OK) { - /* if adapter_get_speed fails then the clock_mode - * has not been configured, this happens if parport_toggling_time is - * called before the adapter speed is set */ + /* + * If adapter_get_speed fails then the clock_mode has + * not been configured, this happens if toggling_time is + * called before the adapter speed is set. + */ LOG_INFO("no parport speed set - defaulting to zero wait states"); wait_states = 0; } @@ -470,7 +480,7 @@ COMMAND_HANDLER(parport_handle_parport_toggling_time_command) static const struct command_registration parport_subcommand_handlers[] = { { .name = "port", - .handler = parport_handle_parport_port_command, + .handler = parport_handle_port_command, .mode = COMMAND_CONFIG, .help = "Display the address of the I/O port (e.g. 0x378) " "or the number of the '/dev/parport' device used. " @@ -479,11 +489,11 @@ static const struct command_registration parport_subcommand_handlers[] = { }, { .name = "cable", - .handler = parport_handle_parport_cable_command, + .handler = parport_handle_cable_command, .mode = COMMAND_CONFIG, .help = "Set the layout of the parallel port cable " "used to connect to the target.", - /* REVISIT there's no way to list layouts we know ... */ + // TODO: REVISIT there's no way to list layouts we know. .usage = "[layout]", }, { @@ -496,7 +506,7 @@ static const struct command_registration parport_subcommand_handlers[] = { }, { .name = "toggling_time", - .handler = parport_handle_parport_toggling_time_command, + .handler = parport_handle_toggling_time_command, .mode = COMMAND_CONFIG, .help = "Displays or assigns how many nanoseconds it " "takes for the hardware to toggle TCK.", From 40d58ce5290a51c58615c4f95912b69fa7975aea Mon Sep 17 00:00:00 2001 From: MicBiso Date: Wed, 10 Apr 2024 12:38:09 +0200 Subject: [PATCH 41/44] tcl/target/renesas_rz_g2: Rename to renesas_rz and add RZ/V2L-G3S Rename file to get it more generic and add more targets belonging to the same family. Add support for two new devices: RZ/V2L and RZ/G3S Change-Id: Idb7f4d81d2f95ad15ef686e940f43ed29f49f343 Signed-off-by: MicBiso Reviewed-on: https://review.openocd.org/c/openocd/+/8211 Reviewed-by: Antonio Borneo Tested-by: jenkins --- .../{renesas_rz_g2.cfg => renesas_rz.cfg} | 78 ++++++++++++++----- 1 file changed, 58 insertions(+), 20 deletions(-) rename tcl/target/{renesas_rz_g2.cfg => renesas_rz.cfg} (70%) diff --git a/tcl/target/renesas_rz_g2.cfg b/tcl/target/renesas_rz.cfg similarity index 70% rename from tcl/target/renesas_rz_g2.cfg rename to tcl/target/renesas_rz.cfg index a3d5f48fb..a0489de3d 100644 --- a/tcl/target/renesas_rz_g2.cfg +++ b/tcl/target/renesas_rz.cfg @@ -1,23 +1,25 @@ # SPDX-License-Identifier: GPL-2.0-or-later -# Renesas RZ/G2 SOCs +# Renesas RZ SOCs # - There are a combination of Cortex-A57s, Cortex-A53s, Cortex-A55, Cortex-R7 # and Cortex-M33 for each SOC -# - Each SOC can boot through the Cortex-A5x cores +# - Each SOC can boot through the Cortex-A5x cores or the Cortex-M33 -# Supported RZ/G2 SOCs and their cores: +# Supported RZ SOCs and their cores: # RZ/G2H: Cortex-A57 x4, Cortex-A53 x4, Cortex-R7 # RZ/G2M: Cortex-A57 x2, Cortex-A53 x4, Cortex-R7 # RZ/G2N: Cortex-A57 x2, Cortex-R7 # RZ/G2E: Cortex-A53 x2, Cortex-R7 # RZ/G2L: Cortex-A55 x2, Cortex-M33 +# RZ/V2L: Cortex-A55 x2, Cortex-M33 # RZ/G2LC: Cortex-A55 x2, Cortex-M33 # RZ/G2UL: Cortex-A55 x1, Cortex-M33 +# RZ/G3S: Cortex-A55 x1, Cortex-M33 x2 # Usage: # There are 2 configuration options: # SOC: Selects the supported SOC. (Default 'G2L') -# BOOT_CORE: Selects the booting core. 'CA57', 'CA53' or 'CA55' +# BOOT_CORE: Selects the booting core. 'CA57', 'CA53', 'CA55' or CM33 transport select jtag reset_config trst_and_srst srst_gates_jtag @@ -77,6 +79,13 @@ switch $_soc { set _boot_core CA55 set _ap_num 0 } + V2L { + set _CHIPNAME r9a07g054l + set _num_ca55 2 + set _num_cm33 1 + set _boot_core CA55 + set _ap_num 0 + } G2LC { set _CHIPNAME r9a07g044c set _num_ca55 2 @@ -91,6 +100,13 @@ switch $_soc { set _boot_core CA55 set _ap_num 0 } + G3S { + set _CHIPNAME r9a08g045s + set _num_ca55 1 + set _num_cm33 2 + set _boot_core CA55 + set _ap_num 0 + } default { error "'$_soc' is invalid!" } @@ -112,16 +128,16 @@ if { [info exists DAP_TAPID] } { set _DAP_TAPID 0x6ba00477 } -echo "\t$_soc - $_num_ca57 CA57(s), $_num_ca55 CA55(s), $_num_ca53 CA53(s), $_num_cr7 CR7(s), \ - $_num_cm33 CM33(s)" +echo "\t$_soc - $_num_ca57 CA57(s), $_num_ca55 CA55(s), $_num_ca53 CA53(s), \ + $_num_cr7 CR7(s), $_num_cm33 CM33(s)" echo "\tBoot Core - $_boot_core\n" set _DAPNAME $_CHIPNAME.dap # TAP and DAP -jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_DAP_TAPID \ - -ignore-version +jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf \ + -expected-id $_DAP_TAPID -ignore-version dap create $_DAPNAME -chain-position $_CHIPNAME.cpu echo "$_CHIPNAME.cpu" @@ -133,8 +149,8 @@ set CA53_DBGBASE {0x80C10000 0x80D10000 0x80E10000 0x80F10000} set CA53_CTIBASE {0x80C20000 0x80D20000 0x80E20000 0x80F20000} set CR7_DBGBASE 0x80910000 set CR7_CTIBASE 0x80918000 -set CM33_DBGBASE 0xE000E000 -set CM33_CTIBASE 0xE0042000 +set CM33_DBGBASE {0xE000E000 0xE010E000} +set CM33_CTIBASE {0xE0042000 0xE0142000} set smp_targets "" @@ -145,7 +161,8 @@ proc setup_a5x {core_name dbgbase ctibase num boot} { cti create $_CTINAME -dap $::_DAPNAME -ap-num $::_ap_num \ -baseaddr [lindex $ctibase $_core] target create $_TARGETNAME aarch64 -dap $::_DAPNAME \ - -ap-num $::_ap_num -dbgbase [lindex $dbgbase $_core] -cti $_CTINAME + -ap-num $::_ap_num -dbgbase [lindex $dbgbase $_core] \ + -cti $_CTINAME if { $_core > 0 || $boot == 0 } { $_TARGETNAME configure -defer-examine } @@ -160,13 +177,29 @@ proc setup_cr7 {dbgbase ctibase} { target create $_TARGETNAME cortex_r4 -dap $::_DAPNAME \ -ap-num 1 -dbgbase $dbgbase -defer-examine } - -proc setup_cm33 {dbgbase ctibase} { - set _TARGETNAME $::_CHIPNAME.m33 - set _CTINAME $_TARGETNAME.cti - cti create $_CTINAME -dap $::_DAPNAME -ap-num 2 -baseaddr $ctibase - target create $_TARGETNAME cortex_m -dap $::_DAPNAME \ - -ap-num 2 -dbgbase $dbgbase -defer-examine +proc setup_cm33 {dbgbase ctibase num boot} { + if { $::_soc == "G2L" || $::_soc == "V2L" \ + || $::_soc == "G2LC" || $::_soc == "G2UL" } { + set _ap_num 2 + } elseif { $::_soc == "G3S" } { + set _ap_num 3 + } + for { set _core 0 } { $_core < $num } { incr _core } { + if { $num <= 1 } { + set _TARGETNAME $::_CHIPNAME.m33 + } else { + set _TARGETNAME $::_CHIPNAME.m33.$_core + } + set _CTINAME $_TARGETNAME.cti + cti create $_CTINAME -dap $::_DAPNAME -ap-num $_ap_num \ + -baseaddr [lindex $ctibase $_core] + target create $_TARGETNAME cortex_m -dap $::_DAPNAME \ + -ap-num $_ap_num -dbgbase [lindex $dbgbase $_core] + if { $boot == 0 } { + $_TARGETNAME configure -defer-examine + } + incr $_ap_num + } } # Organize target list based on the boot core @@ -180,12 +213,17 @@ if { $_boot_core == "CA57" } { setup_cr7 $CR7_DBGBASE $CR7_CTIBASE } elseif { $_boot_core == "CA55" } { setup_a5x a55 $CA55_DBGBASE $CA55_CTIBASE $_num_ca55 1 - setup_cm33 $CM33_DBGBASE $CM33_CTIBASE + setup_cm33 $CM33_DBGBASE $CM33_CTIBASE $_num_cm33 0 +} elseif { $_boot_core == "CM33" } { + setup_a5x a55 $CA55_DBGBASE $CA55_CTIBASE $_num_ca55 0 + setup_cm33 $CM33_DBGBASE $CM33_CTIBASE $_num_cm33 1 } + echo "SMP targets:$smp_targets" eval "target smp $smp_targets" -if { $_soc == "G2L" || $_soc == "G2LC" || $_soc == "G2UL" } { +if { $_soc == "G2L" || $_soc == "V2L" || $_soc == "G2LC" \ +|| $_soc == "G2UL" || $_soc == "G3S"} { target create $_CHIPNAME.axi_ap mem_ap -dap $_DAPNAME -ap-num 1 } From bcebc84882116c5c08c9243297a925262b1c3f0f Mon Sep 17 00:00:00 2001 From: Mark Zhuang Date: Sat, 26 Oct 2024 10:30:18 +0800 Subject: [PATCH 42/44] contrib: convert 'unsigned' to 'unsigned int' Conversion done with checkpatch --fix-inplace -types UNSPECIFIED_INT Change-Id: I0e31f87d437fcf3503736474f10a63f9c6be242b Signed-off-by: Mark Zhuang Reviewed-on: https://review.openocd.org/c/openocd/+/8368 Reviewed-by: Antonio Borneo Tested-by: jenkins --- contrib/itmdump.c | 24 +++++++++++------------ contrib/loaders/flash/fespi/riscv_fespi.c | 20 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/contrib/itmdump.c b/contrib/itmdump.c index e7523d9bc..7c93a3963 100644 --- a/contrib/itmdump.c +++ b/contrib/itmdump.c @@ -43,9 +43,9 @@ unsigned int dump_swit; * NOTE that this specific encoding could be space-optimized; and that * trace data streams could also be history-sensitive. */ -static void show_task(int port, unsigned data) +static void show_task(int port, unsigned int data) { - unsigned code = data >> 16; + unsigned int code = data >> 16; char buf[16]; if (dump_swit) @@ -77,7 +77,7 @@ static void show_task(int port, unsigned data) static void show_reserved(FILE *f, char *label, int c) { - unsigned i; + unsigned int i; if (dump_swit) return; @@ -96,9 +96,9 @@ static void show_reserved(FILE *f, char *label, int c) printf("\n"); } -static bool read_varlen(FILE *f, int c, unsigned *value) +static bool read_varlen(FILE *f, int c, unsigned int *value) { - unsigned size; + unsigned int size; unsigned char buf[4]; *value = 0; @@ -135,8 +135,8 @@ err: static void show_hard(FILE *f, int c) { - unsigned type = c >> 3; - unsigned value; + unsigned int type = c >> 3; + unsigned int value; char *label; if (dump_swit) @@ -230,16 +230,16 @@ static void show_hard(FILE *f, int c) */ struct { int port; - void (*show)(int port, unsigned data); + void (*show)(int port, unsigned int data); } format[] = { { .port = 31, .show = show_task, }, }; static void show_swit(FILE *f, int c) { - unsigned port = c >> 3; - unsigned value = 0; - unsigned i; + unsigned int port = c >> 3; + unsigned int value = 0; + unsigned int i; if (port + 1 == dump_swit) { if (!read_varlen(f, c, &value)) @@ -272,7 +272,7 @@ static void show_swit(FILE *f, int c) static void show_timestamp(FILE *f, int c) { - unsigned counter = 0; + unsigned int counter = 0; char *label = ""; bool delayed = false; diff --git a/contrib/loaders/flash/fespi/riscv_fespi.c b/contrib/loaders/flash/fespi/riscv_fespi.c index 17ae2fd22..08fb09477 100644 --- a/contrib/loaders/flash/fespi/riscv_fespi.c +++ b/contrib/loaders/flash/fespi/riscv_fespi.c @@ -103,7 +103,7 @@ static void fespi_disable_hw_mode(volatile uint32_t *ctrl_base); static void fespi_enable_hw_mode(volatile uint32_t *ctrl_base); static int fespi_wip(volatile uint32_t *ctrl_base); static int fespi_write_buffer(volatile uint32_t *ctrl_base, - const uint8_t *buffer, unsigned offset, unsigned len, + const uint8_t *buffer, unsigned int offset, unsigned int len, uint32_t flash_info); /* Can set bits 3:0 in result. */ @@ -113,7 +113,7 @@ static int fespi_write_buffer(volatile uint32_t *ctrl_base, * after pprog_cmd */ int flash_fespi(volatile uint32_t *ctrl_base, uint32_t page_size, - const uint8_t *buffer, unsigned offset, uint32_t count, + const uint8_t *buffer, unsigned int offset, uint32_t count, uint32_t flash_info) { int result; @@ -163,12 +163,12 @@ err: return result; } -static uint32_t fespi_read_reg(volatile uint32_t *ctrl_base, unsigned address) +static uint32_t fespi_read_reg(volatile uint32_t *ctrl_base, unsigned int address) { return ctrl_base[address / 4]; } -static void fespi_write_reg(volatile uint32_t *ctrl_base, unsigned address, uint32_t value) +static void fespi_write_reg(volatile uint32_t *ctrl_base, unsigned int address, uint32_t value) { ctrl_base[address / 4] = value; } @@ -188,7 +188,7 @@ static void fespi_enable_hw_mode(volatile uint32_t *ctrl_base) /* Can set bits 7:4 in result. */ static int fespi_txwm_wait(volatile uint32_t *ctrl_base) { - unsigned timeout = TIMEOUT; + unsigned int timeout = TIMEOUT; while (timeout--) { uint32_t ip = fespi_read_reg(ctrl_base, FESPI_REG_IP); @@ -209,7 +209,7 @@ static void fespi_set_dir(volatile uint32_t *ctrl_base, bool dir) /* Can set bits 11:8 in result. */ static int fespi_tx(volatile uint32_t *ctrl_base, uint8_t in) { - unsigned timeout = TIMEOUT; + unsigned int timeout = TIMEOUT; while (timeout--) { uint32_t txfifo = fespi_read_reg(ctrl_base, FESPI_REG_TXFIFO); @@ -224,7 +224,7 @@ static int fespi_tx(volatile uint32_t *ctrl_base, uint8_t in) /* Can set bits 15:12 in result. */ static int fespi_rx(volatile uint32_t *ctrl_base, uint8_t *out) { - unsigned timeout = TIMEOUT; + unsigned int timeout = TIMEOUT; while (timeout--) { uint32_t value = fespi_read_reg(ctrl_base, FESPI_REG_RXFIFO); @@ -252,7 +252,7 @@ static int fespi_wip(volatile uint32_t *ctrl_base) if (result != ERROR_OK) return result | ERROR_STACK(0x20000); - unsigned timeout = TIMEOUT; + unsigned int timeout = TIMEOUT; while (timeout--) { result = fespi_tx(ctrl_base, 0); if (result != ERROR_OK) @@ -273,7 +273,7 @@ static int fespi_wip(volatile uint32_t *ctrl_base) /* Can set bits 23:20 in result. */ static int fespi_write_buffer(volatile uint32_t *ctrl_base, - const uint8_t *buffer, unsigned offset, unsigned len, + const uint8_t *buffer, unsigned int offset, unsigned int len, uint32_t flash_info) { int result = fespi_tx(ctrl_base, SPIFLASH_WRITE_ENABLE); @@ -304,7 +304,7 @@ static int fespi_write_buffer(volatile uint32_t *ctrl_base, if (result != ERROR_OK) return result | ERROR_STACK(0x600000); - for (unsigned i = 0; i < len; i++) { + for (unsigned int i = 0; i < len; i++) { result = fespi_tx(ctrl_base, buffer[i]); if (result != ERROR_OK) return result | ERROR_STACK(0x700000); From b68d23da3c3bc67cffc750fddd64a6be9c615fdb Mon Sep 17 00:00:00 2001 From: Marek Kraus Date: Wed, 23 Oct 2024 16:27:33 +0200 Subject: [PATCH 43/44] tcl/target/bl702: implement full software reset In previous implementation, it was known that it does not perform full reset, and that some peripherals, such as GLB core, which handles among other stuff GPIOs, was not reset. It was presumed, that full reset by software is not possible, although, by accident, even when comment says that CTRL_PWRON_RESET is set to 1, it is not (value written into 0x40000018 supposed to be 0x7, not 0x6). CTRL_PWRON_RESET indeed triggers full "power-on like" reset, so this method is implemented in this commit. There are some workarounds to make reset seamless, without any error messages, which are described in comments of TCL script. Only down-side of this reset is, that chip is halted after reset bit later in BootROM than previous implementation, but it's still good. Change-Id: Ife2cdcc6a2d96a2e24039bfec149705baf046318 Signed-off-by: Marek Kraus Reviewed-on: https://review.openocd.org/c/openocd/+/8529 Reviewed-by: Antonio Borneo Tested-by: jenkins --- tcl/target/bl702.cfg | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tcl/target/bl702.cfg b/tcl/target/bl702.cfg index 6d4a048d9..5046cd189 100644 --- a/tcl/target/bl702.cfg +++ b/tcl/target/bl702.cfg @@ -34,6 +34,10 @@ $_TARGETNAME configure -work-area-phys 0x22020000 -work-area-size 0x10000 -work- # Internal RC ticks on 32 MHz, so this speed should be safe to use. adapter speed 4000 +# Debug Module's ndmreset resets only Trust Zone Controller, so we need to do SW reset instead. +# CTRL_PWRON_RESET triggers full "power-on like" reset. +# This means that pinmux configuration to access JTAG is reset as well, and configured back early +# in BootROM. $_TARGETNAME configure -event reset-assert-pre { halt @@ -55,6 +59,15 @@ $_TARGETNAME configure -event reset-assert-pre { # Do reset # In GLB_SWRST_CFG2, clear CTRL_SYS_RESET, CTRL_CPU_RESET and CTRL_PWRON_RESET mmw 0x40000018 0x0 0x00000007 + + # Since this full software reset resets GPIO pinmux as well, we will lose access + # to JTAG right away after writing to register. This chip doesn't support abstract + # memory access, so when this is done by progbuf or sysbus, OpenOCD will fail to read + # if write was successful or not, and will print error about that. Since receiving of + # this error is expected, we will turn off log printing for a moment, + set lvl [lindex [debug_level] 1] + debug_level -1 # In GLB_SWRST_CFG2, set CTRL_SYS_RESET, CTRL_CPU_RESET and CTRL_PWRON_RESET to 1 - mmw 0x40000018 0x6 0x0 + catch {mmw 0x40000018 0x7 0x0} + debug_level $lvl } From fd62626dff25cf503a25040d3040b0a2bb9b2a76 Mon Sep 17 00:00:00 2001 From: Evgeniy Naydanov Date: Mon, 16 Sep 2024 18:01:17 +0300 Subject: [PATCH 44/44] target/breakpoints: fix types in `watchpoint_add_internal()` There was a conflict: 1. commit 2cd8ebf44d1a ("breakpoints: use 64-bit type for watchpoint mask and value") 2. commit 0bf3373e808a ("target/breakpoints: Use 'unsigned int' for length") The second commit was created erlier, but merged later so the types of `mask` and `value` became `uint32_t` in `watchpoint_add_internal()`. This created a bug: `WATCHPOINT_IGNORE_DATA_VALUE_MASK` is defined as `(~(uint64_t)0)`. Truncation to uint32_t makes it so the comparisons with the constant don't work. Change-Id: I19c414c351f52aff72a60330d83c29db7bbca375 Signed-off-by: Evgeniy Naydanov Reviewed-on: https://review.openocd.org/c/openocd/+/8500 Reviewed-by: Antonio Borneo Reviewed-by: Jan Matyas Tested-by: jenkins Reviewed-by: zapb Reviewed-by: Karl Palsson --- src/target/breakpoints.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c index 2fbb69e07..9378abcb1 100644 --- a/src/target/breakpoints.c +++ b/src/target/breakpoints.c @@ -500,7 +500,7 @@ struct breakpoint *breakpoint_find(struct target *target, target_addr_t address) } static int watchpoint_add_internal(struct target *target, target_addr_t address, - unsigned int length, enum watchpoint_rw rw, uint32_t value, uint32_t mask) + unsigned int length, enum watchpoint_rw rw, uint64_t value, uint64_t mask) { struct watchpoint *watchpoint = target->watchpoints; struct watchpoint **watchpoint_p = &target->watchpoints;