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

Function nexus_map_resource

freebsd/x86/x86/nexus.c:478–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476}
477
478static int
479nexus_map_resource(device_t bus, device_t child, int type, struct resource *r,
480 struct resource_map_request *argsp, struct resource_map *map)
481{
482 struct resource_map_request args;
483 rman_res_t end, length, start;
484
485 /* Resources must be active to be mapped. */
486 if (!(rman_get_flags(r) & RF_ACTIVE))
487 return (ENXIO);
488
489 /* Mappings are only supported on I/O and memory resources. */
490 switch (type) {
491 case SYS_RES_IOPORT:
492 case SYS_RES_MEMORY:
493 break;
494 default:
495 return (EINVAL);
496 }
497
498 resource_init_map_request(&args);
499 if (argsp != NULL)
500 bcopy(argsp, &args, imin(argsp->size, args.size));
501 start = rman_get_start(r) + args.offset;
502 if (args.length == 0)
503 length = rman_get_size(r);
504 else
505 length = args.length;
506 end = start + length - 1;
507 if (start > rman_get_end(r) || start < rman_get_start(r))
508 return (EINVAL);
509 if (end > rman_get_end(r) || end < start)
510 return (EINVAL);
511
512 /*
513 * If this is a memory resource, map it into the kernel.
514 */
515 switch (type) {
516 case SYS_RES_IOPORT:
517 map->r_bushandle = start;
518 map->r_bustag = X86_BUS_SPACE_IO;
519 map->r_size = length;
520 map->r_vaddr = NULL;
521 break;
522 case SYS_RES_MEMORY:
523 map->r_vaddr = pmap_mapdev_attr(start, length, args.memattr);
524 map->r_bustag = X86_BUS_SPACE_MEM;
525 map->r_size = length;
526
527 /*
528 * The handle is the virtual address.
529 */
530 map->r_bushandle = (bus_space_handle_t)map->r_vaddr;
531 break;
532 }
533 return (0);
534}
535

Callers 1

nexus_activate_resourceFunction · 0.85

Calls 6

rman_get_flagsFunction · 0.85
iminFunction · 0.85
rman_get_startFunction · 0.85
rman_get_sizeFunction · 0.85
rman_get_endFunction · 0.85
pmap_mapdev_attrFunction · 0.50

Tested by

no test coverage detected