genirq/irq_sim: Add a simple interrupt simulator framework
[linux-block.git] / include / linux / irq_sim.h
CommitLineData
b19af510
BG
1#ifndef _LINUX_IRQ_SIM_H
2#define _LINUX_IRQ_SIM_H
3/*
4 * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/irq_work.h>
13
14/*
15 * Provides a framework for allocating simulated interrupts which can be
16 * requested like normal irqs and enqueued from process context.
17 */
18
19struct irq_sim_work_ctx {
20 struct irq_work work;
21 int irq;
22};
23
24struct irq_sim_irq_ctx {
25 int irqnum;
26 bool enabled;
27};
28
29struct irq_sim {
30 struct irq_sim_work_ctx work_ctx;
31 int irq_base;
32 unsigned int irq_count;
33 struct irq_sim_irq_ctx *irqs;
34};
35
36int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs);
37void irq_sim_fini(struct irq_sim *sim);
38void irq_sim_fire(struct irq_sim *sim, unsigned int offset);
39int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset);
40
41#endif /* _LINUX_IRQ_SIM_H */