Use new RTDM's mmap, not anymore a special case compared to normal linux mmap.
--- a/lib/master.c Fri Sep 14 23:37:19 2018 +0200
+++ b/lib/master.c Thu Sep 27 00:21:27 2018 +0200
@@ -543,12 +543,6 @@
master->process_data_size = io.process_data_size;
if (master->process_data_size) {
-#ifdef USE_RTDM
- /* memory-mapping was already done in kernel. The user-space addess is
- * provided in the ioctl data.
- */
- master->process_data = io.process_data;
-#else
master->process_data = mmap(0, master->process_data_size,
PROT_READ | PROT_WRITE, MAP_SHARED, master->fd, 0);
if (master->process_data == MAP_FAILED) {
@@ -558,7 +552,6 @@
master->process_data_size = 0;
return -errno;
}
-#endif
// Access the mapped region to cause the initial page fault
master->process_data[0] = 0x00;
--- a/master/ioctl.c Fri Sep 14 23:37:19 2018 +0200
+++ b/master/ioctl.c Thu Sep 27 00:21:27 2018 +0200
@@ -1704,8 +1704,6 @@
if (unlikely(!ctx->requested))
return -EPERM;
- io.process_data = NULL;
-
/* Get the sum of the domains' process data sizes. */
ctx->process_data_size = 0;
@@ -1735,18 +1733,6 @@
ctx->process_data + offset);
offset += ecrt_domain_size(domain);
}
-
-#ifdef EC_IOCTL_RTDM
- /* RTDM uses a different approach for memory-mapping, which has to be
- * initiated by the kernel.
- */
- ret = ec_rtdm_mmap(ctx, &io.process_data);
- if (ret < 0) {
- EC_MASTER_ERR(master, "Failed to map process data"
- " memory to user space (code %i).\n", ret);
- return ret;
- }
-#endif
}
io.process_data_size = ctx->process_data_size;
--- a/master/ioctl.h Fri Sep 14 23:37:19 2018 +0200
+++ b/master/ioctl.h Thu Sep 27 00:21:27 2018 +0200
@@ -592,7 +592,6 @@
typedef struct {
// outputs
- void *process_data;
size_t process_data_size;
} ec_ioctl_master_activate_t;
@@ -774,7 +773,6 @@
long ec_ioctl_rtdm(ec_master_t *, ec_ioctl_context_t *, unsigned int,
void __user *);
-int ec_rtdm_mmap(ec_ioctl_context_t *, void **);
#endif
--- a/master/rtdm.c Fri Sep 14 23:37:19 2018 +0200
+++ b/master/rtdm.c Thu Sep 27 00:21:27 2018 +0200
@@ -51,6 +51,7 @@
void ec_rtdm_close(struct rtdm_fd *);
int ec_rtdm_ioctl(struct rtdm_fd *,
unsigned int, void __user *);
+int ec_rtdm_mmap(struct rtdm_fd *fd, struct vm_area_struct *vma);
/****************************************************************************/
@@ -66,7 +67,8 @@
.open = ec_rtdm_open,
.close = ec_rtdm_close,
.ioctl_rt = ec_rtdm_ioctl,
- .ioctl_nrt = ec_rtdm_ioctl
+ .ioctl_nrt = ec_rtdm_ioctl,
+ .mmap = ec_rtdm_mmap
},
};
@@ -211,25 +213,11 @@
/** Memory-map process data to user space.
*
- * \return Zero on success, otherwise a negative error code.
- */
-int ec_rtdm_mmap(
- ec_ioctl_context_t *ctx, /**< Context. */
- void **user_address /**< Userspace address. */
- )
-{
- int ret;
-
- ret = rtdm_mmap_to_user(rtdm_private_to_fd(ctx),
- ctx->process_data, ctx->process_data_size,
- PROT_READ | PROT_WRITE,
- user_address,
- NULL, NULL);
- if (ret < 0) {
- return ret;
- }
-
- return 0;
-}
-
-/****************************************************************************/
+ */
+int ec_rtdm_mmap(struct rtdm_fd *fd, struct vm_area_struct *vma)
+{
+ ec_ioctl_context_t *ctx = (ec_ioctl_context_t *) rtdm_fd_to_private(fd);
+ return rtdm_mmap_vmem(vma, (void *)ctx->process_data);
+}
+
+/****************************************************************************/