Changeset 7b1df577 in rtems


Ignore:
Timestamp:
Oct 6, 2009, 10:42:48 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
2b22160f
Parents:
133bffb
Message:

2009-10-06 Joel Sherrill <joel.sherrill@…>

  • sapi/src/ioregisterdriver.c: Reowork so this is a context switch disable critical section not interrupt disable critical section. Hopefully eliminated dead code which showed up in coverage runs.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r133bffb r7b1df577  
     12009-10-06      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * sapi/src/ioregisterdriver.c: Reowork so this is a context switch
     4        disable critical section not interrupt disable critical section.
     5        Hopefully eliminated dead code which showed up in coverage runs.
     6
    172009-10-04      Sebastian Huber <Sebastian.Huber@embedded-brains.de>
    28
  • cpukit/sapi/src/ioregisterdriver.c

    r133bffb r7b1df577  
    2727#include <rtems/io.h>
    2828#include <rtems/rtems/intr.h>
    29 
    30 rtems_status_code rtems_io_driver_io_error(
    31   rtems_device_major_number major,
    32   rtems_device_minor_number minor,
    33   void *arg
    34 )
    35 {
    36   return RTEMS_IO_ERROR;
    37 }
     29#include <rtems/score/thread.h>
    3830
    3931static inline bool rtems_io_is_empty_table(
     
    4234{
    4335  return table->initialization_entry == NULL && table->open_entry == NULL;
    44 }
    45 
    46 static inline void rtems_io_occupy_table(
    47   rtems_driver_address_table *table
    48 )
    49 {
    50   table->open_entry = rtems_io_driver_io_error;
    5136}
    5237
     
    5843  rtems_device_major_number m = 0;
    5944 
    60   if ( major == NULL ) {
    61     return RTEMS_INVALID_ADDRESS;
    62   }
     45  /* major is error checked by caller */
    6346
    6447  for ( m = 0; m < n; ++m ) {
    6548    rtems_driver_address_table *const table = _IO_Driver_address_table + m;
    66     rtems_interrupt_level level;
    6749
    68     rtems_interrupt_disable( level );
    69     if ( rtems_io_is_empty_table( table ) ) {
    70       rtems_io_occupy_table( table );
    71       rtems_interrupt_enable( level );
    72 
     50    if ( rtems_io_is_empty_table( table ) )
    7351      break;
    74     }
    75     rtems_interrupt_enable( level );
    7652  }
    7753
     
    7955  *major = m;
    8056
    81   if ( m != n ) {
     57  if ( m != n )
    8258    return RTEMS_SUCCESSFUL;
    83   } else {
    84     return RTEMS_TOO_MANY;
    85   }
     59
     60  return RTEMS_TOO_MANY;
    8661}
    8762
    8863rtems_status_code rtems_io_register_driver(
    89   rtems_device_major_number major,
     64  rtems_device_major_number         major,
    9065  const rtems_driver_address_table *driver_table,
    91   rtems_device_major_number *registered_major
     66  rtems_device_major_number        *registered_major
    9267)
    9368{
    9469  rtems_device_major_number major_limit = _IO_Number_of_drivers;
    9570
    96   if ( registered_major == NULL ) {
     71  if ( registered_major == NULL )
    9772    return RTEMS_INVALID_ADDRESS;
    98   }
    9973
    10074  /* Set it to an invalid value */
    10175  *registered_major = major_limit;
    10276
    103   if ( driver_table == NULL ) {
     77  if ( driver_table == NULL )
    10478    return RTEMS_INVALID_ADDRESS;
    105   }
    10679
    107   if ( rtems_io_is_empty_table( driver_table ) ) {
     80  if ( rtems_io_is_empty_table( driver_table ) )
    10881    return RTEMS_INVALID_ADDRESS;
    109   }
    11082
    111   if ( major >= major_limit ) {
     83  if ( major >= major_limit )
    11284    return RTEMS_INVALID_NUMBER;
    113   }
     85
     86  _Thread_Disable_dispatch();
    11487
    11588  if ( major == 0 ) {
    11689    rtems_status_code sc = rtems_io_obtain_major_number( registered_major );
    11790
    118     if ( sc == RTEMS_SUCCESSFUL ) {
    119       major = *registered_major;
    120     } else {
    121       return RTEMS_TOO_MANY;
     91    if ( sc != RTEMS_SUCCESSFUL ) {
     92      _Thread_Enable_dispatch();
     93      return sc;
    12294    }
     95    major = *registered_major;
    12396  } else {
    12497    rtems_driver_address_table *const table = _IO_Driver_address_table + major;
    125     rtems_interrupt_level level;
    12698
    127     rtems_interrupt_disable( level );
    128     if ( rtems_io_is_empty_table( table ) ) {
    129       rtems_io_occupy_table( table );
    130       rtems_interrupt_enable( level );
    131     } else {
    132       rtems_interrupt_enable( level );
    133 
     99    if ( !rtems_io_is_empty_table( table ) ) {
     100      _Thread_Enable_dispatch();
    134101      return RTEMS_RESOURCE_IN_USE;
    135102    }
     
    140107  _IO_Driver_address_table [major] = *driver_table;
    141108
     109  _Thread_Enable_dispatch();
     110
    142111  return rtems_io_initialize( major, 0, NULL );
    143112}
Note: See TracChangeset for help on using the changeset viewer.