From 0e08ff003347d0282bbc45c73997cab3048805df Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 2 Aug 2000 21:12:36 +0000 Subject: Patch from Eric Norum to add optional support for fast mutexes that bypass the API level to directly interface with the SuperCore. --- c/src/exec/libnetworking/rtems/rtems_glue.c | 50 +++++++++++++++++++++++++++-- c/src/libnetworking/rtems/rtems_glue.c | 50 +++++++++++++++++++++++++++-- 2 files changed, 94 insertions(+), 6 deletions(-) (limited to 'c/src') diff --git a/c/src/exec/libnetworking/rtems/rtems_glue.c b/c/src/exec/libnetworking/rtems/rtems_glue.c index 31b44a6656..86a1dbfc21 100644 --- a/c/src/exec/libnetworking/rtems/rtems_glue.c +++ b/c/src/exec/libnetworking/rtems/rtems_glue.c @@ -2,6 +2,12 @@ * $Id$ */ +#define RTEMS_FAST_MUTEX + +#ifdef RTEMS_FAST_MUTEX +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 +#endif + #include #include #include @@ -45,6 +51,9 @@ unsigned long sb_efficiency = 8; * Network task synchronization */ static rtems_id networkSemaphore; +#ifdef RTEMS_FAST_MUTEX +Semaphore_Control *the_networkSemaphore; +#endif static rtems_id networkDaemonTid; static rtems_unsigned32 networkDaemonPriority; static void networkDaemon (void *task_argument); @@ -221,9 +230,9 @@ rtems_bsdnet_initialize (void) */ sc = rtems_semaphore_create (rtems_build_name('B', 'S', 'D', 'n'), 0, - RTEMS_FIFO | + RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | - RTEMS_NO_INHERIT_PRIORITY | + RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL, 0, @@ -232,6 +241,13 @@ rtems_bsdnet_initialize (void) printf ("Can't create network seamphore: `%s'\n", rtems_status_text (sc)); return -1; } +#ifdef RTEMS_FAST_MUTEX + { + Objects_Locations location; + the_networkSemaphore = _Semaphore_Get( networkSemaphore, &location ); + _Thread_Enable_dispatch(); + } +#endif /* * Compute clock tick conversion factors @@ -270,11 +286,25 @@ rtems_bsdnet_initialize (void) void rtems_bsdnet_semaphore_obtain (void) { +#ifdef RTEMS_FAST_MUTEX + ISR_Level level; + _ISR_Disable (level); + _CORE_mutex_Seize ( + &the_networkSemaphore->Core_control.mutex, + networkSemaphore, + 1, /* wait */ + 0, /* forever */ + level + ); + if (_Thread_Executing->Wait.return_code) + rtems_panic ("Can't obtain network semaphore\n"); +#else rtems_status_code sc; sc = rtems_semaphore_obtain (networkSemaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (sc != RTEMS_SUCCESSFUL) rtems_panic ("Can't obtain network semaphore: `%s'\n", rtems_status_text (sc)); +#endif } /* @@ -283,12 +313,26 @@ rtems_bsdnet_semaphore_obtain (void) void rtems_bsdnet_semaphore_release (void) { +#ifdef RTEMS_FAST_MUTEX + int i; + + _Thread_Disable_dispatch(); + i = _CORE_mutex_Surrender ( + &the_networkSemaphore->Core_control.mutex, + networkSemaphore, + NULL + ); + _Thread_Enable_dispatch(); + if (i) + rtems_panic ("Can't release network semaphore\n"); +#else rtems_status_code sc; sc = rtems_semaphore_release (networkSemaphore); if (sc != RTEMS_SUCCESSFUL) rtems_panic ("Can't release network semaphore: `%s'\n", rtems_status_text (sc)); - } +#endif +} /* * Wait for something to happen to a socket buffer diff --git a/c/src/libnetworking/rtems/rtems_glue.c b/c/src/libnetworking/rtems/rtems_glue.c index 31b44a6656..86a1dbfc21 100644 --- a/c/src/libnetworking/rtems/rtems_glue.c +++ b/c/src/libnetworking/rtems/rtems_glue.c @@ -2,6 +2,12 @@ * $Id$ */ +#define RTEMS_FAST_MUTEX + +#ifdef RTEMS_FAST_MUTEX +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 +#endif + #include #include #include @@ -45,6 +51,9 @@ unsigned long sb_efficiency = 8; * Network task synchronization */ static rtems_id networkSemaphore; +#ifdef RTEMS_FAST_MUTEX +Semaphore_Control *the_networkSemaphore; +#endif static rtems_id networkDaemonTid; static rtems_unsigned32 networkDaemonPriority; static void networkDaemon (void *task_argument); @@ -221,9 +230,9 @@ rtems_bsdnet_initialize (void) */ sc = rtems_semaphore_create (rtems_build_name('B', 'S', 'D', 'n'), 0, - RTEMS_FIFO | + RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | - RTEMS_NO_INHERIT_PRIORITY | + RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL, 0, @@ -232,6 +241,13 @@ rtems_bsdnet_initialize (void) printf ("Can't create network seamphore: `%s'\n", rtems_status_text (sc)); return -1; } +#ifdef RTEMS_FAST_MUTEX + { + Objects_Locations location; + the_networkSemaphore = _Semaphore_Get( networkSemaphore, &location ); + _Thread_Enable_dispatch(); + } +#endif /* * Compute clock tick conversion factors @@ -270,11 +286,25 @@ rtems_bsdnet_initialize (void) void rtems_bsdnet_semaphore_obtain (void) { +#ifdef RTEMS_FAST_MUTEX + ISR_Level level; + _ISR_Disable (level); + _CORE_mutex_Seize ( + &the_networkSemaphore->Core_control.mutex, + networkSemaphore, + 1, /* wait */ + 0, /* forever */ + level + ); + if (_Thread_Executing->Wait.return_code) + rtems_panic ("Can't obtain network semaphore\n"); +#else rtems_status_code sc; sc = rtems_semaphore_obtain (networkSemaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (sc != RTEMS_SUCCESSFUL) rtems_panic ("Can't obtain network semaphore: `%s'\n", rtems_status_text (sc)); +#endif } /* @@ -283,12 +313,26 @@ rtems_bsdnet_semaphore_obtain (void) void rtems_bsdnet_semaphore_release (void) { +#ifdef RTEMS_FAST_MUTEX + int i; + + _Thread_Disable_dispatch(); + i = _CORE_mutex_Surrender ( + &the_networkSemaphore->Core_control.mutex, + networkSemaphore, + NULL + ); + _Thread_Enable_dispatch(); + if (i) + rtems_panic ("Can't release network semaphore\n"); +#else rtems_status_code sc; sc = rtems_semaphore_release (networkSemaphore); if (sc != RTEMS_SUCCESSFUL) rtems_panic ("Can't release network semaphore: `%s'\n", rtems_status_text (sc)); - } +#endif +} /* * Wait for something to happen to a socket buffer -- cgit v1.2.3