summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-10-07 16:27:51 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-10-07 16:27:51 +0200
commita830cb864d4cd1b4d386844a53da4f5eef81d3c0 (patch)
treec6f2ffd2c6f003992131505ebc97f9a6c5e61c86 /cpukit
parenttermios: Fix transmit daemon (diff)
downloadrtems-a830cb864d4cd1b4d386844a53da4f5eef81d3c0.tar.bz2
termios: Separate flow control from normal handler
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/libcsupport/include/rtems/termiostypes.h35
-rw-r--r--cpukit/libcsupport/src/termios.c23
2 files changed, 41 insertions, 17 deletions
diff --git a/cpukit/libcsupport/include/rtems/termiostypes.h b/cpukit/libcsupport/include/rtems/termiostypes.h
index 6339456b20..045a91f4c2 100644
--- a/cpukit/libcsupport/include/rtems/termiostypes.h
+++ b/cpukit/libcsupport/include/rtems/termiostypes.h
@@ -144,6 +144,18 @@ typedef struct {
);
/**
+ * @brief Termios device mode.
+ */
+ rtems_termios_device_mode mode;
+} rtems_termios_device_handler;
+
+/**
+ * @brief Termios device flow control handler.
+ *
+ * @see rtems_termios_device_install().
+ */
+typedef struct {
+ /**
* @brief Indicate to stop remote transmitter.
*
* @param[in] tty The Termios control.
@@ -160,12 +172,7 @@ typedef struct {
* @see rtems_termios_get_device_context().
*/
void (*start_remote_tx)(struct rtems_termios_tty *tty);
-
- /**
- * @brief Termios device mode.
- */
- rtems_termios_device_mode mode;
-} rtems_termios_device_handler;
+} rtems_termios_device_flow;
/**
* @brief Termios device node for installed devices.
@@ -177,6 +184,7 @@ typedef struct rtems_termios_device_node {
rtems_device_major_number major;
rtems_device_minor_number minor;
const rtems_termios_device_handler *handler;
+ const rtems_termios_device_flow *flow;
void *context;
struct rtems_termios_tty *tty;
} rtems_termios_device_node;
@@ -254,6 +262,11 @@ typedef struct rtems_termios_tty {
*/
rtems_termios_device_handler handler;
+ /**
+ * @brief The device flow control handler.
+ */
+ rtems_termios_device_flow flow;
+
volatile unsigned int flow_ctrl;
unsigned int lowwater,highwater;
@@ -295,11 +308,14 @@ typedef struct rtems_termios_tty {
* @brief Installs a Termios device.
*
* @param[in] device_file If not @c NULL, then a device file for the specified
- * major and minor number will be created.
+ * major and minor number will be created.
* @param[in] major The device major number of the corresponding device driver.
* @param[in] minor The device minor number of the corresponding device driver.
* @param[in] handler The device handler. It must be persistent throughout the
* installed time of the device.
+ * @param[in] flow The device flow control handler. The device flow control
+ * handler are optional and may be @c NULL. If present must be persistent
+ * throughout the installed time of the device.
* @param[in] context The device context. It must be persistent throughout the
* installed time of the device.
*
@@ -307,17 +323,18 @@ typedef struct rtems_termios_tty {
* @retval RTEMS_NO_MEMORY Not enough memory to create a device node.
* @retval RTEMS_UNSATISFIED Creation of the device file failed.
* @retval RTEMS_RESOURCE_IN_USE There exists a device node for this major and
- * minor number pair.
+ * minor number pair.
* @retval RTEMS_INCORRECT_STATE Termios is not initialized.
*
* @see rtems_termios_device_remove(), rtems_termios_device_open(),
- * rtems_termios_device_close() and rtems_termios_get_device_context().
+ * rtems_termios_device_close() and rtems_termios_get_device_context().
*/
rtems_status_code rtems_termios_device_install(
const char *device_file,
rtems_device_major_number major,
rtems_device_minor_number minor,
const rtems_termios_device_handler *handler,
+ const rtems_termios_device_flow *flow,
void *context
);
diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c
index 52171a14b3..6119b22a55 100644
--- a/cpukit/libcsupport/src/termios.c
+++ b/cpukit/libcsupport/src/termios.c
@@ -133,6 +133,7 @@ rtems_status_code rtems_termios_device_install(
rtems_device_major_number major,
rtems_device_minor_number minor,
const rtems_termios_device_handler *handler,
+ const rtems_termios_device_flow *flow,
void *context
)
{
@@ -148,6 +149,7 @@ rtems_status_code rtems_termios_device_install(
new_device_node->major = major;
new_device_node->minor = minor;
new_device_node->handler = handler;
+ new_device_node->flow = flow;
new_device_node->context = context;
new_device_node->tty = NULL;
@@ -458,6 +460,11 @@ rtems_termios_open_tty(
if (device_node != NULL) {
device_node->tty = tty;
tty->handler = *device_node->handler;
+
+ if (device_node->flow != NULL) {
+ tty->flow = *device_node->flow;
+ }
+
tty->device_node = device_node;
tty->device_context = device_node->context;
memset(&tty->device, 0, sizeof(tty->device));
@@ -472,9 +479,9 @@ rtems_termios_open_tty(
rtems_termios_callback_write : NULL;
tty->handler.set_attributes = callbacks->setAttributes != NULL ?
rtems_termios_callback_setAttributes : NULL;
- tty->handler.stop_remote_tx = callbacks->stopRemoteTx != NULL ?
+ tty->flow.stop_remote_tx = callbacks->stopRemoteTx != NULL ?
rtems_termios_callback_stopRemoteTx : NULL;
- tty->handler.start_remote_tx = callbacks->startRemoteTx != NULL ?
+ tty->flow.start_remote_tx = callbacks->startRemoteTx != NULL ?
rtems_termios_callback_startRemoteTx : NULL;
tty->handler.mode = callbacks->outputUsesInterrupts;
tty->device_context = NULL;
@@ -818,8 +825,8 @@ termios_set_flowctrl(struct rtems_termios_tty *tty)
/* restart remote Tx, if it was stopped */
if ((tty->flow_ctrl & FL_IRTSOFF) &&
- (tty->handler.start_remote_tx != NULL)) {
- tty->handler.start_remote_tx(tty);
+ (tty->flow.start_remote_tx != NULL)) {
+ tty->flow.start_remote_tx(tty);
}
tty->flow_ctrl &= ~(FL_IRTSOFF);
}
@@ -1444,8 +1451,8 @@ fillBufferQueue (struct rtems_termios_tty *tty)
} else if (tty->flow_ctrl & FL_MDRTS) {
tty->flow_ctrl &= ~FL_IRTSOFF;
/* activate RTS line */
- if (tty->handler.start_remote_tx != NULL) {
- tty->handler.start_remote_tx(tty);
+ if (tty->flow.start_remote_tx != NULL) {
+ tty->flow.start_remote_tx(tty);
}
}
}
@@ -1624,8 +1631,8 @@ rtems_termios_enqueue_raw_characters (void *ttyp, const char *buf, int len)
} else if ((tty->flow_ctrl & (FL_MDRTS | FL_IRTSOFF)) == (FL_MDRTS) ) {
tty->flow_ctrl |= FL_IRTSOFF;
/* deactivate RTS line */
- if (tty->handler.stop_remote_tx != NULL) {
- tty->handler.stop_remote_tx(tty);
+ if (tty->flow.stop_remote_tx != NULL) {
+ tty->flow.stop_remote_tx(tty);
}
}
}