Use mmap handler in Xenomai3
This commit is contained in:
parent
e76109c854
commit
1dae91d8c3
|
|
@ -745,6 +745,7 @@ else
|
|||
xeno_rtdm_ldflags=`$xenomaidir/bin/xeno-config --skin rtdm --auto-init-solib --ldflags`
|
||||
xeno_v3=1
|
||||
xeno=0
|
||||
AC_DEFINE([EC_RTDM_OPS_HAS_MMAP], [1], [RTDM device operations has mmap handler])
|
||||
else
|
||||
xeno_native_cflags=`$xenomaidir/bin/xeno-config --skin native --cflags`
|
||||
xeno_native_ldflags=`$xenomaidir/bin/xeno-config --skin native --ldflags`
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ endif
|
|||
if ENABLE_XENOMAI_V3
|
||||
libethercat_rtdm_la_CFLAGS += $(XENOMAI_RTDM_CFLAGS)
|
||||
libethercat_rtdm_la_LDFLAGS += $(XENOMAI_RTDM_LDFLAGS)
|
||||
libethercat_rtdm_la_CFLAGS += -DUSE_RTDM_XENOMAI_V3
|
||||
libethercat_rtdm_la_CFLAGS += -DUSE_RTDM_XENOMAI_V3 -DEC_RTDM_OPS_HAS_MMAP
|
||||
else
|
||||
libethercat_rtdm_la_CFLAGS += -DUSE_RTDM
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ int ecrt_master_activate(ec_master_t *master)
|
|||
master->process_data_size = io.process_data_size;
|
||||
|
||||
if (master->process_data_size) {
|
||||
#if defined(USE_RTDM) || defined(USE_RTDM_XENOMAI_V3)
|
||||
#if defined(USE_RTDM) || !defined(EC_RTDM_OPS_HAS_MMAP)
|
||||
/* memory-mapping was already done in kernel. The user-space addess is
|
||||
* provided in the ioctl data.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1893,7 +1893,7 @@ static ATTRIBUTES int ec_ioctl_activate(
|
|||
offset += ecrt_domain_size(domain);
|
||||
}
|
||||
|
||||
#ifdef EC_IOCTL_RTDM
|
||||
#if defined(EC_IOCTL_RTDM) && !defined(EC_RTDM_OPS_HAS_MMAP)
|
||||
/* RTDM uses a different approach for memory-mapping, which has to be
|
||||
* initiated by the kernel.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -845,7 +845,10 @@ long ec_ioctl(ec_master_t *, ec_ioctl_context_t *, unsigned int,
|
|||
|
||||
long ec_ioctl_rtdm(ec_master_t *, ec_ioctl_context_t *, unsigned int,
|
||||
void __user *);
|
||||
|
||||
#ifndef EC_RTDM_OPS_HAS_MMAP
|
||||
int ec_rtdm_mmap(ec_ioctl_context_t *, void **);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -273,6 +273,12 @@ static int ec_rtdm_ioctl(struct rtdm_fd *fd, unsigned int request,
|
|||
return ec_ioctl_rtdm(rtdm_dev->master, &ctx->ioctl_ctx, request, arg);
|
||||
}
|
||||
|
||||
static int ec_rtdm_mmap(struct rtdm_fd *fd, struct vm_area_struct *vma)
|
||||
{
|
||||
struct ec_rtdm_context *ctx = (struct ec_rtdm_context *) rtdm_fd_to_private(fd);
|
||||
return rtdm_mmap_kmem(vma, (void *)ctx->ioctl_ctx.process_data);
|
||||
}
|
||||
|
||||
static struct rtdm_driver ec_rtdm_driver = {
|
||||
.profile_info = RTDM_PROFILE_INFO(ec_rtdm,
|
||||
RTDM_CLASS_EXPERIMENTAL,
|
||||
|
|
@ -286,6 +292,7 @@ static struct rtdm_driver ec_rtdm_driver = {
|
|||
.close = ec_rtdm_close,
|
||||
.ioctl_rt = ec_rtdm_ioctl_rt,
|
||||
.ioctl_nrt = ec_rtdm_ioctl,
|
||||
.mmap = ec_rtdm_mmap,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -331,20 +338,3 @@ void ec_rtdm_dev_clear(ec_rtdm_dev_t *rtdm_dev)
|
|||
|
||||
kfree(rtdm_dev->dev);
|
||||
}
|
||||
|
||||
int ec_rtdm_mmap(ec_ioctl_context_t *ioctl_ctx, void **user_address)
|
||||
{
|
||||
struct ec_rtdm_context *ctx =
|
||||
container_of(ioctl_ctx, struct ec_rtdm_context, ioctl_ctx);
|
||||
int ret;
|
||||
|
||||
ret = rtdm_mmap_to_user(ctx->fd,
|
||||
ioctl_ctx->process_data, ioctl_ctx->process_data_size,
|
||||
PROT_READ | PROT_WRITE,
|
||||
user_address,
|
||||
NULL, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue