Commit 0b96f187 authored by Jan Kiszka's avatar Jan Kiszka

First dovetail hacks

Lays the ground for the real hacks. Boots but fails to initialize a lot
of things, thus does not run anything relevant yet.

Oh, and completely ignores I-pipe.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent fd535e9b
......@@ -19,8 +19,8 @@
#ifndef _COBALT_KERNEL_APC_H
#define _COBALT_KERNEL_APC_H
#include <linux/ipipe.h>
#include <asm/xenomai/machine.h>
//#include <linux/ipipe.h>
//#include <asm/xenomai/machine.h>
/**
* @addtogroup cobalt_core_apc
......@@ -35,10 +35,10 @@ void xnapc_free(int apc);
static inline void __xnapc_schedule(int apc)
{
unsigned long *p = &raw_cpu_ptr(&cobalt_machine_cpudata)->apc_pending;
/* unsigned long *p = &raw_cpu_ptr(&cobalt_machine_cpudata)->apc_pending;
if (!__test_and_set_bit(apc, p))
ipipe_post_irq_root(cobalt_pipeline.apc_virq);
ipipe_post_irq_root(cobalt_pipeline.apc_virq);*/
}
/**
......@@ -65,11 +65,11 @@ static inline void __xnapc_schedule(int apc)
*/
static inline void xnapc_schedule(int apc)
{
unsigned long flags;
/* unsigned long flags;
flags = ipipe_test_and_stall_head() & 1;
__xnapc_schedule(apc);
ipipe_restore_head(flags);
ipipe_restore_head(flags);*/
}
void apc_dispatch(unsigned int virq, void *arg);
......
......@@ -57,10 +57,10 @@
do { } while (0)
#endif
#define primary_mode_only() XENO_BUG_ON(CONTEXT, ipipe_root_p)
#define secondary_mode_only() XENO_BUG_ON(CONTEXT, !ipipe_root_p)
#define primary_mode_only() XENO_BUG_ON(CONTEXT, running_inband())
#define secondary_mode_only() XENO_BUG_ON(CONTEXT, running_oob())
#define interrupt_only() XENO_BUG_ON(CONTEXT, !xnsched_interrupt_p())
#define realtime_cpu_only() XENO_BUG_ON(CONTEXT, !xnsched_supported_cpu(ipipe_processor_id()))
#define realtime_cpu_only() XENO_BUG_ON(CONTEXT, !xnsched_supported_cpu(raw_smp_processor_id()))
#define thread_only() XENO_BUG_ON(CONTEXT, xnsched_interrupt_p())
#define irqoff_only() XENO_BUG_ON(CONTEXT, hard_irqs_disabled() == 0)
#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
......
......@@ -19,7 +19,7 @@
#ifndef _COBALT_KERNEL_CLOCK_H
#define _COBALT_KERNEL_CLOCK_H
#include <linux/ipipe.h>
//#include <linux/ipipe.h>
#include <cobalt/kernel/list.h>
#include <cobalt/kernel/vfile.h>
#include <cobalt/uapi/kernel/types.h>
......@@ -52,7 +52,7 @@ struct xnclock {
xnticks_t (*read_raw)(struct xnclock *clock);
xnticks_t (*read_monotonic)(struct xnclock *clock);
int (*set_time)(struct xnclock *clock,
const struct timespec *ts);
const struct timespec64 *ts);
xnsticks_t (*ns_to_ticks)(struct xnclock *clock,
xnsticks_t ns);
xnsticks_t (*ticks_to_ns)(struct xnclock *clock,
......@@ -65,7 +65,7 @@ struct xnclock {
struct xnsched *sched);
#endif
int (*adjust_time)(struct xnclock *clock,
struct timex *tx);
struct __kernel_timex *tx);
int (*set_gravity)(struct xnclock *clock,
const struct xnclock_gravity *p);
void (*reset_gravity)(struct xnclock *clock);
......@@ -128,9 +128,10 @@ xnticks_t xnclock_core_read_monotonic(void);
static inline xnticks_t xnclock_core_read_raw(void)
{
unsigned long long t;
/* unsigned long long t;
ipipe_read_tsc(t);
return t;
return t;*/
return ktime_get();
}
/* We use the Linux defaults */
......@@ -213,7 +214,7 @@ static inline xnticks_t xnclock_read_monotonic(struct xnclock *clock)
}
static inline int xnclock_set_time(struct xnclock *clock,
const struct timespec *ts)
const struct timespec64 *ts)
{
if (likely(clock == &nkclock))
return -EINVAL;
......@@ -266,7 +267,7 @@ static inline xnticks_t xnclock_read_monotonic(struct xnclock *clock)
}
static inline int xnclock_set_time(struct xnclock *clock,
const struct timespec *ts)
const struct timespec64 *ts)
{
/*
* There is no way to change the core clock's idea of time.
......@@ -277,7 +278,7 @@ static inline int xnclock_set_time(struct xnclock *clock,
#endif /* !CONFIG_XENO_OPT_EXTCLOCK */
static inline int xnclock_adjust_time(struct xnclock *clock,
struct timex *tx)
struct __kernel_timex *tx)
{
if (clock->ops.adjust_time == NULL)
return -EOPNOTSUPP;
......
......@@ -20,7 +20,8 @@
#ifndef _COBALT_KERNEL_LOCK_H
#define _COBALT_KERNEL_LOCK_H
#include <linux/ipipe.h>
//#include <linux/ipipe.h>
#include <linux/dovetail.h>
#include <linux/percpu.h>
#include <cobalt/kernel/assert.h>
......@@ -36,32 +37,38 @@ typedef unsigned long spl_t;
*
* @param[out] x An unsigned long integer context variable
*/
#define splhigh(x) ((x) = ipipe_test_and_stall_head() & 1)
//#define splhigh(x) ((x) = ipipe_test_and_stall_head() & 1)
#define splhigh(x) ((x) = oob_irq_save())
#ifdef CONFIG_SMP
/**
* Restore the saved hard interrupt state on the local processor.
*
* @param[in] x The context variable previously updated by splhigh()
*/
#define splexit(x) ipipe_restore_head(x & 1)
//#define splexit(x) ipipe_restore_head(x & 1)
#define splexit(x) oob_irq_restore(x)
#else /* !CONFIG_SMP */
#define splexit(x) ipipe_restore_head(x)
//#define splexit(x) ipipe_restore_head(x)
#define splexit(x) oob_irq_restore(x)
#endif /* !CONFIG_SMP */
/**
* Hard disable interrupts on the local processor.
*/
#define splmax() ipipe_stall_head()
//#define splmax() ipipe_stall_head()
#define splmax() oob_irq_disable()
/**
* Hard enable interrupts on the local processor.
*/
#define splnone() ipipe_unstall_head()
//#define splnone() ipipe_unstall_head()
#define splnone() oob_irq_enable()
/**
* Test hard interrupt state on the local processor.
*
* @return Zero if the local processor currently accepts interrupts,
* non-zero otherwise.
*/
#define spltest() ipipe_test_head()
//#define spltest() ipipe_test_head()
#define spltest() oob_irqs_disabled()
#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
......@@ -175,7 +182,7 @@ static inline void xnlock_init (struct xnlock *lock)
static inline int ____xnlock_get(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS)
{
int cpu = ipipe_processor_id();
int cpu = raw_smp_processor_id();
unsigned long long start;
if (lock->owner == cpu)
......@@ -213,7 +220,7 @@ void ___xnlock_put(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
/* Disable UP-over-SMP kernel optimization in debug mode. */
#define __locking_active__ 1
#else
#define __locking_active__ ipipe_smp_p
#define __locking_active__ IS_ENABLED(CONFIG_SMP)
#endif
static inline spl_t
......@@ -242,7 +249,7 @@ static inline void __xnlock_put_irqrestore(struct xnlock *lock, spl_t flags
static inline int xnlock_is_owner(struct xnlock *lock)
{
if (__locking_active__)
return lock->owner == ipipe_processor_id();
return lock->owner == raw_smp_processor_id();
return 1;
}
......
......@@ -32,6 +32,7 @@
#include <linux/cdev.h>
#include <linux/wait.h>
#include <linux/notifier.h>
#include <linux/irq_work.h>
#include <xenomai/version.h>
#include <cobalt/kernel/heap.h>
#include <cobalt/kernel/sched.h>
......@@ -541,13 +542,13 @@ rtdm_execute_atomically(void) { }
/**
* Static lock initialisation
*/
#define RTDM_LOCK_UNLOCKED(__name) IPIPE_SPIN_LOCK_UNLOCKED
#define RTDM_LOCK_UNLOCKED(__name) __HARD_SPIN_LOCK_INITIALIZER(__name)
#define DEFINE_RTDM_LOCK(__name) \
rtdm_lock_t __name = RTDM_LOCK_UNLOCKED(__name)
/** Lock variable */
typedef ipipe_spinlock_t rtdm_lock_t;
typedef hard_spinlock_t rtdm_lock_t;
/** Variable to save the context while holding a lock */
typedef unsigned long rtdm_lockctx_t;
......@@ -606,7 +607,7 @@ static inline rtdm_lockctx_t __rtdm_lock_get_irqsave(rtdm_lock_t *lock)
{
rtdm_lockctx_t context;
context = ipipe_test_and_stall_head();
context = oob_irq_save();
raw_spin_lock(lock);
xnsched_lock();
......@@ -626,7 +627,7 @@ void rtdm_lock_put_irqrestore(rtdm_lock_t *lock, rtdm_lockctx_t context)
{
raw_spin_unlock(lock);
xnsched_unlock();
ipipe_restore_head(context);
oob_irq_restore(context);
}
/**
......@@ -898,19 +899,13 @@ typedef void (*rtdm_nrtsig_handler_t)(rtdm_nrtsig_t *nrt_sig, void *arg);
struct rtdm_nrtsig {
rtdm_nrtsig_handler_t handler;
void *arg;
struct irq_work irq_work;
};
void rtdm_schedule_nrt_work(struct work_struct *lostage_work);
/** @} rtdm_nrtsignal */
#ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
static inline void rtdm_nrtsig_init(rtdm_nrtsig_t *nrt_sig,
rtdm_nrtsig_handler_t handler, void *arg)
{
nrt_sig->handler = handler;
nrt_sig->arg = arg;
}
static inline void rtdm_nrtsig_destroy(rtdm_nrtsig_t *nrt_sig)
{
nrt_sig->handler = NULL;
......@@ -1315,7 +1310,7 @@ static inline int rtdm_rt_capable(struct rtdm_fd *fd)
static inline int rtdm_in_rt_context(void)
{
return (ipipe_current_domain != ipipe_root_domain);
return running_oob();
}
#define RTDM_IOV_FASTMAX 16
......
......@@ -380,7 +380,7 @@ int __rtdm_fd_recvmmsg(int ufd, void __user *u_msgvec, unsigned int vlen,
unsigned int flags, void __user *u_timeout,
int (*get_mmsg)(struct mmsghdr *mmsg, void __user *u_mmsg),
int (*put_mmsg)(void __user **u_mmsg_p, const struct mmsghdr *mmsg),
int (*get_timespec)(struct timespec *ts, const void __user *u_ts));
int (*get_timespec)(struct timespec64 *ts, const void __user *u_ts));
ssize_t rtdm_fd_sendmsg(int ufd, const struct user_msghdr *msg,
int flags);
......
......@@ -198,6 +198,8 @@ struct xnthread {
const char *exe_path; /* Executable path */
u32 proghash; /* Hash value for exe_path */
#endif
struct dovetail_altsched_context altsched;
};
static inline int xnthread_get_state(const struct xnthread *thread)
......@@ -372,7 +374,7 @@ void __xnthread_discard(struct xnthread *thread);
*/
static inline struct xnthread *xnthread_current(void)
{
return ipipe_current_threadinfo()->thread;
return dovetail_current_state()->thread;
}
/**
......@@ -388,7 +390,7 @@ static inline struct xnthread *xnthread_current(void)
*/
static inline struct xnthread *xnthread_from_task(struct task_struct *p)
{
return ipipe_task_threadinfo(p)->thread;
return dovetail_task_state(p)->thread;
}
/**
......
......@@ -502,6 +502,8 @@ static inline void xntimer_dequeue(struct xntimer *timer,
timer->status |= XNTIMER_DEQUEUED;
}
struct xnthread;
unsigned long long xntimer_get_overruns(struct xntimer *timer,
struct xnthread *waiter,
xnticks_t now);
......
......@@ -20,35 +20,35 @@
#define _COBALT_KERNEL_TRACE_H
#include <linux/types.h>
#include <linux/ipipe_trace.h>
//#include <linux/ipipe_trace.h>
#include <cobalt/uapi/kernel/trace.h>
static inline int xntrace_max_begin(unsigned long v)
{
ipipe_trace_begin(v);
//ipipe_trace_begin(v);
return 0;
}
static inline int xntrace_max_end(unsigned long v)
{
ipipe_trace_end(v);
//ipipe_trace_end(v);
return 0;
}
static inline int xntrace_max_reset(void)
{
ipipe_trace_max_reset();
//ipipe_trace_max_reset();
return 0;
}
static inline int xntrace_user_start(void)
{
return ipipe_trace_frozen_reset();
return /*ipipe_trace_frozen_reset()*/ 0;
}
static inline int xntrace_user_stop(unsigned long v)
{
ipipe_trace_freeze(v);
//ipipe_trace_freeze(v);
return 0;
}
......@@ -56,49 +56,49 @@ static inline int xntrace_user_freeze(unsigned long v, int once)
{
int ret = 0;
if (!once)
/* if (!once)
ret = ipipe_trace_frozen_reset();
ipipe_trace_freeze(v);
ipipe_trace_freeze(v);*/
return ret;
}
static inline int xntrace_special(unsigned char id, unsigned long v)
{
ipipe_trace_special(id, v);
// ipipe_trace_special(id, v);
return 0;
}
static inline int xntrace_special_u64(unsigned char id,
unsigned long long v)
{
ipipe_trace_special(id, (unsigned long)(v >> 32));
ipipe_trace_special(id, (unsigned long)(v & 0xFFFFFFFF));
// ipipe_trace_special(id, (unsigned long)(v >> 32));
// ipipe_trace_special(id, (unsigned long)(v & 0xFFFFFFFF));
return 0;
}
static inline int xntrace_pid(pid_t pid, short prio)
{
ipipe_trace_pid(pid, prio);
// ipipe_trace_pid(pid, prio);
return 0;
}
static inline int xntrace_tick(unsigned long delay_ticks)
{
ipipe_trace_event(0, delay_ticks);
// ipipe_trace_event(0, delay_ticks);
return 0;
}
static inline int xntrace_panic_freeze(void)
{
ipipe_trace_panic_freeze();
// ipipe_trace_panic_freeze();
return 0;
}
static inline int xntrace_panic_dump(void)
{
ipipe_trace_panic_dump();
// ipipe_trace_panic_dump();
return 0;
}
......
......@@ -31,15 +31,15 @@
struct __sched_ss_param {
int __sched_low_priority;
struct timespec __sched_repl_period;
struct timespec __sched_init_budget;
struct timespec64 __sched_repl_period;
struct timespec64 __sched_init_budget;
int __sched_max_repl;
};
#define sched_rr_quantum sched_u.rr.__sched_rr_quantum
struct __sched_rr_param {
struct timespec __sched_rr_quantum;
struct timespec64 __sched_rr_quantum;
};
#ifndef SCHED_TP
......@@ -52,8 +52,8 @@ struct __sched_tp_param {
};
struct sched_tp_window {
struct timespec offset;
struct timespec duration;
struct timespec64 offset;
struct timespec64 duration;
int ptid;
};
......
obj-$(CONFIG_XENOMAI) += xenomai.o rtdm/ posix/
xenomai-y := apc.o \
arith.o \
xenomai-y := arith.o \
bufd.o \
clock.o \
heap.o \
......
......@@ -30,7 +30,7 @@ static inline void xnarch_get_latencies(struct xnclock_gravity *p)
{
unsigned long sched_latency;
#if CONFIG_XENO_OPT_TIMING_SCHEDLAT != 0
#if CONFIG_XENO_OPT_TIMING_SCHEDLAT != 0 || 1
sched_latency = CONFIG_XENO_OPT_TIMING_SCHEDLAT;
#else /* !CONFIG_XENO_OPT_TIMING_SCHEDLAT */
......
......@@ -36,12 +36,13 @@ typedef union fpregs_state x86_fpustate;
struct xnarchtcb {
struct xntcb core;
/*
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
unsigned long sp;
unsigned long *spp;
unsigned long ip;
unsigned long *ipp;
#endif
#endif
#ifdef IPIPE_X86_FPU_EAGER
struct fpu *kfpu;
#else
......@@ -49,9 +50,15 @@ struct xnarchtcb {
unsigned int root_used_math: 1;
x86_fpustate *kfpu_state;
#endif
*/
unsigned int root_kfpu: 1;
};
struct xnarch_fault_data {
int exception;
struct pt_regs *regs;
};
#define xnarch_fpu_ptr(tcb) ((tcb)->fpup)
#define xnarch_fault_regs(d) ((d)->regs)
......@@ -66,8 +73,8 @@ struct xnarchtcb {
void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to);
int xnarch_handle_fpu_fault(struct xnthread *from,
struct xnthread *to, struct ipipe_trap_data *d);
/*int xnarch_handle_fpu_fault(struct xnthread *from,
struct xnthread *to, struct ipipe_trap_data *d);*/
void xnarch_leave_root(struct xnthread *root);
......@@ -81,10 +88,10 @@ static inline void xnarch_enter_root(struct xnthread *root) { }
static inline int xnarch_escalate(void)
{
if (ipipe_root_p) {
/* if (ipipe_root_p) {
ipipe_raise_irq(cobalt_pipeline.escalate_virq);
return 1;
}
}*/
return 0;
}
......
......@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <linux/ipipe_tickdev.h>
//#include <linux/ipipe_tickdev.h>
#include <cobalt/kernel/arith.h>
#include <asm/xenomai/syscall.h>
#include <asm/xenomai/machine.h>
......@@ -44,6 +44,7 @@ long strncpy_from_user_nocheck(char *dst, const char __user *src, long count)
}
EXPORT_SYMBOL_GPL(strncpy_from_user_nocheck);
#if 0
static unsigned long mach_x86_calibrate(void)
{
unsigned long delay = (cobalt_pipeline.timer_freq + HZ / 2) / HZ;
......@@ -77,6 +78,7 @@ static unsigned long mach_x86_calibrate(void)
*/
return xnarch_ulldiv(dt, i + 5, NULL);
}
#endif
static int mach_x86_init(void)
{
......@@ -128,7 +130,7 @@ struct cobalt_machine cobalt_machine = {
.init = mach_x86_init,
.late_init = NULL,
.cleanup = mach_x86_cleanup,
.calibrate = mach_x86_calibrate,
// .calibrate = mach_x86_calibrate,
.prefault = NULL,
.fault_labels = fault_labels,
};
......@@ -18,7 +18,7 @@
*/
#include <linux/percpu.h>
#include <linux/errno.h>
#include <linux/ipipe_tickdev.h>
//#include <linux/ipipe_tickdev.h>
#include <cobalt/kernel/sched.h>
#include <cobalt/kernel/timer.h>
#include <cobalt/kernel/clock.h>
......@@ -222,13 +222,21 @@ void xnclock_core_local_shot(struct xnsched *sched)
xntrace_tick((unsigned)delay);
#ifdef CONFIG_IPIPE
ipipe_timer_set(delay);
#else
#warning TODO
#endif
}
#ifdef CONFIG_SMP
void xnclock_core_remote_shot(struct xnsched *sched)
{
#ifdef CONFIG_IPIPE
ipipe_send_ipi(IPIPE_HRTIMER_IPI, *cpumask_of(xnsched_cpu(sched)));
#else
#warning TODO
#endif
}
#endif
......@@ -513,7 +521,7 @@ void print_core_clock_status(struct xnclock *clock,
#endif /* CONFIG_XENO_OPT_WATCHDOG */
xnvfile_printf(it, "%8s: timer=%s, clock=%s\n",
"devices", ipipe_timer_name(), ipipe_clock_name());
"devices", /*ipipe_timer_name()*/"?", /*ipipe_clock_name()*/"?");
xnvfile_printf(it, "%8s: %s\n", "watchdog", wd_status);
xnvfile_printf(it, "%8s: %Lu\n", "setup",
xnclock_ticks_to_ns(&nkclock, nktimerlat));
......@@ -890,7 +898,8 @@ void xnclock_cleanup(void)
int __init xnclock_init(unsigned long long freq)
{
xnclock_update_freq(freq);
nktimerlat = xnarch_timer_calibrate();
#warning TODO
nktimerlat = 0; //xnarch_timer_calibrate();
xnclock_reset_gravity(&nkclock);
xnclock_register(&nkclock, &xnsched_realtime_cpus);
......
......@@ -848,7 +848,7 @@ void *xnheap_vmalloc(size_t size)
* software on a 32bit system had to be wrong in the first
* place anyway.
*/
return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL);
return __vmalloc(size, GFP_KERNEL/*, PAGE_KERNEL*/);
}
EXPORT_SYMBOL_GPL(xnheap_vmalloc);
......
......@@ -19,7 +19,7 @@
#ifndef _COBALT_ASM_GENERIC_MACHINE_H
#define _COBALT_ASM_GENERIC_MACHINE_H
#include <linux/ipipe.h>
//#include <linux/ipipe.h>
#include <linux/percpu.h>
#include <asm/byteorder.h>
#include <asm/xenomai/wrappers.h>
......@@ -38,16 +38,16 @@ struct cobalt_machine {
extern struct cobalt_machine cobalt_machine;
struct cobalt_machine_cpudata {
/*struct cobalt_machine_cpudata {
unsigned long apc_pending;
unsigned long apc_shots[BITS_PER_LONG];
unsigned int faults[IPIPE_NR_FAULTS];
};
DECLARE_PER_CPU(struct cobalt_machine_cpudata, cobalt_machine_cpudata);
DECLARE_PER_CPU(struct cobalt_machine_cpudata, cobalt_machine_cpudata);*/
struct cobalt_pipeline {
struct ipipe_domain domain;
// struct ipipe_domain domain;
unsigned long timer_freq;
unsigned long clock_freq;
unsigned int apc_virq;
......
/**
* Copyright (C) 2012 Philippe Gerum <rpm@xenomai.org>.
* Copyright (c) Siemens AG, 2020
*
* Xenomai is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by