gicv3.h revision 1.4.4.3 1 1.4.4.3 martin /* $NetBSD: gicv3.h,v 1.4.4.3 2020/04/08 14:07:28 martin 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.3 martin #include <sys/vmem.h>
34 1.4.4.2 christos
35 1.4.4.2 christos struct gicv3_dma {
36 1.4.4.2 christos bus_dma_segment_t segs[1];
37 1.4.4.2 christos bus_dmamap_t map;
38 1.4.4.2 christos uint8_t *base;
39 1.4.4.2 christos bus_size_t len;
40 1.4.4.2 christos };
41 1.4.4.2 christos
42 1.4.4.2 christos struct gicv3_lpi_callback {
43 1.4.4.2 christos void (*cpu_init)(void *, struct cpu_info *);
44 1.4.4.2 christos void (*get_affinity)(void *, size_t, kcpuset_t *);
45 1.4.4.2 christos int (*set_affinity)(void *, size_t, const kcpuset_t *);
46 1.4.4.2 christos
47 1.4.4.2 christos void *priv;
48 1.4.4.2 christos
49 1.4.4.2 christos LIST_ENTRY(gicv3_lpi_callback) list;
50 1.4.4.2 christos };
51 1.4.4.2 christos
52 1.4.4.2 christos struct gicv3_softc {
53 1.4.4.2 christos struct pic_softc sc_pic; /* SGI/PPI/SGIs */
54 1.4.4.2 christos struct pic_softc sc_lpi; /* LPIs */
55 1.4.4.2 christos device_t sc_dev;
56 1.4.4.2 christos
57 1.4.4.2 christos bus_space_tag_t sc_bst;
58 1.4.4.2 christos bus_dma_tag_t sc_dmat;
59 1.4.4.2 christos
60 1.4.4.2 christos bus_space_handle_t sc_bsh_d; /* GICD */
61 1.4.4.2 christos bus_space_handle_t *sc_bsh_r; /* GICR */
62 1.4.4.2 christos u_int sc_bsh_r_count;
63 1.4.4.2 christos
64 1.4.4.2 christos uint32_t sc_enabled_sgippi;
65 1.4.4.2 christos uint64_t sc_irouter[MAXCPUS];
66 1.4.4.2 christos
67 1.4.4.2 christos /* LPI configuration table */
68 1.4.4.2 christos struct gicv3_dma sc_lpiconf;
69 1.4.4.2 christos
70 1.4.4.2 christos /* LPI pending tables */
71 1.4.4.2 christos struct gicv3_dma sc_lpipend[MAXCPUS];
72 1.4.4.2 christos
73 1.4.4.3 martin /* LPI IDs */
74 1.4.4.3 martin vmem_t *sc_lpi_pool;
75 1.4.4.3 martin
76 1.4.4.2 christos /* Unique identifier for PEs */
77 1.4.4.2 christos u_int sc_processor_id[MAXCPUS];
78 1.4.4.2 christos
79 1.4.4.2 christos /* Callbacks */
80 1.4.4.2 christos LIST_HEAD(, gicv3_lpi_callback) sc_lpi_callbacks;
81 1.4.4.2 christos };
82 1.4.4.2 christos
83 1.4.4.2 christos int gicv3_init(struct gicv3_softc *);
84 1.4.4.2 christos void gicv3_dma_alloc(struct gicv3_softc *, struct gicv3_dma *, bus_size_t, bus_size_t);
85 1.4.4.2 christos void gicv3_irq_handler(void *);
86 1.4.4.2 christos
87 1.4.4.2 christos #endif /* _ARM_CORTEX_GICV3_H */
88