2014-10-04 23:59:44 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* include/aio.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
*
|
|
|
|
* 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_AIO_H
|
|
|
|
#define __INCLUDE_AIO_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2014-10-05 04:22:00 +08:00
|
|
|
#include <nuttx/wqueue.h>
|
|
|
|
|
2014-10-04 23:59:44 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
2014-10-05 04:22:00 +08:00
|
|
|
/* Configuration ************************************************************/
|
2014-10-05 20:02:37 +08:00
|
|
|
/* These interfaces are not available to kernel code */
|
|
|
|
|
|
|
|
#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && defined(__KERNEL__)
|
2014-10-06 05:44:43 +08:00
|
|
|
# undef CONFIG_FS_AIO
|
2014-10-05 20:02:37 +08:00
|
|
|
#endif
|
|
|
|
|
2014-10-06 05:33:31 +08:00
|
|
|
/* Work queue support is required. The low-priority work queue is required
|
|
|
|
* so that the asynchronous I/O does not interfere with high priority driver
|
|
|
|
* operations. If this pre-requisite is met, then asynchronous I/O support
|
2014-10-06 05:44:43 +08:00
|
|
|
* can be enabled with CONFIG_FS_AIO
|
2014-10-05 04:22:00 +08:00
|
|
|
*/
|
|
|
|
|
2014-10-06 05:44:43 +08:00
|
|
|
#ifdef CONFIG_FS_AIO
|
2014-10-05 04:22:00 +08:00
|
|
|
|
|
|
|
#ifndef CONFIG_SCHED_WORKQUEUE
|
2014-10-05 20:02:37 +08:00
|
|
|
# error Asynchronous I/O requires CONFIG_SCHED_WORKQUEUE
|
2014-10-06 05:33:31 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_SCHED_LPWORK
|
|
|
|
# error Asynchronous I/O requires CONFIG_SCHED_LPWORK
|
2014-10-05 04:22:00 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Standard Definitions *****************************************************/
|
2014-10-04 23:59:44 +08:00
|
|
|
/* aio_cancel return values
|
|
|
|
*
|
|
|
|
* AIO_ALLDONE - Indicates that none of the requested operations could
|
|
|
|
* be cancelled since they are already complete.
|
|
|
|
* AIO_CANCELED - Indicates that all requested operations have been
|
|
|
|
* cancelled.
|
|
|
|
* AIO_NOTCANCELED - Indicates that some of the requested operations could
|
|
|
|
* not be cancelled since they are in progress.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define AIO_CANCELED 0
|
|
|
|
#define AIO_ALLDONE 1
|
|
|
|
#define AIO_NOTCANCELED 2
|
|
|
|
|
|
|
|
/* lio_listio element operations
|
|
|
|
*
|
|
|
|
* LIO_NOP - Indicates that no transfer is requested.
|
|
|
|
* LIO_READ - Requests a read operation.
|
|
|
|
* LIO_WRITE - Requests a write operation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LIO_NOP 0
|
|
|
|
#define LIO_READ 1
|
|
|
|
#define LIO_WRITE 2
|
|
|
|
|
|
|
|
/* lio_listio modes
|
|
|
|
*
|
|
|
|
* LIO_NOWAIT - Indicates that the calling thread is to continue
|
|
|
|
* execution while the lio_listio() operation is being
|
|
|
|
* performed, and no notification is given when the
|
|
|
|
* operation is complete.
|
|
|
|
* LIO_WAIT - Indicates that the calling thread is to suspend until
|
|
|
|
* the lio_listio() operation is complete.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LIO_NOWAIT 0
|
|
|
|
#define LIO_WAIT 1
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct aiocb
|
|
|
|
{
|
2014-10-05 04:22:00 +08:00
|
|
|
/* Standard fields required by POSIX */
|
|
|
|
|
2014-10-04 23:59:44 +08:00
|
|
|
struct sigevent aio_sigevent; /* Signal number and value */
|
|
|
|
FAR volatile void *aio_buf; /* Location of buffer */
|
|
|
|
off_t aio_offset; /* File offset */
|
|
|
|
size_t aio_nbytes; /* Length of transfer */
|
2014-10-11 22:15:23 +08:00
|
|
|
#if (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS) > 127
|
2014-10-07 22:36:53 +08:00
|
|
|
int16_t aio_fildes; /* File descriptor (should be int) */
|
2014-10-09 22:34:49 +08:00
|
|
|
#else
|
|
|
|
int8_t aio_fildes; /* File descriptor (should be int) */
|
|
|
|
#endif
|
2014-10-07 22:36:53 +08:00
|
|
|
int8_t aio_reqprio; /* Request priority offset (not used, should be int) */
|
|
|
|
uint8_t aio_lio_opcode; /* Operation to be performed (should be int) */
|
2014-10-05 04:22:00 +08:00
|
|
|
|
2014-10-05 20:53:56 +08:00
|
|
|
/* Non-standard, implementation-dependent data. For portability reasons,
|
|
|
|
* application code should never reference these elements.
|
|
|
|
*/
|
2014-10-05 04:22:00 +08:00
|
|
|
|
2014-10-05 07:30:24 +08:00
|
|
|
volatile ssize_t aio_result; /* Support for aio_error() and aio_return() */
|
2014-10-06 01:43:42 +08:00
|
|
|
FAR void *aio_priv; /* Used by signal handlers */
|
2014-10-04 23:59:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-10-05 22:22:39 +08:00
|
|
|
int aio_cancel(int fildes, FAR struct aiocb *aiocbp);
|
2014-10-04 23:59:44 +08:00
|
|
|
int aio_error(FAR const struct aiocb *aiocbp);
|
2014-10-05 22:53:13 +08:00
|
|
|
int aio_fsync(int op, FAR struct aiocb *aiocbp);
|
2014-10-04 23:59:44 +08:00
|
|
|
int aio_read(FAR struct aiocb *aiocbp);
|
|
|
|
ssize_t aio_return(FAR struct aiocb *aiocbp);
|
|
|
|
int aio_suspend(FAR const struct aiocb *const list[], int nent,
|
|
|
|
FAR const struct timespec *timeout);
|
|
|
|
int aio_write(FAR struct aiocb *aiocbp);
|
|
|
|
int lio_listio(int mode, FAR struct aiocb *const list[], int nent,
|
|
|
|
FAR struct sigevent *sig);
|
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-10-06 05:44:43 +08:00
|
|
|
#endif /* CONFIG_FS_AIO */
|
2014-10-04 23:59:44 +08:00
|
|
|
#endif /* __INCLUDE_AIO_H */
|