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