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
/*
 * SPDX-License-Identifier: GPL-2.0
 *
 * Copyright (C) 2020 Philippe Gerum  <rpm@xenomai.org>
 */
 
#ifndef _COBALT_KERNEL_IPIPE_SIRQ_H
#define _COBALT_KERNEL_IPIPE_SIRQ_H
 
#include <linux/ipipe.h>
#include <pipeline/machine.h>
 
/*
 * Wrappers to create "synthetic IRQs" the I-pipe way (used to be
 * called "virtual IRQs" there). Those interrupt channels can only be
 * triggered by software; they have per-CPU semantics. We use them to
 * schedule handlers to be run on the in-band execution stage, meaning
 * "secondary mode" in the Cobalt jargon.
 */
 
static inline
int pipeline_create_inband_sirq(irqreturn_t (*handler)(int irq, void *dev_id))
{
   int sirq, ret;
 
   sirq = ipipe_alloc_virq();
   if (sirq == 0)
       return -EAGAIN;
 
   /*
    * ipipe_irq_handler_t is close enough to the signature of a
    * regular IRQ handler: use the latter in the generic code
    * shared with Dovetail.  The extraneous return code will be
    * ignored by the I-pipe core.
    */
   ret = ipipe_request_irq(ipipe_root_domain, sirq,
               (ipipe_irq_handler_t)handler,
               NULL, NULL);
   if (ret) {
       ipipe_free_virq(sirq);
       return ret;
   }
 
   return sirq;
}
 
static inline
void pipeline_delete_inband_sirq(int sirq)
{
   ipipe_free_irq(ipipe_root_domain, sirq);
   ipipe_free_virq(sirq);
}
 
static inline void pipeline_post_sirq(int sirq)
{
   ipipe_post_irq_root(sirq);
}
 
#endif /* !_COBALT_KERNEL_IPIPE_SIRQ_H */