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
/*
 * SPDX-License-Identifier: GPL-2.0
 *
 * Copyright (C) 2020 Philippe Gerum  <rpm@xenomai.org>
 */
 
#ifndef _COBALT_KERNEL_DOVETAIL_SIRQ_H
#define _COBALT_KERNEL_DOVETAIL_SIRQ_H
 
#include <linux/irq_pipeline.h>
#include <cobalt/kernel/assert.h>
 
/*
 * Wrappers to create "synthetic IRQs" the Dovetail way. Those
 * interrupt channels can only be trigged by software, in order to run
 * a handler on the in-band execution stage.
 */
 
static inline
int pipeline_create_inband_sirq(irqreturn_t (*handler)(int irq, void *dev_id))
{
   /*
    * Allocate an IRQ from the synthetic interrupt domain then
    * trap it to @handler, to be fired from the in-band stage.
    */
   int sirq, ret;
 
   sirq = irq_create_direct_mapping(synthetic_irq_domain);
   if (sirq == 0)
       return -EAGAIN;
 
   ret = __request_percpu_irq(sirq,
           handler,
           IRQF_NO_THREAD,
           "Inband sirq",
           &cobalt_machine_cpudata);
 
   if (ret) {
       irq_dispose_mapping(sirq);
       return ret;
   }
 
   return sirq;
}
 
static inline
void pipeline_delete_inband_sirq(int sirq)
{
   /*
    * Free the synthetic IRQ then deallocate it to its
    * originating domain.
    */
   free_percpu_irq(sirq,
       &cobalt_machine_cpudata);
 
   irq_dispose_mapping(sirq);
}
 
static inline void pipeline_post_sirq(int sirq)
{
   /* Trigger the synthetic IRQ */
   irq_post_inband(sirq);
}
 
#endif /* !_COBALT_KERNEL_DOVETAIL_SIRQ_H */