From 9deb5b8b2822eb49c7a31d35d37d9b59dcd6555c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 1 Aug 1997 18:12:11 +0000 Subject: Katsutoshi Shibuya (shibuya@mxb.meshnet.or.jp)of BU-Denken Co., Ltd. (Sapporo, Japan) submitted the extended console driver for the MVME162LX BSP and the POSIX tcsetattr() and tcgetattr() routines. This device driver supports four serial ports, cooked IO, and provides a portable base for Zilog 8530 based console drivers. --- c/src/lib/libc/Makefile.in | 2 +- c/src/lib/libc/libio.h | 7 +++++++ c/src/lib/libc/newlibif.c | 30 ++++++++++++++++++++++++++++++ c/src/lib/libc/tcattr.c | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 c/src/lib/libc/tcattr.c (limited to 'c/src/lib/libc') diff --git a/c/src/lib/libc/Makefile.in b/c/src/lib/libc/Makefile.in index 9b5c9238d6..ea9f78709e 100644 --- a/c/src/lib/libc/Makefile.in +++ b/c/src/lib/libc/Makefile.in @@ -12,7 +12,7 @@ LIB=${ARCH}/${LIBNAME} # C and C++ source names, if any, go here -- minus the .c or .cc C_PIECES=__gettod __brk __times malloc syscalls \ - no_libc newlibc newlibif support unixlibc libio hosterr + no_libc newlibc newlibif support unixlibc libio hosterr tcattr C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) diff --git a/c/src/lib/libc/libio.h b/c/src/lib/libc/libio.h index c79dfc2e33..d77480e4af 100644 --- a/c/src/lib/libc/libio.h +++ b/c/src/lib/libc/libio.h @@ -121,4 +121,11 @@ void rtems_register_libio_handler(int handler_flag, #define rtems_file_descriptor_type(fd) ((fd) & 0xF000) #define rtems_file_descriptor_type_index(fd) ((((fd) & 0xF000) >> 12) - 1) +/* + * IOCTL values + */ + +#define RTEMS_IO_GET_ATTRIBUTES 1 +#define RTEMS_IO_SET_ATTRIBUTES 2 + #endif /* _RTEMS_LIBIO_H */ diff --git a/c/src/lib/libc/newlibif.c b/c/src/lib/libc/newlibif.c index 5b59554428..aca1f369f7 100644 --- a/c/src/lib/libc/newlibif.c +++ b/c/src/lib/libc/newlibif.c @@ -87,4 +87,34 @@ fstat(int fd, * getpid and kill are provided directly by rtems */ +/* + * ioctl -- IO control + */ + +int +ioctl(int fd, int request, void *argp) +{ + return __rtems_ioctl(fd,request,argp); +} + +/* + * tcgetattr/tcsetattr -- get/set attributes of a device. + * + * by K.Shibuya + */ + +int +tcgetattr(int fd, struct termios *tp) +{ + return __rtems_ioctl(fd,RTEMS_IO_GET_ATTRIBUTES,tp); +} + +int +tcsetattr(int fd, int opt, struct termios *tp) +{ + if(opt != TCSANOW) + return -1; + return __rtems_ioctl(fd,RTEMS_IO_SET_ATTRIBUTES,tp); +} + #endif diff --git a/c/src/lib/libc/tcattr.c b/c/src/lib/libc/tcattr.c new file mode 100644 index 0000000000..aaa5ff6e6e --- /dev/null +++ b/c/src/lib/libc/tcattr.c @@ -0,0 +1,40 @@ +/* + * This file contains the RTEMS implementation of the POSIX API + * routines tcgetattr and tcsetattr. + * + * $Id$ + * + */ + +#include +#if defined(RTEMS_NEWLIB) + +#include +#include +#include +#include + +#include "internal.h" +#include "libio.h" + +/* + * tcgetattr/tcsetattr -- get/set attributes of a device. + * + * submitted by K.Shibuya + */ + +int +tcgetattr(int fd, struct termios *tp) +{ + return __rtems_ioctl(fd,RTEMS_IO_GET_ATTRIBUTES,tp); +} + +int +tcsetattr(int fd, int opt, struct termios *tp) +{ + if(opt != TCSANOW) + return -1; + return __rtems_ioctl(fd,RTEMS_IO_SET_ATTRIBUTES,tp); +} + +#endif -- cgit v1.2.3