Changeset b06e68ef in rtems for cpukit/sapi/src


Ignore:
Timestamp:
Aug 17, 1995, 7:51:51 PM (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
95fbca1
Parents:
3b438fa
Message:

Numerous miscellaneous features incorporated from Tony Bennett
(tbennett@…) including the following major additions:

+ variable length messages
+ named devices
+ debug monitor
+ association tables/variables

Location:
cpukit/sapi/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/src/exinit.c

    r3b438fa rb06e68ef  
    178178
    179179  _Message_queue_Manager_initialization(
    180     configuration_table->maximum_message_queues,
    181     configuration_table->maximum_messages
     180    configuration_table->maximum_message_queues
    182181  );
    183182
  • cpukit/sapi/src/io.c

    r3b438fa rb06e68ef  
    1919#include <rtems/isr.h>
    2020#include <rtems/thread.h>
     21#include <rtems/intr.h>
     22
     23#include <string.h>
    2124
    2225/*PAGE
     
    3437{
    3538   rtems_device_major_number major;
    36    unsigned32                ignored;
    3739
    3840   for ( major=0 ; major < _IO_Number_of_drivers ; major ++ )
    39      (void) rtems_io_initialize( major, 0, _Configuration_Table, &ignored );
    40 }
     41     (void) rtems_io_initialize( major, 0, _Configuration_Table);
     42}
     43
     44/*PAGE
     45 *
     46 *  rtems_io_register_name
     47 *
     48 *  Associate a name with a driver
     49 *
     50 *  Input Paramters:
     51 *
     52 *  Output Parameters:
     53 */
     54
     55rtems_status_code rtems_io_register_name(
     56    char *device_name,
     57    rtems_device_major_number major,
     58    rtems_device_minor_number minor
     59  )
     60{
     61    rtems_driver_name_t *np;
     62    unsigned32 level;
     63
     64    /* find an empty slot */
     65    for (np = rtems_driver_name_table; np < &rtems_driver_name_table[RTEMS_MAX_DRIVER_NAMES]; np++)
     66    {
     67        rtems_interrupt_disable(level);
     68        if (np->device_name == 0)
     69        {
     70            np->device_name = device_name;
     71            np->device_name_length = strlen(device_name);
     72            np->major = major;
     73            np->minor = minor;
     74            rtems_interrupt_enable(level);
     75
     76            return RTEMS_SUCCESSFUL;
     77        }
     78        rtems_interrupt_enable(level);
     79    }
     80
     81    return RTEMS_TOO_MANY;
     82}
     83
     84/*PAGE
     85 *
     86 *  rtems_io_lookup_name
     87 *
     88 *  Find what driver "owns" this name
     89 *
     90 *  Input Paramters:
     91 *
     92 *  Output Parameters:
     93 */
     94
     95rtems_status_code rtems_io_lookup_name(
     96    const char *pathname,
     97    rtems_driver_name_t **rnp
     98  )
     99{
     100    rtems_driver_name_t *np;
     101
     102    for (np = rtems_driver_name_table; np < &rtems_driver_name_table[RTEMS_MAX_DRIVER_NAMES]; np++)
     103        if (np->device_name)
     104            if (strncmp(np->device_name, pathname, np->device_name_length) == 0)
     105            {               
     106                *rnp = np;
     107                return RTEMS_SUCCESSFUL;
     108            }
     109   
     110    *rnp = 0;
     111    return RTEMS_UNSATISFIED;
     112}
     113
    41114
    42115/*PAGE
     
    50123 *    minor        - device number
    51124 *    argument     - pointer to argument(s)
    52  *    return_value - pointer to driver's return value
    53  *
    54  *  Output Parameters:
    55  *    returns       - return code
    56  *    *return_value - driver's return code
     125 *
     126 *  Output Parameters:
     127 *    returns       - return code
    57128 */
    58129
     
    60131  rtems_device_major_number  major,
    61132  rtems_device_minor_number  minor,
    62   void             *argument,
    63   unsigned32       *return_value
    64 )
    65 {
    66   return _IO_Handler_routine(
    67             IO_INITIALIZE_OPERATION,
    68             major,
    69             minor,
    70             argument,
    71             return_value
    72          );
     133  void             *argument
     134)
     135{
     136    rtems_device_driver_entry callout;
     137   
     138    if ( major >= _IO_Number_of_drivers )
     139        return RTEMS_INVALID_NUMBER;
     140
     141    callout = _IO_Driver_address_table[major].initialization;
     142    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
    73143}
    74144
     
    83153 *    minor        - device number
    84154 *    argument     - pointer to argument(s)
    85  *    return_value - pointer to driver's return value
    86  *
    87  *  Output Parameters:
    88  *    returns       - return code
    89  *    *return_value - driver's return code
     155 *
     156 *  Output Parameters:
     157 *    returns       - return code
    90158 */
    91159
     
    93161  rtems_device_major_number  major,
    94162  rtems_device_minor_number  minor,
    95   void             *argument,
    96   unsigned32       *return_value
    97 )
    98 {
    99   return _IO_Handler_routine(
    100             IO_OPEN_OPERATION,
    101             major,
    102             minor,
    103             argument,
    104             return_value
    105          );
     163  void             *argument
     164)
     165{
     166    rtems_device_driver_entry callout;
     167   
     168    if ( major >= _IO_Number_of_drivers )
     169        return RTEMS_INVALID_NUMBER;
     170
     171    callout = _IO_Driver_address_table[major].open;
     172    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
    106173}
    107174
     
    116183 *    minor        - device number
    117184 *    argument     - pointer to argument(s)
    118  *    return_value - pointer to driver's return value
    119  *
    120  *  Output Parameters:
    121  *    returns       - return code
    122  *    *return_value - driver's return code
     185 *
     186 *  Output Parameters:
     187 *    returns       - return code
    123188 */
    124189
     
    126191  rtems_device_major_number  major,
    127192  rtems_device_minor_number  minor,
    128   void             *argument,
    129   unsigned32       *return_value
    130 )
    131 {
    132   return _IO_Handler_routine(
    133             IO_CLOSE_OPERATION,
    134             major,
    135             minor,
    136             argument,
    137             return_value
    138          );
     193  void             *argument
     194)
     195{
     196    rtems_device_driver_entry callout;
     197   
     198    if ( major >= _IO_Number_of_drivers )
     199        return RTEMS_INVALID_NUMBER;
     200
     201    callout = _IO_Driver_address_table[major].close;
     202    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
    139203}
    140204
     
    149213 *    minor        - device number
    150214 *    argument     - pointer to argument(s)
    151  *    return_value - pointer to driver's return value
    152  *
    153  *  Output Parameters:
    154  *    returns       - return code
    155  *    *return_value - driver's return code
     215 *
     216 *  Output Parameters:
     217 *    returns       - return code
    156218 */
    157219
     
    159221  rtems_device_major_number  major,
    160222  rtems_device_minor_number  minor,
    161   void             *argument,
    162   unsigned32       *return_value
    163 )
    164 {
    165   return _IO_Handler_routine(
    166             IO_READ_OPERATION,
    167             major,
    168             minor,
    169             argument,
    170             return_value
    171          );
     223  void             *argument
     224)
     225{
     226    rtems_device_driver_entry callout;
     227   
     228    if ( major >= _IO_Number_of_drivers )
     229        return RTEMS_INVALID_NUMBER;
     230
     231    callout = _IO_Driver_address_table[major].read;
     232    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
    172233}
    173234
     
    182243 *    minor        - device number
    183244 *    argument     - pointer to argument(s)
    184  *    return_value - pointer to driver's return value
    185  *
    186  *  Output Parameters:
    187  *    returns       - return code
    188  *    *return_value - driver's return code
     245 *
     246 *  Output Parameters:
     247 *    returns       - return code
    189248 */
    190249
     
    192251  rtems_device_major_number  major,
    193252  rtems_device_minor_number  minor,
    194   void             *argument,
    195   unsigned32       *return_value
    196 )
    197 {
    198   return _IO_Handler_routine(
    199             IO_WRITE_OPERATION,
    200             major,
    201             minor,
    202             argument,
    203             return_value
    204          );
     253  void             *argument
     254)
     255{
     256    rtems_device_driver_entry callout;
     257   
     258    if ( major >= _IO_Number_of_drivers )
     259        return RTEMS_INVALID_NUMBER;
     260
     261    callout = _IO_Driver_address_table[major].write;
     262    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
    205263}
    206264
     
    215273 *    minor        - device number
    216274 *    argument     - pointer to argument(s)
    217  *    return_value - pointer to driver's return value
    218  *
    219  *  Output Parameters:
    220  *    returns       - return code
    221  *    *return_value - driver's return code
     275 *
     276 *  Output Parameters:
     277 *    returns       - return code
    222278 */
    223279
     
    225281  rtems_device_major_number  major,
    226282  rtems_device_minor_number  minor,
    227   void             *argument,
    228   unsigned32       *return_value
    229 )
    230 {
    231   return _IO_Handler_routine(
    232             IO_CONTROL_OPERATION,
    233             major,
    234             minor,
    235             argument,
    236             return_value
    237          );
    238 }
    239 
    240 /*PAGE
    241  *
    242  *  _IO_Handler_routine
    243  *
    244  *  This routine implements all IO manager directives.
    245  *
    246  *  Input Paramters:
    247  *    operation    - I/O operation to be performed
    248  *    major        - device driver number
    249  *    minor        - device number
    250  *    argument     - pointer to argument(s)
    251  *    return_value - pointer to driver's return value
    252  *
    253  *  Output Parameters:
    254  *    returns       - return code
    255  *    *return_value - driver's return code
    256  */
    257 
    258 rtems_status_code _IO_Handler_routine(
    259   IO_operations              operation,
    260   rtems_device_major_number  major,
    261   rtems_device_minor_number  minor,
    262   void                      *argument,
    263   unsigned32                *return_value
    264 )
    265 {
    266   rtems_device_driver_entry io_callout;
    267 
    268   /*
    269    *  NOTE:  There is no range checking as in Ada because:
    270    *           + arrays in Ada are not always zero based.
    271    *           + with zero based arrays, a comparison of an unsigned
    272    *             number being less than zero would be necessary to
    273    *             check it as a range.  This would cause a warning for
    274    *             checking an unsigned number for being negative.
    275    */
    276 
    277   if ( major >= _IO_Number_of_drivers )
    278     return ( RTEMS_INVALID_NUMBER );
    279 
    280   switch ( operation ) {
    281      case IO_INITIALIZE_OPERATION:
    282         io_callout = _IO_Driver_address_table[ major ].initialization;
    283         break;
    284      case IO_OPEN_OPERATION:
    285         io_callout = _IO_Driver_address_table[ major ].open;
    286         break;
    287      case IO_CLOSE_OPERATION:
    288         io_callout = _IO_Driver_address_table[ major ].close;
    289         break;
    290      case IO_READ_OPERATION:
    291         io_callout = _IO_Driver_address_table[ major ].read;
    292         break;
    293      case IO_WRITE_OPERATION:
    294         io_callout = _IO_Driver_address_table[ major ].write;
    295         break;
    296      case IO_CONTROL_OPERATION:
    297         io_callout = _IO_Driver_address_table[ major ].control;
    298         break;
    299      default:             /* unreached -- only to remove warnings */
    300         io_callout = NULL;
    301         break;
    302   }
    303 
    304   if ( io_callout != NULL )
    305      (*io_callout)(
    306         major,
    307         minor,
    308         argument,
    309         _Thread_Executing->Object.id,
    310         return_value
    311      );
    312   else
    313      *return_value = 0;
    314 
    315   return( RTEMS_SUCCESSFUL );
    316 }
     283  void             *argument
     284)
     285{
     286    rtems_device_driver_entry callout;
     287   
     288    if ( major >= _IO_Number_of_drivers )
     289        return RTEMS_INVALID_NUMBER;
     290
     291    callout = _IO_Driver_address_table[major].control;
     292    return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
     293}
     294
Note: See TracChangeset for help on using the changeset viewer.