balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 1 | #ifndef __SH_INTC_H__ |
| 2 | #define __SH_INTC_H__ |
| 3 | |
aurel32 | 96e2fc4 | 2008-11-21 21:06:42 +0000 | [diff] [blame] | 4 | #include "qemu-common.h" |
| 5 | #include "irq.h" |
Benoît Canet | b279e5e | 2011-11-17 14:23:01 +0100 | [diff] [blame] | 6 | #include "exec-memory.h" |
aurel32 | 96e2fc4 | 2008-11-21 21:06:42 +0000 | [diff] [blame] | 7 | |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 8 | typedef unsigned char intc_enum; |
| 9 | |
| 10 | struct intc_vect { |
| 11 | intc_enum enum_id; |
| 12 | unsigned short vect; |
| 13 | }; |
| 14 | |
| 15 | #define INTC_VECT(enum_id, vect) { enum_id, vect } |
| 16 | |
| 17 | struct intc_group { |
| 18 | intc_enum enum_id; |
| 19 | intc_enum enum_ids[32]; |
| 20 | }; |
| 21 | |
Blue Swirl | 001faf3 | 2009-05-13 17:53:17 +0000 | [diff] [blame] | 22 | #define INTC_GROUP(enum_id, ...) { enum_id, { __VA_ARGS__ } } |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 23 | |
| 24 | struct intc_mask_reg { |
| 25 | unsigned long set_reg, clr_reg, reg_width; |
| 26 | intc_enum enum_ids[32]; |
| 27 | unsigned long value; |
| 28 | }; |
| 29 | |
| 30 | struct intc_prio_reg { |
| 31 | unsigned long set_reg, clr_reg, reg_width, field_width; |
| 32 | intc_enum enum_ids[16]; |
| 33 | unsigned long value; |
| 34 | }; |
| 35 | |
malc | b1503cd | 2008-12-22 20:33:55 +0000 | [diff] [blame] | 36 | #define _INTC_ARRAY(a) a, ARRAY_SIZE(a) |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 37 | |
| 38 | struct intc_source { |
| 39 | unsigned short vect; |
| 40 | intc_enum next_enum_id; |
| 41 | |
ths | e96e204 | 2007-12-02 06:18:24 +0000 | [diff] [blame] | 42 | int asserted; /* emulates the interrupt signal line from device to intc */ |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 43 | int enable_count; |
| 44 | int enable_max; |
ths | e96e204 | 2007-12-02 06:18:24 +0000 | [diff] [blame] | 45 | int pending; /* emulates the result of signal and masking */ |
| 46 | struct intc_desc *parent; |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | struct intc_desc { |
Benoît Canet | b279e5e | 2011-11-17 14:23:01 +0100 | [diff] [blame] | 50 | MemoryRegion iomem; |
| 51 | MemoryRegion *iomem_aliases; |
aurel32 | 96e2fc4 | 2008-11-21 21:06:42 +0000 | [diff] [blame] | 52 | qemu_irq *irqs; |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 53 | struct intc_source *sources; |
| 54 | int nr_sources; |
| 55 | struct intc_mask_reg *mask_regs; |
| 56 | int nr_mask_regs; |
| 57 | struct intc_prio_reg *prio_regs; |
| 58 | int nr_prio_regs; |
ths | e96e204 | 2007-12-02 06:18:24 +0000 | [diff] [blame] | 59 | int pending; /* number of interrupt sources that has pending set */ |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
ths | e96e204 | 2007-12-02 06:18:24 +0000 | [diff] [blame] | 62 | int sh_intc_get_pending_vector(struct intc_desc *desc, int imask); |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 63 | struct intc_source *sh_intc_source(struct intc_desc *desc, intc_enum id); |
ths | e96e204 | 2007-12-02 06:18:24 +0000 | [diff] [blame] | 64 | void sh_intc_toggle_source(struct intc_source *source, |
| 65 | int enable_adj, int assert_adj); |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 66 | |
| 67 | void sh_intc_register_sources(struct intc_desc *desc, |
| 68 | struct intc_vect *vectors, |
| 69 | int nr_vectors, |
| 70 | struct intc_group *groups, |
| 71 | int nr_groups); |
| 72 | |
Benoît Canet | b279e5e | 2011-11-17 14:23:01 +0100 | [diff] [blame] | 73 | int sh_intc_init(MemoryRegion *sysmem, |
| 74 | struct intc_desc *desc, |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 75 | int nr_sources, |
| 76 | struct intc_mask_reg *mask_regs, |
| 77 | int nr_mask_regs, |
| 78 | struct intc_prio_reg *prio_regs, |
| 79 | int nr_prio_regs); |
| 80 | |
balrog | c6d86a3 | 2008-12-07 18:49:57 +0000 | [diff] [blame] | 81 | void sh_intc_set_irl(void *opaque, int n, int level); |
| 82 | |
balrog | 80f515e | 2007-10-04 21:53:55 +0000 | [diff] [blame] | 83 | #endif /* __SH_INTC_H__ */ |