xref: /freebsd/share/man/man9/bus_adjust_resource.9 (revision fef01f0498aa7b256bc37bbf28ee0e8ac9b2536f)
185ee63c9SJohn Baldwin.\" -*- nroff -*-
285ee63c9SJohn Baldwin.\"
3179fa75eSJohn Baldwin.\" Copyright (c) 2011 Hudson River Trading LLC
485ee63c9SJohn Baldwin.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
585ee63c9SJohn Baldwin.\" All rights reserved.
685ee63c9SJohn Baldwin.\"
785ee63c9SJohn Baldwin.\" Redistribution and use in source and binary forms, with or without
885ee63c9SJohn Baldwin.\" modification, are permitted provided that the following conditions
985ee63c9SJohn Baldwin.\" are met:
1085ee63c9SJohn Baldwin.\" 1. Redistributions of source code must retain the above copyright
1185ee63c9SJohn Baldwin.\"    notice, this list of conditions and the following disclaimer.
1285ee63c9SJohn Baldwin.\" 2. Redistributions in binary form must reproduce the above copyright
1385ee63c9SJohn Baldwin.\"    notice, this list of conditions and the following disclaimer in the
1485ee63c9SJohn Baldwin.\"    documentation and/or other materials provided with the distribution.
1585ee63c9SJohn Baldwin.\"
1685ee63c9SJohn Baldwin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1785ee63c9SJohn Baldwin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1885ee63c9SJohn Baldwin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1985ee63c9SJohn Baldwin.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2085ee63c9SJohn Baldwin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2185ee63c9SJohn Baldwin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2285ee63c9SJohn Baldwin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2385ee63c9SJohn Baldwin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2485ee63c9SJohn Baldwin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2585ee63c9SJohn Baldwin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2685ee63c9SJohn Baldwin.\" SUCH DAMAGE.
2785ee63c9SJohn Baldwin.\"
28*fef01f04SJohn Baldwin.Dd March 13, 2024
2985ee63c9SJohn Baldwin.Dt BUS_ADJUST_RESOURCE 9
3085ee63c9SJohn Baldwin.Os
3185ee63c9SJohn Baldwin.Sh NAME
3285ee63c9SJohn Baldwin.Nm bus_adjust_resource
3385ee63c9SJohn Baldwin.Nd adjust resource allocated from a parent bus
3485ee63c9SJohn Baldwin.Sh SYNOPSIS
3585ee63c9SJohn Baldwin.In sys/param.h
3685ee63c9SJohn Baldwin.In sys/bus.h
3785ee63c9SJohn Baldwin.Pp
3885ee63c9SJohn Baldwin.In machine/bus.h
3985ee63c9SJohn Baldwin.In sys/rman.h
4085ee63c9SJohn Baldwin.In machine/resource.h
4185ee63c9SJohn Baldwin.Ft int
42ee9e0ce4SChristian Brueffer.Fo bus_adjust_resource
43*fef01f04SJohn Baldwin.Fa "device_t dev" "struct resource *r"
44ee9e0ce4SChristian Brueffer.Fa "rman_res_t start" "rman_res_t end"
45ee9e0ce4SChristian Brueffer.Fc
4685ee63c9SJohn Baldwin.Sh DESCRIPTION
4785ee63c9SJohn BaldwinThis function is used to ask the parent bus to adjust the resource range
4885ee63c9SJohn Baldwinassigned to an allocated resource.
4985ee63c9SJohn BaldwinThe resource
5085ee63c9SJohn Baldwin.Fa r
5185ee63c9SJohn Baldwinshould have been allocated by a previous call to
5285ee63c9SJohn Baldwin.Xr bus_alloc_resource 9 .
5385ee63c9SJohn BaldwinThe new resource range must overlap the existing range of
5485ee63c9SJohn Baldwin.Fa r .
5585ee63c9SJohn Baldwin.Pp
5685ee63c9SJohn BaldwinNote that none of the constraints of the original allocation request such
5785ee63c9SJohn Baldwinas alignment or boundary restrictions are checked by
5885ee63c9SJohn Baldwin.Fn bus_adjust_resource .
5985ee63c9SJohn BaldwinIt is the caller's responsibility to enforce any such requirements.
6085ee63c9SJohn Baldwin.Sh RETURN VALUES
6185ee63c9SJohn BaldwinThe
6285ee63c9SJohn Baldwin.Fn bus_adjust_resource
6385ee63c9SJohn Baldwinmethod returns zero on success or an error code on failure.
64135bce2aSUlrich Spörlein.Sh EXAMPLES
65135bce2aSUlrich SpörleinGrow an existing memory resource by 4096 bytes.
66135bce2aSUlrich Spörlein.Bd -literal
67135bce2aSUlrich Spörlein	struct resource *res;
68135bce2aSUlrich Spörlein	int error;
69135bce2aSUlrich Spörlein
70*fef01f04SJohn Baldwin	error = bus_adjust_resource(dev, res, rman_get_start(res),
71*fef01f04SJohn Baldwin	    rman_get_end(res) + 0x1000);
72135bce2aSUlrich Spörlein.Ed
7385ee63c9SJohn Baldwin.Sh ERRORS
7485ee63c9SJohn Baldwin.Fn bus_adjust_resource
7585ee63c9SJohn Baldwinwill fail if:
7685ee63c9SJohn Baldwin.Bl -tag -width Er
7785ee63c9SJohn Baldwin.It Bq Er EINVAL
7885ee63c9SJohn BaldwinThe
7985ee63c9SJohn Baldwin.Fa dev
8085ee63c9SJohn Baldwindevice does not have a parent device.
8185ee63c9SJohn Baldwin.It Bq Er EINVAL
8285ee63c9SJohn BaldwinThe
8385ee63c9SJohn Baldwin.Fa r
8485ee63c9SJohn Baldwinresource is a shared resource.
8585ee63c9SJohn Baldwin.It Bq Er EINVAL
8685ee63c9SJohn BaldwinThe new address range does not overlap with the existing address range of
8785ee63c9SJohn Baldwin.Fa r .
8885ee63c9SJohn Baldwin.It Bq Er EBUSY
8985ee63c9SJohn BaldwinThe new address range conflicts with another allocated resource.
9085ee63c9SJohn Baldwin.El
9185ee63c9SJohn Baldwin.Sh SEE ALSO
9285ee63c9SJohn Baldwin.Xr bus_alloc_resource 9 ,
9385ee63c9SJohn Baldwin.Xr bus_release_resource 9 ,
9485ee63c9SJohn Baldwin.Xr device 9 ,
9585ee63c9SJohn Baldwin.Xr driver 9
96