change log for rtems (2011-12-14)

rtems-vc at rtems.org rtems-vc at rtems.org
Wed Dec 14 09:11:57 UTC 2011


 *sh*:
2011-12-14	Sebastian Huber <sebastian.huber at embedded-brains.de>

	* libcsupport/include/rtems/termiostypes.h,
	libcsupport/src/termios_baud2num.c,
	libcsupport/src/termios_baudtable.c,
	libcsupport/src/termios_num2baud.c,
	libcsupport/src/termios_setinitialbaud.c: Added const qualifier to
	baud associations.  Fixed integer types.

M 1.3092  cpukit/ChangeLog
M   1.16  cpukit/libcsupport/include/rtems/termiostypes.h
M    1.6  cpukit/libcsupport/src/termios_baud2num.c
M    1.2  cpukit/libcsupport/src/termios_baudtable.c
M    1.5  cpukit/libcsupport/src/termios_num2baud.c
M    1.5  cpukit/libcsupport/src/termios_setinitialbaud.c

diff -u rtems/cpukit/ChangeLog:1.3091 rtems/cpukit/ChangeLog:1.3092
--- rtems/cpukit/ChangeLog:1.3091	Tue Dec 13 08:37:02 2011
+++ rtems/cpukit/ChangeLog	Wed Dec 14 02:50:48 2011
@@ -1,3 +1,12 @@
+2011-12-14	Sebastian Huber <sebastian.huber at embedded-brains.de>
+
+	* libcsupport/include/rtems/termiostypes.h,
+	libcsupport/src/termios_baud2num.c,
+	libcsupport/src/termios_baudtable.c,
+	libcsupport/src/termios_num2baud.c,
+	libcsupport/src/termios_setinitialbaud.c: Added const qualifier to
+	baud associations.  Fixed integer types.
+
 2011-12-13	Sebastian Huber <sebastian.huber at embedded-brains.de>
 
 	* sapi/include/confdefs.h: Fixed workspace size estimate of tasks.

diff -u rtems/cpukit/libcsupport/include/rtems/termiostypes.h:1.15 rtems/cpukit/libcsupport/include/rtems/termiostypes.h:1.16
--- rtems/cpukit/libcsupport/include/rtems/termiostypes.h:1.15	Tue Oct 11 02:57:46 2011
+++ rtems/cpukit/libcsupport/include/rtems/termiostypes.h	Wed Dec 14 02:50:49 2011
@@ -20,7 +20,9 @@
 
 #include <rtems.h>
 #include <rtems/libio.h>
+#include <rtems/assoc.h>
 #include <stdint.h>
+#include <termios.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -181,26 +183,42 @@
 #define MAXLDISC  8
 
 /* baudrate xxx integer type */
-typedef int32_t rtems_termios_baud_t;
+typedef uint32_t rtems_termios_baud_t;
 
-/* convert xxx integer to equivalent Bxxx constant */
-int  rtems_termios_number_to_baud(rtems_termios_baud_t baud);
+extern const rtems_assoc_t rtems_termios_baud_table [];
 
-/* convert Bxxx constant to xxx integer */
-rtems_termios_baud_t rtems_termios_baud_to_number(int termios_baud);
+/**
+ * @brief Converts the integral baud value @a baud to the Termios control flag
+ * representation.
+ *
+ * @retval B0 Invalid baud value or a baud value of 0.
+ * @retval other Baud constant according to @a baud.
+ */
+tcflag_t rtems_termios_number_to_baud(rtems_termios_baud_t baud);
+
+/**
+ * @brief Converts the baud part of the Termios control flags @a c_cflag to an
+ * integral baud value.
+ *
+ * There is no need to mask the @a c_cflag with @c CBAUD.
+ *
+ * @retval 0 Invalid baud value or a baud value of @c B0.
+ * @retval other Integral baud value.
+ */
+rtems_termios_baud_t rtems_termios_baud_to_number(tcflag_t c_cflag);
 
 /* convert Bxxx constant to index */
 int  rtems_termios_baud_to_index(rtems_termios_baud_t termios_baud);
 
-/*
- *  This method is used by a driver to tell termios its
- *  initial baud rate.  This is especially important when
- *  the device driver does not set the baud to the default
- *  of B9600.
- */
-int  rtems_termios_set_initial_baud(
-  struct rtems_termios_tty *ttyp,
-  rtems_termios_baud_t      baud
+/**
+ * @brief Sets the initial @a baud in the Termios context @a tty.
+ *
+ * @retval 0 Successful operation.
+ * @retval -1 Invalid baud value.
+ */
+int rtems_termios_set_initial_baud(
+  struct rtems_termios_tty *tty,
+  rtems_termios_baud_t baud
 );
 
 #ifdef __cplusplus

diff -u rtems/cpukit/libcsupport/src/termios_baud2num.c:1.5 rtems/cpukit/libcsupport/src/termios_baud2num.c:1.6
--- rtems/cpukit/libcsupport/src/termios_baud2num.c:1.5	Sat Jul 24 11:12:49 2010
+++ rtems/cpukit/libcsupport/src/termios_baud2num.c	Wed Dec 14 02:50:49 2011
@@ -10,24 +10,14 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+  #include "config.h"
 #endif
 
-#include <sys/termios.h>
 #include <rtems/termiostypes.h>
-#include <rtems/assoc.h>
 
-extern rtems_assoc_t termios_assoc_table[];
-
-int32_t rtems_termios_baud_to_number(
-  int termios_baud
-)
+rtems_termios_baud_t rtems_termios_baud_to_number(tcflag_t c_cflag)
 {
-  int baud;
-
-  baud = rtems_assoc_local_by_remote( termios_assoc_table, termios_baud );
-  if ( baud == 0 && termios_baud != 0 )
-    return -1;
+  uint32_t remote_value = (uint32_t) (c_cflag & CBAUD);
 
-  return baud;
+  return rtems_assoc_local_by_remote(rtems_termios_baud_table, remote_value);
 }

diff -u rtems/cpukit/libcsupport/src/termios_baudtable.c:1.1 rtems/cpukit/libcsupport/src/termios_baudtable.c:1.2
--- rtems/cpukit/libcsupport/src/termios_baudtable.c:1.1	Sat Jul 24 11:12:49 2010
+++ rtems/cpukit/libcsupport/src/termios_baudtable.c	Wed Dec 14 02:50:49 2011
@@ -10,14 +10,12 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+  #include "config.h"
 #endif
 
-#include <sys/termios.h>
 #include <rtems/termiostypes.h>
-#include <rtems/assoc.h>
 
-rtems_assoc_t termios_assoc_table[] = {
+const rtems_assoc_t rtems_termios_baud_table [] = {
   { "B0",      0,      B0 },
   { "B50",     50,     B50 },
   { "B75",     75,     B75 },

diff -u rtems/cpukit/libcsupport/src/termios_num2baud.c:1.4 rtems/cpukit/libcsupport/src/termios_num2baud.c:1.5
--- rtems/cpukit/libcsupport/src/termios_num2baud.c:1.4	Sat Jul 24 11:12:49 2010
+++ rtems/cpukit/libcsupport/src/termios_num2baud.c	Wed Dec 14 02:50:49 2011
@@ -10,23 +10,21 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+  #include "config.h"
 #endif
 
-#include <sys/termios.h>
 #include <rtems/termiostypes.h>
-#include <rtems/assoc.h>
 
-extern rtems_assoc_t termios_assoc_table[];
-
-int rtems_termios_number_to_baud(
-  int32_t baud
-)
+tcflag_t rtems_termios_number_to_baud(rtems_termios_baud_t baud)
 {
-  int termios_baud;
+  uint32_t remote_value = rtems_assoc_remote_by_local(
+    rtems_termios_baud_table,
+    baud
+  );
+
+  if (remote_value == 0) {
+    remote_value = B0;
+  }
 
-  termios_baud = rtems_assoc_remote_by_local( termios_assoc_table, baud );
-  if ( termios_baud == 0 && baud != 0 )
-    return -1;
-  return termios_baud;
+  return (tcflag_t) remote_value;
 }

diff -u rtems/cpukit/libcsupport/src/termios_setinitialbaud.c:1.4 rtems/cpukit/libcsupport/src/termios_setinitialbaud.c:1.5
--- rtems/cpukit/libcsupport/src/termios_setinitialbaud.c:1.4	Sat Mar 27 00:36:47 2010
+++ rtems/cpukit/libcsupport/src/termios_setinitialbaud.c	Wed Dec 14 02:50:49 2011
@@ -10,24 +10,26 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+  #include "config.h"
 #endif
 
-#include <sys/termios.h>
 #include <rtems/termiostypes.h>
 
-int  rtems_termios_set_initial_baud(
-  struct rtems_termios_tty *ttyp,
-  int32_t                   baud
+int rtems_termios_set_initial_baud(
+  struct rtems_termios_tty *tty,
+  rtems_termios_baud_t baud
 )
 {
-  int cflags_baud;
+  int rv = 0;
+  tcflag_t c_cflag_baud = rtems_termios_number_to_baud(baud);
 
-  cflags_baud = rtems_termios_number_to_baud(baud);
-  if ( cflags_baud == -1 )
-    return -1;
+  if ( c_cflag_baud == 0 ) {
+    tcflag_t cbaud = CBAUD;
 
-  ttyp->termios.c_cflag = (ttyp->termios.c_cflag & ~CBAUD) | cflags_baud;
+    tty->termios.c_cflag = (tty->termios.c_cflag & ~cbaud) | c_cflag_baud;
+  } else {
+    rv = -1;
+  }
 
-  return 0;
+  return rv;
 }



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20111214/14ef8215/attachment-0001.html>


More information about the vc mailing list