summaryrefslogtreecommitdiffstats
path: root/cpukit/sapi
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1995-08-17 19:51:51 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1995-08-17 19:51:51 +0000
commitb06e68ef1f6df69cc86d72356c3a002054a35fad (patch)
tree722b2da3cc83f1cf03019cab8cf895a509eb6801 /cpukit/sapi
parent3b438fa4b0284d340b60d865f4afcb76f363bc90 (diff)
downloadrtems-b06e68ef1f6df69cc86d72356c3a002054a35fad.tar.bz2
Numerous miscellaneous features incorporated from Tony Bennett
(tbennett@divnc.com) including the following major additions: + variable length messages + named devices + debug monitor + association tables/variables
Diffstat (limited to 'cpukit/sapi')
-rw-r--r--cpukit/sapi/include/rtems/config.h63
-rw-r--r--cpukit/sapi/include/rtems/io.h98
-rw-r--r--cpukit/sapi/src/exinit.c3
-rw-r--r--cpukit/sapi/src/io.c268
4 files changed, 208 insertions, 224 deletions
diff --git a/cpukit/sapi/include/rtems/config.h b/cpukit/sapi/include/rtems/config.h
index b5080b6133..c2001c8074 100644
--- a/cpukit/sapi/include/rtems/config.h
+++ b/cpukit/sapi/include/rtems/config.h
@@ -32,14 +32,14 @@ extern "C" {
*/
typedef struct {
- Objects_Name name; /* task name */
- unsigned32 stack_size; /* task stack size */
+ Objects_Name name; /* task name */
+ unsigned32 stack_size; /* task stack size */
rtems_task_priority initial_priority; /* task priority */
- rtems_attribute attribute_set; /* task attributes */
- rtems_task_entry entry_point; /* task entry point */
- rtems_mode mode_set; /* task initial mode */
- unsigned32 argument; /* task argument */
-} rtems_initialization_tasks_table;
+ rtems_attribute attribute_set; /* task attributes */
+ rtems_task_entry entry_point; /* task entry point */
+ rtems_mode mode_set; /* task initial mode */
+ unsigned32 argument; /* task argument */
+} rtems_initialization_tasks_table;
/*
*
@@ -56,14 +56,12 @@ typedef struct {
typedef unsigned32 rtems_device_major_number;
typedef unsigned32 rtems_device_minor_number;
-typedef void rtems_device_driver;
+typedef rtems_status_code rtems_device_driver;
typedef rtems_device_driver ( *rtems_device_driver_entry )(
rtems_device_major_number,
rtems_device_minor_number,
- void *,
- Objects_Id,
- unsigned32 *
+ void *
);
typedef struct {
@@ -173,12 +171,13 @@ typedef rtems_mpci_entry ( *rtems_mpci_receive_entry )(
typedef struct {
unsigned32 default_timeout; /* in ticks */
+ unsigned32 maximum_packet_size;
rtems_mpci_initialization_entry initialization;
rtems_mpci_get_packet_entry get_packet;
rtems_mpci_return_packet_entry return_packet;
rtems_mpci_send_entry send_packet;
rtems_mpci_receive_entry receive_packet;
-} rtems_mpci_table;
+} rtems_mpci_table;
/*
* The following records define the Multiprocessor Configuration
@@ -192,8 +191,7 @@ struct Configuration_Table_MP {
unsigned32 maximum_nodes; /* maximum # nodes in system */
unsigned32 maximum_global_objects; /* maximum # global objects */
unsigned32 maximum_proxies; /* maximum # proxies */
- rtems_mpci_table *User_mpci_table;
- /* pointer to MPCI table */
+ rtems_mpci_table *User_mpci_table; /* pointer to MPCI table */
};
/*
@@ -209,25 +207,24 @@ struct Configuration_Table_MP {
*/
struct Configuration_Table {
- void *work_space_start;
- unsigned32 work_space_size;
- unsigned32 maximum_tasks;
- unsigned32 maximum_timers;
- unsigned32 maximum_semaphores;
- unsigned32 maximum_message_queues;
- unsigned32 maximum_messages;
- unsigned32 maximum_partitions;
- unsigned32 maximum_regions;
- unsigned32 maximum_ports;
- unsigned32 maximum_periods;
- unsigned32 maximum_extensions;
- unsigned32 microseconds_per_tick;
- unsigned32 ticks_per_timeslice;
- unsigned32 number_of_initialization_tasks;
+ void *work_space_start;
+ unsigned32 work_space_size;
+ unsigned32 maximum_tasks;
+ unsigned32 maximum_timers;
+ unsigned32 maximum_semaphores;
+ unsigned32 maximum_message_queues;
+ unsigned32 maximum_partitions;
+ unsigned32 maximum_regions;
+ unsigned32 maximum_ports;
+ unsigned32 maximum_periods;
+ unsigned32 maximum_extensions;
+ unsigned32 microseconds_per_tick;
+ unsigned32 ticks_per_timeslice;
+ unsigned32 number_of_initialization_tasks;
rtems_initialization_tasks_table *User_initialization_tasks_table;
- unsigned32 number_of_device_drivers;
+ unsigned32 number_of_device_drivers;
rtems_driver_address_table *Device_driver_table;
- rtems_extensions_table *User_extension_table;
+ rtems_extensions_table *User_extension_table;
rtems_multiprocessing_table *User_multiprocessing_table;
};
@@ -244,7 +241,7 @@ extern const rtems_multiprocessing_table
* configuration information.
*/
-EXTERN rtems_configuration_table *_Configuration_Table;
+EXTERN rtems_configuration_table *_Configuration_Table;
EXTERN rtems_multiprocessing_table *_Configuration_MP_table;
EXTERN rtems_mpci_table *_Configuration_MPCI_table;
@@ -258,7 +255,7 @@ EXTERN rtems_mpci_table *_Configuration_MPCI_table;
*/
STATIC INLINE void _Configuration_Handler_initialization(
- rtems_configuration_table *configuration_table,
+ rtems_configuration_table *configuration_table,
rtems_multiprocessing_table *multiprocessing_table,
rtems_mpci_table *users_mpci_table
);
diff --git a/cpukit/sapi/include/rtems/io.h b/cpukit/sapi/include/rtems/io.h
index 43c52cd35d..ef9fc69d03 100644
--- a/cpukit/sapi/include/rtems/io.h
+++ b/cpukit/sapi/include/rtems/io.h
@@ -35,27 +35,30 @@ extern "C" {
#include <rtems/config.h>
/*
- * The following type defines the set of IO operations which are
- * recognized by _IO_Handler and can be supported by a RTEMS
- * device driver.
+ * The following declare the data required to manage the Device Driver
+ * Address Table.
*/
-typedef enum {
- IO_INITIALIZE_OPERATION = 0,
- IO_OPEN_OPERATION = 1,
- IO_CLOSE_OPERATION = 2,
- IO_READ_OPERATION = 3,
- IO_WRITE_OPERATION = 4,
- IO_CONTROL_OPERATION = 5
-} IO_operations;
+EXTERN unsigned32 _IO_Number_of_drivers;
+EXTERN rtems_driver_address_table *_IO_Driver_address_table;
/*
- * The following declare the data required to manage the Device Driver
- * Address Table.
+ * Table for the io device names
*/
-EXTERN unsigned32 _IO_Number_of_drivers;
-EXTERN rtems_driver_address_table *_IO_Driver_address_table;
+typedef struct {
+ char *device_name;
+ unsigned32 device_name_length;
+ rtems_device_major_number major;
+ rtems_device_minor_number minor;
+} rtems_driver_name_t;
+
+/*XXX this really should be allocated some better way... */
+/*XXX it should probably be a chain and use a 'maximum' drivers field
+ * in config table */
+#define RTEMS_MAX_DRIVER_NAMES 20
+EXTERN rtems_driver_name_t rtems_driver_name_table[RTEMS_MAX_DRIVER_NAMES];
+
/*
* _IO_Manager_initialization
@@ -71,6 +74,36 @@ STATIC INLINE void _IO_Manager_initialization(
);
/*
+ * rtems_io_register_name
+ *
+ * DESCRIPTION:
+ *
+ * Associate a name with a driver.
+ *
+ */
+
+rtems_status_code rtems_io_register_name(
+ char *device_name,
+ rtems_device_major_number major,
+ rtems_device_minor_number minor
+);
+
+
+/*
+ * rtems_io_lookup_name
+ *
+ * DESCRIPTION:
+ *
+ * Find what driver "owns" this name
+ */
+
+rtems_status_code rtems_io_lookup_name(
+ const char *pathname,
+ rtems_driver_name_t **rnp
+);
+
+
+/*
* rtems_io_initialize
*
* DESCRIPTION:
@@ -82,8 +115,7 @@ STATIC INLINE void _IO_Manager_initialization(
rtems_status_code rtems_io_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
);
/*
@@ -98,8 +130,7 @@ rtems_status_code rtems_io_initialize(
rtems_status_code rtems_io_open(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
);
/*
@@ -114,8 +145,7 @@ rtems_status_code rtems_io_open(
rtems_status_code rtems_io_close(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
);
/*
@@ -130,8 +160,7 @@ rtems_status_code rtems_io_close(
rtems_status_code rtems_io_read(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
);
/*
@@ -146,8 +175,7 @@ rtems_status_code rtems_io_read(
rtems_status_code rtems_io_write(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
);
/*
@@ -162,8 +190,7 @@ rtems_status_code rtems_io_write(
rtems_status_code rtems_io_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
);
/*
@@ -177,23 +204,6 @@ rtems_status_code rtems_io_control(
void _IO_Initialize_all_drivers( void );
-/*
- * _IO_Handler_routine
- *
- * DESCRIPTION:
- *
- * This routine provides the common foundation for all of the IO
- * Manager's directives.
- */
-
-rtems_status_code _IO_Handler_routine(
- IO_operations operation,
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
-);
-
#include <rtems/io.inl>
#ifdef __cplusplus
diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c
index 984dca68be..2d3261c256 100644
--- a/cpukit/sapi/src/exinit.c
+++ b/cpukit/sapi/src/exinit.c
@@ -177,8 +177,7 @@ rtems_interrupt_level rtems_initialize_executive_early(
_Event_Manager_initialization();
_Message_queue_Manager_initialization(
- configuration_table->maximum_message_queues,
- configuration_table->maximum_messages
+ configuration_table->maximum_message_queues
);
_Semaphore_Manager_initialization(
diff --git a/cpukit/sapi/src/io.c b/cpukit/sapi/src/io.c
index 916053da7e..4ab45b33f5 100644
--- a/cpukit/sapi/src/io.c
+++ b/cpukit/sapi/src/io.c
@@ -18,6 +18,9 @@
#include <rtems/io.h>
#include <rtems/isr.h>
#include <rtems/thread.h>
+#include <rtems/intr.h>
+
+#include <string.h>
/*PAGE
*
@@ -33,12 +36,82 @@
void _IO_Initialize_all_drivers( void )
{
rtems_device_major_number major;
- unsigned32 ignored;
for ( major=0 ; major < _IO_Number_of_drivers ; major ++ )
- (void) rtems_io_initialize( major, 0, _Configuration_Table, &ignored );
+ (void) rtems_io_initialize( major, 0, _Configuration_Table);
+}
+
+/*PAGE
+ *
+ * rtems_io_register_name
+ *
+ * Associate a name with a driver
+ *
+ * Input Paramters:
+ *
+ * Output Parameters:
+ */
+
+rtems_status_code rtems_io_register_name(
+ char *device_name,
+ rtems_device_major_number major,
+ rtems_device_minor_number minor
+ )
+{
+ rtems_driver_name_t *np;
+ unsigned32 level;
+
+ /* find an empty slot */
+ for (np = rtems_driver_name_table; np < &rtems_driver_name_table[RTEMS_MAX_DRIVER_NAMES]; np++)
+ {
+ rtems_interrupt_disable(level);
+ if (np->device_name == 0)
+ {
+ np->device_name = device_name;
+ np->device_name_length = strlen(device_name);
+ np->major = major;
+ np->minor = minor;
+ rtems_interrupt_enable(level);
+
+ return RTEMS_SUCCESSFUL;
+ }
+ rtems_interrupt_enable(level);
+ }
+
+ return RTEMS_TOO_MANY;
+}
+
+/*PAGE
+ *
+ * rtems_io_lookup_name
+ *
+ * Find what driver "owns" this name
+ *
+ * Input Paramters:
+ *
+ * Output Parameters:
+ */
+
+rtems_status_code rtems_io_lookup_name(
+ const char *pathname,
+ rtems_driver_name_t **rnp
+ )
+{
+ rtems_driver_name_t *np;
+
+ for (np = rtems_driver_name_table; np < &rtems_driver_name_table[RTEMS_MAX_DRIVER_NAMES]; np++)
+ if (np->device_name)
+ if (strncmp(np->device_name, pathname, np->device_name_length) == 0)
+ {
+ *rnp = np;
+ return RTEMS_SUCCESSFUL;
+ }
+
+ *rnp = 0;
+ return RTEMS_UNSATISFIED;
}
+
/*PAGE
*
* rtems_io_initialize
@@ -49,27 +122,24 @@ void _IO_Initialize_all_drivers( void )
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
- * return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
- * *return_value - driver's return code
*/
rtems_status_code rtems_io_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
)
{
- return _IO_Handler_routine(
- IO_INITIALIZE_OPERATION,
- major,
- minor,
- argument,
- return_value
- );
+ rtems_device_driver_entry callout;
+
+ if ( major >= _IO_Number_of_drivers )
+ return RTEMS_INVALID_NUMBER;
+
+ callout = _IO_Driver_address_table[major].initialization;
+ return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -82,27 +152,24 @@ rtems_status_code rtems_io_initialize(
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
- * return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
- * *return_value - driver's return code
*/
rtems_status_code rtems_io_open(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
)
{
- return _IO_Handler_routine(
- IO_OPEN_OPERATION,
- major,
- minor,
- argument,
- return_value
- );
+ rtems_device_driver_entry callout;
+
+ if ( major >= _IO_Number_of_drivers )
+ return RTEMS_INVALID_NUMBER;
+
+ callout = _IO_Driver_address_table[major].open;
+ return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -115,27 +182,24 @@ rtems_status_code rtems_io_open(
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
- * return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
- * *return_value - driver's return code
*/
rtems_status_code rtems_io_close(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
)
{
- return _IO_Handler_routine(
- IO_CLOSE_OPERATION,
- major,
- minor,
- argument,
- return_value
- );
+ rtems_device_driver_entry callout;
+
+ if ( major >= _IO_Number_of_drivers )
+ return RTEMS_INVALID_NUMBER;
+
+ callout = _IO_Driver_address_table[major].close;
+ return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -148,27 +212,24 @@ rtems_status_code rtems_io_close(
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
- * return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
- * *return_value - driver's return code
*/
rtems_status_code rtems_io_read(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
)
{
- return _IO_Handler_routine(
- IO_READ_OPERATION,
- major,
- minor,
- argument,
- return_value
- );
+ rtems_device_driver_entry callout;
+
+ if ( major >= _IO_Number_of_drivers )
+ return RTEMS_INVALID_NUMBER;
+
+ callout = _IO_Driver_address_table[major].read;
+ return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -181,27 +242,24 @@ rtems_status_code rtems_io_read(
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
- * return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
- * *return_value - driver's return code
*/
rtems_status_code rtems_io_write(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
)
{
- return _IO_Handler_routine(
- IO_WRITE_OPERATION,
- major,
- minor,
- argument,
- return_value
- );
+ rtems_device_driver_entry callout;
+
+ if ( major >= _IO_Number_of_drivers )
+ return RTEMS_INVALID_NUMBER;
+
+ callout = _IO_Driver_address_table[major].write;
+ return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -214,103 +272,23 @@ rtems_status_code rtems_io_write(
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
- * return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
- * *return_value - driver's return code
*/
rtems_status_code rtems_io_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
+ void *argument
)
{
- return _IO_Handler_routine(
- IO_CONTROL_OPERATION,
- major,
- minor,
- argument,
- return_value
- );
-}
-
-/*PAGE
- *
- * _IO_Handler_routine
- *
- * This routine implements all IO manager directives.
- *
- * Input Paramters:
- * operation - I/O operation to be performed
- * major - device driver number
- * minor - device number
- * argument - pointer to argument(s)
- * return_value - pointer to driver's return value
- *
- * Output Parameters:
- * returns - return code
- * *return_value - driver's return code
- */
+ rtems_device_driver_entry callout;
+
+ if ( major >= _IO_Number_of_drivers )
+ return RTEMS_INVALID_NUMBER;
-rtems_status_code _IO_Handler_routine(
- IO_operations operation,
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *argument,
- unsigned32 *return_value
-)
-{
- rtems_device_driver_entry io_callout;
-
- /*
- * NOTE: There is no range checking as in Ada because:
- * + arrays in Ada are not always zero based.
- * + with zero based arrays, a comparison of an unsigned
- * number being less than zero would be necessary to
- * check it as a range. This would cause a warning for
- * checking an unsigned number for being negative.
- */
-
- if ( major >= _IO_Number_of_drivers )
- return ( RTEMS_INVALID_NUMBER );
-
- switch ( operation ) {
- case IO_INITIALIZE_OPERATION:
- io_callout = _IO_Driver_address_table[ major ].initialization;
- break;
- case IO_OPEN_OPERATION:
- io_callout = _IO_Driver_address_table[ major ].open;
- break;
- case IO_CLOSE_OPERATION:
- io_callout = _IO_Driver_address_table[ major ].close;
- break;
- case IO_READ_OPERATION:
- io_callout = _IO_Driver_address_table[ major ].read;
- break;
- case IO_WRITE_OPERATION:
- io_callout = _IO_Driver_address_table[ major ].write;
- break;
- case IO_CONTROL_OPERATION:
- io_callout = _IO_Driver_address_table[ major ].control;
- break;
- default: /* unreached -- only to remove warnings */
- io_callout = NULL;
- break;
- }
-
- if ( io_callout != NULL )
- (*io_callout)(
- major,
- minor,
- argument,
- _Thread_Executing->Object.id,
- return_value
- );
- else
- *return_value = 0;
-
- return( RTEMS_SUCCESSFUL );
+ callout = _IO_Driver_address_table[major].control;
+ return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
+