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