[4c98a3e] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @brief Initialization of Device Drivers |
---|
[ac7d5ef0] | 5 | * |
---|
[4c98a3e] | 6 | * @ingroup ClassicIO |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
[790b50b] | 10 | * COPYRIGHT (c) 1989-2008. |
---|
[ac7d5ef0] | 11 | * On-Line Applications Research Corporation (OAR). |
---|
| 12 | * |
---|
[98e4ebf5] | 13 | * The license and distribution terms for this file may be |
---|
| 14 | * found in the file LICENSE in this distribution or at |
---|
[2ba508b] | 15 | * http://www.rtems.com/license/LICENSE. |
---|
[ac7d5ef0] | 16 | */ |
---|
| 17 | |
---|
[16351f7a] | 18 | #if HAVE_CONFIG_H |
---|
| 19 | #include "config.h" |
---|
| 20 | #endif |
---|
| 21 | |
---|
[ac7d5ef0] | 22 | #include <rtems/system.h> |
---|
[790b50b] | 23 | #include <rtems/config.h> |
---|
[ac7d5ef0] | 24 | #include <rtems/io.h> |
---|
[5e9b32b] | 25 | #include <rtems/score/isr.h> |
---|
| 26 | #include <rtems/score/thread.h> |
---|
[66d9e3ad] | 27 | #include <rtems/score/wkspace.h> |
---|
[b06e68ef] | 28 | |
---|
| 29 | #include <string.h> |
---|
[ac7d5ef0] | 30 | |
---|
[790b50b] | 31 | void _IO_Manager_initialization(void) |
---|
[66d9e3ad] | 32 | { |
---|
[790b50b] | 33 | uint32_t index; |
---|
| 34 | rtems_driver_address_table *driver_table; |
---|
| 35 | uint32_t drivers_in_table; |
---|
| 36 | uint32_t number_of_drivers; |
---|
| 37 | |
---|
[ec8b6c4] | 38 | driver_table = rtems_configuration_get_device_driver_table(); |
---|
[1a75b4b] | 39 | drivers_in_table = rtems_configuration_get_number_of_device_drivers(); |
---|
[c53b330c] | 40 | number_of_drivers = rtems_configuration_get_maximum_drivers(); |
---|
[7a03c09b] | 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 ) |
---|
[0ab34c90] | 47 | number_of_drivers = drivers_in_table; |
---|
[8486081] | 48 | |
---|
[7a03c09b] | 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 | |
---|
[28352fae] | 65 | _IO_Driver_address_table = (rtems_driver_address_table *) |
---|
[7a03c09b] | 66 | _Workspace_Allocate_or_fatal_error( |
---|
| 67 | sizeof( rtems_driver_address_table ) * ( number_of_drivers ) |
---|
| 68 | ); |
---|
[059a3714] | 69 | _IO_Number_of_drivers = number_of_drivers; |
---|
[7a03c09b] | 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]; |
---|
[66d9e3ad] | 78 | } |
---|
| 79 | |
---|
[ac7d5ef0] | 80 | void _IO_Initialize_all_drivers( void ) |
---|
| 81 | { |
---|
| 82 | rtems_device_major_number major; |
---|
| 83 | |
---|
| 84 | for ( major=0 ; major < _IO_Number_of_drivers ; major ++ ) |
---|
[eafa35e7] | 85 | (void) rtems_io_initialize( major, 0, NULL ); |
---|
[b06e68ef] | 86 | } |
---|