bus_alloc_resource: First step in passing resource IDs by value
Add wrapper inline functions for bus_alloc_resource* that accept a resource ID by value (instead of a pointer). The rest of the bus resource API (outside of compat shims) does not accept resource IDs as arguments, but instead obtains the resource ID from the resource itself when needed. As such, there is no reason to return any potentially modified resource IDs to the caller. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53401
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd May 20, 2016
|
||||
.Dd October 30, 2025
|
||||
.Dt BUS_ALLOC_RESOURCE 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -43,14 +43,14 @@
|
||||
.In machine/resource.h
|
||||
.Ft struct resource *
|
||||
.Fo bus_alloc_resource
|
||||
.Fa "device_t dev" "int type" "int *rid" "rman_res_t start" "rman_res_t end"
|
||||
.Fa "device_t dev" "int type" "int rid" "rman_res_t start" "rman_res_t end"
|
||||
.Fa "rman_res_t count" "u_int flags"
|
||||
.Fc
|
||||
.Ft struct resource *
|
||||
.Fn bus_alloc_resource_any "device_t dev" "int type" "int *rid" "u_int flags"
|
||||
.Fn bus_alloc_resource_any "device_t dev" "int type" "int rid" "u_int flags"
|
||||
.Ft struct resource *
|
||||
.Fo bus_alloc_resource_anywhere
|
||||
.Fa "device_t dev" "int type" "int *rid" "rman_res_t count" "u_int flags"
|
||||
.Fa "device_t dev" "int type" "int rid" "rman_res_t count" "u_int flags"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
This is an easy interface to the resource-management functions.
|
||||
@@ -106,15 +106,13 @@ for I/O memory
|
||||
.El
|
||||
.It
|
||||
.Fa rid
|
||||
points to a bus specific handle that identifies the resource being allocated.
|
||||
is 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, this is an index into the array of resources described by the PC Card's
|
||||
CIS entry.
|
||||
For PCI, the offset into PCI config space which has the BAR to use to access
|
||||
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.
|
||||
.It
|
||||
.Fa start
|
||||
and
|
||||
@@ -175,20 +173,12 @@ A pointer to
|
||||
is returned on success, a null pointer otherwise.
|
||||
.Sh EXAMPLES
|
||||
This is some example code that allocates a 32 byte I/O port range and an IRQ.
|
||||
The values of
|
||||
.Va portid
|
||||
and
|
||||
.Va irqid
|
||||
should be saved in the softc of the device after these calls.
|
||||
.Bd -literal
|
||||
struct resource *portres, *irqres;
|
||||
int portid, irqid;
|
||||
|
||||
portid = 0;
|
||||
irqid = 0;
|
||||
portres = bus_alloc_resource(dev, SYS_RES_IOPORT, &portid,
|
||||
portres = bus_alloc_resource(dev, SYS_RES_IOPORT, 0,
|
||||
0ul, ~0ul, 32, RF_ACTIVE);
|
||||
irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, &irqid,
|
||||
irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, 0,
|
||||
RF_ACTIVE | RF_SHAREABLE);
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
|
||||
Reference in New Issue
Block a user