*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->FreeBSD man pages -> bus_alloc_resource (9)              
Title
Content
Arch
Section
 

BUS_ALLOC_RESOURCE(9)

Contents


NAME    [Toc]    [Back]

     bus_alloc_resource -- alloc resources on a bus

SYNOPSIS    [Toc]    [Back]

     #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);

DESCRIPTION    [Toc]    [Back]

     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.

     Its arguments are as follows:

     dev is the device that requests ownership of the resource.  Before allocation,
 the resource is owned by the parent bus.

     type is the type of resource you want to allocate.  It is one of:

     SYS_RES_IRQ     for IRQs

     SYS_RES_DRQ     for ISA DMA lines

     SYS_RES_IOPORT  for I/O ports

     SYS_RES_MEMORY  for I/O memory

     rid points to a bus specific handle that identifies the resource being
     allocated.  For ISA this is an index into an array of resources that have
     been setup for this device by either the PnP mechanism, or via the hints
     mechanism.  For PCCARD, similar things are used as of writing, but that
     may change in the future with newcard.  For PCI it just happens to be the
     offset into pci config space which has a word that describes the
     resource.	The bus methods are free to change the RIDs that they are
     given as a parameter.  You must not depend on the value you gave it earlier.


     start and end are the start/end addresses of the resource.  If you specify
 values of 0 for start and ~0 for end and 1 for count, the default
     values for the bus are calculated.

     count is the size of the resource, e.g. the size of an I/O port (often 1,
     but some devices override this).  If you specified the default values for
     start and end, then the default value of the bus is used if count is
     smaller than the default value and count is used, if it is bigger as the
     default value.

     flags sets the flags for the resource.  You can set one or more of these
     flags:

     RF_ALLOCATED  resource has been reserved.	The resource still needs to be
		   activated with bus_activate_resource(9).

     RF_ACTIVE	   activate resource atomically.

     RF_SHAREABLE  resource permits contemporaneous sharing.  Should always be
		   set unless you know, that the resource cannot be shared.
		   It is the bus-code's task to filter out the flag if the bus
		   doesn't support sharing, which is, for example, the case
		   for pccard/cardbus, which can or cannot share devices,
		   depending on the bus.

     RF_TIMESHARE  resource permits time-division sharing.

RETURN VALUES    [Toc]    [Back]

     A pointer to struct res is returned on success, a null pointer otherwise.

EXAMPLES    [Toc]    [Back]

     This is some example code.  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(dev, SYS_RES_IRQ, &irqid,
			     0ul, ~0ul, 1, RF_ACTIVE | RF_SHAREABLE);

SEE ALSO    [Toc]    [Back]

      
      
     bus_activate_resource(9), bus_release_resource(9), device(9), driver(9)

AUTHORS    [Toc]    [Back]

     This man page was written by Alexander Langer <[email protected]> with
     parts by Warner Losh <[email protected]>.


FreeBSD 5.2.1			 May 18, 2000			 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
glresources IRIX X resources used by GL programs
SgScale IRIX XmScale SGI Resources
bus_release_resource FreeBSD release resources on a bus
SgText IRIX XmText SGI Resources
SgTextField IRIX XmText SGI Resources
listres Tru64 list resources in widgets
cvusage IRIX run a command, and print out the resources it used
ssusage IRIX run a command, and print out the resources it used
windres Linux manipulate Windows resources.
alConnect IRIX connect two audio I/O resources
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service