From fd0704318043d0264f1feee0225dadd7448b4c52 Mon Sep 17 00:00:00 2001 From: "Anton D. Kachalov" Date: Mon, 10 Aug 2015 18:15:24 +0300 Subject: [PATCH 1/7] Add simple `epoll' wrapper around `poll' Signed-off-by: Anton D. Kachalov --- fs/vfs/Make.defs | 2 +- fs/vfs/epoll.c | 102 ++++++++++++++++++++++++++++++++++++++++++++ include/sys/epoll.h | 59 +++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 fs/vfs/epoll.c create mode 100644 include/sys/epoll.h diff --git a/fs/vfs/Make.defs b/fs/vfs/Make.defs index 09d0eb52429..6769e8b12cc 100644 --- a/fs/vfs/Make.defs +++ b/fs/vfs/Make.defs @@ -68,7 +68,7 @@ else CSRCS += fs_close.c fs_dup.c fs_dup2.c fs_fcntl.c fs_dupfd.c fs_dupfd2.c CSRCS += fs_getfilep.c fs_ioctl.c fs_lseek.c fs_mkdir.c fs_open.c fs_poll.c CSRCS += fs_read.c fs_rename.c fs_rmdir.c fs_stat.c fs_statfs.c fs_select.c -CSRCS += fs_unlink.c fs_write.c +CSRCS += fs_unlink.c fs_write.c epoll.c # Certain interfaces are not available if there is no mountpoint support diff --git a/fs/vfs/epoll.c b/fs/vfs/epoll.c new file mode 100644 index 00000000000..9b7bdf2d7e2 --- /dev/null +++ b/fs/vfs/epoll.c @@ -0,0 +1,102 @@ +#include +#include +#include +#include +#include + +#include + +int epoll_create(int size) +{ + struct epoll_head *eph = malloc(sizeof(struct epoll_head)); + + eph->size = size; + eph->occupied = 0; + eph->evs = malloc(sizeof(struct epoll_event) * eph->size); + + return (int)eph; +} + +void epoll_close(int epfd) +{ + struct epoll_head *eph = (struct epoll_head *)epfd; + + free(eph->evs); + free(eph); +} + +int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) +{ + struct epoll_head *eph = (struct epoll_head *)epfd; + + switch (op) + { + case EPOLL_CTL_ADD: + printf("%08x CTL ADD(%d): fd=%d ev=%08x\n", epfd, eph->occupied, fd, ev->events); + eph->evs[eph->occupied].events = ev->events | POLLERR | POLLHUP; + eph->evs[eph->occupied++].data.fd = fd; + return 0; + + case EPOLL_CTL_DEL: + { + int i; + for (i=0; i < eph->occupied; i++) + { + if (eph->evs[i].data.fd == fd) + { + if (i != eph->occupied-1) + memmove(&eph->evs[i], &eph->evs[i + 1], eph->occupied - i); + eph->occupied--; + return 0; + } + } + return -ENOENT; + } + + case EPOLL_CTL_MOD: + { + int i; + printf("%08x CTL MOD(%d): fd=%d ev=%08x\n", epfd, eph->occupied, fd, ev->events); + for (i=0; i < eph->occupied; i++) + { + if (eph->evs[i].data.fd == fd) + { + eph->evs[i].events = ev->events | POLLERR | POLLHUP; + return 0; + } + } + return -ENOENT; + } + } + + return -EINVAL; +} + +int epoll_wait(int epfd, struct epoll_event *evs, int maxevents, int timeout) +{ + int i; + int rc; + struct epoll_head *eph = (struct epoll_head *)epfd; + + rc = poll((struct pollfd *)eph->evs, eph->occupied, timeout); + + if (rc <= 0) + { + if (rc < 0) { + printf("%08x poll fail: %d for %d, %d msecs\n", epfd, rc, eph->occupied, timeout); + for (i=0; i < eph->occupied; i++) + { + printf("%02d: fd=%d\n", i, eph->evs[i].data.fd); + } + } + return rc; + } + + for (i=0; i < rc; i++) + { + evs[i].data.fd = (pollevent_t)eph->evs[i].data.fd; + evs[i].events = (pollevent_t)eph->evs[i].revents; + } + + return rc; +} diff --git a/include/sys/epoll.h b/include/sys/epoll.h new file mode 100644 index 00000000000..96fe2efe17c --- /dev/null +++ b/include/sys/epoll.h @@ -0,0 +1,59 @@ +#ifndef _EPOLL__H +#define _EPOLL__H + +#include + +enum EPOLL_EVENTS + { + EPOLLIN = POLLIN, +#define EPOLLIN EPOLLIN + EPOLLPRI = POLLPRI, +#define EPOLLPRI EPOLLPRI + EPOLLOUT = POLLOUT, +#define EPOLLOUT EPOLLOUT + EPOLLRDNORM = POLLRDNORM, +#define EPOLLRDNORM EPOLLRDNORM + EPOLLRDBAND = POLLRDBAND, +#define EPOLLRDBAND EPOLLRDBAND + EPOLLWRNORM = POLLWRNORM, +#define EPOLLWRNORM EPOLLWRNORM + EPOLLWRBAND = POLLWRBAND, +#define EPOLLWRBAND EPOLLWRBAND + EPOLLERR = POLLERR, +#define EPOLLERR EPOLLERR + EPOLLHUP = POLLHUP, +#define EPOLLHUP EPOLLHUP + }; + +#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ +#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ +#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ + +typedef union poll_data +{ + int fd; /* The descriptor being polled */ +} epoll_data_t; + +struct epoll_event +{ + epoll_data_t data; + sem_t *sem; /* Pointer to semaphore used to post output event */ + pollevent_t events; /* The input event flags */ + pollevent_t revents; /* The output event flags */ + FAR void *priv; /* For use by drivers */ +}; + +struct epoll_head +{ + int size; + int occupied; + struct epoll_event *evs; +}; + +int epoll_create(int size); +int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev); +int epoll_wait(int epfd, struct epoll_event *evs, int maxevents, int timeout); + +void epoll_close(int epfd); + +#endif From d61e49b7cde46c3028ea3c7bfc2c299086cdea36 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 10 Aug 2015 10:05:56 -0600 Subject: [PATCH 2/7] Fix typo, include comments in the SPI slave interface header file --- arch | 2 +- include/nuttx/spi/slave.h | 31 ++++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/arch b/arch index 1efba67cba0..3f84c8507a6 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit 1efba67cba08b28a2a4a1a4649daf2df93b2d596 +Subproject commit 3f84c8507a657e0066b388b21a02537a9a3abab6 diff --git a/include/nuttx/spi/slave.h b/include/nuttx/spi/slave.h index f57493fa53b..2fb7dd3762d 100644 --- a/include/nuttx/spi/slave.h +++ b/include/nuttx/spi/slave.h @@ -133,7 +133,7 @@ * sctrlr - SPI slave controller interface instance * * Returned Value: - * true if the output wueue is full + * true if the output queue is full * ****************************************************************************/ @@ -172,11 +172,12 @@ * none * * Assumptions: - * May be called from an interrupt handler. + * May be called from an interrupt handler. Processing should be as + * brief as possible. * ****************************************************************************/ -#define SPI_SDEV_SELECT(d,s) ((c)->ops->select(d,s)) +#define SPI_SDEV_SELECT(d,s) ((d)->ops->select(d,s)) /**************************************************************************** * Name: SPI_SDEV_CMDDATA @@ -199,7 +200,8 @@ * none * * Assumptions: - * May be called from an interrupt handler. + * May be called from an interrupt handler. Processing should be as + * brief as possible. * ****************************************************************************/ @@ -225,7 +227,8 @@ * The next data value to be shifted out * * Assumptions: - * May be called from an interrupt handler. + * May be called from an interrupt handler and the response is usually + * time critical. * ****************************************************************************/ @@ -248,7 +251,10 @@ * None * * Assumptions: - * May be called from an interrupt handler. + * May be called from an interrupt handler and in time-critical + * circumstances. A good implementation might just add the newly + * received word to a queue, post a processing task, and return as + * quickly as possible to avoid any data overrun problems. * ****************************************************************************/ @@ -355,7 +361,12 @@ * For the case of uni-directional transfer of data from the master to * the SPI device, there is no need to call the enqueue() method at all; * the value that is shifted out is not important that fallback behavior - * is suficient. + * is sufficient. + * + * The SPI slave controller driver, of course, has no sense of the + * directionality of a data transfer; its role is only to exchange the + * data shifted in from the master with new data to be shifted out from + * the SPI device driver. * * 6) The activity of 5) will continue until the master raises the chip * select signal. In that case, the SPI slave controller driver will @@ -369,6 +380,12 @@ * the initial indication of chip selected will be the only call to the * select() method that is made. * + * Other SPI peripherals (such as Atmel) do not make the state of the + * chip select pin available (only the final rising edge transitions). + * So the SPI device driver implementation may use the chip select + * reports to optimize performance, but the design should never depend + * upon it. + * * A typical DMA data transfer processes as follows: * To be provided */ From 0c34ef7468dfcb7e503d29667cdb74842da170e5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 10 Aug 2015 10:17:48 -0600 Subject: [PATCH 3/7] Update ChangeLog --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 37a4b8cd75b..5696dd3a909 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10796,4 +10796,6 @@ interface (2015-08-08). * arch/arm/src/samv7: Add the framework for an SPI slave drvier. This driver has a lot of missing logic on initial commit (2015-08-09). + * arch/arm/src/samv7: Basic, no-DMA SPI slave driver is in place + (2015-080=-10). From c74dc5f83f3199b55088a9022aa3ed4b08480265 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 10 Aug 2015 10:38:41 -0600 Subject: [PATCH 4/7] Changes from review epoll() implementation for consistency with NuttX naming and coding style --- ChangeLog | 4 +- arch | 2 +- fs/vfs/Make.defs | 8 +- fs/vfs/epoll.c | 102 --------------------- fs/vfs/fs_epoll.c | 211 ++++++++++++++++++++++++++++++++++++++++++++ include/sys/epoll.h | 71 ++++++++++++--- 6 files changed, 280 insertions(+), 118 deletions(-) delete mode 100644 fs/vfs/epoll.c create mode 100644 fs/vfs/fs_epoll.c diff --git a/ChangeLog b/ChangeLog index 5696dd3a909..7e92de8a31d 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10798,4 +10798,6 @@ driver has a lot of missing logic on initial commit (2015-08-09). * arch/arm/src/samv7: Basic, no-DMA SPI slave driver is in place (2015-080=-10). - + * fs/vfs/epoll.c and include/sys/epoll.h: Add a very simple epoll layer + just around poll calls. To satisfy build app requirements. From Anton + D. Kachalov. diff --git a/arch b/arch index 3f84c8507a6..43d20de693c 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit 3f84c8507a657e0066b388b21a02537a9a3abab6 +Subproject commit 43d20de693c2be5f98ca0dc23bc5d91b22845f1f diff --git a/fs/vfs/Make.defs b/fs/vfs/Make.defs index 6769e8b12cc..4c3fca02584 100644 --- a/fs/vfs/Make.defs +++ b/fs/vfs/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # fs/vfs/Make.defs # -# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -66,9 +66,9 @@ else # Common file/socket descriptor support CSRCS += fs_close.c fs_dup.c fs_dup2.c fs_fcntl.c fs_dupfd.c fs_dupfd2.c -CSRCS += fs_getfilep.c fs_ioctl.c fs_lseek.c fs_mkdir.c fs_open.c fs_poll.c -CSRCS += fs_read.c fs_rename.c fs_rmdir.c fs_stat.c fs_statfs.c fs_select.c -CSRCS += fs_unlink.c fs_write.c epoll.c +CSRCS += fs_epoll.c fs_getfilep.c fs_ioctl.c fs_lseek.c fs_mkdir.c fs_open.c +CSRCS += fs_poll.c fs_read.c fs_rename.c fs_rmdir.c fs_stat.c fs_statfs.c +CSRCS += fs_select.c fs_unlink.c fs_write.c # Certain interfaces are not available if there is no mountpoint support diff --git a/fs/vfs/epoll.c b/fs/vfs/epoll.c deleted file mode 100644 index 9b7bdf2d7e2..00000000000 --- a/fs/vfs/epoll.c +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -int epoll_create(int size) -{ - struct epoll_head *eph = malloc(sizeof(struct epoll_head)); - - eph->size = size; - eph->occupied = 0; - eph->evs = malloc(sizeof(struct epoll_event) * eph->size); - - return (int)eph; -} - -void epoll_close(int epfd) -{ - struct epoll_head *eph = (struct epoll_head *)epfd; - - free(eph->evs); - free(eph); -} - -int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) -{ - struct epoll_head *eph = (struct epoll_head *)epfd; - - switch (op) - { - case EPOLL_CTL_ADD: - printf("%08x CTL ADD(%d): fd=%d ev=%08x\n", epfd, eph->occupied, fd, ev->events); - eph->evs[eph->occupied].events = ev->events | POLLERR | POLLHUP; - eph->evs[eph->occupied++].data.fd = fd; - return 0; - - case EPOLL_CTL_DEL: - { - int i; - for (i=0; i < eph->occupied; i++) - { - if (eph->evs[i].data.fd == fd) - { - if (i != eph->occupied-1) - memmove(&eph->evs[i], &eph->evs[i + 1], eph->occupied - i); - eph->occupied--; - return 0; - } - } - return -ENOENT; - } - - case EPOLL_CTL_MOD: - { - int i; - printf("%08x CTL MOD(%d): fd=%d ev=%08x\n", epfd, eph->occupied, fd, ev->events); - for (i=0; i < eph->occupied; i++) - { - if (eph->evs[i].data.fd == fd) - { - eph->evs[i].events = ev->events | POLLERR | POLLHUP; - return 0; - } - } - return -ENOENT; - } - } - - return -EINVAL; -} - -int epoll_wait(int epfd, struct epoll_event *evs, int maxevents, int timeout) -{ - int i; - int rc; - struct epoll_head *eph = (struct epoll_head *)epfd; - - rc = poll((struct pollfd *)eph->evs, eph->occupied, timeout); - - if (rc <= 0) - { - if (rc < 0) { - printf("%08x poll fail: %d for %d, %d msecs\n", epfd, rc, eph->occupied, timeout); - for (i=0; i < eph->occupied; i++) - { - printf("%02d: fd=%d\n", i, eph->evs[i].data.fd); - } - } - return rc; - } - - for (i=0; i < rc; i++) - { - evs[i].data.fd = (pollevent_t)eph->evs[i].data.fd; - evs[i].events = (pollevent_t)eph->evs[i].revents; - } - - return rc; -} diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c new file mode 100644 index 00000000000..420e066d4ca --- /dev/null +++ b/fs/vfs/fs_epoll.c @@ -0,0 +1,211 @@ +/**************************************************************************** + * fs/vfs/fs_epoll.c + * + * Copyright (C) 2015 Anton D. Kachalov. All rights reserved. + * Author: Anton D. Kachalov + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include + +#include + +#ifndef CONFIG_DISABLE_POLL + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: epoll_create + * + * Description: + * + * Input Parameters: + * + * Returned Value: + * + ****************************************************************************/ + +int epoll_create(int size) +{ + FAR struct epoll_head *eph = + (FAR struct epoll_head *)malloc(sizeof(struct epoll_head)); + + eph->size = size; + eph->occupied = 0; + eph->evs = malloc(sizeof(struct epoll_event) * eph->size); + + return (int)eph; +} + +/**************************************************************************** + * Name: epoll_close + * + * Description: + * + * Input Parameters: + * + * Returned Value: + * + ****************************************************************************/ + +void epoll_close(int epfd) +{ + struct epoll_head *eph = (struct epoll_head *)epfd; + + free(eph->evs); + free(eph); +} + +/**************************************************************************** + * Name: epoll_ctl + * + * Description: + * + * Input Parameters: + * + * Returned Value: + * + ****************************************************************************/ + +int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) +{ + FAR struct epoll_head *eph = (FAR struct epoll_head *)epfd; + + switch (op) + { + case EPOLL_CTL_ADD: + printf("%08x CTL ADD(%d): fd=%d ev=%08x\n", + epfd, eph->occupied, fd, ev->events); + + eph->evs[eph->occupied].events = ev->events | POLLERR | POLLHUP; + eph->evs[eph->occupied++].data.fd = fd; + return 0; + + case EPOLL_CTL_DEL: + { + int i; + + for (i = 0; i < eph->occupied; i++) + { + if (eph->evs[i].data.fd == fd) + { + if (i != eph->occupied-1) + { + memmove(&eph->evs[i], &eph->evs[i + 1], + eph->occupied - i); + } + + eph->occupied--; + return 0; + } + } + + return -ENOENT; + } + + case EPOLL_CTL_MOD: + { + int i; + + printf("%08x CTL MOD(%d): fd=%d ev=%08x\n", + epfd, eph->occupied, fd, ev->events); + + for (i = 0; i < eph->occupied; i++) + { + if (eph->evs[i].data.fd == fd) + { + eph->evs[i].events = ev->events | POLLERR | POLLHUP; + return 0; + } + } + + return -ENOENT; + } + } + + return -EINVAL; +} + +/**************************************************************************** + * Name: epoll_wait + * + * Description: + * + * Input Parameters: + * + * Returned Value: + * + ****************************************************************************/ + +int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, + int timeout) +{ + int i; + int rc; + FAR struct epoll_head *eph = (FAR struct epoll_head *)epfd; + + rc = poll((FAR struct pollfd *)eph->evs, eph->occupied, timeout); + + if (rc <= 0) + { + if (rc < 0) + { + printf("%08x poll fail: %d for %d, %d msecs\n", + epfd, rc, eph->occupied, timeout); + + for (i = 0; i < eph->occupied; i++) + { + printf("%02d: fd=%d\n", i, eph->evs[i].data.fd); + } + } + + return rc; + } + + for (i = 0; i < rc; i++) + { + evs[i].data.fd = (pollevent_t)eph->evs[i].data.fd; + evs[i].events = (pollevent_t)eph->evs[i].revents; + } + + return rc; +} + +#endif /* CONFIG_DISABLE_POLL */ diff --git a/include/sys/epoll.h b/include/sys/epoll.h index 96fe2efe17c..01aecdd69ef 100644 --- a/include/sys/epoll.h +++ b/include/sys/epoll.h @@ -1,8 +1,59 @@ -#ifndef _EPOLL__H -#define _EPOLL__H +/**************************************************************************** + * fs/vfs/fs_epoll.c + * + * Copyright (C) 2015 Anton D. Kachalov. All rights reserved. + * Author: Anton D. Kachalov + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_SYS_EPOLL_H +#define __INCLUDE_NUTTX_SYS_EPOLL_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ #include +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ +#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ +#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + enum EPOLL_EVENTS { EPOLLIN = POLLIN, @@ -25,19 +76,15 @@ enum EPOLL_EVENTS #define EPOLLHUP EPOLLHUP }; -#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ -#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ -#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ - typedef union poll_data { - int fd; /* The descriptor being polled */ + int fd; /* The descriptor being polled */ } epoll_data_t; struct epoll_event { epoll_data_t data; - sem_t *sem; /* Pointer to semaphore used to post output event */ + FAR sem_t *sem; /* Pointer to semaphore used to post output event */ pollevent_t events; /* The input event flags */ pollevent_t revents; /* The output event flags */ FAR void *priv; /* For use by drivers */ @@ -47,13 +94,17 @@ struct epoll_head { int size; int occupied; - struct epoll_event *evs; + FAR struct epoll_event *evs; }; +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + int epoll_create(int size); int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev); int epoll_wait(int epfd, struct epoll_event *evs, int maxevents, int timeout); void epoll_close(int epfd); -#endif +#endif /* __INCLUDE_NUTTX_SYS_EPOLL_H */ From 422ea4f6732edeece1a3de6fa350701daa5f61cb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 10 Aug 2015 10:41:58 -0600 Subject: [PATCH 5/7] Another epoll() change: Should not call printf from inside the OS --- fs/vfs/fs_epoll.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c index 420e066d4ca..8cd6e227ac2 100644 --- a/fs/vfs/fs_epoll.c +++ b/fs/vfs/fs_epoll.c @@ -37,13 +37,16 @@ * Included Files ****************************************************************************/ +#include + +#include + #include #include #include #include #include - -#include +#include #ifndef CONFIG_DISABLE_POLL @@ -111,8 +114,8 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) switch (op) { case EPOLL_CTL_ADD: - printf("%08x CTL ADD(%d): fd=%d ev=%08x\n", - epfd, eph->occupied, fd, ev->events); + fvdbg("%08x CTL ADD(%d): fd=%d ev=%08x\n", + epfd, eph->occupied, fd, ev->events); eph->evs[eph->occupied].events = ev->events | POLLERR | POLLHUP; eph->evs[eph->occupied++].data.fd = fd; @@ -144,8 +147,8 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) { int i; - printf("%08x CTL MOD(%d): fd=%d ev=%08x\n", - epfd, eph->occupied, fd, ev->events); + fvdbg("%08x CTL MOD(%d): fd=%d ev=%08x\n", + epfd, eph->occupied, fd, ev->events); for (i = 0; i < eph->occupied; i++) { @@ -187,12 +190,12 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, { if (rc < 0) { - printf("%08x poll fail: %d for %d, %d msecs\n", - epfd, rc, eph->occupied, timeout); + fdbg("%08x poll fail: %d for %d, %d msecs\n", + epfd, rc, eph->occupied, timeout); for (i = 0; i < eph->occupied; i++) { - printf("%02d: fd=%d\n", i, eph->evs[i].data.fd); + fdbg("%02d: fd=%d\n", i, eph->evs[i].data.fd); } } From c68b4b10e48c501f1a12952682a808d2505f147d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 10 Aug 2015 11:05:35 -0600 Subject: [PATCH 6/7] Sync submodules --- arch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch b/arch index 43d20de693c..6190d664666 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit 43d20de693c2be5f98ca0dc23bc5d91b22845f1f +Subproject commit 6190d664666b19580969c4e620646ef4e54f0182 From c83d92e84688dd861a8f0cf60b6fe7c6a8056dc2 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Mon, 10 Aug 2015 11:30:37 -0600 Subject: [PATCH 7/7] RAMTRON: Update driver to include support for newer RAMTRON parts. --- ChangeLog | 3 +++ drivers/mtd/ramtron.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7e92de8a31d..03e6dd4558b 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10801,3 +10801,6 @@ * fs/vfs/epoll.c and include/sys/epoll.h: Add a very simple epoll layer just around poll calls. To satisfy build app requirements. From Anton D. Kachalov. + * drivers/mtd/ramtron.c: Update to include supportf for newer + RAMTRON parts. From David Sidrane. + diff --git a/drivers/mtd/ramtron.c b/drivers/mtd/ramtron.c index 215c13f7b21..b800d0f27cf 100644 --- a/drivers/mtd/ramtron.c +++ b/drivers/mtd/ramtron.c @@ -176,6 +176,14 @@ static const struct ramtron_parts_s g_ramtron_parts[] = 2, /* addr_len */ RAMTRON_INIT_CLK_MAX /* speed */ }, + { + "FM25V01A", /* name */ + 0x21, /* id1 */ + 0x08, /* id2 */ + 16L*1024L, /* size */ + 2, /* addr_len */ + RAMTRON_INIT_CLK_MAX /* speed */ + }, { "FM25V02", /* name */ 0x22, /* id1 */ @@ -184,6 +192,14 @@ static const struct ramtron_parts_s g_ramtron_parts[] = 2, /* addr_len */ RAMTRON_INIT_CLK_MAX /* speed */ }, + { + "FM25V02A", /* name */ + 0x22, /* id1 */ + 0x08, /* id2 */ + 32L*1024L, /* size */ + 2, /* addr_len */ + RAMTRON_INIT_CLK_MAX /* speed */ + }, { "FM25VN02", /* name */ 0x22, /* id1 */ @@ -224,6 +240,22 @@ static const struct ramtron_parts_s g_ramtron_parts[] = 3, /* addr_len */ RAMTRON_INIT_CLK_MAX /* speed */ }, + { + "FM25V20A", /* name */ + 0x25, /* id1 */ + 0x08, /* id2 */ + 256L*1024L, /* size */ + 3, /* addr_len */ + RAMTRON_INIT_CLK_MAX /* speed */ + }, + { + "CY15B104Q", /* name */ + 0x26, /* id1 */ + 0x08, /* id2 */ + 512L*1024L, /* size */ + 3, /* addr_len */ + RAMTRON_INIT_CLK_MAX /* speed */ + }, { "MB85RS1MT", /* name */ 0x27, /* id1 */