bus_alloc_resource,
- Provided by: freebsd-manpages (Version: 9.2+1-1)
- Report a bug
#include
<sys/param.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include
<machine/resource.h>
struct resource *
bus_alloc_resource(device_t
dev, int type,
int *rid,
u_long start,
u_long end,
u_long count,
u_int flags);
struct resource *
bus_alloc_resource_any(device_t
dev, int type,
int *rid,
u_int flags);
This is an easy interface to the resource-management functions. It hides the indirection through the parent's method table. This function generally should be called in attach, but (except in some rare cases) never earlier.
The
bus_alloc_resource_any()
function is a convenience wrapper for
bus_alloc_resource().
It sets the values for start,
end, and count to the default
resource (see description of start below).
The arguments are as follows:
SYS_RES_IRQSYS_RES_DRQSYS_RES_IOPORTSYS_RES_MEMORYRF_ALLOCATEDRF_ACTIVERF_SHAREABLERF_TIMESHAREA pointer to struct resource is returned on success, a null pointer otherwise.
This is some example code that allocates a 32 byte I/O port range and an IRQ. The values of portid and irqid should be saved in the softc of the device after these calls.
struct resource *portres, *irqres; int portid, irqid; portid = 0; irqid = 0; portres = bus_alloc_resource(dev, SYS_RES_IOPORT, &portid, 0ul, ~0ul, 32, RF_ACTIVE); irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, &irqid, RF_ACTIVE | RF_SHAREABLE);
bus_activate_resource(9), bus_adjust_resource(9), bus_release_resource(9), device(9), driver(9)
This manual page was written by Alexander Langer ⟨alex@big.endian.de⟩ with parts by Warner Losh ⟨imp@FreeBSD.org⟩.