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