Commit f518a3ca authored by Philippe Gerum's avatar Philippe Gerum
Browse files

all: convert to ABI enabling compat syscall support



These changes fix up the argument passed to the core system calls in
order to abide by the new ABI allowing 32bit applications to issue
requests to 64bit kernels.
Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <rpm@xenomai.org>
parent c6116e33
......@@ -419,11 +419,11 @@ static void *timer_test_sitter(void *arg)
if (ret < 0)
error(1, -ret, "evl_attach_self() failed");
mr.last = &last;
mr.histogram = histogram;
mr.last_ptr = (__u64)(uintptr_t)&last;
mr.histogram_ptr = (__u64)(uintptr_t)histogram;
mr.len = histogram ? histogram_cells * sizeof(int32_t) : 0;
result.data = &mr;
result.data_ptr = (__u64)(uintptr_t)&mr;
result.len = sizeof(mr);
/* Run test until signal. */
......@@ -873,7 +873,7 @@ static void do_tuning(int type)
pthread_sigmask(SIG_UNBLOCK, &sigmask, NULL);
result.data = &gravity;
result.data_ptr = (__u64)(uintptr_t)&gravity;
result.len = sizeof(gravity);
ret = oob_ioctl(latmus_fd, EVL_LATIOC_RUN, &result);
if (ret)
......
......@@ -11,12 +11,14 @@ uapi: $(O_UAPI)
$(O_UAPI): $(O_DIR)/.uapi_stamp
@test -d $(UAPI)/ || (echo "make: UAPI: $(UAPI) does not look right" && exit 1)
$(Q)$(MKDIR_P) $(O_UAPI)
$(Q)$(RM) -f $(O_UAPI)/asm $(O_UAPI)/evl
$(Q)$(RM) -f $(O_UAPI)/asm $(O_UAPI)/asm-generic $(O_UAPI)/evl
$(Q)if test -r $(UAPI)/Kbuild; then \
$(LN_S) $(UAPI)/arch/$(ARCH)/include/uapi/asm $(O_UAPI)/asm; \
$(LN_S) $(UAPI)/include/uapi/asm-generic $(O_UAPI)/asm-generic; \
$(LN_S) $(UAPI)/include/uapi/evl $(O_UAPI)/evl; \
elif test \! -L $(O_UAPI)/asm; then \
$(LN_S) $(UAPI)/asm $(O_UAPI)/asm; \
$(LN_S) $(UAPI)/asm-generic $(O_UAPI)/asm-generic; \
$(LN_S) $(UAPI)/evl $(O_UAPI)/evl; \
fi
......
......@@ -22,7 +22,7 @@
#define __EVL__ 10 /* API version */
#define EVL_ABI_PREREQ 19
#define EVL_ABI_PREREQ 20
struct evl_version {
int api_level; /* libevl.so: __EVL__ */
......
/*
* SPDX-License-Identifier: MIT
*
* Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org>
* Copyright (C) 2018-2020 Philippe Gerum <rpm@xenomai.org>
*/
#ifndef _LIB_EVL_ARM_SYSCALL_H
#define _LIB_EVL_ARM_SYSCALL_H
#include <uapi/asm/dovetail.h>
#include <uapi/asm-generic/dovetail.h>
#define evl_syscall3(__nr, __a0, __a1, __a2) \
#define evl_syscall3(__nr, __a0, __a1, __a2) \
({ \
register unsigned long __asc __asm__("r7"); \
register unsigned long __sc __asm__("r7"); \
register unsigned long __res __asm__("r0"); \
register unsigned long __sc __asm__("r0"); \
register unsigned long __r0 __asm__("r0"); \
register unsigned long __r1 __asm__("r1"); \
register unsigned long __r2 __asm__("r2"); \
register unsigned long __r3 __asm__("r3"); \
__asc = __ARM_NR_dovetail; \
__sc = (unsigned int)(__nr); \
__r1 = (unsigned long)(__a0); \
__r2 = (unsigned long)(__a1); \
__r3 = (unsigned long)(__a2); \
__sc = (unsigned long)(__nr)|__OOB_SYSCALL_BIT; \
__r0 = (unsigned long)(__a0); \
__r1 = (unsigned long)(__a1); \
__r2 = (unsigned long)(__a2); \
__asm__ __volatile__ ( \
"swi #0;\n\t" \
: "=r" (__res) \
: "r" (__asc), "r" (__sc), \
"r" (__r1), "r" (__r2), "r" (__r3) \
: "r" (__sc), \
"r" (__r0), "r" (__r1), "r" (__r2) \
: "cc", "memory"); \
__res; \
})
......
/*
* SPDX-License-Identifier: MIT
*
* Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org>
* Copyright (C) 2018-2020 Philippe Gerum <rpm@xenomai.org>
*/
#ifndef _LIB_EVL_ARM64_SYSCALL_H
#define _LIB_EVL_ARM64_SYSCALL_H
#include <uapi/asm/evl/syscall.h>
#include <uapi/asm-generic/dovetail.h>
#define evl_syscall3(__nr, __a0, __a1, __a2) \
#define evl_syscall3(__nr, __a0, __a1, __a2) \
({ \
register unsigned int __sc __asm__("w8"); \
register unsigned long __res __asm__("x0"); \
register unsigned long __x0 __asm__("x0"); \
register unsigned long __x1 __asm__("x1"); \
register unsigned long __x2 __asm__("x2"); \
__sc = (unsigned int)((__nr)|__EVL_SYSCALL_BIT); \
__sc = (unsigned int)((__nr)|__OOB_SYSCALL_BIT); \
__x0 = (unsigned long)(__a0); \
__x1 = (unsigned long)(__a1); \
__x2 = (unsigned long)(__a2); \
......
......@@ -7,7 +7,7 @@
#ifndef _LIB_EVL_X86_SYSCALL_H
#define _LIB_EVL_X86_SYSCALL_H
#include <uapi/asm/evl/syscall.h>
#include <uapi/asm-generic/dovetail.h>
#define evl_syscall3(__nr, __a0, __a1, __a2) \
({ \
......@@ -18,7 +18,7 @@
__asm__ __volatile__ ( \
"syscall;\n\t" \
: "=a" (__res) \
: "0" ((__nr)|__EVL_SYSCALL_BIT), \
: "0" ((__nr)|__OOB_SYSCALL_BIT), \
"r" (_a0), "r" (_a1), "r" (_a2) \
: "cc", "memory", "r11", "cx"); \
(int)__res; \
......
......@@ -215,7 +215,7 @@ int evl_timedwait_event(struct evl_event *evt,
return ret;
req.gatefd = mutex->u.active.efd;
req.timeout = __evl_ktimespec(timeout, kts);
req.timeout_ptr = __evl_ktimespec_ptr64(timeout, kts);
req.status = -EINVAL;
req.value = 0; /* dummy */
unwait.ureq.gatefd = req.gatefd;
......
......@@ -187,7 +187,7 @@ int evl_timedwait_flags(struct evl_flags *flg,
}
req.gatefd = -1;
req.timeout = __evl_ktimespec(timeout, kts);
req.timeout_ptr = __evl_ktimespec_ptr64(timeout, kts);
req.status = -EINVAL;
req.value = 0;
......
......@@ -58,8 +58,8 @@ int create_evl_element(const char *type, const char *name,
goto out_factory;
}
clone.name = name;
clone.attrs = attrs;
clone.name_ptr = __evl_ptr64(name);
clone.attrs_ptr = __evl_ptr64(attrs);
ret = ioctl(ffd, EVL_IOC_CLONE, &clone);
if (ret) {
ret = -errno;
......
......@@ -13,6 +13,8 @@
#include <evl/thread.h>
#include <uapi/evl/types.h>
#define __evl_ptr64(__ptr) ((__u64)(uintptr_t)(__ptr))
#if __WORDSIZE == 64 || __TIMESIZE == 64
/*
* If timespec is y2038-safe, we don't need to bounce via an
......@@ -66,6 +68,12 @@
})
#endif
#define __evl_ktimespec_ptr64(__ts, __kts) \
__evl_ptr64(__evl_ktimespec(__ts, __kts))
#define __evl_kitimerspec_ptr64(__its, __kits) \
__evl_ptr64(__evl_kitimerspec(__its, __kits))
extern __thread __attribute__ ((tls_model (EVL_TLS_MODEL)))
fundle_t evl_current;
......
......@@ -53,8 +53,8 @@ static int do_poll(int efd, struct evl_poll_event *pollset,
struct __evl_timespec kts;
int ret;
wreq.timeout = __evl_ktimespec(timeout, kts);
wreq.pollset = pollset;
wreq.timeout_ptr = __evl_ktimespec_ptr64(timeout, kts);
wreq.pollset_ptr = __evl_ptr64(pollset);
wreq.nrset = nrset;
ret = oob_ioctl(efd, EVL_POLIOC_WAIT, &wreq);
if (ret)
......
......@@ -45,8 +45,8 @@ int evl_sched_control(int policy,
ctlreq.policy = policy;
ctlreq.cpu = cpu;
ctlreq.param = param;
ctlreq.info = info;
ctlreq.param_ptr = __evl_ptr64(param);
ctlreq.info_ptr = __evl_ptr64(info);
return do_call(evl_ctlfd, EVL_CTLIOC_SCHEDCTL, &ctlreq);
}
......@@ -61,7 +61,7 @@ int evl_get_cpustate(int cpu, int *state_r)
return -ENXIO;
cpst.cpu = cpu;
cpst.state = &state;
cpst.state_ptr = __evl_ptr64(&state);
ret = do_call(evl_ctlfd, EVL_CTLIOC_GET_CPUSTATE, &cpst);
if (ret)
......
......@@ -190,7 +190,7 @@ int evl_timedget_sem(struct evl_sem *sem, const struct timespec *timeout)
return ret;
req.gatefd = -1;
req.timeout = __evl_ktimespec(timeout, kts);
req.timeout_ptr = __evl_ktimespec_ptr64(timeout, kts);
req.status = -EINVAL;
req.value = 0; /* dummy */
......
......@@ -47,8 +47,8 @@ int evl_set_timer(int efd,
struct __evl_itimerspec kits, koits;
struct evl_timerfd_setreq sreq;
sreq.value = __evl_kitimerspec(value, kits);
sreq.ovalue = __evl_kitimerspec(ovalue, koits);
sreq.value_ptr = __evl_kitimerspec_ptr64(value, kits);
sreq.ovalue_ptr = __evl_kitimerspec_ptr64(ovalue, koits);
return do_call(efd, EVL_TFDIOC_SET, &sreq);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment