Move ec_rtdm_context into common header

This commit is contained in:
Bjarne von Horn 2024-01-31 10:21:06 +01:00
parent 0a41222ee6
commit 95209d2858
4 changed files with 60 additions and 14 deletions

View File

@ -60,6 +60,7 @@ noinst_HEADERS = \
reg_request.c reg_request.h \ reg_request.c reg_request.h \
rtdm-ioctl.c \ rtdm-ioctl.c \
rtdm.c rtdm.h \ rtdm.c rtdm.h \
rtdm_details.h \
rtdm_xenomai_v3.c \ rtdm_xenomai_v3.c \
sdo.c sdo.h \ sdo.c sdo.h \
sdo_entry.c sdo_entry.h \ sdo_entry.c sdo_entry.h \

View File

@ -33,6 +33,7 @@
#include "master.h" #include "master.h"
#include "ioctl.h" #include "ioctl.h"
#include "rtdm.h" #include "rtdm.h"
#include "rtdm_details.h"
/** Set to 1 to enable device operations debugging. /** Set to 1 to enable device operations debugging.
*/ */
@ -40,15 +41,6 @@
/****************************************************************************/ /****************************************************************************/
/** Context structure for an open RTDM file handle.
*/
typedef struct {
rtdm_user_info_t *user_fd; /**< RTDM user data. */
ec_ioctl_context_t ioctl_ctx; /**< Context structure. */
} ec_rtdm_context_t;
/****************************************************************************/
int ec_rtdm_open(struct rtdm_dev_context *, rtdm_user_info_t *, int); int ec_rtdm_open(struct rtdm_dev_context *, rtdm_user_info_t *, int);
int ec_rtdm_close(struct rtdm_dev_context *, rtdm_user_info_t *); int ec_rtdm_close(struct rtdm_dev_context *, rtdm_user_info_t *);
int ec_rtdm_ioctl(struct rtdm_dev_context *, rtdm_user_info_t *, int ec_rtdm_ioctl(struct rtdm_dev_context *, rtdm_user_info_t *,

57
master/rtdm_details.h Normal file
View File

@ -0,0 +1,57 @@
/*****************************************************************************
*
* Copyright (C) 2024 Bjarne von Horn <vh@igh.de>
*
* This file is part of the IgH EtherCAT master.
*
* The IgH EtherCAT master 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; version 2 of the License.
*
* The IgH EtherCAT master 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 the IgH EtherCAT master. If not, see <http://www.gnu.org/licenses/>.
*
* The license mentioned above concerns the source code only. Using the
* EtherCAT technology and brand is only permitted in compliance with the
* industrial property and similar rights of Beckhoff Automation GmbH.
*
****************************************************************************/
#ifndef __EC_RTDM_DETAILS_H__
#define __EC_RTDM_DETAILS_H__
#include "../config.h"
#include <linux/kernel.h>
#ifdef EC_RTDM_XENOMAI_V3
#include <rtdm/driver.h>
#define EC_RTDM_USERFD_T struct rtdm_fd
#else // EC_RTDM_XENOMAI_V3
#include <rtdm/rtdm_driver.h>
#define EC_RTDM_USERFD_T rtdm_user_info_t
#endif
/****************************************************************************/
/** Context structure for an open RTDM file handle.
*/
typedef struct ec_rtdm_context {
EC_RTDM_USERFD_T *user_fd; /**< RTDM user data. */
ec_ioctl_context_t ioctl_ctx; /**< Context structure. */
} ec_rtdm_context_t;
/****************************************************************************/
#endif // __EC_RTDM_DETAILS_H__

View File

@ -37,16 +37,12 @@
#include "master.h" #include "master.h"
#include "ioctl.h" #include "ioctl.h"
#include "rtdm.h" #include "rtdm.h"
#include "rtdm_details.h"
/** Set to 1 to enable device operations debugging. /** Set to 1 to enable device operations debugging.
*/ */
#define DEBUG_RTDM 0 #define DEBUG_RTDM 0
struct ec_rtdm_context {
struct rtdm_fd *user_fd;
ec_ioctl_context_t ioctl_ctx; /**< Context structure. */
};
static int ec_rtdm_open(struct rtdm_fd *fd, int oflags) static int ec_rtdm_open(struct rtdm_fd *fd, int oflags)
{ {
struct ec_rtdm_context *ctx = rtdm_fd_to_private(fd); struct ec_rtdm_context *ctx = rtdm_fd_to_private(fd);