mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-27 06:58:19 +00:00
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.
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
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.
|
||||
|
||||
2007-05-29 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||
|
||||
* sapi/include/confdefs.h, sapi/src/io.c: Readded code to copy driver
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
48
cpukit/sapi/src/ioclose.c
Normal file
48
cpukit/sapi/src/ioclose.c
Normal file
@@ -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;
|
||||
}
|
||||
48
cpukit/sapi/src/iocontrol.c
Normal file
48
cpukit/sapi/src/iocontrol.c
Normal file
@@ -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;
|
||||
}
|
||||
22
cpukit/sapi/src/iodata.c
Normal file
22
cpukit/sapi/src/iodata.c
Normal file
@@ -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>
|
||||
48
cpukit/sapi/src/ioinitialize.c
Normal file
48
cpukit/sapi/src/ioinitialize.c
Normal file
@@ -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;
|
||||
}
|
||||
48
cpukit/sapi/src/ioopen.c
Normal file
48
cpukit/sapi/src/ioopen.c
Normal file
@@ -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;
|
||||
}
|
||||
48
cpukit/sapi/src/ioread.c
Normal file
48
cpukit/sapi/src/ioread.c
Normal file
@@ -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;
|
||||
}
|
||||
94
cpukit/sapi/src/ioregisterdriver.c
Normal file
94
cpukit/sapi/src/ioregisterdriver.c
Normal file
@@ -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;
|
||||
}
|
||||
48
cpukit/sapi/src/iounregisterdriver.c
Normal file
48
cpukit/sapi/src/iounregisterdriver.c
Normal file
@@ -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;
|
||||
}
|
||||
48
cpukit/sapi/src/iowrite.c
Normal file
48
cpukit/sapi/src/iowrite.c
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user