[Xenomai-git] Gilles Chanteperdrix : cobalt/fd: add common fd implementation
Module: xenomai-gch Branch: for-forge Commit: 102c0f95bb7f70806e3c020a03d793cbbed931a1 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=102c0f95bb7f70806e3c020a03d793cbbed931a1 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Mon Dec 23 21:03:04 2013 +0100 cobalt/fd: add common fd implementation --- include/cobalt/kernel/fd.h| 186 ++ include/cobalt/kernel/ppd.h |3 +- include/cobalt/uapi/syscall.h |6 + kernel/cobalt/Makefile|1 + kernel/cobalt/fd.c| 533 + kernel/cobalt/init.c |3 + kernel/cobalt/posix/Makefile |1 + kernel/cobalt/posix/fdio.c| 74 ++ kernel/cobalt/posix/fdio.h| 35 +++ kernel/cobalt/posix/select.c |9 + kernel/cobalt/posix/syscall.c |7 + kernel/cobalt/shadow.c|3 + lib/cobalt/rtdm.c | 57 - 13 files changed, 907 insertions(+), 11 deletions(-) diff --git a/include/cobalt/kernel/fd.h b/include/cobalt/kernel/fd.h new file mode 100644 index 000..c2282d3 --- /dev/null +++ b/include/cobalt/kernel/fd.h @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2005-2007 Jan Kiszka jan.kis...@web.de + * Copyright (C) 2005 Joerg Langenberg joerg.langenb...@gmx.net + * Copyright (C) 2008,2013,2014 Gilles Chanteperdrix g...@xenomai.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _COBALT_KERNEL_FD_H +#define _COBALT_KERNEL_FD_H + +#include linux/types.h +#include linux/socket.h +#include cobalt/kernel/tree.h + +struct xnfd; +struct xnselector; +struct xnsys_ppd; + +/** + * IOCTL handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] request Request number as passed by the user + * @param[in,out] arg Request argument as passed by the user + * + * @return A positive value or 0 on success. On failure return either + * -ENOSYS, to request that the function be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c ioctl() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef int xnfd_ioctl_t(struct xnfd *fd, unsigned int request, void __user *arg); + +/** + * Read handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[out] buf Input buffer as passed by the user + * @param[in] size Number of bytes the user requests to read + * + * @return On success, the number of bytes read. On failure return either + * -ENOSYS, to request that this handler be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c read() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_read_t(struct xnfd *fd, void __user *buf, size_t size); + +/** + * Write handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] buf Output buffer as passed by the user + * @param[in] size Number of bytes the user requests to write + * + * @return On success, the number of bytes written. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c write() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_write_t(struct xnfd *fd, const void __user *buf, size_t size); + +/** + * Receive message handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in,out] msg Message descriptor as passed by the user, automatically + * mirrored to safe kernel memory in case of user mode call + * @param[in] flags Message flags as passed by the user + * + * @return On success, the number of bytes received. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c recvmsg() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_recvmsg_t(struct xnfd *fd, struct msghdr *msg, int flags); + +/** + * Transmit message handler + * + * @param[in] fd File descriptor
[Xenomai-git] Gilles Chanteperdrix : cobalt/fd: add common fd implementation
Module: xenomai-gch Branch: for-forge Commit: 0c2d552f45d3b1a5688129f515c489d04b9881e8 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=0c2d552f45d3b1a5688129f515c489d04b9881e8 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Mon Dec 23 21:03:04 2013 +0100 cobalt/fd: add common fd implementation --- include/cobalt/kernel/fd.h| 186 ++ include/cobalt/kernel/ppd.h |3 +- include/cobalt/uapi/syscall.h |6 + kernel/cobalt/Makefile|1 + kernel/cobalt/fd.c| 533 + kernel/cobalt/init.c |3 + kernel/cobalt/posix/Makefile |1 + kernel/cobalt/posix/fdio.c| 74 ++ kernel/cobalt/posix/fdio.h| 35 +++ kernel/cobalt/posix/select.c |9 + kernel/cobalt/posix/syscall.c |7 + kernel/cobalt/shadow.c|3 + lib/cobalt/rtdm.c | 57 - 13 files changed, 907 insertions(+), 11 deletions(-) diff --git a/include/cobalt/kernel/fd.h b/include/cobalt/kernel/fd.h new file mode 100644 index 000..c2282d3 --- /dev/null +++ b/include/cobalt/kernel/fd.h @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2005-2007 Jan Kiszka jan.kis...@web.de + * Copyright (C) 2005 Joerg Langenberg joerg.langenb...@gmx.net + * Copyright (C) 2008,2013,2014 Gilles Chanteperdrix g...@xenomai.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _COBALT_KERNEL_FD_H +#define _COBALT_KERNEL_FD_H + +#include linux/types.h +#include linux/socket.h +#include cobalt/kernel/tree.h + +struct xnfd; +struct xnselector; +struct xnsys_ppd; + +/** + * IOCTL handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] request Request number as passed by the user + * @param[in,out] arg Request argument as passed by the user + * + * @return A positive value or 0 on success. On failure return either + * -ENOSYS, to request that the function be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c ioctl() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef int xnfd_ioctl_t(struct xnfd *fd, unsigned int request, void __user *arg); + +/** + * Read handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[out] buf Input buffer as passed by the user + * @param[in] size Number of bytes the user requests to read + * + * @return On success, the number of bytes read. On failure return either + * -ENOSYS, to request that this handler be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c read() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_read_t(struct xnfd *fd, void __user *buf, size_t size); + +/** + * Write handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] buf Output buffer as passed by the user + * @param[in] size Number of bytes the user requests to write + * + * @return On success, the number of bytes written. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c write() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_write_t(struct xnfd *fd, const void __user *buf, size_t size); + +/** + * Receive message handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in,out] msg Message descriptor as passed by the user, automatically + * mirrored to safe kernel memory in case of user mode call + * @param[in] flags Message flags as passed by the user + * + * @return On success, the number of bytes received. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c recvmsg() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_recvmsg_t(struct xnfd *fd, struct msghdr *msg, int flags); + +/** + * Transmit message handler + * + * @param[in] fd File descriptor
[Xenomai-git] Gilles Chanteperdrix : cobalt/fd: add common fd implementation
Module: xenomai-gch Branch: for-forge Commit: 2014a5b1a4bd7b2907222aaacd01d1270dd7a23e URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=2014a5b1a4bd7b2907222aaacd01d1270dd7a23e Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Mon Dec 23 21:03:04 2013 +0100 cobalt/fd: add common fd implementation --- include/cobalt/kernel/fd.h| 186 +++ include/cobalt/kernel/ppd.h |3 +- include/cobalt/uapi/syscall.h |6 + kernel/cobalt/Makefile|1 + kernel/cobalt/fd.c| 527 + kernel/cobalt/init.c |3 + kernel/cobalt/posix/Makefile |1 + kernel/cobalt/posix/fdio.c| 74 ++ kernel/cobalt/posix/fdio.h| 35 +++ kernel/cobalt/posix/select.c |9 + kernel/cobalt/posix/syscall.c |7 + kernel/cobalt/shadow.c|3 + lib/cobalt/rtdm.c | 57 - 13 files changed, 901 insertions(+), 11 deletions(-) diff --git a/include/cobalt/kernel/fd.h b/include/cobalt/kernel/fd.h new file mode 100644 index 000..ab99efb --- /dev/null +++ b/include/cobalt/kernel/fd.h @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2005-2007 Jan Kiszka jan.kis...@web.de + * Copyright (C) 2005 Joerg Langenberg joerg.langenb...@gmx.net + * Copyright (C) 2008,2013,2014 Gilles Chanteperdrix g...@xenomai.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _COBALT_KERNEL_FD_H +#define _COBALT_KERNEL_FD_H + +#include linux/types.h +#include linux/socket.h +#include cobalt/kernel/tree.h + +struct xnfd; +struct xnselector; +struct xnsys_ppd; + +/** + * IOCTL handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] request Request number as passed by the user + * @param[in,out] arg Request argument as passed by the user + * + * @return A positive value or 0 on success. On failure return either + * -ENOSYS, to request that the function be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c ioctl() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef int xnfd_ioctl_t(struct xnfd *fd, unsigned int request, void __user *arg); + +/** + * Read handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[out] buf Input buffer as passed by the user + * @param[in] size Number of bytes the user requests to read + * + * @return On success, the number of bytes read. On failure return either + * -ENOSYS, to request that this handler be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c read() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_read_t(struct xnfd *fd, void __user *buf, size_t size); + +/** + * Write handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] buf Output buffer as passed by the user + * @param[in] size Number of bytes the user requests to write + * + * @return On success, the number of bytes written. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c write() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_write_t(struct xnfd *fd, const void __user *buf, size_t size); + +/** + * Receive message handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in,out] msg Message descriptor as passed by the user, automatically + * mirrored to safe kernel memory in case of user mode call + * @param[in] flags Message flags as passed by the user + * + * @return On success, the number of bytes received. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c recvmsg() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_recvmsg_t(struct xnfd *fd, struct msghdr *msg, int flags); + +/** + * Transmit message handler + * + * @param[in] fd File
[Xenomai-git] Gilles Chanteperdrix : cobalt/fd: add common fd implementation
Module: xenomai-gch Branch: for-forge Commit: e44ed21a6c6d2a5c510d775a7c308f7e1046c13b URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=e44ed21a6c6d2a5c510d775a7c308f7e1046c13b Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Mon Dec 23 21:03:04 2013 +0100 cobalt/fd: add common fd implementation --- include/cobalt/kernel/fd.h| 186 +++ include/cobalt/kernel/ppd.h |3 +- include/cobalt/uapi/syscall.h |6 + kernel/cobalt/Makefile|1 + kernel/cobalt/fd.c| 527 + kernel/cobalt/init.c |3 + kernel/cobalt/posix/Makefile |1 + kernel/cobalt/posix/fdio.c| 74 ++ kernel/cobalt/posix/fdio.h| 35 +++ kernel/cobalt/posix/select.c |9 + kernel/cobalt/posix/syscall.c |7 + kernel/cobalt/shadow.c|3 + lib/cobalt/rtdm.c | 57 - 13 files changed, 901 insertions(+), 11 deletions(-) diff --git a/include/cobalt/kernel/fd.h b/include/cobalt/kernel/fd.h new file mode 100644 index 000..ab99efb --- /dev/null +++ b/include/cobalt/kernel/fd.h @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2005-2007 Jan Kiszka jan.kis...@web.de + * Copyright (C) 2005 Joerg Langenberg joerg.langenb...@gmx.net + * Copyright (C) 2008,2013,2014 Gilles Chanteperdrix g...@xenomai.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _COBALT_KERNEL_FD_H +#define _COBALT_KERNEL_FD_H + +#include linux/types.h +#include linux/socket.h +#include cobalt/kernel/tree.h + +struct xnfd; +struct xnselector; +struct xnsys_ppd; + +/** + * IOCTL handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] request Request number as passed by the user + * @param[in,out] arg Request argument as passed by the user + * + * @return A positive value or 0 on success. On failure return either + * -ENOSYS, to request that the function be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c ioctl() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef int xnfd_ioctl_t(struct xnfd *fd, unsigned int request, void __user *arg); + +/** + * Read handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[out] buf Input buffer as passed by the user + * @param[in] size Number of bytes the user requests to read + * + * @return On success, the number of bytes read. On failure return either + * -ENOSYS, to request that this handler be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c read() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_read_t(struct xnfd *fd, void __user *buf, size_t size); + +/** + * Write handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] buf Output buffer as passed by the user + * @param[in] size Number of bytes the user requests to write + * + * @return On success, the number of bytes written. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c write() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_write_t(struct xnfd *fd, const void __user *buf, size_t size); + +/** + * Receive message handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in,out] msg Message descriptor as passed by the user, automatically + * mirrored to safe kernel memory in case of user mode call + * @param[in] flags Message flags as passed by the user + * + * @return On success, the number of bytes received. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c recvmsg() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_recvmsg_t(struct xnfd *fd, struct msghdr *msg, int flags); + +/** + * Transmit message handler + * + * @param[in] fd File
[Xenomai-git] Gilles Chanteperdrix : cobalt/fd: add common fd implementation
Module: xenomai-gch Branch: for-forge Commit: e635caff115bdc9b47cdd044c8efda82bf8c27e8 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=e635caff115bdc9b47cdd044c8efda82bf8c27e8 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Mon Dec 23 21:03:04 2013 +0100 cobalt/fd: add common fd implementation --- include/cobalt/kernel/fd.h| 184 include/cobalt/kernel/ppd.h |3 +- include/cobalt/uapi/syscall.h |6 + kernel/cobalt/Makefile|1 + kernel/cobalt/fd.c| 461 + kernel/cobalt/init.c |1 + kernel/cobalt/posix/Makefile |1 + kernel/cobalt/posix/fdio.c| 55 + kernel/cobalt/posix/fdio.h| 16 ++ kernel/cobalt/posix/select.c |9 + kernel/cobalt/posix/syscall.c |7 + kernel/cobalt/shadow.c|3 + lib/cobalt/rtdm.c | 57 - 13 files changed, 793 insertions(+), 11 deletions(-) diff --git a/include/cobalt/kernel/fd.h b/include/cobalt/kernel/fd.h new file mode 100644 index 000..757b548 --- /dev/null +++ b/include/cobalt/kernel/fd.h @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2005-2007 Jan Kiszka jan.kis...@web.de + * Copyright (C) 2005 Joerg Langenberg joerg.langenb...@gmx.net + * Copyright (C) 2008,2013,2014 Gilles Chanteperdrix g...@xenomai.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _COBALT_KERNEL_FD_H +#define _COBALT_KERNEL_FD_H + +#include linux/types.h +#include linux/socket.h +#include cobalt/kernel/tree.h + +struct xnfd; +struct xnselector; +struct xnsys_ppd; + +/** + * IOCTL handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] request Request number as passed by the user + * @param[in,out] arg Request argument as passed by the user + * + * @return A positive value or 0 on success. On failure return either + * -ENOSYS, to request that the function be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c ioctl() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef int xnfd_ioctl_t(struct xnfd *fd, unsigned int request, void __user *arg); + +/** + * Read handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[out] buf Input buffer as passed by the user + * @param[in] size Number of bytes the user requests to read + * + * @return On success, the number of bytes read. On failure return either + * -ENOSYS, to request that this handler be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c read() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_read_t(struct xnfd *fd, void __user *buf, size_t size); + +/** + * Write handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] buf Output buffer as passed by the user + * @param[in] size Number of bytes the user requests to write + * + * @return On success, the number of bytes written. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c write() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_write_t(struct xnfd *fd, const void __user *buf, size_t size); + +/** + * Receive message handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in,out] msg Message descriptor as passed by the user, automatically + * mirrored to safe kernel memory in case of user mode call + * @param[in] flags Message flags as passed by the user + * + * @return On success, the number of bytes received. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c recvmsg() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_recvmsg_t(struct xnfd *fd, struct msghdr *msg, int flags); + +/** + * Transmit message handler + * + * @param[in] fd File descriptor
[Xenomai-git] Gilles Chanteperdrix : cobalt/fd: add common fd implementation
Module: xenomai-gch Branch: for-forge Commit: ae842401995867d85783a010240cb4d762350b08 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=ae842401995867d85783a010240cb4d762350b08 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Mon Dec 23 21:03:04 2013 +0100 cobalt/fd: add common fd implementation --- include/cobalt/kernel/fd.h| 189 +++ include/cobalt/kernel/ppd.h |3 +- include/cobalt/uapi/syscall.h |6 + kernel/cobalt/Makefile|1 + kernel/cobalt/fd.c| 508 + kernel/cobalt/init.c |3 + kernel/cobalt/posix/Makefile |1 + kernel/cobalt/posix/fdio.c| 74 ++ kernel/cobalt/posix/fdio.h| 35 +++ kernel/cobalt/posix/select.c |9 + kernel/cobalt/posix/syscall.c |7 + kernel/cobalt/shadow.c|3 + lib/cobalt/rtdm.c | 57 - 13 files changed, 885 insertions(+), 11 deletions(-) diff --git a/include/cobalt/kernel/fd.h b/include/cobalt/kernel/fd.h new file mode 100644 index 000..f12a19f --- /dev/null +++ b/include/cobalt/kernel/fd.h @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2005-2007 Jan Kiszka jan.kis...@web.de + * Copyright (C) 2005 Joerg Langenberg joerg.langenb...@gmx.net + * Copyright (C) 2008,2013,2014 Gilles Chanteperdrix g...@xenomai.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _COBALT_KERNEL_FD_H +#define _COBALT_KERNEL_FD_H + +#include linux/types.h +#include linux/socket.h +#include cobalt/kernel/tree.h + +struct xnfd; +struct xnselector; +struct xnsys_ppd; + +/** + * IOCTL handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] request Request number as passed by the user + * @param[in,out] arg Request argument as passed by the user + * + * @return A positive value or 0 on success. On failure return either + * -ENOSYS, to request that the function be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c ioctl() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef int xnfd_ioctl_t(struct xnfd *fd, unsigned int request, void __user *arg); + +/** + * Read handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[out] buf Input buffer as passed by the user + * @param[in] size Number of bytes the user requests to read + * + * @return On success, the number of bytes read. On failure return either + * -ENOSYS, to request that this handler be called again from the opposite + * realtime/non-realtime context, or another negative error code. + * + * @see @c read() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_read_t(struct xnfd *fd, void __user *buf, size_t size); + +/** + * Write handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in] buf Output buffer as passed by the user + * @param[in] size Number of bytes the user requests to write + * + * @return On success, the number of bytes written. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c write() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_write_t(struct xnfd *fd, const void __user *buf, size_t size); + +/** + * Receive message handler + * + * @param[in] fd File descriptor structure associated with opened device instance + * @param[in,out] msg Message descriptor as passed by the user, automatically + * mirrored to safe kernel memory in case of user mode call + * @param[in] flags Message flags as passed by the user + * + * @return On success, the number of bytes received. On failure return + * either -ENOSYS, to request that this handler be called again from the + * opposite realtime/non-realtime context, or another negative error code. + * + * @see @c recvmsg() in IEEE Std 1003.1, + * http://www.opengroup.org/onlinepubs/009695399 + */ +typedef ssize_t xnfd_recvmsg_t(struct xnfd *fd, struct msghdr *msg, int flags); + +/** + * Transmit message handler + * + * @param[in] fd File
[Xenomai-git] Gilles Chanteperdrix : cobalt/fd: add common fd implementation
Module: xenomai-gch Branch: for-forge Commit: a1d38c06eec107ec0ba62fc78a48c8cc7d3a5e68 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=a1d38c06eec107ec0ba62fc78a48c8cc7d3a5e68 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Mon Dec 23 21:03:04 2013 +0100 cobalt/fd: add common fd implementation --- include/cobalt/kernel/fd.h | 67 include/cobalt/kernel/ppd.h |1 + kernel/cobalt/Makefile |1 + kernel/cobalt/fd.c | 230 ++ kernel/cobalt/init.c |9 +- kernel/cobalt/posix/select.c |9 ++ kernel/cobalt/shadow.c |3 + 7 files changed, 319 insertions(+), 1 deletion(-) diff --git a/include/cobalt/kernel/fd.h b/include/cobalt/kernel/fd.h new file mode 100644 index 000..54ef678 --- /dev/null +++ b/include/cobalt/kernel/fd.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2013 Gilles Chanteperdrix gilles.chanteperd...@xenomai.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _COBALT_KERNEL_FD_H +#define _COBALT_KERNEL_FD_H + +struct xnfd; +struct xnselector; +struct xnsys_ppd; + +struct xnfd_ops { + void (*destroy)(struct xnfd *fd); + int (*select_bind)(struct xnfd *fd, struct xnselector *selector, + unsigned type, unsigned index); +}; + +struct xnfd { + unsigned magic; + struct mm_struct *mm; + int ufd; + struct xnfd_ops *ops; + unsigned refs; + struct hlist_node hlink; /* Link in global hash */ + struct list_head link; /* Link in per-process queue */ +}; + +int xnfd_enter(struct xnfd *xnfd, unsigned magic, int ufd, + struct xnsys_ppd *p, struct xnfd_ops *ops); + +struct xnfd *xnfd_get(int ufd, struct mm_struct *mm, unsigned magic); + +int xnfd_put(struct xnfd *xnfd); + +int xnfd_close(int ufd, struct mm_struct *mm, unsigned magic); + +static inline int xnfd_getfd(struct xnfd *xnfd) +{ + return xnfd-ufd; +} + +int xnfd_valid_p(int ufd, struct mm_struct *mm); + +int xnfd_select_bind(int ufd, struct mm_struct *mm, + struct xnselector *selector, unsigned type); + +void xnfd_cleanup(struct xnsys_ppd *p); + +int xnfd_mount(void); + +void xnfd_umount(void); + +#endif /* _COBALT_KERNEL_FD_H */ diff --git a/include/cobalt/kernel/ppd.h b/include/cobalt/kernel/ppd.h index 05e32b3..367f3e0 100644 --- a/include/cobalt/kernel/ppd.h +++ b/include/cobalt/kernel/ppd.h @@ -49,6 +49,7 @@ struct xnsys_ppd { unsigned long mayday_addr; atomic_t refcnt; char *exe_path; + struct list_head fds; }; extern struct xnsys_ppd __xnsys_global_ppd; diff --git a/kernel/cobalt/Makefile b/kernel/cobalt/Makefile index 7e65f10..e5e3355 100644 --- a/kernel/cobalt/Makefile +++ b/kernel/cobalt/Makefile @@ -5,6 +5,7 @@ xenomai-y :=apc.o \ assert.o\ bufd.o \ clock.o \ + fd.o\ heap.o \ init.o \ intr.o \ diff --git a/kernel/cobalt/fd.c b/kernel/cobalt/fd.c new file mode 100644 index 000..19d4569 --- /dev/null +++ b/kernel/cobalt/fd.c @@ -0,0 +1,230 @@ +/* + * Copyright (C) 2013 Gilles Chanteperdrix gilles.chanteperd...@xenomai.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include linux/list.h +#include linux/err.h +#include linux/slab.h +#include linux/mm.h +#include cobalt/kernel/registry.h +#include cobalt/kernel/lock.h +#include cobalt/kernel/fd.h +#include cobalt/kernel/ppd.h + +static struct hlist_head