source: rtems/cpukit/sapi/src/io.c @ 23de794d

4.11
Last change on this file since 23de794d was 4c98a3e, checked in by Christopher Kerl <zargyyoyo@…>, on Dec 7, 2012 at 2:49:54 PM

sapi misc: Clean up Doxygen GCI task #1

http://www.google-melange.com/gci/task/view/google/gci2012/8011204

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