hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * SPDX-License-Identifier: GPL-2.0
 */
 
#ifndef _COBALT_KERNEL_DOVETAIL_PIPELINE_H
#define _COBALT_KERNEL_DOVETAIL_PIPELINE_H
 
#include <linux/irq_pipeline.h>
#include <linux/cpumask.h>
#include <cobalt/kernel/assert.h>
#include <asm/xenomai/features.h>
#include <asm/xenomai/syscall.h>
#include <asm/syscall.h>
#include <pipeline/machine.h>
 
typedef unsigned long spl_t;
 
/*
 * We only keep the LSB when testing in SMP mode in order to strip off
 * the recursion marker (0x2) the nklock may store there.
 */
#define splhigh(x)  ((x) = oob_irq_save() & 1)
#ifdef CONFIG_SMP
#define splexit(x)  oob_irq_restore(x & 1)
#else /* !CONFIG_SMP */
#define splexit(x)  oob_irq_restore(x)
#endif /* !CONFIG_SMP */
#define splmax()    oob_irq_disable()
#define splnone()   oob_irq_enable()
#define spltest()   oob_irqs_disabled()
 
#define is_secondary_domain()    running_inband()
#define is_primary_domain()    running_oob()
 
#ifdef CONFIG_SMP
 
irqreturn_t pipeline_reschedule_ipi_handler(int irq, void *dev_id);
 
static inline int pipeline_request_resched_ipi(void (*handler)(void))
{
   if (num_possible_cpus() == 1)
       return 0;
 
   /* Trap the out-of-band rescheduling interrupt. */
   return __request_percpu_irq(RESCHEDULE_OOB_IPI,
           pipeline_reschedule_ipi_handler,
           IRQF_OOB,
           "Xenomai reschedule",
           &cobalt_machine_cpudata);
}
 
static inline void pipeline_free_resched_ipi(void)
{
   if (num_possible_cpus() > 1)
       /* Release the out-of-band rescheduling interrupt. */
       free_percpu_irq(RESCHEDULE_OOB_IPI, &cobalt_machine_cpudata);
}
 
static inline void pipeline_send_resched_ipi(const struct cpumask *dest)
{
   /*
    * Trigger the out-of-band rescheduling interrupt on remote
    * CPU(s).
    */
   irq_send_oob_ipi(RESCHEDULE_OOB_IPI, dest);
}
 
static inline void pipeline_send_timer_ipi(const struct cpumask *dest)
{
   /*
    * Trigger the out-of-band timer interrupt on remote CPU(s).
    */
   irq_send_oob_ipi(TIMER_OOB_IPI, dest);
}
 
#else  /* !CONFIG_SMP */
 
static inline int pipeline_request_resched_ipi(void (*handler)(void))
{
   return 0;
}
 
 
static inline void pipeline_free_resched_ipi(void)
{
}
 
#endif    /* CONFIG_SMP */
 
static inline void pipeline_prepare_panic(void)
{
   /* N/A */
}
 
static inline void pipeline_collect_features(struct cobalt_featinfo *f)
{
   f->clock_freq = 0;    /* N/A */
}
 
#ifndef pipeline_get_syscall_args
static inline void pipeline_get_syscall_args(struct task_struct *task,
                        struct pt_regs *regs,
                        unsigned long *args)
{
   syscall_get_arguments(task, regs, args);
}
#endif    /* !pipeline_get_syscall_args */
 
#endif /* !_COBALT_KERNEL_DOVETAIL_PIPELINE_H */