diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-05-29 19:56:35 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-05-29 19:56:35 +0000 |
commit | 9c556023f0d8d47bf5ce39a524e838936db7701f (patch) | |
tree | 9ef5118d3c1c69bd9ad651e681ffe16471b0ea14 /cpukit/sapi | |
parent | 2007-05-29 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-9c556023f0d8d47bf5ce39a524e838936db7701f.tar.bz2 |
2007-05-29 Joel Sherrill <joel.sherrill@OARcorp.com>
* sapi/Makefile.am, sapi/include/rtems/io.h, sapi/src/io.c: Split into
one function per file execpt io.c which contains required
initialization methods.
* sapi/src/ioclose.c, sapi/src/iocontrol.c, sapi/src/iodata.c,
sapi/src/ioinitialize.c, sapi/src/ioopen.c, sapi/src/ioread.c,
sapi/src/ioregisterdriver.c, sapi/src/iounregisterdriver.c,
sapi/src/iowrite.c: New files.
Diffstat (limited to 'cpukit/sapi')
-rw-r--r-- | cpukit/sapi/Makefile.am | 6 | ||||
-rw-r--r-- | cpukit/sapi/include/rtems/io.h | 8 | ||||
-rw-r--r-- | cpukit/sapi/src/io.c | 296 | ||||
-rw-r--r-- | cpukit/sapi/src/ioclose.c | 48 | ||||
-rw-r--r-- | cpukit/sapi/src/iocontrol.c | 48 | ||||
-rw-r--r-- | cpukit/sapi/src/iodata.c | 22 | ||||
-rw-r--r-- | cpukit/sapi/src/ioinitialize.c | 48 | ||||
-rw-r--r-- | cpukit/sapi/src/ioopen.c | 48 | ||||
-rw-r--r-- | cpukit/sapi/src/ioread.c | 48 | ||||
-rw-r--r-- | cpukit/sapi/src/ioregisterdriver.c | 94 | ||||
-rw-r--r-- | cpukit/sapi/src/iounregisterdriver.c | 48 | ||||
-rw-r--r-- | cpukit/sapi/src/iowrite.c | 48 |
12 files changed, 466 insertions, 296 deletions
diff --git a/cpukit/sapi/Makefile.am b/cpukit/sapi/Makefile.am index 531d0e779a..ad4b3fa864 100644 --- a/cpukit/sapi/Makefile.am +++ b/cpukit/sapi/Makefile.am @@ -22,8 +22,10 @@ AM_CPPFLAGS += -D__RTEMS_INSIDE__ noinst_LIBRARIES = libsapi.a libsapi_a_SOURCES = src/debug.c src/extension.c src/extensioncreate.c \ src/extensiondelete.c src/extensionident.c src/fatal.c src/exinit.c \ - src/exshutdown.c src/io.c src/itronapi.c src/posixapi.c src/rtemsapi.c \ - src/extensiondata.c + src/exshutdown.c src/io.c src/ioclose.c src/iocontrol.c src/iodata.c \ + src/ioinitialize.c src/ioopen.c src/ioread.c src/ioregisterdriver.c \ + src/iounregisterdriver.c src/iowrite.c src/itronapi.c src/posixapi.c \ + src/rtemsapi.c src/extensiondata.c libsapi_a_CPPFLAGS = $(AM_CPPFLAGS) include $(srcdir)/preinstall.am diff --git a/cpukit/sapi/include/rtems/io.h b/cpukit/sapi/include/rtems/io.h index ace50f0459..fdabc028b6 100644 --- a/cpukit/sapi/include/rtems/io.h +++ b/cpukit/sapi/include/rtems/io.h @@ -30,6 +30,10 @@ #ifndef _RTEMS_IO_H #define _RTEMS_IO_H +#ifndef SAPI_IO_EXTERN +#define SAPI_IO_EXTERN extern +#endif + #ifdef __cplusplus extern "C" { #endif @@ -88,8 +92,8 @@ typedef struct { * Address Table and Device Name Table. */ -SAPI_EXTERN uint32_t _IO_Number_of_drivers; -SAPI_EXTERN rtems_driver_address_table *_IO_Driver_address_table; +SAPI_IO_EXTERN uint32_t _IO_Number_of_drivers; +SAPI_IO_EXTERN rtems_driver_address_table *_IO_Driver_address_table; /* * _IO_Manager_initialization diff --git a/cpukit/sapi/src/io.c b/cpukit/sapi/src/io.c index f200a514ac..bd5cd4f0ec 100644 --- a/cpukit/sapi/src/io.c +++ b/cpukit/sapi/src/io.c @@ -1,8 +1,7 @@ /* - * Input/Output Manager + * Input/Output Manager - Initialize Device Driver Subsystem * - * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -24,8 +23,7 @@ #include <string.h> -/*PAGE - * +/* * _IO_Manager_initialization * * The IO manager has been extended to support runtime driver @@ -81,8 +79,7 @@ void _IO_Manager_initialization( number_of_drivers = drivers_in_table; } -/*PAGE - * +/* * _IO_Initialize_all_drivers * * This routine initializes all device drivers @@ -99,288 +96,3 @@ void _IO_Initialize_all_drivers( void ) for ( major=0 ; major < _IO_Number_of_drivers ; major ++ ) (void) rtems_io_initialize( major, 0, NULL ); } - -/*PAGE - * - * rtems_io_register_driver - * - * Register a driver into the device driver table. - * - * Input Paramters: - * major - device major number (0 means allocate - * a number) - * driver_table - driver callout function table - * registered_major - the major number which is registered - * - * Output Parameters: - * RTEMS_SUCCESSFUL - if successful - * error code - if unsuccessful - */ - -rtems_status_code rtems_io_register_driver( - rtems_device_major_number major, - rtems_driver_address_table *driver_table, - rtems_device_major_number *registered_major -) -{ - - /* - * Validate the pointer data and contents passed in - */ - if ( !driver_table ) - return RTEMS_INVALID_ADDRESS; - - if ( !registered_major ) - return RTEMS_INVALID_ADDRESS; - - if ( !driver_table->initialization_entry && !driver_table->open_entry ) - return RTEMS_INVALID_ADDRESS; - - *registered_major = 0; - - /* - * The requested major number is higher than what is configured. - */ - if ( major >= _IO_Number_of_drivers ) - return RTEMS_INVALID_NUMBER; - - /* - * Test for initialise/open being present to indicate the driver slot is - * in use. - */ - - if ( major == 0 ) { - boolean found = FALSE; - for ( major = _IO_Number_of_drivers - 1 ; major ; major-- ) { - if ( !_IO_Driver_address_table[major].initialization_entry && - !_IO_Driver_address_table[major].open_entry ) { - found = TRUE; - break; - } - } - - if ( !found ) - return RTEMS_TOO_MANY; - } - - if ( _IO_Driver_address_table[major].initialization_entry || - _IO_Driver_address_table[major].open_entry ) - return RTEMS_RESOURCE_IN_USE; - - - _IO_Driver_address_table[major] = *driver_table; - *registered_major = major; - - rtems_io_initialize( major, 0, NULL ); - - return RTEMS_SUCCESSFUL; -} - -/*PAGE - * - * rtems_io_unregister_driver - * - * Unregister a driver from the device driver table. - * - * Input Paramters: - * major - device major number - * - * Output Parameters: - * RTEMS_SUCCESSFUL - if successful - * error code - if unsuccessful - */ - -rtems_status_code rtems_io_unregister_driver( - rtems_device_major_number major -) -{ - if ( major < _IO_Number_of_drivers ) { - memset( - &_IO_Driver_address_table[major], - 0, - sizeof( rtems_driver_address_table ) - ); - return RTEMS_SUCCESSFUL; - } - return RTEMS_UNSATISFIED; -} - -/*PAGE - * - * rtems_io_initialize - * - * This routine is the initialization directive of the IO manager. - * - * Input Paramters: - * major - device driver number - * minor - device number - * argument - pointer to argument(s) - * - * Output Parameters: - * returns - return code - */ - -rtems_status_code rtems_io_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -) -{ - rtems_device_driver_entry callout; - - if ( major >= _IO_Number_of_drivers ) - return RTEMS_INVALID_NUMBER; - - callout = _IO_Driver_address_table[major].initialization_entry; - return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; -} - -/*PAGE - * - * rtems_io_open - * - * This routine is the open directive of the IO manager. - * - * Input Paramters: - * major - device driver number - * minor - device number - * argument - pointer to argument(s) - * - * Output Parameters: - * returns - return code - */ - -rtems_status_code rtems_io_open( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -) -{ - rtems_device_driver_entry callout; - - if ( major >= _IO_Number_of_drivers ) - return RTEMS_INVALID_NUMBER; - - callout = _IO_Driver_address_table[major].open_entry; - return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; -} - -/*PAGE - * - * rtems_io_close - * - * This routine is the close directive of the IO manager. - * - * Input Paramters: - * major - device driver number - * minor - device number - * argument - pointer to argument(s) - * - * Output Parameters: - * returns - return code - */ - -rtems_status_code rtems_io_close( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -) -{ - rtems_device_driver_entry callout; - - if ( major >= _IO_Number_of_drivers ) - return RTEMS_INVALID_NUMBER; - - callout = _IO_Driver_address_table[major].close_entry; - return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; -} - -/*PAGE - * - * rtems_io_read - * - * This routine is the read directive of the IO manager. - * - * Input Paramters: - * major - device driver number - * minor - device number - * argument - pointer to argument(s) - * - * Output Parameters: - * returns - return code - */ - -rtems_status_code rtems_io_read( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -) -{ - rtems_device_driver_entry callout; - - if ( major >= _IO_Number_of_drivers ) - return RTEMS_INVALID_NUMBER; - - callout = _IO_Driver_address_table[major].read_entry; - return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; -} - -/*PAGE - * - * rtems_io_write - * - * This routine is the write directive of the IO manager. - * - * Input Paramters: - * major - device driver number - * minor - device number - * argument - pointer to argument(s) - * - * Output Parameters: - * returns - return code - */ - -rtems_status_code rtems_io_write( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -) -{ - rtems_device_driver_entry callout; - - if ( major >= _IO_Number_of_drivers ) - return RTEMS_INVALID_NUMBER; - - callout = _IO_Driver_address_table[major].write_entry; - return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; -} - -/*PAGE - * - * rtems_io_control - * - * This routine is the control directive of the IO manager. - * - * Input Paramters: - * major - device driver number - * minor - device number - * argument - pointer to argument(s) - * - * Output Parameters: - * returns - return code - */ - -rtems_status_code rtems_io_control( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -) -{ - rtems_device_driver_entry callout; - - if ( major >= _IO_Number_of_drivers ) - return RTEMS_INVALID_NUMBER; - - callout = _IO_Driver_address_table[major].control_entry; - return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; -} diff --git a/cpukit/sapi/src/ioclose.c b/cpukit/sapi/src/ioclose.c new file mode 100644 index 0000000000..65d43f55ec --- /dev/null +++ b/cpukit/sapi/src/ioclose.c @@ -0,0 +1,48 @@ +/* + * Input/Output Manager -- Close Device + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/io.h> + +/* + * rtems_io_close + * + * This routine is the close directive of the IO manager. + * + * Input Paramters: + * major - device driver number + * minor - device number + * argument - pointer to argument(s) + * + * Output Parameters: + * returns - return code + */ + +rtems_status_code rtems_io_close( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +) +{ + rtems_device_driver_entry callout; + + if ( major >= _IO_Number_of_drivers ) + return RTEMS_INVALID_NUMBER; + + callout = _IO_Driver_address_table[major].close_entry; + return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; +} diff --git a/cpukit/sapi/src/iocontrol.c b/cpukit/sapi/src/iocontrol.c new file mode 100644 index 0000000000..1f1d0d38ea --- /dev/null +++ b/cpukit/sapi/src/iocontrol.c @@ -0,0 +1,48 @@ +/* + * Input/Output Manager - Device Control + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/io.h> + +/* + * rtems_io_control + * + * This routine is the control directive of the IO manager. + * + * Input Paramters: + * major - device driver number + * minor - device number + * argument - pointer to argument(s) + * + * Output Parameters: + * returns - return code + */ + +rtems_status_code rtems_io_control( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +) +{ + rtems_device_driver_entry callout; + + if ( major >= _IO_Number_of_drivers ) + return RTEMS_INVALID_NUMBER; + + callout = _IO_Driver_address_table[major].control_entry; + return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; +} diff --git a/cpukit/sapi/src/iodata.c b/cpukit/sapi/src/iodata.c new file mode 100644 index 0000000000..f15de6979d --- /dev/null +++ b/cpukit/sapi/src/iodata.c @@ -0,0 +1,22 @@ +/* + * RTEMS Task Manager -- Instantiate Data + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +/* instantiate RTEMS IO manager data */ +#define SAPI_IO_EXTERN + +#include <rtems/system.h> +#include <rtems/io.h> diff --git a/cpukit/sapi/src/ioinitialize.c b/cpukit/sapi/src/ioinitialize.c new file mode 100644 index 0000000000..998edbb6b2 --- /dev/null +++ b/cpukit/sapi/src/ioinitialize.c @@ -0,0 +1,48 @@ +/* + * Input/Output Manager - Initialize Device + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/io.h> + +/* + * rtems_io_initialize + * + * This routine is the initialization directive of the IO manager. + * + * Input Paramters: + * major - device driver number + * minor - device number + * argument - pointer to argument(s) + * + * Output Parameters: + * returns - return code + */ + +rtems_status_code rtems_io_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +) +{ + rtems_device_driver_entry callout; + + if ( major >= _IO_Number_of_drivers ) + return RTEMS_INVALID_NUMBER; + + callout = _IO_Driver_address_table[major].initialization_entry; + return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; +} diff --git a/cpukit/sapi/src/ioopen.c b/cpukit/sapi/src/ioopen.c new file mode 100644 index 0000000000..f8f1c84a86 --- /dev/null +++ b/cpukit/sapi/src/ioopen.c @@ -0,0 +1,48 @@ +/* + * Input/Output Manager - Open Device + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/io.h> + +/* + * rtems_io_open + * + * This routine is the open directive of the IO manager. + * + * Input Paramters: + * major - device driver number + * minor - device number + * argument - pointer to argument(s) + * + * Output Parameters: + * returns - return code + */ + +rtems_status_code rtems_io_open( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +) +{ + rtems_device_driver_entry callout; + + if ( major >= _IO_Number_of_drivers ) + return RTEMS_INVALID_NUMBER; + + callout = _IO_Driver_address_table[major].open_entry; + return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; +} diff --git a/cpukit/sapi/src/ioread.c b/cpukit/sapi/src/ioread.c new file mode 100644 index 0000000000..3b090ef764 --- /dev/null +++ b/cpukit/sapi/src/ioread.c @@ -0,0 +1,48 @@ +/* + * Input/Output Manager - Device Read + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/io.h> + +/* + * rtems_io_read + * + * This routine is the read directive of the IO manager. + * + * Input Paramters: + * major - device driver number + * minor - device number + * argument - pointer to argument(s) + * + * Output Parameters: + * returns - return code + */ + +rtems_status_code rtems_io_read( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +) +{ + rtems_device_driver_entry callout; + + if ( major >= _IO_Number_of_drivers ) + return RTEMS_INVALID_NUMBER; + + callout = _IO_Driver_address_table[major].read_entry; + return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; +} diff --git a/cpukit/sapi/src/ioregisterdriver.c b/cpukit/sapi/src/ioregisterdriver.c new file mode 100644 index 0000000000..45d5ffe97b --- /dev/null +++ b/cpukit/sapi/src/ioregisterdriver.c @@ -0,0 +1,94 @@ +/* + * Input/Output Manager - Dynamically Register Device Driver + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/io.h> + +/* + * rtems_io_register_driver + * + * Register a driver into the device driver table. + * + * Input Paramters: + * major - device major number (0 means allocate + * a number) + * driver_table - driver callout function table + * registered_major - the major number which is registered + * + * Output Parameters: + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_io_register_driver( + rtems_device_major_number major, + rtems_driver_address_table *driver_table, + rtems_device_major_number *registered_major +) +{ + + /* + * Validate the pointer data and contents passed in + */ + if ( !driver_table ) + return RTEMS_INVALID_ADDRESS; + + if ( !registered_major ) + return RTEMS_INVALID_ADDRESS; + + if ( !driver_table->initialization_entry && !driver_table->open_entry ) + return RTEMS_INVALID_ADDRESS; + + *registered_major = 0; + + /* + * The requested major number is higher than what is configured. + */ + if ( major >= _IO_Number_of_drivers ) + return RTEMS_INVALID_NUMBER; + + /* + * Test for initialise/open being present to indicate the driver slot is + * in use. + */ + + if ( major == 0 ) { + boolean found = FALSE; + for ( major = _IO_Number_of_drivers - 1 ; major ; major-- ) { + if ( !_IO_Driver_address_table[major].initialization_entry && + !_IO_Driver_address_table[major].open_entry ) { + found = TRUE; + break; + } + } + + if ( !found ) + return RTEMS_TOO_MANY; + } + + if ( _IO_Driver_address_table[major].initialization_entry || + _IO_Driver_address_table[major].open_entry ) + return RTEMS_RESOURCE_IN_USE; + + + _IO_Driver_address_table[major] = *driver_table; + *registered_major = major; + + rtems_io_initialize( major, 0, NULL ); + + return RTEMS_SUCCESSFUL; +} diff --git a/cpukit/sapi/src/iounregisterdriver.c b/cpukit/sapi/src/iounregisterdriver.c new file mode 100644 index 0000000000..5761138b09 --- /dev/null +++ b/cpukit/sapi/src/iounregisterdriver.c @@ -0,0 +1,48 @@ +/* + * Input/Output Manager - Dynamically Unregister Device Driver + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/io.h> +#include <string.h> + +/* + * rtems_io_unregister_driver + * + * Unregister a driver from the device driver table. + * + * Input Paramters: + * major - device major number + * + * Output Parameters: + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_io_unregister_driver( + rtems_device_major_number major +) +{ + if ( major < _IO_Number_of_drivers ) { + memset( + &_IO_Driver_address_table[major], + 0, + sizeof( rtems_driver_address_table ) + ); + return RTEMS_SUCCESSFUL; + } + return RTEMS_UNSATISFIED; +} diff --git a/cpukit/sapi/src/iowrite.c b/cpukit/sapi/src/iowrite.c new file mode 100644 index 0000000000..9283404e73 --- /dev/null +++ b/cpukit/sapi/src/iowrite.c @@ -0,0 +1,48 @@ +/* + * Input/Output Manager - Device Write + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/io.h> + +/* + * rtems_io_write + * + * This routine is the write directive of the IO manager. + * + * Input Paramters: + * major - device driver number + * minor - device number + * argument - pointer to argument(s) + * + * Output Parameters: + * returns - return code + */ + +rtems_status_code rtems_io_write( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +) +{ + rtems_device_driver_entry callout; + + if ( major >= _IO_Number_of_drivers ) + return RTEMS_INVALID_NUMBER; + + callout = _IO_Driver_address_table[major].write_entry; + return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; +} |