picvar.h revision 1.5 1 /* $NetBSD: picvar.h,v 1.5 2010/11/15 09:25:58 bsh Exp $ */
2 /*-
3 * Copyright (c) 2008 The NetBSD Foundation, Inc.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Matt Thomas.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30 #ifndef _ARM_PIC_PICVAR_H_
31 #define _ARM_PIC_PICVAR_H_
32
33 int _splraise(int);
34 int _spllower(int);
35 void splx(int);
36 const char *
37 intr_typename(int);
38
39 struct pic_softc;
40 struct intrsource;
41
42 int pic_handle_intr(void *);
43 void pic_mark_pending(struct pic_softc *pic, int irq);
44 void pic_mark_pending_source(struct pic_softc *pic, struct intrsource *is);
45 uint32_t pic_mark_pending_sources(struct pic_softc *pic, size_t irq_base,
46 uint32_t pending);
47 void *pic_establish_intr(struct pic_softc *pic, int irq, int ipl, int type,
48 int (*func)(void *), void *arg);
49 int pic_alloc_irq(struct pic_softc *pic);
50 void pic_disestablish_source(struct intrsource *is);
51 void pic_do_pending_ints(register_t psw, int newipl, void *frame);
52 void pic_dispatch(struct intrsource *is, void *frame);
53
54 void *intr_establish(int irq, int ipl, int type, int (*func)(void *),
55 void *arg);
56 void intr_disestablish(void *);
57
58 #ifdef _INTR_PRIVATE
59
60 #include <sys/evcnt.h>
61
62 #ifndef PIC_MAXPICS
63 #define PIC_MAXPICS 32
64 #endif
65 #ifndef PIC_MAXSOURCES
66 #define PIC_MAXSOURCES 64
67 #endif
68 #ifndef PIC_MAXMAXSOURCES
69 #define PIC_MAXMAXSOURCES 128
70 #endif
71
72 struct intrsource {
73 int (*is_func)(void *);
74 void *is_arg;
75 struct pic_softc *is_pic; /* owning PIC */
76 uint8_t is_type; /* IST_xxx */
77 uint8_t is_ipl; /* IPL_xxx */
78 uint8_t is_irq; /* local to pic */
79 uint8_t is_iplidx;
80 struct evcnt is_ev;
81 char is_source[16];
82 };
83
84 struct pic_softc {
85 const struct pic_ops *pic_ops;
86 struct intrsource **pic_sources;
87 volatile uint32_t pic_pending_irqs[(PIC_MAXSOURCES + 31) / 32];
88 volatile uint32_t pic_blocked_irqs[(PIC_MAXSOURCES + 31) / 32];
89 volatile uint32_t pic_pending_ipls;
90 size_t pic_maxsources;
91 uint8_t pic_id;
92 int16_t pic_irqbase;
93 char pic_name[14];
94 };
95
96 struct pic_ops {
97 void (*pic_unblock_irqs)(struct pic_softc *, size_t, uint32_t);
98 void (*pic_block_irqs)(struct pic_softc *, size_t, uint32_t);
99 int (*pic_find_pending_irqs)(struct pic_softc *);
100
101 void (*pic_establish_irq)(struct pic_softc *, struct intrsource *);
102 void (*pic_source_name)(struct pic_softc *, int, char *, size_t);
103 };
104
105
106 void pic_add(struct pic_softc *, int);
107 void pic_do_pending_int(void);
108
109 extern struct pic_softc * pic_list[PIC_MAXPICS];
110 #endif /* _INTR_PRIVATE */
111
112 #endif /* _ARM_PIC_PICVAR_H_ */
113