summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/i386/pc386/console/fb_vga.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/i386/pc386/console/fb_vga.c')
-rw-r--r--c/src/lib/libbsp/i386/pc386/console/fb_vga.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/console/fb_vga.c b/c/src/lib/libbsp/i386/pc386/console/fb_vga.c
index 444f44d979..75ad56eb98 100644
--- a/c/src/lib/libbsp/i386/pc386/console/fb_vga.c
+++ b/c/src/lib/libbsp/i386/pc386/console/fb_vga.c
@@ -20,12 +20,14 @@
#include <rtems/fb.h>
#include <rtems/framebuffer.h>
+#include <rtems/score/atomic.h>
+
/* these routines are defined in vgainit.c.*/
extern void ega_hwinit( void );
extern void ega_hwterm( void );
-/* mutex attribure */
-pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+/* flag to limit driver to protect against multiple opens */
+static Atomic_Flag driver_mutex;
/* screen information for the VGA driver */
static struct fb_var_screeninfo fb_var =
@@ -87,6 +89,8 @@ rtems_device_driver frame_buffer_initialize(
rtems_fatal_error_occurred( status );
}
+ _Atomic_Flag_clear(&driver_mutex, ATOMIC_ORDER_RELEASE);
+
return RTEMS_SUCCESSFUL;
}
@@ -99,7 +103,7 @@ rtems_device_driver frame_buffer_open(
void *arg
)
{
- if (pthread_mutex_trylock(&mutex)== 0){
+ if (_Atomic_Flag_test_and_set(&driver_mutex, ATOMIC_ORDER_ACQUIRE) != 0 ) {
/* restore previous state. for VGA this means return to text mode.
* leave out if graphics hardware has been initialized in
* frame_buffer_initialize()
@@ -121,17 +125,13 @@ rtems_device_driver frame_buffer_close(
void *arg
)
{
- if (pthread_mutex_unlock(&mutex) == 0){
- /* restore previous state. for VGA this means return to text mode.
- * leave out if graphics hardware has been initialized in
- * frame_buffer_initialize() */
- ega_hwterm();
- printk( "FBVGA close called.\n" );
- return RTEMS_SUCCESSFUL;
- }
-
- return RTEMS_UNSATISFIED;
-}
+ _Atomic_Flag_clear(&driver_mutex, ATOMIC_ORDER_RELEASE);
+ /* restore previous state. for VGA this means return to text mode.
+ * leave out if graphics hardware has been initialized in
+ * frame_buffer_initialize() */
+ ega_hwterm();
+ printk( "FBVGA close called.\n" );
+ return RTEMS_SUCCESSFUL;
/*
* fbvga device driver READ entry point.