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

Function nexus_activate_resource

freebsd/arm/arm/nexus.c:342–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340#endif
341
342static int
343nexus_activate_resource(device_t bus, device_t child, int type, int rid,
344 struct resource *r)
345{
346 int err;
347 bus_addr_t paddr;
348 bus_size_t psize;
349 bus_space_handle_t vaddr;
350
351 if ((err = rman_activate_resource(r)) != 0)
352 return (err);
353
354 /*
355 * If this is a memory resource, map it into the kernel.
356 */
357 if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) {
358 paddr = (bus_addr_t)rman_get_start(r);
359 psize = (bus_size_t)rman_get_size(r);
360#ifdef FDT
361 err = bus_space_map(fdtbus_bs_tag, paddr, psize, 0, &vaddr);
362 if (err != 0) {
363 rman_deactivate_resource(r);
364 return (err);
365 }
366 rman_set_bustag(r, fdtbus_bs_tag);
367#else
368 vaddr = (bus_space_handle_t)pmap_mapdev((vm_offset_t)paddr,
369 (vm_size_t)psize);
370 if (vaddr == 0) {
371 rman_deactivate_resource(r);
372 return (ENOMEM);
373 }
374 rman_set_bustag(r, (void *)1);
375#endif
376 rman_set_virtual(r, (void *)vaddr);
377 rman_set_bushandle(r, vaddr);
378 return (0);
379 } else if (type == SYS_RES_IRQ) {
380 err = intr_activate_irq(child, r);
381 if (err != 0) {
382 rman_deactivate_resource(r);
383 return (err);
384 }
385 }
386 return (0);
387}
388
389static int
390nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,

Callers

nothing calls this directly

Calls 10

rman_activate_resourceFunction · 0.85
rman_get_startFunction · 0.85
rman_get_sizeFunction · 0.85
bus_space_mapFunction · 0.85
rman_deactivate_resourceFunction · 0.85
rman_set_bustagFunction · 0.85
rman_set_virtualFunction · 0.85
rman_set_bushandleFunction · 0.85
intr_activate_irqFunction · 0.85
pmap_mapdevFunction · 0.50

Tested by

no test coverage detected