OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [include/] [l4/] [generic/] [irq.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Generic irq handling definitions.
3
 *
4
 * Copyright (C) 2010 B Labs Ltd.
5
 */
6
#ifndef __GENERIC_IRQ_H__
7
#define __GENERIC_IRQ_H__
8
 
9
#include <l4/lib/string.h>
10
#include <l4/lib/wait.h>
11
#include <l4/lib/printk.h>
12
#include INC_PLAT(irq.h)
13
#include INC_ARCH(types.h)
14
 
15
/* Represents none or spurious irq */
16
#define IRQ_NIL                         0xFFFFFFFF /* -1 */
17
#define IRQ_SPURIOUS                    0xFFFFFFFE /* -2 */
18
 
19
/* Successful irq handling state */
20
#define IRQ_HANDLED                             0
21
 
22
typedef void (*irq_op_t)(l4id_t irq);
23
struct irq_chip_ops {
24
        void (*init)();
25
        l4id_t (*read_irq)(void *data);
26
        irq_op_t ack_and_mask;
27
        irq_op_t unmask;
28
        void (*set_cpu)(l4id_t irq, unsigned int cpumask);
29
};
30
 
31
struct irq_chip {
32
        char name[32];
33
        int level;              /* Cascading level */
34
        int cascade;            /* The irq that lower chip uses on this chip */
35
        int start;              /* The global irq offset for this chip */
36
        int end;                /* End of this chip's irqs */
37
        void *data;             /* Anything that a of interest to a driver */
38
        struct irq_chip_ops ops;
39
};
40
 
41
struct irq_desc;
42
typedef int (*irq_handler_t)(struct irq_desc *irq_desc);
43
struct irq_desc {
44
        char name[8];
45
        struct irq_chip *chip;
46
 
47
        /* Thread registered for this irq */
48
        struct ktcb *task;
49
 
50
        /* Notification slot for this irq */
51
        int task_notify_slot;
52
 
53
        /* Waitqueue head for this irq */
54
        struct waitqueue_head wqh_irq;
55
 
56
        /* NOTE: This could be a list for multiple handlers for shared irqs */
57
        irq_handler_t handler;
58
};
59
 
60
extern struct irq_desc irq_desc_array[];
61
extern struct irq_chip irq_chip_array[];
62
 
63
static inline void irq_enable(int irq_index)
64
{
65
        struct irq_desc *this_irq = irq_desc_array + irq_index;
66
        struct irq_chip *this_chip = this_irq->chip;
67
 
68
        this_chip->ops.unmask(irq_index - this_chip->start);
69
}
70
 
71
static inline void irq_disable(int irq_index)
72
{
73
        struct irq_desc *this_irq = irq_desc_array + irq_index;
74
        struct irq_chip *this_chip = this_irq->chip;
75
        this_chip->ops.ack_and_mask(irq_index - this_chip->start);
76
}
77
 
78
static inline void irq_set_cpu(int irq_index, unsigned int cpumask)
79
{
80
        struct irq_desc *this_irq = irq_desc_array + irq_index;
81
        struct irq_chip *this_chip = this_irq->chip;
82
 
83
        this_chip->ops.set_cpu(irq_index - this_chip->start, cpumask);
84
}
85
 
86
int irq_register(struct ktcb *task, int notify_slot, l4id_t irq_index);
87
int irq_thread_notify(struct irq_desc *desc);
88
 
89
void do_irq(void);
90
void irq_controllers_init(void);
91
 
92
#endif /* __GENERIC_IRQ_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.