Ignore:
Timestamp:
Jun 9, 2015, 8:48:22 PM (6 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, 5, master
Children:
0562060
Parents:
aa2a62c
git-author:
Joel Sherrill <joel.sherrill@…> (06/09/15 20:48:22)
git-committer:
Joel Sherrill <joel.sherrill@…> (06/11/15 15:06:33)
Message:

pc386/console/fb*.c: Use atomics to avoid dependency on pthreads

closes #2364.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/pc386/console/fb_vga.c

    raa2a62c rbecbeda  
    2121#include <rtems/framebuffer.h>
    2222
     23#include <rtems/score/atomic.h>
     24
    2325/* these routines are defined in vgainit.c.*/
    2426extern void ega_hwinit( void );
    2527extern void ega_hwterm( void );
    2628
    27 /* mutex attribure */
    28 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
     29/* flag to limit driver to protect against multiple opens */
     30static Atomic_Flag driver_mutex;
    2931
    3032/* screen information for the VGA driver */
     
    8890  }
    8991
     92  _Atomic_Flag_clear(&driver_mutex, ATOMIC_ORDER_RELEASE);
     93
    9094  return RTEMS_SUCCESSFUL;
    9195}
     
    100104)
    101105{
    102   if (pthread_mutex_trylock(&mutex)== 0){
     106  if (_Atomic_Flag_test_and_set(&driver_mutex, ATOMIC_ORDER_ACQUIRE) != 0 ) {
    103107      /* restore previous state.  for VGA this means return to text mode.
    104108       * leave out if graphics hardware has been initialized in
     
    122126)
    123127{
    124   if (pthread_mutex_unlock(&mutex) == 0){
    125     /* restore previous state.  for VGA this means return to text mode.
    126      * leave out if graphics hardware has been initialized in
    127      * frame_buffer_initialize() */
    128     ega_hwterm();
    129     printk( "FBVGA close called.\n" );
    130     return RTEMS_SUCCESSFUL;
    131   }
    132 
    133   return RTEMS_UNSATISFIED;
    134 }
     128  _Atomic_Flag_clear(&driver_mutex, ATOMIC_ORDER_RELEASE);
     129  /* restore previous state.  for VGA this means return to text mode.
     130   * leave out if graphics hardware has been initialized in
     131   * frame_buffer_initialize() */
     132  ega_hwterm();
     133  printk( "FBVGA close called.\n" );
     134  return RTEMS_SUCCESSFUL;
    135135
    136136/*
Note: See TracChangeset for help on using the changeset viewer.