xref: /freebsd/share/man/man9/bus_adjust_resource.9 (revision ee9e0ce4cb6408dfdd90fe7faac58067c20b42a0)
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.\"
2885ee63c9SJohn Baldwin.\" $FreeBSD$
2985ee63c9SJohn Baldwin.\"
30*ee9e0ce4SChristian Brueffer.Dd April 23, 2016
3185ee63c9SJohn Baldwin.Dt BUS_ADJUST_RESOURCE 9
3285ee63c9SJohn Baldwin.Os
3385ee63c9SJohn Baldwin.Sh NAME
3485ee63c9SJohn Baldwin.Nm bus_adjust_resource
3585ee63c9SJohn Baldwin.Nd adjust resource allocated from a parent bus
3685ee63c9SJohn Baldwin.Sh SYNOPSIS
3785ee63c9SJohn Baldwin.In sys/param.h
3885ee63c9SJohn Baldwin.In sys/bus.h
3985ee63c9SJohn Baldwin.Pp
4085ee63c9SJohn Baldwin.In machine/bus.h
4185ee63c9SJohn Baldwin.In sys/rman.h
4285ee63c9SJohn Baldwin.In machine/resource.h
4385ee63c9SJohn Baldwin.Ft int
44*ee9e0ce4SChristian Brueffer.Fo bus_adjust_resource
45*ee9e0ce4SChristian Brueffer.Fa "device_t dev" "int type" "struct resource *r"
46*ee9e0ce4SChristian Brueffer.Fa "rman_res_t start" "rman_res_t end"
47*ee9e0ce4SChristian Brueffer.Fc
4885ee63c9SJohn Baldwin.Sh DESCRIPTION
4985ee63c9SJohn BaldwinThis function is used to ask the parent bus to adjust the resource range
5085ee63c9SJohn Baldwinassigned to an allocated resource.
5185ee63c9SJohn BaldwinThe resource
5285ee63c9SJohn Baldwin.Fa r
5385ee63c9SJohn Baldwinshould have been allocated by a previous call to
5485ee63c9SJohn Baldwin.Xr bus_alloc_resource 9 .
5585ee63c9SJohn BaldwinThe new resource range must overlap the existing range of
5685ee63c9SJohn Baldwin.Fa r .
5785ee63c9SJohn BaldwinThe
5885ee63c9SJohn Baldwin.Fa type
5985ee63c9SJohn Baldwinargument should match the
6085ee63c9SJohn Baldwin.Fa type
6185ee63c9SJohn Baldwinargument passed to
6285ee63c9SJohn Baldwin.Xr bus_alloc_resource 9
6385ee63c9SJohn Baldwinwhen the resource was initially allocated.
6485ee63c9SJohn Baldwin.Pp
6585ee63c9SJohn BaldwinNote that none of the constraints of the original allocation request such
6685ee63c9SJohn Baldwinas alignment or boundary restrictions are checked by
6785ee63c9SJohn Baldwin.Fn bus_adjust_resource .
6885ee63c9SJohn BaldwinIt is the caller's responsibility to enforce any such requirements.
6985ee63c9SJohn Baldwin.Sh RETURN VALUES
7085ee63c9SJohn BaldwinThe
7185ee63c9SJohn Baldwin.Fn bus_adjust_resource
7285ee63c9SJohn Baldwinmethod returns zero on success or an error code on failure.
73135bce2aSUlrich Spörlein.Sh EXAMPLES
74135bce2aSUlrich SpörleinGrow an existing memory resource by 4096 bytes.
75135bce2aSUlrich Spörlein.Bd -literal
76135bce2aSUlrich Spörlein	struct resource *res;
77135bce2aSUlrich Spörlein	int error;
78135bce2aSUlrich Spörlein
79135bce2aSUlrich Spörlein	error = bus_adjust_resource(dev, SYS_RES_MEMORY, res,
80135bce2aSUlrich Spörlein	    rman_get_start(res), rman_get_end(res) + 0x1000);
81135bce2aSUlrich Spörlein.Ed
8285ee63c9SJohn Baldwin.Sh ERRORS
8385ee63c9SJohn Baldwin.Fn bus_adjust_resource
8485ee63c9SJohn Baldwinwill fail if:
8585ee63c9SJohn Baldwin.Bl -tag -width Er
8685ee63c9SJohn Baldwin.It Bq Er EINVAL
8785ee63c9SJohn BaldwinThe
8885ee63c9SJohn Baldwin.Fa dev
8985ee63c9SJohn Baldwindevice does not have a parent device.
9085ee63c9SJohn Baldwin.It Bq Er EINVAL
9185ee63c9SJohn BaldwinThe
9285ee63c9SJohn Baldwin.Fa r
9385ee63c9SJohn Baldwinresource is a shared resource.
9485ee63c9SJohn Baldwin.It Bq Er EINVAL
9585ee63c9SJohn BaldwinThe new address range does not overlap with the existing address range of
9685ee63c9SJohn Baldwin.Fa r .
9785ee63c9SJohn Baldwin.It Bq Er EBUSY
9885ee63c9SJohn BaldwinThe new address range conflicts with another allocated resource.
9985ee63c9SJohn Baldwin.El
10085ee63c9SJohn Baldwin.Sh SEE ALSO
10185ee63c9SJohn Baldwin.Xr bus_alloc_resource 9 ,
10285ee63c9SJohn Baldwin.Xr bus_release_resource 9 ,
10385ee63c9SJohn Baldwin.Xr device 9 ,
10485ee63c9SJohn Baldwin.Xr driver 9
105