diff options
-rw-r--r-- | uLan/ports/os/rtems/arch/sys_arch.c | 18 | ||||
-rw-r--r-- | uLan/ports/os/rtems/arch/sys_arch.h | 9 |
2 files changed, 27 insertions, 0 deletions
diff --git a/uLan/ports/os/rtems/arch/sys_arch.c b/uLan/ports/os/rtems/arch/sys_arch.c index fa344a1..3a454b8 100644 --- a/uLan/ports/os/rtems/arch/sys_arch.c +++ b/uLan/ports/os/rtems/arch/sys_arch.c @@ -57,6 +57,14 @@ sys_now() return temp; } +#ifdef __rtems__ +#if RTEMS_SMP +#include <rtems/thread.h> +rtems_recursive_mutex sys_arch_lock = + RTEMS_RECURSIVE_MUTEX_INITIALIZER( "LWIP System Protection Lock" ); +#endif +#endif + void sys_init(void) { @@ -366,14 +374,24 @@ sys_arch_protect() { sys_prot_t pval; +#if RTEMS_SMP + pval = _Thread_Dispatch_disable(); + rtems_recursive_mutex_lock( &sys_arch_lock ); +#else rtems_interrupt_disable(pval); +#endif return pval; } void sys_arch_unprotect(sys_prot_t pval) { +#if RTEMS_SMP + rtems_recursive_mutex_unlock( &sys_arch_lock ); + _Thread_Dispatch_enable(pval); +#else rtems_interrupt_enable(pval); +#endif } err_t sys_mbox_trypost_fromisr(sys_mbox_t *q, void *msg) diff --git a/uLan/ports/os/rtems/arch/sys_arch.h b/uLan/ports/os/rtems/arch/sys_arch.h index a80244d..6ec578b 100644 --- a/uLan/ports/os/rtems/arch/sys_arch.h +++ b/uLan/ports/os/rtems/arch/sys_arch.h @@ -68,7 +68,16 @@ typedef port_mailbox_t sys_mbox_t; typedef port_sem_t sys_sem_t; typedef rtems_id sys_thread_t; typedef port_mutex_t sys_mutex_t; +#ifdef __rtems__ +#include <rtems/score/threaddispatch.h> +#ifdef RTEMS_SMP +typedef Per_CPU_Control *sys_prot_t; +#else typedef rtems_interrupt_level sys_prot_t; +#endif +#else +typedef rtems_interrupt_level sys_prot_t; +#endif void sys_arch_delay(unsigned int x); |