Skip to content

Commit

Permalink
jtagtap: optimize _no_delay() paths at -O3 like swdptap
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTracer committed Nov 25, 2023
1 parent ecaa803 commit 6aac352
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/platforms/common/jtagtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ jtag_proc_s jtag_proc;

static void jtagtap_reset(void);
static inline void platform_delay_busy(const uint32_t loops) __attribute__((always_inline));
static void jtagtap_tms_seq(uint32_t tms_states, size_t ticks);
static void jtagtap_tdi_tdo_seq(uint8_t *data_out, bool final_tms, const uint8_t *data_in, size_t clock_cycles);
static void jtagtap_tdi_seq(bool final_tms, const uint8_t *data_in, size_t clock_cycles);
static bool jtagtap_next(bool tms, bool tdi);
static void jtagtap_cycle(bool tms, bool tdi, size_t clock_cycles);
static void jtagtap_tms_seq(uint32_t tms_states, size_t ticks) __attribute__((optimize(3)));
static void jtagtap_tdi_tdo_seq(uint8_t *data_out, bool final_tms, const uint8_t *data_in, size_t clock_cycles)
__attribute__((optimize(3)));
static void jtagtap_tdi_seq(bool final_tms, const uint8_t *data_in, size_t clock_cycles) __attribute__((optimize(3)));
static bool jtagtap_next(bool tms, bool tdi) __attribute__((optimize(3)));
static void jtagtap_cycle(bool tms, bool tdi, size_t clock_cycles) __attribute__((optimize(3)));

void jtagtap_init(void)
{
Expand Down Expand Up @@ -94,6 +95,8 @@ static bool jtagtap_next_clk_delay()
return result != 0;
}

static bool jtagtap_next_no_delay() __attribute__((optimize(3)));

static bool jtagtap_next_no_delay()
{
gpio_set(TCK_PORT, TCK_PIN);
Expand Down Expand Up @@ -125,6 +128,9 @@ static void jtagtap_tms_seq_clk_delay(uint32_t tms_states, const size_t clock_cy
}
}

static void jtagtap_tms_seq_no_delay(uint32_t tms_states, const size_t clock_cycles)
__attribute__((noinline, optimize(3)));

static void jtagtap_tms_seq_no_delay(uint32_t tms_states, const size_t clock_cycles)
{
bool state = tms_states & 1U;
Expand Down Expand Up @@ -183,6 +189,9 @@ static void jtagtap_tdi_tdo_seq_clk_delay(
}
}

static void jtagtap_tdi_tdo_seq_no_delay(const uint8_t *const data_in, uint8_t *const data_out, const bool final_tms,
const size_t clock_cycles) __attribute__((optimize(3)));

static void jtagtap_tdi_tdo_seq_no_delay(
const uint8_t *const data_in, uint8_t *const data_out, const bool final_tms, const size_t clock_cycles)
{
Expand Down Expand Up @@ -257,6 +266,9 @@ static void jtagtap_tdi_seq_clk_delay(const uint8_t *const data_in, const bool f
}
}

static void jtagtap_tdi_seq_no_delay(const uint8_t *const data_in, const bool final_tms, size_t clock_cycles)
__attribute__((optimize(3)));

static void jtagtap_tdi_seq_no_delay(const uint8_t *const data_in, const bool final_tms, size_t clock_cycles)
{
for (size_t cycle = 0; cycle < clock_cycles;) {
Expand Down Expand Up @@ -307,6 +319,8 @@ static void jtagtap_cycle_clk_delay(const size_t clock_cycles)
}
}

static void jtagtap_cycle_no_delay(const size_t clock_cycles) __attribute__((optimize(3)));

static void jtagtap_cycle_no_delay(const size_t clock_cycles)
{
for (size_t cycle = 0; cycle < clock_cycles; ++cycle) {
Expand Down

0 comments on commit 6aac352

Please sign in to comment.