sh_intc.h 1.91 KB
Newer Older
1 2 3
#ifndef __SH_INTC_H__
#define __SH_INTC_H__

4 5 6
#include "qemu-common.h"
#include "irq.h"

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
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, ids...) { enum_id, { ids } }

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;
};

35
#define _INTC_ARRAY(a) a, ARRAY_SIZE(a)
36 37 38 39 40

struct intc_source {
    unsigned short vect;
    intc_enum next_enum_id;

41
    int asserted; /* emulates the interrupt signal line from device to intc */
42 43
    int enable_count;
    int enable_max;
44 45
    int pending; /* emulates the result of signal and masking */
    struct intc_desc *parent;
46 47 48
};

struct intc_desc {
49
    qemu_irq *irqs;
50 51 52 53 54 55 56
    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 iomemtype;
57
    int pending; /* number of interrupt sources that has pending set */
58 59
};

60
int sh_intc_get_pending_vector(struct intc_desc *desc, int imask);
61
struct intc_source *sh_intc_source(struct intc_desc *desc, intc_enum id);
62 63
void sh_intc_toggle_source(struct intc_source *source,
			   int enable_adj, int assert_adj);
64 65 66 67 68 69 70 71 72 73 74 75 76 77

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(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);

78 79
void sh_intc_set_irl(void *opaque, int n, int level);

80
#endif /* __SH_INTC_H__ */