diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-05-03 00:15:49 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-10-21 01:25:17 -0400 |
commit | 92e1481a52bfe5e371b7c7d464e526d6314979c5 (patch) | |
tree | ae280478b2748fdbd98b9c399731bf6179c5e9a5 /src/pru/main.c | |
parent | 5c10001bc525701f0ef004041cbbf093522f6de6 (diff) | |
download | kutter-92e1481a52bfe5e371b7c7d464e526d6314979c5.tar.gz kutter-92e1481a52bfe5e371b7c7d464e526d6314979c5.tar.xz kutter-92e1481a52bfe5e371b7c7d464e526d6314979c5.zip |
pru: Perform message encoding on pru0 to free space on pru1
Copy the parameters of calls to console_sendf() on pru1 to pru0 and
then call that function on pru0. Although copying the parameters is a
"hack", the code size reduction is notable.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/pru/main.c')
-rw-r--r-- | src/pru/main.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/pru/main.c b/src/pru/main.c index 37354d90..27634a12 100644 --- a/src/pru/main.c +++ b/src/pru/main.c @@ -1,6 +1,6 @@ // Main starting point for PRU code. // -// Copyright (C) 2017 Kevin O'Connor <kevin@koconnor.net> +// Copyright (C) 2017-2021 Kevin O'Connor <kevin@koconnor.net> // // This file may be distributed under the terms of the GNU GPLv3 license. @@ -78,6 +78,8 @@ timer_kick(void) CT_INTC.SECR0 = 1 << IEP_EVENT; } +static uint32_t in_timer_dispatch; + static void _irq_poll(void) { @@ -88,9 +90,11 @@ _irq_poll(void) } if (secr0 & (1 << IEP_EVENT)) { CT_IEP.TMR_CMP_STS = 0xff; + in_timer_dispatch = 1; uint32_t next = timer_dispatch_many(); timer_set(next); CT_INTC.SECR0 = 1 << IEP_EVENT; + in_timer_dispatch = 0; } } void __attribute__((optimize("O2"))) @@ -141,26 +145,23 @@ DECL_TASK(console_task); void console_sendf(const struct command_encoder *ce, va_list args) { - // Verify space for message - uint32_t send_push_pos = SHARED_MEM->send_push_pos; - struct shared_response_buffer *s = &SHARED_MEM->send_data[send_push_pos]; - if (readl(&s->count)) - return; - - // Generate message - uint32_t msglen = command_encodef(s->data, ce, args); + SHARED_MEM->next_encoder_args = args; + writel(&SHARED_MEM->next_encoder, (uint32_t)ce); // Signal PRU0 to transmit message - writel(&s->count, msglen); write_r31(R31_WRITE_IRQ_SELECT | (KICK_PRU0_EVENT - R31_WRITE_IRQ_OFFSET)); - SHARED_MEM->send_push_pos = ( - (send_push_pos + 1) % ARRAY_SIZE(SHARED_MEM->send_data)); + uint32_t itd = in_timer_dispatch; + while (readl(&SHARED_MEM->next_encoder)) + if (!itd) + irq_poll(); } void console_shutdown(void) { writel(&SHARED_MEM->next_command, 0); + writel(&SHARED_MEM->next_encoder, 0); + in_timer_dispatch = 0; } DECL_SHUTDOWN(console_shutdown); |