xref: /freebsd/share/man/man9/bus_adjust_resource.9 (revision 85ee63c9238483c787a12547328a6b1c196264db)
1*85ee63c9SJohn Baldwin.\" -*- nroff -*-
2*85ee63c9SJohn Baldwin.\"
3*85ee63c9SJohn Baldwin.\" Copyright (c) 2011 Advanced Computing Technologies LLC
4*85ee63c9SJohn Baldwin.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
5*85ee63c9SJohn Baldwin.\" All rights reserved.
6*85ee63c9SJohn Baldwin.\"
7*85ee63c9SJohn Baldwin.\" Redistribution and use in source and binary forms, with or without
8*85ee63c9SJohn Baldwin.\" modification, are permitted provided that the following conditions
9*85ee63c9SJohn Baldwin.\" are met:
10*85ee63c9SJohn Baldwin.\" 1. Redistributions of source code must retain the above copyright
11*85ee63c9SJohn Baldwin.\"    notice, this list of conditions and the following disclaimer.
12*85ee63c9SJohn Baldwin.\" 2. Redistributions in binary form must reproduce the above copyright
13*85ee63c9SJohn Baldwin.\"    notice, this list of conditions and the following disclaimer in the
14*85ee63c9SJohn Baldwin.\"    documentation and/or other materials provided with the distribution.
15*85ee63c9SJohn Baldwin.\"
16*85ee63c9SJohn Baldwin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17*85ee63c9SJohn Baldwin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*85ee63c9SJohn Baldwin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*85ee63c9SJohn Baldwin.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20*85ee63c9SJohn Baldwin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*85ee63c9SJohn Baldwin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22*85ee63c9SJohn Baldwin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*85ee63c9SJohn Baldwin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*85ee63c9SJohn Baldwin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*85ee63c9SJohn Baldwin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*85ee63c9SJohn Baldwin.\" SUCH DAMAGE.
27*85ee63c9SJohn Baldwin.\"
28*85ee63c9SJohn Baldwin.\" $FreeBSD$
29*85ee63c9SJohn Baldwin.\"
30*85ee63c9SJohn Baldwin.Dd April 29, 2011
31*85ee63c9SJohn Baldwin.Dt BUS_ADJUST_RESOURCE 9
32*85ee63c9SJohn Baldwin.Os
33*85ee63c9SJohn Baldwin.Sh NAME
34*85ee63c9SJohn Baldwin.Nm bus_adjust_resource
35*85ee63c9SJohn Baldwin.Nd adjust resource allocated from a parent bus
36*85ee63c9SJohn Baldwin.Sh SYNOPSIS
37*85ee63c9SJohn Baldwin.In sys/param.h
38*85ee63c9SJohn Baldwin.In sys/bus.h
39*85ee63c9SJohn Baldwin.Pp
40*85ee63c9SJohn Baldwin.In machine/bus.h
41*85ee63c9SJohn Baldwin.In sys/rman.h
42*85ee63c9SJohn Baldwin.In machine/resource.h
43*85ee63c9SJohn Baldwin.Ft int
44*85ee63c9SJohn Baldwin.Fn bus_adjust_resource "device_t dev" "int type" "struct resource *r" "u_long start" "u_long end"
45*85ee63c9SJohn Baldwin.Sh DESCRIPTION
46*85ee63c9SJohn BaldwinThis function is used to ask the parent bus to adjust the resource range
47*85ee63c9SJohn Baldwinassigned to an allocated resource.
48*85ee63c9SJohn BaldwinThe resource
49*85ee63c9SJohn Baldwin.Fa r
50*85ee63c9SJohn Baldwinshould have been allocated by a previous call to
51*85ee63c9SJohn Baldwin.Xr bus_alloc_resource 9 .
52*85ee63c9SJohn BaldwinThe new resource range must overlap the existing range of
53*85ee63c9SJohn Baldwin.Fa r .
54*85ee63c9SJohn BaldwinThe
55*85ee63c9SJohn Baldwin.Fa type
56*85ee63c9SJohn Baldwinargument should match the
57*85ee63c9SJohn Baldwin.Fa type
58*85ee63c9SJohn Baldwinargument passed to
59*85ee63c9SJohn Baldwin.Xr bus_alloc_resource 9
60*85ee63c9SJohn Baldwinwhen the resource was initially allocated.
61*85ee63c9SJohn Baldwin.Pp
62*85ee63c9SJohn BaldwinNote that none of the constraints of the original allocation request such
63*85ee63c9SJohn Baldwinas alignment or boundary restrictions are checked by
64*85ee63c9SJohn Baldwin.Fn bus_adjust_resource .
65*85ee63c9SJohn BaldwinIt is the caller's responsibility to enforce any such requirements.
66*85ee63c9SJohn Baldwin.Sh RETURN VALUES
67*85ee63c9SJohn BaldwinThe
68*85ee63c9SJohn Baldwin.Fn bus_adjust_resource
69*85ee63c9SJohn Baldwinmethod returns zero on success or an error code on failure.
70*85ee63c9SJohn Baldwin.Sh ERRORS
71*85ee63c9SJohn Baldwin.Fn bus_adjust_resource
72*85ee63c9SJohn Baldwinwill fail if:
73*85ee63c9SJohn Baldwin.Bl -tag -width Er
74*85ee63c9SJohn Baldwin.It Bq Er EINVAL
75*85ee63c9SJohn BaldwinThe
76*85ee63c9SJohn Baldwin.Fa dev
77*85ee63c9SJohn Baldwindevice does not have a parent device.
78*85ee63c9SJohn Baldwin.It Bq Er EINVAL
79*85ee63c9SJohn BaldwinThe
80*85ee63c9SJohn Baldwin.Fa r
81*85ee63c9SJohn Baldwinresource is a shared resource.
82*85ee63c9SJohn Baldwin.It Bq Er EINVAL
83*85ee63c9SJohn BaldwinThe new address range does not overlap with the existing address range of
84*85ee63c9SJohn Baldwin.Fa r .
85*85ee63c9SJohn Baldwin.It Bq Er EBUSY
86*85ee63c9SJohn BaldwinThe new address range conflicts with another allocated resource.
87*85ee63c9SJohn Baldwin.El
88*85ee63c9SJohn Baldwin.Sh EXAMPLES
89*85ee63c9SJohn BaldwinGrow an existing memory resource by 4096 bytes.
90*85ee63c9SJohn Baldwin.Bd -literal
91*85ee63c9SJohn Baldwin	struct resource *res;
92*85ee63c9SJohn Baldwin	int error;
93*85ee63c9SJohn Baldwin
94*85ee63c9SJohn Baldwin	error = bus_adjust_resource(dev, SYS_RES_MEMORY, res,
95*85ee63c9SJohn Baldwin	    rman_get_start(res), rman_get_end(res) + 0x1000);
96*85ee63c9SJohn Baldwin.Ed
97*85ee63c9SJohn Baldwin.Sh SEE ALSO
98*85ee63c9SJohn Baldwin.Xr bus_alloc_resource 9 ,
99*85ee63c9SJohn Baldwin.Xr bus_release_resource 9 ,
100*85ee63c9SJohn Baldwin.Xr device 9 ,
101*85ee63c9SJohn Baldwin.Xr driver 9
102