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