gicv3.h revision 1.4.4.2 1 1.4.4.2 christos /* $NetBSD: gicv3.h,v 1.4.4.2 2019/06/10 22:05:52 christos Exp $ */
2 1.4.4.2 christos
3 1.4.4.2 christos /*-
4 1.4.4.2 christos * Copyright (c) 2018 Jared McNeill <jmcneill (at) invisible.ca>
5 1.4.4.2 christos * All rights reserved.
6 1.4.4.2 christos *
7 1.4.4.2 christos * Redistribution and use in source and binary forms, with or without
8 1.4.4.2 christos * modification, are permitted provided that the following conditions
9 1.4.4.2 christos * are met:
10 1.4.4.2 christos * 1. Redistributions of source code must retain the above copyright
11 1.4.4.2 christos * notice, this list of conditions and the following disclaimer.
12 1.4.4.2 christos * 2. Redistributions in binary form must reproduce the above copyright
13 1.4.4.2 christos * notice, this list of conditions and the following disclaimer in the
14 1.4.4.2 christos * documentation and/or other materials provided with the distribution.
15 1.4.4.2 christos *
16 1.4.4.2 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.4.4.2 christos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.4.4.2 christos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.4.4.2 christos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.4.4.2 christos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.4.4.2 christos * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.4.4.2 christos * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.4.4.2 christos * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.4.4.2 christos * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.4.4.2 christos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.4.4.2 christos * SUCH DAMAGE.
27 1.4.4.2 christos */
28 1.4.4.2 christos
29 1.4.4.2 christos #ifndef _ARM_CORTEX_GICV3_H
30 1.4.4.2 christos #define _ARM_CORTEX_GICV3_H
31 1.4.4.2 christos
32 1.4.4.2 christos #include <sys/intr.h>
33 1.4.4.2 christos
34 1.4.4.2 christos struct gicv3_dma {
35 1.4.4.2 christos bus_dma_segment_t segs[1];
36 1.4.4.2 christos bus_dmamap_t map;
37 1.4.4.2 christos uint8_t *base;
38 1.4.4.2 christos bus_size_t len;
39 1.4.4.2 christos };
40 1.4.4.2 christos
41 1.4.4.2 christos struct gicv3_lpi_callback {
42 1.4.4.2 christos void (*cpu_init)(void *, struct cpu_info *);
43 1.4.4.2 christos void (*get_affinity)(void *, size_t, kcpuset_t *);
44 1.4.4.2 christos int (*set_affinity)(void *, size_t, const kcpuset_t *);
45 1.4.4.2 christos
46 1.4.4.2 christos void *priv;
47 1.4.4.2 christos
48 1.4.4.2 christos LIST_ENTRY(gicv3_lpi_callback) list;
49 1.4.4.2 christos };
50 1.4.4.2 christos
51 1.4.4.2 christos struct gicv3_softc {
52 1.4.4.2 christos struct pic_softc sc_pic; /* SGI/PPI/SGIs */
53 1.4.4.2 christos struct pic_softc sc_lpi; /* LPIs */
54 1.4.4.2 christos device_t sc_dev;
55 1.4.4.2 christos
56 1.4.4.2 christos bus_space_tag_t sc_bst;
57 1.4.4.2 christos bus_dma_tag_t sc_dmat;
58 1.4.4.2 christos
59 1.4.4.2 christos bus_space_handle_t sc_bsh_d; /* GICD */
60 1.4.4.2 christos bus_space_handle_t *sc_bsh_r; /* GICR */
61 1.4.4.2 christos u_int sc_bsh_r_count;
62 1.4.4.2 christos
63 1.4.4.2 christos uint32_t sc_enabled_sgippi;
64 1.4.4.2 christos uint64_t sc_irouter[MAXCPUS];
65 1.4.4.2 christos
66 1.4.4.2 christos /* LPI configuration table */
67 1.4.4.2 christos struct gicv3_dma sc_lpiconf;
68 1.4.4.2 christos
69 1.4.4.2 christos /* LPI pending tables */
70 1.4.4.2 christos struct gicv3_dma sc_lpipend[MAXCPUS];
71 1.4.4.2 christos
72 1.4.4.2 christos /* Unique identifier for PEs */
73 1.4.4.2 christos u_int sc_processor_id[MAXCPUS];
74 1.4.4.2 christos
75 1.4.4.2 christos /* Callbacks */
76 1.4.4.2 christos LIST_HEAD(, gicv3_lpi_callback) sc_lpi_callbacks;
77 1.4.4.2 christos };
78 1.4.4.2 christos
79 1.4.4.2 christos int gicv3_init(struct gicv3_softc *);
80 1.4.4.2 christos void gicv3_dma_alloc(struct gicv3_softc *, struct gicv3_dma *, bus_size_t, bus_size_t);
81 1.4.4.2 christos void gicv3_irq_handler(void *);
82 1.4.4.2 christos
83 1.4.4.2 christos #endif /* _ARM_CORTEX_GICV3_H */
84