<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr"><div>The xilinx-zynqmp-rpu bsp_reset() is modified, but not included in the spec file for the new option. Its family differs from the arm/xilinx-zynqmp BSP family with a -rpu suffix. I'd be fine with this being enabled for the AArch64 BSPs as well, but I imagine that's better as a separate patch.<br></div><div><br></div><div>Kinsey<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 19, 2024 at 3:39 AM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Make the kernel I/O output character device flushing configurable. The<br>
bsp_reset() function should reset the unit and do nothing else.<br>
<br>
The arm/xilinx-zynq and arm/xilinx-zynqmp BSPs were the only ones doing an UART<br>
flush in bsp_reset(). The bsp_reset() function should reset the system and do<br>
nothing more. Doing additional things like flushing an UART device may not<br>
make sense for all applications. Some applications may not use the UART<br>
device, so it may not be initialized and powered off. Some applications may<br>
use it with an application-specific protocol which doesn't like the additional<br>
four '\r' during reset. Doing a UART flush takes some time and some<br>
applications may prefer a fast reset cycle. The bsp_reset() is the wrong place<br>
to do specific cleanup functions.<br>
<br>
Flushing the kernel I/O output character device is now optionally done in<br>
bsp_fatal_extension() depending on the new BSP option<br>
BSP_FLUSH_KERNEL_CHAR_OUTPUT.<br>
---<br>
bsps/aarch64/xilinx-zynqmp/console/console.c | 3 ++-<br>
bsps/aarch64/xilinx-zynqmp/include/bsp.h | 2 --<br>
bsps/arm/xilinx-zynq/console/debug-console.c | 10 +++++++++<br>
bsps/arm/xilinx-zynq/start/bspreset.c | 4 ----<br>
.../console/console-config.c | 3 ++-<br>
bsps/arm/xilinx-zynqmp-rpu/include/bsp.h | 2 --<br>
bsps/arm/xilinx-zynqmp-rpu/start/bspreset.c | 3 ---<br>
.../xilinx-zynqmp/console/console-config.c | 2 +-<br>
bsps/arm/xilinx-zynqmp/include/bsp.h | 2 --<br>
bsps/arm/xilinx-zynqmp/start/bspreset.c | 4 +---<br>
bsps/include/bsp/bootcard.h | 5 +++++<br>
bsps/shared/start/bspfatal-default.c | 4 ++++<br>
spec/build/bsps/bspopts.yml | 2 ++<br>
spec/build/bsps/optflushkerncharout.yml | 22 +++++++++++++++++++<br>
14 files changed, 49 insertions(+), 19 deletions(-)<br>
create mode 100644 spec/build/bsps/optflushkerncharout.yml<br>
<br>
diff --git a/bsps/aarch64/xilinx-zynqmp/console/console.c b/bsps/aarch64/xilinx-zynqmp/console/console.c<br>
index 9ce0b1da63..d1b2850952 100644<br>
--- a/bsps/aarch64/xilinx-zynqmp/console/console.c<br>
+++ b/bsps/aarch64/xilinx-zynqmp/console/console.c<br>
@@ -41,6 +41,7 @@<br>
#include <rtems/termiostypes.h><br>
<br>
#include <bsp/aarch64-mmu.h><br>
+#include <bsp/bootcard.h><br>
#include <bsp/fdt.h><br>
#include <bsp/irq.h><br>
<br>
@@ -234,7 +235,7 @@ rtems_status_code console_initialize(<br>
return RTEMS_SUCCESSFUL;<br>
}<br>
<br>
-void zynqmp_debug_console_flush(void)<br>
+void bsp_flush_kernel_char_output(void)<br>
{<br>
zynq_uart_reset_tx_flush(&zynqmp_uart_instances[BSP_CONSOLE_MINOR]);<br>
}<br>
diff --git a/bsps/aarch64/xilinx-zynqmp/include/bsp.h b/bsps/aarch64/xilinx-zynqmp/include/bsp.h<br>
index 0ccca8b196..d36abde415 100644<br>
--- a/bsps/aarch64/xilinx-zynqmp/include/bsp.h<br>
+++ b/bsps/aarch64/xilinx-zynqmp/include/bsp.h<br>
@@ -86,8 +86,6 @@ BSP_START_TEXT_SECTION void zynqmp_setup_mmu_and_cache(void);<br>
*/<br>
BSP_START_TEXT_SECTION void zynqmp_setup_secondary_cpu_mmu_and_cache( void );<br>
<br>
-void zynqmp_debug_console_flush(void);<br>
-<br>
uint32_t zynqmp_clock_i2c0(void);<br>
<br>
uint32_t zynqmp_clock_i2c1(void);<br>
diff --git a/bsps/arm/xilinx-zynq/console/debug-console.c b/bsps/arm/xilinx-zynq/console/debug-console.c<br>
index d398ca7988..67fcbdf4a1 100644<br>
--- a/bsps/arm/xilinx-zynq/console/debug-console.c<br>
+++ b/bsps/arm/xilinx-zynq/console/debug-console.c<br>
@@ -38,10 +38,20 @@<br>
#include <rtems/sysinit.h><br>
<br>
#include <bsp.h><br>
+#include <bsp/bootcard.h><br>
#include <dev/serial/zynq-uart.h><br>
+#include <dev/serial/zynq-uart-regs.h><br>
<br>
#include <bspopts.h><br>
<br>
+void bsp_flush_kernel_char_output(void)<br>
+{<br>
+ rtems_termios_device_context *base =<br>
+ &zynq_uart_instances[BSP_CONSOLE_MINOR].base;<br>
+<br>
+ zynq_uart_reset_tx_flush(base);<br>
+}<br>
+<br>
static void zynq_debug_console_out(char c)<br>
{<br>
rtems_termios_device_context *base =<br>
diff --git a/bsps/arm/xilinx-zynq/start/bspreset.c b/bsps/arm/xilinx-zynq/start/bspreset.c<br>
index f8cc3b6999..fcdb1b8ded 100644<br>
--- a/bsps/arm/xilinx-zynq/start/bspreset.c<br>
+++ b/bsps/arm/xilinx-zynq/start/bspreset.c<br>
@@ -33,17 +33,13 @@<br>
* POSSIBILITY OF SUCH DAMAGE.<br>
*/<br>
<br>
-#include <bsp.h><br>
#include <bsp/bootcard.h><br>
-#include <dev/serial/zynq-uart.h><br>
<br>
void bsp_reset(void)<br>
{<br>
volatile uint32_t *slcr_unlock = (volatile uint32_t *) 0xf8000008;<br>
volatile uint32_t *pss_rst_ctrl = (volatile uint32_t *) 0xf8000200;<br>
<br>
- zynq_uart_reset_tx_flush(&zynq_uart_instances[BSP_CONSOLE_MINOR]);<br>
-<br>
while (true) {<br>
*slcr_unlock = 0xdf0d;<br>
*pss_rst_ctrl = 0x1;<br>
diff --git a/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c b/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c<br>
index f52e008f2b..196b2dec58 100644<br>
--- a/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c<br>
+++ b/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c<br>
@@ -35,6 +35,7 @@<br>
#include <rtems/sysinit.h><br>
#include <rtems/termiostypes.h><br>
<br>
+#include <bsp/bootcard.h><br>
#include <bsp/irq.h><br>
#include <dev/serial/zynq-uart.h><br>
<br>
@@ -79,7 +80,7 @@ rtems_status_code console_initialize(<br>
return RTEMS_SUCCESSFUL;<br>
}<br>
<br>
-void zynqmp_debug_console_flush(void)<br>
+void bsp_flush_kernel_char_output(void)<br>
{<br>
zynq_uart_reset_tx_flush(&zynqmp_uart_instances[BSP_CONSOLE_MINOR]);<br>
}<br>
diff --git a/bsps/arm/xilinx-zynqmp-rpu/include/bsp.h b/bsps/arm/xilinx-zynqmp-rpu/include/bsp.h<br>
index e386bd4b26..060147967c 100644<br>
--- a/bsps/arm/xilinx-zynqmp-rpu/include/bsp.h<br>
+++ b/bsps/arm/xilinx-zynqmp-rpu/include/bsp.h<br>
@@ -83,8 +83,6 @@ extern "C" {<br>
*/<br>
BSP_START_TEXT_SECTION void zynqmp_setup_mpu_and_cache(void);<br>
<br>
-void zynqmp_debug_console_flush(void);<br>
-<br>
#ifdef __cplusplus<br>
}<br>
#endif /* __cplusplus */<br>
diff --git a/bsps/arm/xilinx-zynqmp-rpu/start/bspreset.c b/bsps/arm/xilinx-zynqmp-rpu/start/bspreset.c<br>
index eecb4da838..a894f55f6e 100644<br>
--- a/bsps/arm/xilinx-zynqmp-rpu/start/bspreset.c<br>
+++ b/bsps/arm/xilinx-zynqmp-rpu/start/bspreset.c<br>
@@ -30,13 +30,10 @@<br>
* POSSIBILITY OF SUCH DAMAGE.<br>
*/<br>
<br>
-#include <bsp.h><br>
#include <bsp/bootcard.h><br>
<br>
void bsp_reset(void)<br>
{<br>
- zynqmp_debug_console_flush();<br>
-<br>
while (true) {<br>
/* Wait */<br>
}<br>
diff --git a/bsps/arm/xilinx-zynqmp/console/console-config.c b/bsps/arm/xilinx-zynqmp/console/console-config.c<br>
index eadd7f11a2..360d193ba2 100644<br>
--- a/bsps/arm/xilinx-zynqmp/console/console-config.c<br>
+++ b/bsps/arm/xilinx-zynqmp/console/console-config.c<br>
@@ -81,7 +81,7 @@ rtems_status_code console_initialize(<br>
return RTEMS_SUCCESSFUL;<br>
}<br>
<br>
-void zynqmp_debug_console_flush(void)<br>
+void bsp_flush_kernel_char_output(void)<br>
{<br>
zynq_uart_reset_tx_flush(&zynqmp_uart_instances[BSP_CONSOLE_MINOR]);<br>
}<br>
diff --git a/bsps/arm/xilinx-zynqmp/include/bsp.h b/bsps/arm/xilinx-zynqmp/include/bsp.h<br>
index a08a5feee9..2785e4c2e0 100644<br>
--- a/bsps/arm/xilinx-zynqmp/include/bsp.h<br>
+++ b/bsps/arm/xilinx-zynqmp/include/bsp.h<br>
@@ -79,8 +79,6 @@ extern "C" {<br>
*/<br>
BSP_START_TEXT_SECTION void zynqmp_setup_mmu_and_cache(void);<br>
<br>
-void zynqmp_debug_console_flush(void);<br>
-<br>
#ifdef __cplusplus<br>
}<br>
#endif /* __cplusplus */<br>
diff --git a/bsps/arm/xilinx-zynqmp/start/bspreset.c b/bsps/arm/xilinx-zynqmp/start/bspreset.c<br>
index b43b19b05f..ed2f4da83a 100644<br>
--- a/bsps/arm/xilinx-zynqmp/start/bspreset.c<br>
+++ b/bsps/arm/xilinx-zynqmp/start/bspreset.c<br>
@@ -30,12 +30,10 @@<br>
* POSSIBILITY OF SUCH DAMAGE.<br>
*/<br>
<br>
-#include <bsp.h><br>
+#include <bsp/bootcard.h><br>
<br>
void bsp_reset(void)<br>
{<br>
- zynqmp_debug_console_flush();<br>
-<br>
while (true) {<br>
/* Wait */<br>
}<br>
diff --git a/bsps/include/bsp/bootcard.h b/bsps/include/bsp/bootcard.h<br>
index 5f339d65f8..dfdc3ae7e0 100644<br>
--- a/bsps/include/bsp/bootcard.h<br>
+++ b/bsps/include/bsp/bootcard.h<br>
@@ -94,6 +94,11 @@ struct Per_CPU_Control;<br>
*/<br>
void bsp_start_on_secondary_processor(struct Per_CPU_Control *cpu_self);<br>
<br>
+/**<br>
+ * @brief Flushes the kernel I/O output character device provided by the BSP.<br>
+ */<br>
+void bsp_flush_kernel_char_output(void);<br>
+<br>
/** @} */<br>
<br>
#ifdef __cplusplus<br>
diff --git a/bsps/shared/start/bspfatal-default.c b/bsps/shared/start/bspfatal-default.c<br>
index 557a0960fa..de3f414407 100644<br>
--- a/bsps/shared/start/bspfatal-default.c<br>
+++ b/bsps/shared/start/bspfatal-default.c<br>
@@ -184,6 +184,10 @@ void bsp_fatal_extension(<br>
printk("\n");<br>
#endif<br>
<br>
+ #if BSP_FLUSH_KERNEL_CHAR_OUTPUT<br>
+ bsp_flush_kernel_char_output();<br>
+ #endif<br>
+<br>
/*<br>
* Check both conditions -- if you want to ask for reboot, then<br>
* you must have meant to reset the board.<br>
diff --git a/spec/build/bsps/bspopts.yml b/spec/build/bsps/bspopts.yml<br>
index 734292f421..b2d8ced4f6 100644<br>
--- a/spec/build/bsps/bspopts.yml<br>
+++ b/spec/build/bsps/bspopts.yml<br>
@@ -25,6 +25,8 @@ links:<br>
uid: optincludes<br>
- role: build-dependency<br>
uid: optcflags<br>
+- role: build-dependency<br>
+ uid: optflushkerncharout<br>
- role: build-dependency<br>
uid: optlinkflags<br>
- role: build-dependency<br>
diff --git a/spec/build/bsps/optflushkerncharout.yml b/spec/build/bsps/optflushkerncharout.yml<br>
new file mode 100644<br>
index 0000000000..845184663a<br>
--- /dev/null<br>
+++ b/spec/build/bsps/optflushkerncharout.yml<br>
@@ -0,0 +1,22 @@<br>
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause<br>
+actions:<br>
+- get-integer: null<br>
+- define: null<br>
+build-type: option<br>
+copyrights:<br>
+- Copyright (C) 2024 embedded brains GmbH & Co. KG<br>
+default:<br>
+- enabled-by:<br>
+ - bsps/arm/xilinx-zynq<br>
+ - bsps/arm/xilinx-zynqmp<br>
+ value: 1<br>
+- enabled-by: true<br>
+ value: 0<br>
+description: |<br>
+ If defined to a non-zero value, flush the kernel I/O output character device<br>
+ provided by the BSP when the application exits.<br>
+enabled-by: true<br>
+format: '{}'<br>
+links: []<br>
+name: BSP_FLUSH_KERNEL_CHAR_OUTPUT<br>
+type: build<br>
-- <br>
2.35.3<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div></div>