[PATCH rtems-lwip v1 4/9] lwip: Add support for SMP systems
Kinsey Moore
kinsey.moore at oarcorp.com
Fri Jul 1 22:31:07 UTC 2022
For BSPs that support SMP, the sys_arch_protect and sys_arch_unprotect
calls must use a global mutex instead of a local CPU interrupt disable
to protect critical sections.
---
uLan/ports/os/rtems/arch/sys_arch.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/uLan/ports/os/rtems/arch/sys_arch.c b/uLan/ports/os/rtems/arch/sys_arch.c
index fa344a1..d51810b 100644
--- a/uLan/ports/os/rtems/arch/sys_arch.c
+++ b/uLan/ports/os/rtems/arch/sys_arch.c
@@ -57,10 +57,22 @@ sys_now()
return temp;
}
+#ifdef __rtems__
+#if RTEMS_SMP
+sys_mutex_t sys_arch_mutex;
+#endif
+#endif
+
void
sys_init(void)
{
// Is called to initialize the sys_arch layer.
+#ifdef __rtems__
+#if RTEMS_SMP
+ // initialize global sys arch protect mutex
+ sys_mutex_new(&sys_arch_mutex);
+#endif
+#endif
return;
}
@@ -364,16 +376,25 @@ sys_request_irq(unsigned int irqnum, sys_irq_handler_t handler,
sys_prot_t
sys_arch_protect()
{
+#if RTEMS_SMP
+ sys_mutex_lock(&sys_arch_mutex);
+ return 0;
+#else
sys_prot_t pval;
rtems_interrupt_disable(pval);
return pval;
+#endif
}
void
sys_arch_unprotect(sys_prot_t pval)
{
+#if RTEMS_SMP
+ sys_mutex_unlock(&sys_arch_mutex);
+#else
rtems_interrupt_enable(pval);
+#endif
}
err_t
sys_mbox_trypost_fromisr(sys_mbox_t *q, void *msg)
--
2.30.2
More information about the devel
mailing list