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

4.104.115
Last change on this file since fd3a990 was 790b50b, checked in by Joel Sherrill <joel.sherrill@…>, on 12/17/08 at 22:46:05

2008-12-17 Joel Sherrill <joel.sherrill@…>

  • sapi/include/rtems/extension.h, sapi/include/rtems/io.h, sapi/src/exinit.c, sapi/src/extension.c, sapi/src/io.c, score/include/rtems/score/mpci.h, score/include/rtems/score/object.h, score/include/rtems/score/thread.h, score/include/rtems/score/tod.h, score/include/rtems/score/userext.h, score/include/rtems/score/wkspace.h, score/src/coretod.c, score/src/mpci.c, score/src/object.c, score/src/thread.c, score/src/userext.c, score/src/wkspace.c: Convert SAPI manager and SuperCore? Handler initialization routines to directly pull parameters from configuration 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 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/config.h>
20#include <rtems/io.h>
21#include <rtems/score/isr.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/wkspace.h>
24
25#include <string.h>
26
27/*
28 *  _IO_Manager_initialization
29 *
30 *  The IO manager has been extended to support runtime driver
31 *  registration. The driver table is now allocated in the
32 *  workspace.
33 *
34 */
35
36void _IO_Manager_initialization(void)
37{
38  uint32_t                    index;
39  rtems_driver_address_table *driver_table;
40  uint32_t                    drivers_in_table;
41  uint32_t                    number_of_drivers;
42
43  driver_table      = Configuration.Device_driver_table;
44  drivers_in_table  = Configuration.number_of_device_drivers;
45  number_of_drivers = Configuration.maximum_drivers;
46
47  /*
48   *  If the user claims there are less drivers than are actually in
49   *  the table, then let's just go with the table's count.
50   */
51  if ( number_of_drivers <= drivers_in_table )
52    number_of_drivers = drivers_in_table;
53
54  /*
55   *  If the maximum number of driver is the same as the number in the
56   *  table, then we do not have to copy the driver table.  They can't
57   *  register any dynamically.
58   */
59  if ( number_of_drivers == drivers_in_table ) {
60    _IO_Driver_address_table = driver_table;
61    _IO_Number_of_drivers = number_of_drivers;
62    return;
63  }
64
65  /*
66   *  The application requested extra slots in the driver table, so we
67   *  have to allocate a new driver table and copy theirs to it.
68   */
69
70  _IO_Driver_address_table = (rtems_driver_address_table *)
71      _Workspace_Allocate_or_fatal_error(
72        sizeof( rtems_driver_address_table ) * ( number_of_drivers )
73      );
74  _IO_Number_of_drivers = number_of_drivers;
75
76  memset(
77    _IO_Driver_address_table, 0,
78    sizeof( rtems_driver_address_table ) * ( number_of_drivers )
79  );
80
81  for ( index = 0 ; index < drivers_in_table ; index++ )
82    _IO_Driver_address_table[index] = driver_table[index];
83  number_of_drivers = drivers_in_table;
84}
85
86/*
87 *  _IO_Initialize_all_drivers
88 *
89 *  This routine initializes all device drivers
90 *
91 *  Input Paramters:   NONE
92 *
93 *  Output Parameters: NONE
94 */
95
96void _IO_Initialize_all_drivers( void )
97{
98   rtems_device_major_number major;
99
100   for ( major=0 ; major < _IO_Number_of_drivers ; major ++ )
101     (void) rtems_io_initialize( major, 0, NULL );
102}
Note: See TracBrowser for help on using the repository browser.