MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gic_v3_attach

Function gic_v3_attach

freebsd/arm64/arm64/gic_v3.c:249–375  ·  view source on GitHub ↗

* Device interface. */

Source from the content-addressed store, hash-verified

247 * Device interface.
248 */
249int
250gic_v3_attach(device_t dev)
251{
252 struct gic_v3_softc *sc;
253 gic_v3_initseq_t *init_func;
254 uint32_t typer;
255 int rid;
256 int err;
257 size_t i;
258 u_int irq;
259 const char *name;
260
261 sc = device_get_softc(dev);
262 sc->gic_registered = FALSE;
263 sc->dev = dev;
264 err = 0;
265
266 /* Initialize mutex */
267 mtx_init(&sc->gic_mtx, "GICv3 lock", NULL, MTX_SPIN);
268
269 /*
270 * Allocate array of struct resource.
271 * One entry for Distributor and all remaining for Re-Distributor.
272 */
273 sc->gic_res = malloc(
274 sizeof(*sc->gic_res) * (sc->gic_redists.nregions + 1),
275 M_GIC_V3, M_WAITOK);
276
277 /* Now allocate corresponding resources */
278 for (i = 0, rid = 0; i < (sc->gic_redists.nregions + 1); i++, rid++) {
279 sc->gic_res[rid] = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
280 &rid, RF_ACTIVE);
281 if (sc->gic_res[rid] == NULL)
282 return (ENXIO);
283 }
284
285 /*
286 * Distributor interface
287 */
288 sc->gic_dist = sc->gic_res[0];
289
290 /*
291 * Re-Dristributor interface
292 */
293 /* Allocate space under region descriptions */
294 sc->gic_redists.regions = malloc(
295 sizeof(*sc->gic_redists.regions) * sc->gic_redists.nregions,
296 M_GIC_V3, M_WAITOK);
297
298 /* Fill-up bus_space information for each region. */
299 for (i = 0, rid = 1; i < sc->gic_redists.nregions; i++, rid++)
300 sc->gic_redists.regions[i] = sc->gic_res[rid];
301
302 /* Get the number of supported SPI interrupts */
303 typer = gic_d_read(sc, 4, GICD_TYPER);
304 sc->gic_nirqs = GICD_TYPER_I_NUM(typer);
305 if (sc->gic_nirqs > GIC_I_NUM_MAX)
306 sc->gic_nirqs = GIC_I_NUM_MAX;

Callers 2

gic_v3_acpi_attachFunction · 0.85
gic_v3_fdt_attachFunction · 0.85

Calls 8

device_get_softcFunction · 0.85
mtx_initFunction · 0.85
mallocFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
device_get_nameunitFunction · 0.85
intr_isrc_registerFunction · 0.85
device_printfFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected