From: <kc...@ma...> - 2009-02-10 19:21:31
|
Author: kc8apf Date: 2009-02-10 19:21:17 +0100 (Tue, 10 Feb 2009) New Revision: 1370 Modified: trunk/configure.in trunk/src/helper/types.h trunk/src/jtag/bitbang.c trunk/src/jtag/bitq.c trunk/src/jtag/ft2232.c trunk/src/jtag/gw16012.c trunk/src/jtag/jlink.c trunk/src/jtag/jtag.c trunk/src/jtag/jtag.h trunk/src/jtag/rlink/rlink.c trunk/src/jtag/usbprog.c trunk/src/jtag/vsllink.c trunk/src/jtag/zy1000.c trunk/src/xsvf/xsvf.c Log: Use C89/C99/C++ compliant boolean types Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/configure.in 2009-02-10 18:21:17 UTC (rev 1370) @@ -11,6 +11,7 @@ AC_CHECK_HEADERS(sys/time.h) AC_CHECK_HEADERS(elf.h) AC_CHECK_HEADERS(strings.h) +AC_CHECK_HEADERS(stdbool.h) AC_HEADER_TIME Modified: trunk/src/helper/types.h =================================================================== --- trunk/src/helper/types.h 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/helper/types.h 2009-02-10 18:21:17 UTC (rev 1370) @@ -45,7 +45,22 @@ typedef struct jtag_tap_s jtag_tap_t; +#ifdef HAVE_STDBOOL_H +#include <stdbool.h> +#else /* HAVE_STDBOOL_H */ +#define __bool_true_false_are_defined 1 +#ifndef __cplusplus + +#define false 0 +#define true 1 + +#define bool _Bool +typedef int _Bool; +#endif /* __cplusplus */ + +#endif /* HAVE_STDBOOL_H */ + /* DANGER!!!! here be dragons! * * Leave these fn's as byte accesses because it is safe Modified: trunk/src/jtag/bitbang.c =================================================================== --- trunk/src/jtag/bitbang.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/bitbang.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -112,11 +112,11 @@ state_count = 0; while (num_states) { - if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count]) + if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count]) { tms = 0; } - else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count]) + else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count]) { tms = 1; } Modified: trunk/src/jtag/bitq.c =================================================================== --- trunk/src/jtag/bitq.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/bitq.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -194,9 +194,9 @@ for (i = 0; i<=cmd->num_states; i++) { - if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[i]) + if (tap_state_transition(tap_get_state(), false) == cmd->path[i]) bitq_io(0, 0, 0); - else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[i]) + else if (tap_state_transition(tap_get_state(), true) == cmd->path[i]) bitq_io(1, 0, 0); else { Modified: trunk/src/jtag/ft2232.c =================================================================== --- trunk/src/jtag/ft2232.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/ft2232.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -562,9 +562,9 @@ while (num_states_batch--) { - if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count]) + if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count]) buf_set_u32(&tms_byte, bit_count++, 1, 0x0); - else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count]) + else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count]) buf_set_u32(&tms_byte, bit_count++, 1, 0x1); else { Modified: trunk/src/jtag/gw16012.c =================================================================== --- trunk/src/jtag/gw16012.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/gw16012.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -230,11 +230,11 @@ while (num_states) { gw16012_control(0x0); /* single-bit mode */ - if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count]) + if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count]) { gw16012_data(0x0); /* TCK cycle with TMS low */ } - else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count]) + else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count]) { gw16012_data(0x2); /* TCK cycle with TMS high */ } Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/jlink.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -366,11 +366,11 @@ for (i = 0; i < num_states; i++) { - if (path[i] == tap_state_transition(tap_get_state(), FALSE)) + if (path[i] == tap_state_transition(tap_get_state(), false)) { jlink_tap_append_step(0, 0); } - else if (path[i] == tap_state_transition(tap_get_state(), TRUE)) + else if (path[i] == tap_state_transition(tap_get_state(), true)) { jlink_tap_append_step(1, 0); } Modified: trunk/src/jtag/jtag.c =================================================================== --- trunk/src/jtag/jtag.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/jtag.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -957,8 +957,8 @@ LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences"); exit(-1); } - if ( tap_state_transition(cur_state, 1) != path[i] - && tap_state_transition(cur_state, 0) != path[i]) + if ( tap_state_transition(cur_state, true) != path[i] + && tap_state_transition(cur_state, false) != path[i]) { LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(cur_state), tap_state_name(path[i])); exit(-1); @@ -2920,6 +2920,7 @@ } } + /*-----<Cable Helper API>---------------------------------------*/ /* these Cable Helper API functions are all documented in the jtag.h header file, @@ -2964,6 +2965,7 @@ return end_state_follower; } + int tap_move_ndx( tap_state_t astate ) { /* given a stable state, return the index into the tms_seqs[] array within tap_get_tms_path() */ @@ -2994,6 +2996,7 @@ return ndx; } + int tap_get_tms_path( tap_state_t from, tap_state_t to ) { /* tap_move[i][j]: tap movement command to go from state i to state j @@ -3035,9 +3038,10 @@ return tms_seqs[tap_move_ndx(from)][tap_move_ndx(to)]; } -int tap_is_state_stable(tap_state_t astate) + +bool tap_is_state_stable(tap_state_t astate) { - int is_stable; + bool is_stable; /* A switch() is used because it is symbol dependent (not value dependent like an array), and can also check bounds. @@ -3050,16 +3054,16 @@ case TAP_DRPAUSE: case TAP_IRSHIFT: case TAP_IRPAUSE: - is_stable = 1; + is_stable = true; break; default: - is_stable = 0; + is_stable = false; } return is_stable; } -tap_state_t tap_state_transition(tap_state_t cur_state, int tms) +tap_state_t tap_state_transition(tap_state_t cur_state, bool tms) { tap_state_t new_state; Modified: trunk/src/jtag/jtag.h =================================================================== --- trunk/src/jtag/jtag.h 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/jtag.h 2009-02-10 18:21:17 UTC (rev 1370) @@ -29,6 +29,7 @@ #include "command.h" + #if 0 #define _DEBUG_JTAG_IO_ #endif @@ -37,6 +38,7 @@ #define DEBUG_JTAG_IOZ 64 #endif + /* 16 Tap States, from page 21 of ASSET InterTech, Inc.'s svf.pdf */ enum tap_state { @@ -57,6 +59,7 @@ //extern tap_transition_t tap_transitions[16]; /* describe the TAP state diagram */ + /*-----<Cable Helper API>-------------------------------------------*/ /* The "Cable Helper API" is what the cable drivers can use to help implement @@ -147,9 +150,9 @@ /** * Function tap_is_state_stable - * returns TRUE if the \a astate is stable. + * returns true if the \a astate is stable. */ -int tap_is_state_stable(tap_state_t astate); +bool tap_is_state_stable(tap_state_t astate); /** * Function tap_state_transition @@ -158,7 +161,7 @@ * @param tms is either zero or non-zero, just like a real TMS line in a jtag interface. * @return tap_state_t - the next state a TAP would enter. */ -tap_state_t tap_state_transition(tap_state_t current_state, int tms); +tap_state_t tap_state_transition(tap_state_t current_state, bool tms); /** * Function tap_state_name @@ -168,6 +171,7 @@ /*-----</Cable Helper API>------------------------------------------*/ + extern tap_state_t cmd_queue_end_state; /* finish DR scans in dr_end_state */ extern tap_state_t cmd_queue_cur_state; /* current TAP state */ Modified: trunk/src/jtag/rlink/rlink.c =================================================================== --- trunk/src/jtag/rlink/rlink.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/rlink/rlink.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -927,11 +927,11 @@ state_count = 0; while (num_states) { - if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count]) + if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count]) { tms = 0; } - else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count]) + else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count]) { tms = 1; } Modified: trunk/src/jtag/usbprog.c =================================================================== --- trunk/src/jtag/usbprog.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/usbprog.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -268,13 +268,13 @@ state_count = 0; while (num_states) { - if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count]) + if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count]) { /* LOG_INFO("1"); */ usbprog_write(0, 0, 0); usbprog_write(1, 0, 0); } - else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count]) + else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count]) { /* LOG_INFO("2"); */ usbprog_write(0, 1, 0); Modified: trunk/src/jtag/vsllink.c =================================================================== --- trunk/src/jtag/vsllink.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/vsllink.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -634,11 +634,11 @@ vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] = 0; } - if (path[i - start] == tap_state_transition(tap_get_state(), TRUE)) + if (path[i - start] == tap_state_transition(tap_get_state(), true)) { vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] |= 1 << (i & 7); } - else if (path[i - start] == tap_state_transition(tap_get_state(), FALSE)) + else if (path[i - start] == tap_state_transition(tap_get_state(), false)) { // nothing to do } Modified: trunk/src/jtag/zy1000.c =================================================================== --- trunk/src/jtag/zy1000.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/jtag/zy1000.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -764,11 +764,11 @@ while (num_states) { - if (tap_state_transition(cur_state, FALSE) == path[state_count]) + if (tap_state_transition(cur_state, false) == path[state_count]) { tms = 0; } - else if (tap_state_transition(cur_state, TRUE) == path[state_count]) + else if (tap_state_transition(cur_state, true) == path[state_count]) { tms = 1; } Modified: trunk/src/xsvf/xsvf.c =================================================================== --- trunk/src/xsvf/xsvf.c 2009-02-10 16:11:07 UTC (rev 1369) +++ trunk/src/xsvf/xsvf.c 2009-02-10 18:21:17 UTC (rev 1370) @@ -201,11 +201,11 @@ int j = (move >> i) & 1; if (j) { - curstate = tap_state_transition(curstate, TRUE); + curstate = tap_state_transition(curstate, true); } else { - curstate = tap_state_transition(curstate, FALSE); + curstate = tap_state_transition(curstate, false); } moves[i] = curstate; } |