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