Skip to content

Commit a592d09

Browse files
committed
EVL: WIP
1 parent 840872b commit a592d09

3 files changed

Lines changed: 40 additions & 4 deletions

File tree

src/rtapi/uspace_common.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,20 @@ static int detect_rtai() {
381381
}
382382
#endif
383383
#ifdef USPACE_XENOMAI
384+
static int detect_xenomai_evl() {
385+
struct utsname u;
386+
uname(&u);
387+
return strcasestr (u.release, "-xenomai4") != 0; //ToDo: This is not nice
388+
}
384389
static int detect_xenomai() {
385390
struct utsname u;
386391
uname(&u);
387-
return strcasestr (u.release, "-xenomai") != 0;
392+
return strcasestr (u.release, "-xenomai3") != 0; //ToDo: This is not nice
388393
}
389394
#else
395+
static int detect_xenomai_evl() {
396+
return 0;
397+
}
390398
static int detect_xenomai() {
391399
return 0;
392400
}

src/rtapi/uspace_rtapi_app.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,10 @@ static RtapiApp *makeApp()
855855
}
856856
WithRoot r;
857857
void *dll = nullptr;
858-
if(detect_xenomai()) {
858+
if(detect_xenomai_evl()) {
859+
dll = dlopen(EMC2_HOME "/lib/libuspace-xenomai-evl.so.0", RTLD_NOW);
860+
if(!dll) fprintf(stderr, "dlopen: %s\n", dlerror());
861+
}else if(detect_xenomai()) {
859862
dll = dlopen(EMC2_HOME "/lib/libuspace-xenomai.so.0", RTLD_NOW);
860863
if(!dll) fprintf(stderr, "dlopen: %s\n", dlerror());
861864
} else if(detect_rtai()) {

src/rtapi/uspace_xenomai_evl.cc

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
#include "config.h"
22
#include "rtapi.h"
33
#include "rtapi_uspace.hh"
4+
5+
#include <sched.h>
6+
7+
#include <evl/thread.h>
8+
#include <evl/timer.h>
9+
#include <evl/clock.h>
10+
#include <evl/proxy.h>
11+
12+
#include <error.h> //ToDo: Remove
13+
414
#include <pthread.h>
5-
#include <errno.h>
15+
#include <errno.h>
616
#include <stdio.h>
717
#include <cstring>
818
#ifdef HAVE_SYS_IO_H
@@ -57,6 +67,10 @@ struct XenomaiApp : RtapiApp {
5767
int nprocs = sysconf( _SC_NPROCESSORS_ONLN );
5868
CPU_SET(nprocs-1, &cpuset); // assumes processor numbers are contiguous
5969

70+
fprintf(stderr,
71+
"Start. getuid()=%d geteuid()=%d\n",
72+
getuid(), geteuid());
73+
6074
int ret;
6175
pthread_attr_t attr;
6276
if((ret = pthread_attr_init(&attr)) != 0)
@@ -82,6 +96,17 @@ struct XenomaiApp : RtapiApp {
8296
auto task = reinterpret_cast<RtaiTask*>(arg);
8397
pthread_setspecific(key, arg);
8498

99+
fprintf(stderr,
100+
"Wrapper. getuid()=%d geteuid()=%d\n",
101+
getuid(), geteuid());
102+
103+
/* Attach to the core. */
104+
rtapi_print("linuxcnc-thread:%d\n", gettid());
105+
int tfd = evl_attach_self("linuxcnc-thread:%d", gettid());
106+
if (tfd < 0){
107+
rtapi_print("evl_attach_self() failed ret %i errno %i\n", tfd, errno);
108+
}
109+
85110
struct timespec now;
86111
clock_gettime(CLOCK_MONOTONIC, &now);
87112

@@ -194,6 +219,6 @@ pthread_key_t XenomaiApp::key;
194219
extern "C" RtapiApp *make();
195220

196221
RtapiApp *make() {
197-
rtapi_print_msg(RTAPI_MSG_ERR, "Note: Using XENOMAI (posix-skin) realtime\n");
222+
rtapi_print_msg(RTAPI_MSG_ERR, "Note: Using XENOMAI4 EVL (posix-skin) realtime\n");
198223
return new XenomaiApp;
199224
}

0 commit comments

Comments
 (0)