Changeset b06e68ef in rtems for cpukit/sapi


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
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/include/rtems/config.h

    r3b438fa rb06e68ef  
    3333
    3434typedef struct {
    35   Objects_Name       name;              /* task name */
    36   unsigned32         stack_size;        /* task stack size */
     35  Objects_Name          name;              /* task name */
     36  unsigned32            stack_size;        /* task stack size */
    3737  rtems_task_priority   initial_priority;  /* task priority */
    38   rtems_attribute attribute_set;     /* task attributes */
    39   rtems_task_entry       entry_point;       /* task entry point */
    40   rtems_mode      mode_set;          /* task initial mode */
    41   unsigned32         argument;          /* task argument */
    42 }   rtems_initialization_tasks_table;
     38  rtems_attribute       attribute_set;     /* task attributes */
     39  rtems_task_entry      entry_point;       /* task entry point */
     40  rtems_mode            mode_set;          /* task initial mode */
     41  unsigned32            argument;          /* task argument */
     42} rtems_initialization_tasks_table;
    4343
    4444/*
     
    5757typedef unsigned32 rtems_device_minor_number;
    5858
    59 typedef void rtems_device_driver;
     59typedef rtems_status_code rtems_device_driver;
    6060
    6161typedef rtems_device_driver ( *rtems_device_driver_entry )(
    6262                 rtems_device_major_number,
    6363                 rtems_device_minor_number,
    64                  void *,
    65                  Objects_Id,
    66                  unsigned32 *
     64                 void *
    6765             );
    6866
     
    174172typedef struct {
    175173  unsigned32                      default_timeout;        /* in ticks */
     174  unsigned32                      maximum_packet_size;
    176175  rtems_mpci_initialization_entry initialization;
    177176  rtems_mpci_get_packet_entry     get_packet;
     
    179178  rtems_mpci_send_entry           send_packet;
    180179  rtems_mpci_receive_entry        receive_packet;
    181 }  rtems_mpci_table;
     180} rtems_mpci_table;
    182181
    183182/*
     
    193192  unsigned32  maximum_global_objects; /* maximum # global objects */
    194193  unsigned32  maximum_proxies;        /* maximum # proxies */
    195   rtems_mpci_table *User_mpci_table;
    196                                       /* pointer to MPCI table */
     194  rtems_mpci_table *User_mpci_table;  /* pointer to MPCI table */
    197195};
    198196
     
    210208
    211209struct Configuration_Table {
    212   void                                     *work_space_start;
    213   unsigned32                                work_space_size;
    214   unsigned32                                maximum_tasks;
    215   unsigned32                                maximum_timers;
    216   unsigned32                                maximum_semaphores;
    217   unsigned32                                maximum_message_queues;
    218   unsigned32                                maximum_messages;
    219   unsigned32                                maximum_partitions;
    220   unsigned32                                maximum_regions;
    221   unsigned32                                maximum_ports;
    222   unsigned32                                maximum_periods;
    223   unsigned32                                maximum_extensions;
    224   unsigned32                                microseconds_per_tick;
    225   unsigned32                                ticks_per_timeslice;
    226   unsigned32                                number_of_initialization_tasks;
     210  void                             *work_space_start;
     211  unsigned32                        work_space_size;
     212  unsigned32                        maximum_tasks;
     213  unsigned32                        maximum_timers;
     214  unsigned32                        maximum_semaphores;
     215  unsigned32                        maximum_message_queues;
     216  unsigned32                        maximum_partitions;
     217  unsigned32                        maximum_regions;
     218  unsigned32                        maximum_ports;
     219  unsigned32                        maximum_periods;
     220  unsigned32                        maximum_extensions;
     221  unsigned32                        microseconds_per_tick;
     222  unsigned32                        ticks_per_timeslice;
     223  unsigned32                        number_of_initialization_tasks;
    227224  rtems_initialization_tasks_table *User_initialization_tasks_table;
    228   unsigned32                                number_of_device_drivers;
     225  unsigned32                        number_of_device_drivers;
    229226  rtems_driver_address_table       *Device_driver_table;
    230   rtems_extensions_table            *User_extension_table;
     227  rtems_extensions_table           *User_extension_table;
    231228  rtems_multiprocessing_table      *User_multiprocessing_table;
    232229};
     
    245242 */
    246243
    247 EXTERN rtems_configuration_table                 *_Configuration_Table;
     244EXTERN rtems_configuration_table   *_Configuration_Table;
    248245EXTERN rtems_multiprocessing_table *_Configuration_MP_table;
    249246EXTERN rtems_mpci_table            *_Configuration_MPCI_table;
     
    259256
    260257STATIC INLINE void _Configuration_Handler_initialization(
    261   rtems_configuration_table                 *configuration_table,
     258  rtems_configuration_table   *configuration_table,
    262259  rtems_multiprocessing_table *multiprocessing_table,
    263260  rtems_mpci_table            *users_mpci_table
  • cpukit/sapi/include/rtems/io.h

    r3b438fa rb06e68ef  
    3636
    3737/*
    38  *  The following type defines the set of IO operations which are
    39  *  recognized by _IO_Handler and can be supported by a RTEMS
    40  *  device driver.
    41  */
    42 
    43 typedef enum {
    44   IO_INITIALIZE_OPERATION = 0,
    45   IO_OPEN_OPERATION       = 1,
    46   IO_CLOSE_OPERATION      = 2,
    47   IO_READ_OPERATION       = 3,
    48   IO_WRITE_OPERATION      = 4,
    49   IO_CONTROL_OPERATION    = 5
    50 }  IO_operations;
    51 
    52 /*
    5338 *  The following declare the data required to manage the Device Driver
    5439 *  Address Table.
    5540 */
    5641
    57 EXTERN unsigned32                          _IO_Number_of_drivers;
     42EXTERN unsigned32                  _IO_Number_of_drivers;
    5843EXTERN rtems_driver_address_table *_IO_Driver_address_table;
     44
     45/*
     46 * Table for the io device names
     47 */
     48
     49typedef struct {
     50    char                     *device_name;
     51    unsigned32                device_name_length;
     52    rtems_device_major_number major;
     53    rtems_device_minor_number minor;
     54} rtems_driver_name_t;
     55
     56/*XXX this really should be allocated some better way... */
     57/*XXX it should probably be a chain and use a 'maximum' drivers field
     58 * in config table */
     59#define RTEMS_MAX_DRIVER_NAMES 20
     60EXTERN rtems_driver_name_t rtems_driver_name_table[RTEMS_MAX_DRIVER_NAMES];
     61
    5962
    6063/*
     
    7275
    7376/*
     77 *  rtems_io_register_name
     78 *
     79 *  DESCRIPTION:
     80 *
     81 *  Associate a name with a driver.
     82 *
     83 */
     84
     85rtems_status_code rtems_io_register_name(
     86    char *device_name,
     87    rtems_device_major_number major,
     88    rtems_device_minor_number minor
     89);
     90
     91
     92/*
     93 *  rtems_io_lookup_name
     94 *
     95 *  DESCRIPTION:
     96 *
     97 *  Find what driver "owns" this name
     98 */
     99
     100rtems_status_code rtems_io_lookup_name(
     101    const char *pathname,
     102    rtems_driver_name_t **rnp
     103);
     104
     105
     106/*
    74107 *  rtems_io_initialize
    75108 *
     
    83116  rtems_device_major_number  major,
    84117  rtems_device_minor_number  minor,
    85   void             *argument,
    86   unsigned32       *return_value
     118  void             *argument
    87119);
    88120
     
    99131  rtems_device_major_number  major,
    100132  rtems_device_minor_number  minor,
    101   void             *argument,
    102   unsigned32       *return_value
     133  void             *argument
    103134);
    104135
     
    115146  rtems_device_major_number  major,
    116147  rtems_device_minor_number  minor,
    117   void             *argument,
    118   unsigned32       *return_value
     148  void             *argument
    119149);
    120150
     
    131161  rtems_device_major_number  major,
    132162  rtems_device_minor_number  minor,
    133   void             *argument,
    134   unsigned32       *return_value
     163  void             *argument
    135164);
    136165
     
    147176  rtems_device_major_number  major,
    148177  rtems_device_minor_number  minor,
    149   void             *argument,
    150   unsigned32       *return_value
     178  void             *argument
    151179);
    152180
     
    163191  rtems_device_major_number  major,
    164192  rtems_device_minor_number  minor,
    165   void             *argument,
    166   unsigned32       *return_value
     193  void             *argument
    167194);
    168195
     
    177204
    178205void _IO_Initialize_all_drivers( void );
    179 
    180 /*
    181  *  _IO_Handler_routine
    182  *
    183  *  DESCRIPTION:
    184  *
    185  *  This routine provides the common foundation for all of the IO
    186  *  Manager's directives.
    187  */
    188 
    189 rtems_status_code _IO_Handler_routine(
    190   IO_operations              operation,
    191   rtems_device_major_number  major,
    192   rtems_device_minor_number  minor,
    193   void                      *argument,
    194   unsigned32                *return_value
    195 );
    196206
    197207#include <rtems/io.inl>
  • 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.