
Back in 2016, we discussed[1] rules for headers, and these were generally liked: 1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h. 2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header. 3. Cyclic inclusion is forbidden. This patch gets include/ closer to obeying 2. It's actually extracted from my "[RFC] Baby steps towards saner headers" series[2], which demonstrates a possible path towards checking 2 automatically. It passes the RFC test there. [1] Message-ID: <87h9g8j57d.fsf@blackfin.pond.sub.org> https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03345.html [2] Message-Id: <20190711122827.18970-1-armbru@redhat.com> https://lists.nongnu.org/archive/html/qemu-devel/2019-07/msg02715.html Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20190812052359.30071-2-armbru@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
83 lines
2.2 KiB
C
83 lines
2.2 KiB
C
#ifndef SH_INTC_H
|
|
#define SH_INTC_H
|
|
|
|
#include "exec/memory.h"
|
|
#include "hw/irq.h"
|
|
|
|
typedef unsigned char intc_enum;
|
|
|
|
struct intc_vect {
|
|
intc_enum enum_id;
|
|
unsigned short vect;
|
|
};
|
|
|
|
#define INTC_VECT(enum_id, vect) { enum_id, vect }
|
|
|
|
struct intc_group {
|
|
intc_enum enum_id;
|
|
intc_enum enum_ids[32];
|
|
};
|
|
|
|
#define INTC_GROUP(enum_id, ...) { enum_id, { __VA_ARGS__ } }
|
|
|
|
struct intc_mask_reg {
|
|
unsigned long set_reg, clr_reg, reg_width;
|
|
intc_enum enum_ids[32];
|
|
unsigned long value;
|
|
};
|
|
|
|
struct intc_prio_reg {
|
|
unsigned long set_reg, clr_reg, reg_width, field_width;
|
|
intc_enum enum_ids[16];
|
|
unsigned long value;
|
|
};
|
|
|
|
#define _INTC_ARRAY(a) a, ARRAY_SIZE(a)
|
|
|
|
struct intc_source {
|
|
unsigned short vect;
|
|
intc_enum next_enum_id;
|
|
|
|
int asserted; /* emulates the interrupt signal line from device to intc */
|
|
int enable_count;
|
|
int enable_max;
|
|
int pending; /* emulates the result of signal and masking */
|
|
struct intc_desc *parent;
|
|
};
|
|
|
|
struct intc_desc {
|
|
MemoryRegion iomem;
|
|
MemoryRegion *iomem_aliases;
|
|
qemu_irq *irqs;
|
|
struct intc_source *sources;
|
|
int nr_sources;
|
|
struct intc_mask_reg *mask_regs;
|
|
int nr_mask_regs;
|
|
struct intc_prio_reg *prio_regs;
|
|
int nr_prio_regs;
|
|
int pending; /* number of interrupt sources that has pending set */
|
|
};
|
|
|
|
int sh_intc_get_pending_vector(struct intc_desc *desc, int imask);
|
|
struct intc_source *sh_intc_source(struct intc_desc *desc, intc_enum id);
|
|
void sh_intc_toggle_source(struct intc_source *source,
|
|
int enable_adj, int assert_adj);
|
|
|
|
void sh_intc_register_sources(struct intc_desc *desc,
|
|
struct intc_vect *vectors,
|
|
int nr_vectors,
|
|
struct intc_group *groups,
|
|
int nr_groups);
|
|
|
|
int sh_intc_init(MemoryRegion *sysmem,
|
|
struct intc_desc *desc,
|
|
int nr_sources,
|
|
struct intc_mask_reg *mask_regs,
|
|
int nr_mask_regs,
|
|
struct intc_prio_reg *prio_regs,
|
|
int nr_prio_regs);
|
|
|
|
void sh_intc_set_irl(void *opaque, int n, int level);
|
|
|
|
#endif /* SH_INTC_H */
|