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
|
// SPDX-License-Identifier: BSD-2-Clause
/*
* Copyright (c) 2016, Linaro Limited
* All rights reserved.
*/
#include <kernel/interrupt.h>
#include <trace.h>
/*
* NOTE!
*
* We're assuming that there's no concurrent use of this interface, except
* delivery of interrupts in parallel. Synchronization will be needed when
* we begin to modify settings after boot initialization.
*/
static struct itr_chip *itr_chip;
static SLIST_HEAD(, itr_handler) handlers = SLIST_HEAD_INITIALIZER(handlers);
void itr_init(struct itr_chip *chip)
{
itr_chip = chip;
}
static struct itr_handler *find_handler(size_t it)
{
struct itr_handler *h;
SLIST_FOREACH(h, &handlers, link)
if (h->it == it)
return h;
return NULL;
}
void itr_handle(size_t it)
{
struct itr_handler *h = find_handler(it);
if (!h) {
EMSG("Disabling unhandled interrupt %zu", it);
itr_chip->ops->disable(itr_chip, it);
return;
}
if (h->handler(h) != ITRR_HANDLED) {
EMSG("Disabling interrupt %zu not handled by handler", it);
itr_chip->ops->disable(itr_chip, it);
}
}
void itr_add(struct itr_handler *h)
{
itr_chip->ops->add(itr_chip, h->it, h->flags);
SLIST_INSERT_HEAD(&handlers, h, link);
}
void itr_enable(size_t it)
{
itr_chip->ops->enable(itr_chip, it);
}
void itr_disable(size_t it)
{
itr_chip->ops->disable(itr_chip, it);
}
void itr_raise_pi(size_t it)
{
itr_chip->ops->raise_pi(itr_chip, it);
}
void itr_raise_sgi(size_t it, uint8_t cpu_mask)
{
itr_chip->ops->raise_sgi(itr_chip, it, cpu_mask);
}
void itr_set_affinity(size_t it, uint8_t cpu_mask)
{
itr_chip->ops->set_affinity(itr_chip, it, cpu_mask);
}
|