source: rtems/cpukit/sapi/src/io.c @ ec8b6c4

4.115
Last change on this file since ec8b6c4 was ec8b6c4, checked in by Sebastian Huber <sebastian.huber@…>, on 11/06/12 at 10:37:11

sapi: Use rtems_config*_get_device_driver_table

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  Input/Output Manager - Initialize Device Driver Subsystem
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/config.h>
18#include <rtems/io.h>
19#include <rtems/score/isr.h>
20#include <rtems/score/thread.h>
21#include <rtems/score/wkspace.h>
22
23#include <string.h>
24
25/*
26 *  _IO_Manager_initialization
27 *
28 *  The IO manager has been extended to support runtime driver
29 *  registration. The driver table is now allocated in the
30 *  workspace.
31 *
32 */
33
34void _IO_Manager_initialization(void)
35{
36  uint32_t                    index;
37  rtems_driver_address_table *driver_table;
38  uint32_t                    drivers_in_table;
39  uint32_t                    number_of_drivers;
40
41  driver_table      = rtems_configuration_get_device_driver_table();
42  drivers_in_table  = rtems_configuration_get_number_of_device_drivers();
43  number_of_drivers = rtems_configuration_get_maximum_drivers();
44
45  /*
46   *  If the user claims there are less drivers than are actually in
47   *  the table, then let's just go with the table's count.
48   */
49  if ( number_of_drivers <= drivers_in_table )
50    number_of_drivers = drivers_in_table;
51
52  /*
53   *  If the maximum number of driver is the same as the number in the
54   *  table, then we do not have to copy the driver table.  They can't
55   *  register any dynamically.
56   */
57  if ( number_of_drivers == drivers_in_table ) {
58    _IO_Driver_address_table = driver_table;
59    _IO_Number_of_drivers = number_of_drivers;
60    return;
61  }
62
63  /*
64   *  The application requested extra slots in the driver table, so we
65   *  have to allocate a new driver table and copy theirs to it.
66   */
67
68  _IO_Driver_address_table = (rtems_driver_address_table *)
69      _Workspace_Allocate_or_fatal_error(
70        sizeof( rtems_driver_address_table ) * ( number_of_drivers )
71      );
72  _IO_Number_of_drivers = number_of_drivers;
73
74  memset(
75    _IO_Driver_address_table, 0,
76    sizeof( rtems_driver_address_table ) * ( number_of_drivers )
77  );
78
79  for ( index = 0 ; index < drivers_in_table ; index++ )
80    _IO_Driver_address_table[index] = driver_table[index];
81}
82
83/*
84 *  _IO_Initialize_all_drivers
85 *
86 *  This routine initializes all device drivers
87 *
88 *  Input Paramters:   NONE
89 *
90 *  Output Parameters: NONE
91 */
92
93void _IO_Initialize_all_drivers( void )
94{
95   rtems_device_major_number major;
96
97   for ( major=0 ; major < _IO_Number_of_drivers ; major ++ )
98     (void) rtems_io_initialize( major, 0, NULL );
99}
Note: See TracBrowser for help on using the repository browser.