3 .\" Copyright (c) 2003 M. Warner Losh <imp@FreeBSD.org>
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
15 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 .Dt BUS_ACTIVATE_RESOURCE 9
31 .Nm bus_activate_resource , bus_deactivate_resource
32 .Nd activate or deactivate a resource
39 .In machine/resource.h
41 .Fo bus_activate_resource
42 .Fa "device_t dev" "int type" "int rid" "struct resource *r"
45 .Fo bus_deactivate_resource
46 .Fa "device_t dev" "int type" "int rid" "struct resource *r"
49 These functions activate or deactivate a previously allocated resource.
50 In general, resources must be activated before they can be accessed by
52 Bus drivers may perform additional actions to ensure that the resource is
55 the PCI bus driver enables memory decoding in a PCI device's command register
56 when activating a memory resource.
58 The arguments are as follows:
59 .Bl -tag -width indent
61 The device that requests ownership of the resource.
62 Before allocation, the resource is owned by the parent bus.
64 The type of resource you want to allocate.
67 .Bl -tag -width ".Dv SYS_RES_MEMORY" -compact
80 A pointer to a bus specific handle that identifies the resource being allocated.
85 .Xr bus_alloc_resource 9 .
88 Resources which can be mapped for CPU access by a
90 tag and handle will create a mapping of the entire resource when activated.
91 The tag and handle for this mapping are stored in
93 and can be retrieved via
96 .Xr rman_get_bushandle 9 .
97 These can be used with the
99 API to access device registers or memory described by
101 If the mapping is associated with a virtual address,
102 the virtual address can be retrieved via
103 .Xr rman_get_virtual 9 .
105 This implicit mapping can be disabled by passing the
108 .Xr bus_alloc_resource 9 .
109 A driver may use this if it wishes to allocate its own mappings of a resource
111 .Xr bus_map_resource 9 .
115 is also provided that accepts the associated resource as the first argument
119 The functions in this wrapper API are named similarly to the
123 is removed from their name.
126 can be used in place of
127 .Fn bus_space_read_4 .
128 The wrapper API is preferred in new drivers.
130 These two statements both read a 32-bit register at the start of a
133 bus_space_read_4(rman_get_bustag(res), rman_get_bushandle(res), 0);
137 Zero is returned on success, otherwise an error is returned.
139 .Xr bus_alloc_resource 9 ,
140 .Xr bus_map_resource 9 ,
145 This manual page was written by
146 .An Warner Losh Aq Mt imp@FreeBSD.org .