xsvf: align switch and case statements

The coding style requires the 'case' to be at the same indentation
level of its 'switch' statement.

Align the code accordingly.

No changes are reported by
	git log -p -w --ignore-blank-lines --patience

Change-Id: I24762505cdac22058e0a2a1f4e9235c9006e543d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9048
Tested-by: jenkins
Reviewed-by: zapb <dev@zapb.de>
This commit is contained in:
Antonio Borneo
2025-07-26 13:13:32 +02:00
parent ce3fa4ac08
commit cb526f0659

View File

@@ -117,57 +117,57 @@ static enum tap_state xsvf_to_tap(int xsvf_state)
enum tap_state ret; enum tap_state ret;
switch (xsvf_state) { switch (xsvf_state) {
case XSV_RESET: case XSV_RESET:
ret = TAP_RESET; ret = TAP_RESET;
break; break;
case XSV_IDLE: case XSV_IDLE:
ret = TAP_IDLE; ret = TAP_IDLE;
break; break;
case XSV_DRSELECT: case XSV_DRSELECT:
ret = TAP_DRSELECT; ret = TAP_DRSELECT;
break; break;
case XSV_DRCAPTURE: case XSV_DRCAPTURE:
ret = TAP_DRCAPTURE; ret = TAP_DRCAPTURE;
break; break;
case XSV_DRSHIFT: case XSV_DRSHIFT:
ret = TAP_DRSHIFT; ret = TAP_DRSHIFT;
break; break;
case XSV_DREXIT1: case XSV_DREXIT1:
ret = TAP_DREXIT1; ret = TAP_DREXIT1;
break; break;
case XSV_DRPAUSE: case XSV_DRPAUSE:
ret = TAP_DRPAUSE; ret = TAP_DRPAUSE;
break; break;
case XSV_DREXIT2: case XSV_DREXIT2:
ret = TAP_DREXIT2; ret = TAP_DREXIT2;
break; break;
case XSV_DRUPDATE: case XSV_DRUPDATE:
ret = TAP_DRUPDATE; ret = TAP_DRUPDATE;
break; break;
case XSV_IRSELECT: case XSV_IRSELECT:
ret = TAP_IRSELECT; ret = TAP_IRSELECT;
break; break;
case XSV_IRCAPTURE: case XSV_IRCAPTURE:
ret = TAP_IRCAPTURE; ret = TAP_IRCAPTURE;
break; break;
case XSV_IRSHIFT: case XSV_IRSHIFT:
ret = TAP_IRSHIFT; ret = TAP_IRSHIFT;
break; break;
case XSV_IREXIT1: case XSV_IREXIT1:
ret = TAP_IREXIT1; ret = TAP_IREXIT1;
break; break;
case XSV_IRPAUSE: case XSV_IRPAUSE:
ret = TAP_IRPAUSE; ret = TAP_IRPAUSE;
break; break;
case XSV_IREXIT2: case XSV_IREXIT2:
ret = TAP_IREXIT2; ret = TAP_IREXIT2;
break; break;
case XSV_IRUPDATE: case XSV_IRUPDATE:
ret = TAP_IRUPDATE; ret = TAP_IRUPDATE;
break; break;
default: default:
LOG_ERROR("UNKNOWN XSVF STATE 0x%02X", xsvf_state); LOG_ERROR("UNKNOWN XSVF STATE 0x%02X", xsvf_state);
exit(1); exit(1);
} }
return ret; return ret;
@@ -275,92 +275,91 @@ COMMAND_HANDLER(handle_xsvf_command)
enum tap_state mystate; enum tap_state mystate;
switch (opcode) { switch (opcode) {
case XCOMMENT: case XCOMMENT:
/* ignore/show comments between XSTATE ops */ /* ignore/show comments between XSTATE ops */
break;
case XSTATE:
/* try to collect another transition */
if (pathlen == XSTATE_MAX_PATH) {
LOG_ERROR("XSVF: path too long");
do_abort = 1;
break; break;
case XSTATE: }
/* try to collect another transition */
if (pathlen == XSTATE_MAX_PATH) {
LOG_ERROR("XSVF: path too long");
do_abort = 1;
break;
}
if (read(xsvf_fd, &uc, 1) < 0) { if (read(xsvf_fd, &uc, 1) < 0) {
do_abort = 1; do_abort = 1;
break; break;
} }
mystate = xsvf_to_tap(uc); mystate = xsvf_to_tap(uc);
path[pathlen++] = mystate; path[pathlen++] = mystate;
LOG_DEBUG("XSTATE 0x%02X %s", uc, LOG_DEBUG("XSTATE 0x%02X %s", uc,
tap_state_name(mystate)); tap_state_name(mystate));
/* If path is incomplete, collect more */ /* If path is incomplete, collect more */
if (!svf_tap_state_is_stable(mystate)) if (!svf_tap_state_is_stable(mystate))
continue;
/* Else execute the path transitions we've
* collected so far.
*
* NOTE: Punting on the saved path is not
* strictly correct, but we must to do this
* unless jtag_add_pathmove() stops rejecting
* paths containing RESET. This is probably
* harmless, since there aren't many options
* for going from a stable state to reset;
* at the worst, we may issue extra clocks
* once we get to RESET.
*/
if (mystate == TAP_RESET) {
LOG_WARNING("XSVF: dodgey RESET");
path[0] = mystate;
}
/* FALL THROUGH */
default:
/* Execute the path we collected
*
* NOTE: OpenOCD requires something that XSVF
* doesn't: the last TAP state in the path
* must be stable. In practice, tools that
* create XSVF seem to follow that rule too.
*/
collecting_path = false;
if (path[0] == TAP_RESET)
jtag_add_tlr();
else
jtag_add_pathmove(pathlen, path);
result = jtag_execute_queue();
if (result != ERROR_OK) {
LOG_ERROR("XSVF: pathmove error %d", result);
do_abort = 1;
break;
}
continue; continue;
/* Else execute the path transitions we've
* collected so far.
*
* NOTE: Punting on the saved path is not
* strictly correct, but we must to do this
* unless jtag_add_pathmove() stops rejecting
* paths containing RESET. This is probably
* harmless, since there aren't many options
* for going from a stable state to reset;
* at the worst, we may issue extra clocks
* once we get to RESET.
*/
if (mystate == TAP_RESET) {
LOG_WARNING("XSVF: dodgey RESET");
path[0] = mystate;
}
/* FALL THROUGH */
default:
/* Execute the path we collected
*
* NOTE: OpenOCD requires something that XSVF
* doesn't: the last TAP state in the path
* must be stable. In practice, tools that
* create XSVF seem to follow that rule too.
*/
collecting_path = false;
if (path[0] == TAP_RESET)
jtag_add_tlr();
else
jtag_add_pathmove(pathlen, path);
result = jtag_execute_queue();
if (result != ERROR_OK) {
LOG_ERROR("XSVF: pathmove error %d", result);
do_abort = 1;
break;
}
continue;
} }
} }
switch (opcode) { switch (opcode) {
case XCOMPLETE: case XCOMPLETE:
LOG_DEBUG("XCOMPLETE"); LOG_DEBUG("XCOMPLETE");
result = jtag_execute_queue();
if (result != ERROR_OK)
tdo_mismatch = 1;
break;
result = jtag_execute_queue(); case XTDOMASK:
if (result != ERROR_OK) LOG_DEBUG("XTDOMASK");
tdo_mismatch = 1; if (dr_in_mask &&
break; (xsvf_read_buffer(xsdrsize, xsvf_fd, dr_in_mask) != ERROR_OK))
do_abort = 1;
break;
case XTDOMASK: case XRUNTEST:
LOG_DEBUG("XTDOMASK");
if (dr_in_mask &&
(xsvf_read_buffer(xsdrsize, xsvf_fd, dr_in_mask) != ERROR_OK))
do_abort = 1;
break;
case XRUNTEST:
{ {
uint8_t xruntest_buf[4]; uint8_t xruntest_buf[4];
@@ -374,7 +373,7 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case XREPEAT: case XREPEAT:
{ {
uint8_t myrepeat; uint8_t myrepeat;
@@ -387,7 +386,7 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case XSDRSIZE: case XSDRSIZE:
{ {
uint8_t xsdrsize_buf[4]; uint8_t xsdrsize_buf[4];
@@ -409,8 +408,8 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case XSDR: /* these two are identical except for the dr_in_buf */ case XSDR: /* these two are identical except for the dr_in_buf */
case XSDRTDO: case XSDRTDO:
{ {
int limit = xrepeat; int limit = xrepeat;
int matched = 0; int matched = 0;
@@ -519,47 +518,47 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case XSETSDRMASKS: case XSETSDRMASKS:
LOG_ERROR("unsupported XSETSDRMASKS"); LOG_ERROR("unsupported XSETSDRMASKS");
unsupported = 1; unsupported = 1;
break; break;
case XSDRINC: case XSDRINC:
LOG_ERROR("unsupported XSDRINC"); LOG_ERROR("unsupported XSDRINC");
unsupported = 1; unsupported = 1;
break; break;
case XSDRB: case XSDRB:
LOG_ERROR("unsupported XSDRB"); LOG_ERROR("unsupported XSDRB");
unsupported = 1; unsupported = 1;
break; break;
case XSDRC: case XSDRC:
LOG_ERROR("unsupported XSDRC"); LOG_ERROR("unsupported XSDRC");
unsupported = 1; unsupported = 1;
break; break;
case XSDRE: case XSDRE:
LOG_ERROR("unsupported XSDRE"); LOG_ERROR("unsupported XSDRE");
unsupported = 1; unsupported = 1;
break; break;
case XSDRTDOB: case XSDRTDOB:
LOG_ERROR("unsupported XSDRTDOB"); LOG_ERROR("unsupported XSDRTDOB");
unsupported = 1; unsupported = 1;
break; break;
case XSDRTDOC: case XSDRTDOC:
LOG_ERROR("unsupported XSDRTDOC"); LOG_ERROR("unsupported XSDRTDOC");
unsupported = 1; unsupported = 1;
break; break;
case XSDRTDOE: case XSDRTDOE:
LOG_ERROR("unsupported XSDRTDOE"); LOG_ERROR("unsupported XSDRTDOE");
unsupported = 1; unsupported = 1;
break; break;
case XSTATE: case XSTATE:
{ {
enum tap_state mystate; enum tap_state mystate;
@@ -604,50 +603,48 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case XENDIR: case XENDIR:
if (read(xsvf_fd, &uc, 1) < 0) {
if (read(xsvf_fd, &uc, 1) < 0) { do_abort = 1;
do_abort = 1;
break;
}
/* see page 22 of XSVF spec */
if (uc == 0) {
xendir = TAP_IDLE;
} else if (uc == 1) {
xendir = TAP_IRPAUSE;
} else {
LOG_ERROR("illegial XENDIR argument: 0x%02X", uc);
unsupported = 1;
break;
}
LOG_DEBUG("XENDIR 0x%02X %s", uc, tap_state_name(xendir));
break; break;
}
case XENDDR: /* see page 22 of XSVF spec */
if (uc == 0) {
if (read(xsvf_fd, &uc, 1) < 0) { xendir = TAP_IDLE;
do_abort = 1; } else if (uc == 1) {
break; xendir = TAP_IRPAUSE;
} } else {
LOG_ERROR("illegial XENDIR argument: 0x%02X", uc);
/* see page 22 of XSVF spec */ unsupported = 1;
if (uc == 0) {
xenddr = TAP_IDLE;
} else if (uc == 1) {
xenddr = TAP_DRPAUSE;
} else {
LOG_ERROR("illegial XENDDR argument: 0x%02X", uc);
unsupported = 1;
break;
}
LOG_DEBUG("XENDDR %02X %s", uc, tap_state_name(xenddr));
break; break;
}
case XSIR: LOG_DEBUG("XENDIR 0x%02X %s", uc, tap_state_name(xendir));
case XSIR2: break;
case XENDDR:
if (read(xsvf_fd, &uc, 1) < 0) {
do_abort = 1;
break;
}
/* see page 22 of XSVF spec */
if (uc == 0) {
xenddr = TAP_IDLE;
} else if (uc == 1) {
xenddr = TAP_DRPAUSE;
} else {
LOG_ERROR("illegial XENDDR argument: 0x%02X", uc);
unsupported = 1;
break;
}
LOG_DEBUG("XENDDR %02X %s", uc, tap_state_name(xenddr));
break;
case XSIR:
case XSIR2:
{ {
uint8_t short_buf[2]; uint8_t short_buf[2];
uint8_t *ir_buf; uint8_t *ir_buf;
@@ -710,7 +707,7 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case XCOMMENT: case XCOMMENT:
{ {
unsigned int ndx = 0; unsigned int ndx = 0;
char comment[128]; char comment[128];
@@ -732,7 +729,7 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case XWAIT: case XWAIT:
{ {
/* expected in stream: /* expected in stream:
XWAIT <uint8_t wait_state> <uint8_t end_state> <uint32_t usecs> XWAIT <uint8_t wait_state> <uint8_t end_state> <uint32_t usecs>
@@ -775,7 +772,7 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case XWAITSTATE: case XWAITSTATE:
{ {
/* expected in stream: /* expected in stream:
* XWAITSTATE <uint8_t wait_state> <uint8_t end_state> <uint32_t clock_count> * XWAITSTATE <uint8_t wait_state> <uint8_t end_state> <uint32_t clock_count>
@@ -836,7 +833,7 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case LCOUNT: case LCOUNT:
{ {
/* expected in stream: /* expected in stream:
* LCOUNT <uint32_t loop_count> * LCOUNT <uint32_t loop_count>
@@ -853,7 +850,7 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case LDELAY: case LDELAY:
{ {
/* expected in stream: /* expected in stream:
* LDELAY <uint8_t wait_state> <uint32_t clock_count> <uint32_t usecs_to_sleep> * LDELAY <uint8_t wait_state> <uint32_t clock_count> <uint32_t usecs_to_sleep>
@@ -879,10 +876,10 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
/* LSDR is more like XSDRTDO than it is like XSDR. It uses LDELAY which /* LSDR is more like XSDRTDO than it is like XSDR. It uses LDELAY which
* comes with clocks !AND! sleep requirements. * comes with clocks !AND! sleep requirements.
*/ */
case LSDR: case LSDR:
{ {
int limit = loop_count; int limit = loop_count;
int matched = 0; int matched = 0;
@@ -946,7 +943,7 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
case XTRST: case XTRST:
{ {
uint8_t trst_mode; uint8_t trst_mode;
@@ -972,9 +969,9 @@ COMMAND_HANDLER(handle_xsvf_command)
} }
break; break;
default: default:
LOG_ERROR("unknown xsvf command (0x%02X)", uc); LOG_ERROR("unknown xsvf command (0x%02X)", uc);
unsupported = 1; unsupported = 1;
} }
if (do_abort || unsupported || tdo_mismatch) { if (do_abort || unsupported || tdo_mismatch) {