xref: /freebsd/share/man/man9/bus_activate_resource.9 (revision 9aa021d4164a183c84181ea126b4d5d02e31e857)
1ec33f2d5SWarner Losh.\" -*- nroff -*-
2ec33f2d5SWarner Losh.\"
3ec33f2d5SWarner Losh.\" Copyright (c) 2003 M. Warner Losh
4ec33f2d5SWarner Losh.\"
5ec33f2d5SWarner Losh.\" All rights reserved.
6ec33f2d5SWarner Losh.\"
7ec33f2d5SWarner Losh.\" This program is free software.
8ec33f2d5SWarner Losh.\"
9ec33f2d5SWarner Losh.\" Redistribution and use in source and binary forms, with or without
10ec33f2d5SWarner Losh.\" modification, are permitted provided that the following conditions
11ec33f2d5SWarner Losh.\" are met:
12ec33f2d5SWarner Losh.\" 1. Redistributions of source code must retain the above copyright
13ec33f2d5SWarner Losh.\"    notice, this list of conditions and the following disclaimer.
14ec33f2d5SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright
15ec33f2d5SWarner Losh.\"    notice, this list of conditions and the following disclaimer in the
16ec33f2d5SWarner Losh.\"    documentation and/or other materials provided with the distribution.
17ec33f2d5SWarner Losh.\"
18ec33f2d5SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
19ec33f2d5SWarner Losh.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20ec33f2d5SWarner Losh.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21ec33f2d5SWarner Losh.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
22ec33f2d5SWarner Losh.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23ec33f2d5SWarner Losh.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24ec33f2d5SWarner Losh.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25ec33f2d5SWarner Losh.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26ec33f2d5SWarner Losh.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27ec33f2d5SWarner Losh.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28ec33f2d5SWarner Losh.\"
29ec33f2d5SWarner Losh.\" $FreeBSD$
30ec33f2d5SWarner Losh.\"
3155c661caSJohn Baldwin.Dd April 28, 2016
32ec33f2d5SWarner Losh.Dt BUS_ACTIVATE_RESOURCE 9
33ec33f2d5SWarner Losh.Os
34ec33f2d5SWarner Losh.Sh NAME
353e1cee04SRuslan Ermilov.Nm bus_activate_resource , bus_deactivate_resource
363e1cee04SRuslan Ermilov.Nd activate or deactivate a resource
37ec33f2d5SWarner Losh.Sh SYNOPSIS
38ec33f2d5SWarner Losh.In sys/param.h
39ec33f2d5SWarner Losh.In sys/bus.h
40ec33f2d5SWarner Losh.Pp
41ec33f2d5SWarner Losh.In machine/bus.h
42ec33f2d5SWarner Losh.In sys/rman.h
43ec33f2d5SWarner Losh.In machine/resource.h
44ec33f2d5SWarner Losh.Ft int
453e1cee04SRuslan Ermilov.Fo bus_activate_resource
463e1cee04SRuslan Ermilov.Fa "device_t dev" "int type" "int rid" "struct resource *r"
473e1cee04SRuslan Ermilov.Fc
48ec33f2d5SWarner Losh.Ft int
493e1cee04SRuslan Ermilov.Fo bus_deactivate_resource
503e1cee04SRuslan Ermilov.Fa "device_t dev" "int type" "int rid" "struct resource *r"
513e1cee04SRuslan Ermilov.Fc
52ec33f2d5SWarner Losh.Sh DESCRIPTION
533e1cee04SRuslan ErmilovThese functions activate or deactivate a previously allocated resource.
54ec33f2d5SWarner LoshIn general, resources must be activated before they can be accessed by
55*9aa021d4SJohn Baldwinthe driver.
56*9aa021d4SJohn BaldwinBus drivers may perform additional actions to ensure that the resource is
57*9aa021d4SJohn Baldwinready to be accessed.
58*9aa021d4SJohn BaldwinFor example,
59*9aa021d4SJohn Baldwinthe PCI bus driver enables memory decoding in a PCI device's command register
60*9aa021d4SJohn Baldwinwhen activating a memory resource.
61ec33f2d5SWarner Losh.Pp
623e1cee04SRuslan ErmilovThe arguments are as follows:
633e1cee04SRuslan Ermilov.Bl -tag -width indent
643e1cee04SRuslan Ermilov.It Fa dev
653e1cee04SRuslan ErmilovThe device that requests ownership of the resource.
66ec33f2d5SWarner LoshBefore allocation, the resource is owned by the parent bus.
673e1cee04SRuslan Ermilov.It Fa type
683e1cee04SRuslan ErmilovThe type of resource you want to allocate.
69ec33f2d5SWarner LoshIt is one of:
703e1cee04SRuslan Ermilov.Pp
713e1cee04SRuslan Ermilov.Bl -tag -width ".Dv SYS_RES_MEMORY" -compact
7255c661caSJohn Baldwin.It Dv PCI_RES_BUS
7355c661caSJohn Baldwinfor PCI bus numbers
74ec33f2d5SWarner Losh.It Dv SYS_RES_IRQ
75ec33f2d5SWarner Loshfor IRQs
76ec33f2d5SWarner Losh.It Dv SYS_RES_DRQ
77ec33f2d5SWarner Loshfor ISA DMA lines
78ec33f2d5SWarner Losh.It Dv SYS_RES_IOPORT
79ec33f2d5SWarner Loshfor I/O ports
80ec33f2d5SWarner Losh.It Dv SYS_RES_MEMORY
81ec33f2d5SWarner Loshfor I/O memory
82ec33f2d5SWarner Losh.El
833e1cee04SRuslan Ermilov.It Fa rid
843e1cee04SRuslan ErmilovA pointer to a bus specific handle that identifies the resource being allocated.
853e1cee04SRuslan Ermilov.It Fa r
863e1cee04SRuslan ErmilovA pointer to the
873e1cee04SRuslan Ermilov.Vt "struct resource"
88ec33f2d5SWarner Loshreturned by
89ec33f2d5SWarner Losh.Xr bus_alloc_resource 9 .
90ec33f2d5SWarner Losh.El
91*9aa021d4SJohn Baldwin.Ss Resource Mapping
92*9aa021d4SJohn BaldwinResources which can be mapped for CPU access by a
93*9aa021d4SJohn Baldwin.Xr bus_space
94*9aa021d4SJohn Baldwintag and handle will create a mapping of the entire resource when activated.
95*9aa021d4SJohn BaldwinThe tag and handle for this mapping are stored in
96*9aa021d4SJohn Baldwin.Fa r
97*9aa021d4SJohn Baldwinand can be retrieved via
98*9aa021d4SJohn Baldwin.Xr rman_get_bustag 9
99*9aa021d4SJohn Baldwinand
100*9aa021d4SJohn Baldwin.Xr rman_get_bushandle 9 .
101*9aa021d4SJohn BaldwinThese can be used with the
102*9aa021d4SJohn Baldwin.Xr bus_space 9
103*9aa021d4SJohn BaldwinAPI to access device registers or memory described by
104*9aa021d4SJohn Baldwin.Fa r .
105*9aa021d4SJohn BaldwinIf the mapping is associated with a virtual address,
106*9aa021d4SJohn Baldwinthe virtual address can be retrieved via
107*9aa021d4SJohn Baldwin.Xr rman_get_virtual 9 .
108*9aa021d4SJohn Baldwin.Pp
109*9aa021d4SJohn BaldwinA wrapper API for
110*9aa021d4SJohn Baldwin.Xr bus_space 9
111*9aa021d4SJohn Baldwinis also provided that accepts the associated resource as the first argument
112*9aa021d4SJohn Baldwinin place of the
113*9aa021d4SJohn Baldwin.Xr bus_space 9
114*9aa021d4SJohn Baldwintag and handle.
115*9aa021d4SJohn BaldwinThe functions in this wrapper API are named similarly to the
116*9aa021d4SJohn Baldwin.Xr bus_space 9
117*9aa021d4SJohn BaldwinAPI except that
118*9aa021d4SJohn Baldwin.Dq _space
119*9aa021d4SJohn Baldwinis removed from their name.
120*9aa021d4SJohn BaldwinFor example,
121*9aa021d4SJohn Baldwin.Fn bus_read_4
122*9aa021d4SJohn Baldwincan be used in place of
123*9aa021d4SJohn Baldwin.Fn bus_space_read_4 .
124*9aa021d4SJohn BaldwinThe wrapper API is preferred in new drivers.
125*9aa021d4SJohn Baldwin.Pp
126*9aa021d4SJohn BaldwinThese two statements both read a 32-bit register at the start of a
127*9aa021d4SJohn Baldwinresource:
128*9aa021d4SJohn Baldwin.Bd -literal
129*9aa021d4SJohn Baldwin	bus_space_read_4(rman_get_bustag(res), rman_get_bushandle(res), 0);
130*9aa021d4SJohn Baldwin	bus_read_4(res, 0);
131*9aa021d4SJohn Baldwin.Ed
132ec33f2d5SWarner Losh.Sh RETURN VALUES
1333e1cee04SRuslan ErmilovZero is returned on success, otherwise an error is returned.
134ec33f2d5SWarner Losh.Sh SEE ALSO
135ec33f2d5SWarner Losh.Xr bus_alloc_resource 9 ,
136ec33f2d5SWarner Losh.Xr device 9 ,
137ec33f2d5SWarner Losh.Xr driver 9
138ec33f2d5SWarner Losh.Sh AUTHORS
1393e1cee04SRuslan ErmilovThis manual page was written by
1408a7314fcSBaptiste Daroussin.An Warner Losh Aq Mt imp@FreeBSD.org .
141