xref: /freebsd/share/man/man9/bus_adjust_resource.9 (revision 135bce2a9e632a7cedae2a42f5b2eef2b77d5e56)
185ee63c9SJohn Baldwin.\" -*- nroff -*-
285ee63c9SJohn Baldwin.\"
385ee63c9SJohn Baldwin.\" Copyright (c) 2011 Advanced Computing Technologies 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.\"
3085ee63c9SJohn Baldwin.Dd April 29, 2011
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
4485ee63c9SJohn Baldwin.Fn bus_adjust_resource "device_t dev" "int type" "struct resource *r" "u_long start" "u_long end"
4585ee63c9SJohn Baldwin.Sh DESCRIPTION
4685ee63c9SJohn BaldwinThis function is used to ask the parent bus to adjust the resource range
4785ee63c9SJohn Baldwinassigned to an allocated resource.
4885ee63c9SJohn BaldwinThe resource
4985ee63c9SJohn Baldwin.Fa r
5085ee63c9SJohn Baldwinshould have been allocated by a previous call to
5185ee63c9SJohn Baldwin.Xr bus_alloc_resource 9 .
5285ee63c9SJohn BaldwinThe new resource range must overlap the existing range of
5385ee63c9SJohn Baldwin.Fa r .
5485ee63c9SJohn BaldwinThe
5585ee63c9SJohn Baldwin.Fa type
5685ee63c9SJohn Baldwinargument should match the
5785ee63c9SJohn Baldwin.Fa type
5885ee63c9SJohn Baldwinargument passed to
5985ee63c9SJohn Baldwin.Xr bus_alloc_resource 9
6085ee63c9SJohn Baldwinwhen the resource was initially allocated.
6185ee63c9SJohn Baldwin.Pp
6285ee63c9SJohn BaldwinNote that none of the constraints of the original allocation request such
6385ee63c9SJohn Baldwinas alignment or boundary restrictions are checked by
6485ee63c9SJohn Baldwin.Fn bus_adjust_resource .
6585ee63c9SJohn BaldwinIt is the caller's responsibility to enforce any such requirements.
6685ee63c9SJohn Baldwin.Sh RETURN VALUES
6785ee63c9SJohn BaldwinThe
6885ee63c9SJohn Baldwin.Fn bus_adjust_resource
6985ee63c9SJohn Baldwinmethod returns zero on success or an error code on failure.
70*135bce2aSUlrich Spörlein.Sh EXAMPLES
71*135bce2aSUlrich SpörleinGrow an existing memory resource by 4096 bytes.
72*135bce2aSUlrich Spörlein.Bd -literal
73*135bce2aSUlrich Spörlein	struct resource *res;
74*135bce2aSUlrich Spörlein	int error;
75*135bce2aSUlrich Spörlein
76*135bce2aSUlrich Spörlein	error = bus_adjust_resource(dev, SYS_RES_MEMORY, res,
77*135bce2aSUlrich Spörlein	    rman_get_start(res), rman_get_end(res) + 0x1000);
78*135bce2aSUlrich Spörlein.Ed
7985ee63c9SJohn Baldwin.Sh ERRORS
8085ee63c9SJohn Baldwin.Fn bus_adjust_resource
8185ee63c9SJohn Baldwinwill fail if:
8285ee63c9SJohn Baldwin.Bl -tag -width Er
8385ee63c9SJohn Baldwin.It Bq Er EINVAL
8485ee63c9SJohn BaldwinThe
8585ee63c9SJohn Baldwin.Fa dev
8685ee63c9SJohn Baldwindevice does not have a parent device.
8785ee63c9SJohn Baldwin.It Bq Er EINVAL
8885ee63c9SJohn BaldwinThe
8985ee63c9SJohn Baldwin.Fa r
9085ee63c9SJohn Baldwinresource is a shared resource.
9185ee63c9SJohn Baldwin.It Bq Er EINVAL
9285ee63c9SJohn BaldwinThe new address range does not overlap with the existing address range of
9385ee63c9SJohn Baldwin.Fa r .
9485ee63c9SJohn Baldwin.It Bq Er EBUSY
9585ee63c9SJohn BaldwinThe new address range conflicts with another allocated resource.
9685ee63c9SJohn Baldwin.El
9785ee63c9SJohn Baldwin.Sh SEE ALSO
9885ee63c9SJohn Baldwin.Xr bus_alloc_resource 9 ,
9985ee63c9SJohn Baldwin.Xr bus_release_resource 9 ,
10085ee63c9SJohn Baldwin.Xr device 9 ,
10185ee63c9SJohn Baldwin.Xr driver 9
102