[rtems commit] bsp/tms570: Optimize tms570_debug_console_out()

Sebastian Huber sebh at rtems.org
Mon Jan 15 09:36:31 UTC 2024


Module:    rtems
Branch:    master
Commit:    65831d71ed25b1c1e2daa92a317c82c4aeabbf96
Changeset: http://git.rtems.org/rtems/commit/?id=65831d71ed25b1c1e2daa92a317c82c4aeabbf96

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Dec 21 15:16:49 2023 +0100

bsp/tms570: Optimize tms570_debug_console_out()

Reduce number of interrupt disable/enable actions.

Update #4982.

---

 bsps/arm/tms570/console/printk-support.c | 41 ++++++++++++++++----------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/bsps/arm/tms570/console/printk-support.c b/bsps/arm/tms570/console/printk-support.c
index 6e44ad0969..17c3a1f630 100644
--- a/bsps/arm/tms570/console/printk-support.c
+++ b/bsps/arm/tms570/console/printk-support.c
@@ -10,6 +10,7 @@
  */
 
 /*
+ * Copyright (C) 2023 embedded brains GmbH & Co. KG
  * Copyright (C) 2014 Premysl Houdek <kom541000 at gmail.com>
  *
  * Google Summer of Code 2014 at
@@ -55,33 +56,33 @@
  *
  * @retval Void
  */
-static void tms570_debug_console_putc(char ch)
+static void tms570_debug_console_out(char ch)
 {
   tms570_sci_context *ctx = TMS570_CONSOLE;
   volatile tms570_sci_t *regs = ctx->regs;
-  rtems_interrupt_level level;
 
-  rtems_interrupt_disable(level);
-  while ( ( regs->FLR & TMS570_SCI_FLR_TXRDY ) == 0) {
-    rtems_interrupt_flash(level);
+  while ( true ) {
+    rtems_interrupt_level level;
+
+    while ( ( regs->FLR & TMS570_SCI_FLR_TXRDY ) == 0) {
+      /* Wait */
+    }
+
+    rtems_interrupt_disable( level );
+
+    if ( ( regs->FLR & TMS570_SCI_FLR_TXRDY ) != 0) {
+      regs->TD = ch;
+      rtems_interrupt_enable( level );
+
+      break;
+    }
+
+    rtems_interrupt_enable( level );
   }
-  regs->TD = ch;
+
   while ( ( regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) == 0) {
-    rtems_interrupt_flash(level);
+    /* Wait */
   }
-  rtems_interrupt_enable(level);
-}
-
-/**
- * @brief debug console output
- *
- * debug functions always use serial dev 0 peripheral
- *
- * @retval Void
- */
-static void tms570_debug_console_out(char c)
-{
-  tms570_debug_console_putc(c);
 }
 
 static void tms570_debug_console_init(void)



More information about the vc mailing list