Commit Graph

166 Commits

Author SHA1 Message Date
Frank Benkert
c6942f6137 drivers/serial/serial.c: Optimize wait time in tcdram() for buffer emptying
According to the specification, the close function must wait until all data
has been written before it closes the file (except O_NONBLOCK is set). The
maximum waiting time for this is not specified.

To be able to edit the file list of the process, the close function has to lock
the file list semaphore. After that the close function of the serial driver is
called.

Waiting for the complete transmission of all data is done in the serial driver.
This causes the semaphore to remain locked until all data has been sent.
However, no other thread of the process can edit the file list for that time
(open, close, dup2, etc.). This is not optimal in a multithreaded environment.
Therefore, we have to keep the waiting time within the driver as short as possible.
2017-11-02 08:53:14 -06:00
Gregory Nutt
85a1a3cc98 drivers/usbdev: Correct input flow control logic when watermarks are not enabled. Problem not by and change based on suggestion by Juha Niskanen. 2017-10-18 06:49:11 -06:00
Gregory Nutt
5b04c25dcd drivers/serial/tcdrain: tcdrain() was recently added to the NuttX C library. But there is a problem. The specification of tcdrain() requires that it be a cancellation point. In order to do this, tcdrain was moved from the C library into the OS and the addition cancellation point hooks were added. In non-FLAT builds, access via system calls is also now supported. 2017-10-06 10:55:36 -06:00
Gregory Nutt
936df1bcb5 Adds new OS internal functions nxsig_sleep() and nxsig_usleep. These differ from the standard sleep() and usleep() in that (1) they don't cause cancellation points, and (2) don't set the errno variable (if applicable). All calls to sleep() and usleep() changed to calls to nxsig_sleep() and nxsig_usleep().
Squashed commit of the following:

    Change all calls to usleep() in the OS proper to calls to nxsig_usleep()

    sched/signal:  Add a new OS internal function nxsig_usleep() that is functionally equivalent to usleep() but does not cause a cancellaption point and does not modify the errno variable.

    sched/signal:  Add a new OS internal function nxsig_sleep() that is functionally equivalent to sleep() but does not cause a cancellaption point.
2017-10-06 10:15:01 -06:00
Gregory Nutt
9568600ab1 Squashed commit of the following:
This commit backs out most of commit b4747286b1.  That change was added because sem_wait() would sometimes cause cancellation points inappropriated.  But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.

    In the OS, all calls to sem_wait() changed to nxsem_wait().  nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.

    In all OS functions (not libraries), change sem_wait() to nxsem_wait().  This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.

    sched/semaphore:  Add the function nxsem_wait().  This is a new internal OS interface.  It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
2017-10-04 15:22:27 -06:00
Gregory Nutt
42a0796615 Squashed commit of the following:
sched/semaphore:  Add nxsem_post() which is identical to sem_post() except that it never modifies the errno variable.  Changed all references to sem_post in the OS to nxsem_post().

    sched/semaphore:  Add nxsem_destroy() which is identical to sem_destroy() except that it never modifies the errno variable.  Changed all references to sem_destroy() in the OS to nxsem_destroy().

    libc/semaphore and sched/semaphore:  Add nxsem_getprotocol() and nxsem_setprotocola which are identical to sem_getprotocol() and set_setprotocol() except that they never modifies the errno variable.  Changed all references to sem_setprotocol in the OS to nxsem_setprotocol().  sem_getprotocol() was not used in the OS
2017-10-03 15:35:24 -06:00
Gregory Nutt
83cdb0c552 Squashed commit of the following:
libc/semaphore:  Add nxsem_getvalue() which is identical to sem_getvalue() except that it never modifies the errno variable.  Changed all references to sem_getvalue in the OS to nxsem_getvalue().

    sched/semaphore:  Rename all internal private functions from sem_xyz to nxsem_xyz.  The sem_ prefix is (will be) reserved only for the application semaphore interfaces.

    libc/semaphore:  Add nxsem_init() which is identical to sem_init() except that it never modifies the errno variable.  Changed all references to sem_init in the OS to nxsem_init().

    sched/semaphore:  Rename sem_tickwait() to nxsem_tickwait() so that it is clear this is an internal OS function.

    sched/semaphoate:  Rename sem_reset() to nxsem_reset() so that it is clear this is an internal OS function.
2017-10-03 12:52:31 -06:00
Gregory Nutt
8394f9b60f Squashed commit of the following:
configs/z80sim and xtrs:  Serial driver lower halfs ioctl methods should return a negated errno value, not set the errno variable.

    drivers/wireless:  CC1101 driver not permitted to set errno.

    drivers/sensors:  LIS331DL driver not permitted to set errno.

    drivers/lcd: ILI9341 initialize method not permitted to set errno,

    drivers/serial: 16550 UART driver IOCTL method must not set errno; it must return a negated errno value.
2017-09-30 12:59:33 -06:00
Gregory Nutt
bd027b9019 serial.c: Use common TX drain logic when closing a driver as with the TCDRAIN IOCTL. 2017-08-01 10:14:24 -06:00
Gregory Nutt
4f0238339e serial.c: Finish implementation of TCDRAIN. Based partly on logic from Sebastien Lorquet. 2017-08-01 07:39:08 -06:00
Sebastien Lorquet
e22912db37 drivers/serial/serial.c: Add support for TCFLUSH 2017-08-01 06:30:52 -06:00
Gregory Nutt
0de294a586 Fix lots of occurrences of 'the the', 'the there', 'the these', 'the then', 'the they. 2017-05-11 13:35:56 -06:00
Gregory Nutt
d3b9f5b37f Syslog buffering: Use IOBs to buffer data, not an on-stack buffer 2017-05-10 17:36:08 -06:00
Stefan Kolb
591f35be87 I discovered a problem in the file drivers/serial/serial.c concerning the function uart_close(…). In the case that a serial device is opened with the flag O_NONBLOCK the function uart_close(…) blocks until all data in the buffer is transmitted. The function close(…) called on an handle opened with O_NONBLOCK should not block. The problem occurred with a CDC/ACM device. 2017-05-10 07:59:58 -06:00
Gregory Nutt
e3c9e9e0b8 UART 16550: Missing left parenthesis in function prototype. This is Bitbucket Issue #41. 2017-04-20 06:50:11 -06:00
Jussi Kivilinna
e2702cbe4e STM32F7: fix UART7 and UART8 IFLOWCONTROL options 2017-04-06 08:46:24 -06:00
Gregory Nutt
b4ff7391f8 Convert more drivers to use use irq_attach with argument. 2017-02-27 10:44:13 -06:00
Mark Schulte
b3222bbc8a irq_dispatch: Add argument pointer to irq_dispatch
Provide a user defined callback context for irq's, such that when
registering a callback users can provide a pointer that will get
passed back when the isr is called.
2017-02-27 06:27:56 -06:00
Gregory Nutt
08c001196b drivers/: Remove all explicit use of 'hidden' macro _info. Code must never use this directly. Code must always use a debug macro such as info which is basic on _info but can be appropriately filtered. 2017-01-15 13:00:50 -06:00
Gregory Nutt
4fcbe8e410 drivers: Disable priority inheritance on all semaphores used for signaling 2016-11-03 11:00:47 -06:00
Gregory Nutt
47b043df1e drivers/serial.c: Make sure that priority inheritance is not enabled for the signaling semaphores used in the serial driver. 2016-11-03 08:16:59 -06:00
Gregory Nutt
79c8bb7ddf Updae more comments 2016-07-27 08:03:09 -06:00
Gregory Nutt
59e0c4411f Correct some comments 2016-07-26 13:39:20 -06:00
Gregory Nutt
0c7f5d62e4 More comments 2016-07-26 12:13:30 -06:00
Gregory Nutt
084d200a66 PTY: Cosmetic, update some comments 2016-07-26 10:09:35 -06:00
Gregory Nutt
eaaa69da0a serial.c: Fix an error in FIONWRITE calculation 2016-07-26 06:47:53 -06:00
Gregory Nutt
e0b4a10dfa drivers/serial/pty.c, serial.c, usbdev/cdcacm.c, include/nuttx/fs/ioctl.h: Fix FIONWRITE and add FIONSPACE. All implementations of FIONWRITE were wrong. FIONWRITE should return the number of bytes waiting in the outgoing send queue, not the free space. Rather, FIONSPACE should return the free space in the send queue. 2016-07-25 14:06:32 -06:00
Gregory Nutt
9a8c3572db serial.c: Fix a race condition noted by Stefan Kolb. Between the test if the TX buffer is full and entering a critical section, bytes may be removed from the TX buffer making the wait unnecessary. The unnecessary wait is an inefficiency, but not really a problem. But with USB CDC/ACM it can be a problem because the entire TX buffer may be emptied when we lose the race. If that happens that uart_putxmitchar() can hang waiting for data to be removed from an empty TX buffer. 2016-07-22 07:47:59 -06:00
Gregory Nutt
10fff9011a Move include/nuttx/configdata.h to include/nuttx/mtd/configdata.h 2016-07-21 13:34:54 -06:00
Gregory Nutt
4b4dbc79a2 Move driver related prototypes out of include/nuttx/fs/fs.h and into new include/drivers/drivers.h 2016-07-20 13:15:37 -06:00
Gregory Nutt
2cacc6204a Kconfig: If Pseudo-terminals are enabled, then pipes must be selected as well 2016-07-19 14:26:40 -06:00
Gregory Nutt
318f34fb7d Psuedo-terminal pipe size is now configurable 2016-07-19 14:26:41 -06:00
Gregory Nutt
56582e2263 Update some comments 2016-07-19 10:40:23 -06:00
Gregory Nutt
8bf4684de8 Update some comments 2016-07-19 09:53:52 -06:00
Gregory Nutt
a4458c5016 PTY: Fix a race condition in test-fifo-empty-before-read logic 2016-07-19 06:45:02 -06:00
Gregory Nutt
d9fbf4c90f Eliminate some warnings 2016-07-18 11:27:06 -06:00
Gregory Nutt
1660329d06 Rename up_rnginitialize to devrandom_register 2016-07-18 10:55:37 -06:00
Gregory Nutt
6194467c13 PTY: Fix termios read input processing.. what was I thinking? Also, if some data was read, pty_read() should not block on the empty FIFO. 2016-07-18 08:00:56 -06:00
Gregory Nutt
ded91e451b PTY: Add TERMIOS support. 2016-07-16 10:43:44 -06:00
Alan Carvalho de Assis
8fa14b8fed Fix poll-related compile issues introduced with recent PTY changes 2016-07-16 07:03:38 -06:00
Gregory Nutt
6a75f2df89 PTY: Add some encode to reduce the likely of misinterpreting the return value of the file open() method 2016-07-15 17:13:21 -06:00
Gregory Nutt
4b1553d3ad PTY: Fix some tricky issues. Now seems to be working. A lot more testing is needed 2016-07-15 14:29:32 -06:00
Gregory Nutt
4b5149b244 PTY: Fix a few errors from early testing 2016-07-15 14:09:02 -06:00
Gregory Nutt
9ecd558002 Add the correct implementation of the file_poll() function 2016-07-15 11:34:08 -06:00
Gregory Nutt
f7f7036db8 Update some comments 2016-07-15 11:15:33 -06:00
Gregory Nutt
4d1b811117 PTY: Add support for the poll() method. 2016-07-15 10:07:33 -06:00
Gregory Nutt
95555a0199 PTY: Add ioctls to support locking and unlocking of the slave. LIBC: Add implementation of unlockpt() 2016-07-15 09:39:33 -06:00
Gregory Nutt
6139860c0b PTY: Added PTY IOCTL command definitions. Add support for TIOCGPTN. LIB: Implement ptsname() and ptsname_r() 2016-07-15 08:33:47 -06:00
Gregory Nutt
bcbe9806d2 In SUSv1 model, need to tried the PTY driver pair as unlinked if the master closes its reference 2016-07-15 07:33:48 -06:00
Gregory Nutt
14c216107a PTY: Need to free PTMX minor number is slave is unlinked 2016-07-15 07:22:36 -06:00