1ec33f2d5SWarner Losh.\" -*- nroff -*- 2ec33f2d5SWarner Losh.\" 3*a7147da9SWarner Losh.\" Copyright (c) 2003 M. Warner Losh <imp@FreeBSD.org> 4ec33f2d5SWarner Losh.\" 5ec33f2d5SWarner Losh.\" Redistribution and use in source and binary forms, with or without 6ec33f2d5SWarner Losh.\" modification, are permitted provided that the following conditions 7ec33f2d5SWarner Losh.\" are met: 8ec33f2d5SWarner Losh.\" 1. Redistributions of source code must retain the above copyright 9ec33f2d5SWarner Losh.\" notice, this list of conditions and the following disclaimer. 10ec33f2d5SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright 11ec33f2d5SWarner Losh.\" notice, this list of conditions and the following disclaimer in the 12ec33f2d5SWarner Losh.\" documentation and/or other materials provided with the distribution. 13ec33f2d5SWarner Losh.\" 14ec33f2d5SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 15ec33f2d5SWarner Losh.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16ec33f2d5SWarner Losh.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17ec33f2d5SWarner Losh.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 18ec33f2d5SWarner Losh.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19ec33f2d5SWarner Losh.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20ec33f2d5SWarner Losh.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21ec33f2d5SWarner Losh.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22ec33f2d5SWarner Losh.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23ec33f2d5SWarner Losh.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24ec33f2d5SWarner Losh.\" 25ec33f2d5SWarner Losh.\" $FreeBSD$ 26ec33f2d5SWarner Losh.\" 27cc981af2SJohn Baldwin.Dd May 20, 2016 28ec33f2d5SWarner Losh.Dt BUS_ACTIVATE_RESOURCE 9 29ec33f2d5SWarner Losh.Os 30ec33f2d5SWarner Losh.Sh NAME 313e1cee04SRuslan Ermilov.Nm bus_activate_resource , bus_deactivate_resource 323e1cee04SRuslan Ermilov.Nd activate or deactivate a resource 33ec33f2d5SWarner Losh.Sh SYNOPSIS 34ec33f2d5SWarner Losh.In sys/param.h 35ec33f2d5SWarner Losh.In sys/bus.h 36ec33f2d5SWarner Losh.Pp 37ec33f2d5SWarner Losh.In machine/bus.h 38ec33f2d5SWarner Losh.In sys/rman.h 39ec33f2d5SWarner Losh.In machine/resource.h 40ec33f2d5SWarner Losh.Ft int 413e1cee04SRuslan Ermilov.Fo bus_activate_resource 423e1cee04SRuslan Ermilov.Fa "device_t dev" "int type" "int rid" "struct resource *r" 433e1cee04SRuslan Ermilov.Fc 44ec33f2d5SWarner Losh.Ft int 453e1cee04SRuslan Ermilov.Fo bus_deactivate_resource 463e1cee04SRuslan Ermilov.Fa "device_t dev" "int type" "int rid" "struct resource *r" 473e1cee04SRuslan Ermilov.Fc 48ec33f2d5SWarner Losh.Sh DESCRIPTION 493e1cee04SRuslan ErmilovThese functions activate or deactivate a previously allocated resource. 50ec33f2d5SWarner LoshIn general, resources must be activated before they can be accessed by 519aa021d4SJohn Baldwinthe driver. 529aa021d4SJohn BaldwinBus drivers may perform additional actions to ensure that the resource is 539aa021d4SJohn Baldwinready to be accessed. 549aa021d4SJohn BaldwinFor example, 559aa021d4SJohn Baldwinthe PCI bus driver enables memory decoding in a PCI device's command register 569aa021d4SJohn Baldwinwhen activating a memory resource. 57ec33f2d5SWarner Losh.Pp 583e1cee04SRuslan ErmilovThe arguments are as follows: 593e1cee04SRuslan Ermilov.Bl -tag -width indent 603e1cee04SRuslan Ermilov.It Fa dev 613e1cee04SRuslan ErmilovThe device that requests ownership of the resource. 62ec33f2d5SWarner LoshBefore allocation, the resource is owned by the parent bus. 633e1cee04SRuslan Ermilov.It Fa type 643e1cee04SRuslan ErmilovThe type of resource you want to allocate. 65ec33f2d5SWarner LoshIt is one of: 663e1cee04SRuslan Ermilov.Pp 673e1cee04SRuslan Ermilov.Bl -tag -width ".Dv SYS_RES_MEMORY" -compact 6855c661caSJohn Baldwin.It Dv PCI_RES_BUS 6955c661caSJohn Baldwinfor PCI bus numbers 70ec33f2d5SWarner Losh.It Dv SYS_RES_IRQ 71ec33f2d5SWarner Loshfor IRQs 72ec33f2d5SWarner Losh.It Dv SYS_RES_DRQ 73ec33f2d5SWarner Loshfor ISA DMA lines 74ec33f2d5SWarner Losh.It Dv SYS_RES_IOPORT 75ec33f2d5SWarner Loshfor I/O ports 76ec33f2d5SWarner Losh.It Dv SYS_RES_MEMORY 77ec33f2d5SWarner Loshfor I/O memory 78ec33f2d5SWarner Losh.El 793e1cee04SRuslan Ermilov.It Fa rid 803e1cee04SRuslan ErmilovA pointer to a bus specific handle that identifies the resource being allocated. 813e1cee04SRuslan Ermilov.It Fa r 823e1cee04SRuslan ErmilovA pointer to the 833e1cee04SRuslan Ermilov.Vt "struct resource" 84ec33f2d5SWarner Loshreturned by 85ec33f2d5SWarner Losh.Xr bus_alloc_resource 9 . 86ec33f2d5SWarner Losh.El 879aa021d4SJohn Baldwin.Ss Resource Mapping 889aa021d4SJohn BaldwinResources which can be mapped for CPU access by a 89a7b81566SJohn Baldwin.Xr bus_space 9 909aa021d4SJohn Baldwintag and handle will create a mapping of the entire resource when activated. 919aa021d4SJohn BaldwinThe tag and handle for this mapping are stored in 929aa021d4SJohn Baldwin.Fa r 939aa021d4SJohn Baldwinand can be retrieved via 949aa021d4SJohn Baldwin.Xr rman_get_bustag 9 959aa021d4SJohn Baldwinand 969aa021d4SJohn Baldwin.Xr rman_get_bushandle 9 . 979aa021d4SJohn BaldwinThese can be used with the 989aa021d4SJohn Baldwin.Xr bus_space 9 999aa021d4SJohn BaldwinAPI to access device registers or memory described by 1009aa021d4SJohn Baldwin.Fa r . 1019aa021d4SJohn BaldwinIf the mapping is associated with a virtual address, 1029aa021d4SJohn Baldwinthe virtual address can be retrieved via 1039aa021d4SJohn Baldwin.Xr rman_get_virtual 9 . 1049aa021d4SJohn Baldwin.Pp 105cc981af2SJohn BaldwinThis implicit mapping can be disabled by passing the 106cc981af2SJohn Baldwin.Dv RF_UNMAPPED 107cc981af2SJohn Baldwinflag to 108cc981af2SJohn Baldwin.Xr bus_alloc_resource 9 . 109cc981af2SJohn BaldwinA driver may use this if it wishes to allocate its own mappings of a resource 110cc981af2SJohn Baldwinusing 111cc981af2SJohn Baldwin.Xr bus_map_resource 9 . 112cc981af2SJohn Baldwin.Pp 1139aa021d4SJohn BaldwinA wrapper API for 1149aa021d4SJohn Baldwin.Xr bus_space 9 1159aa021d4SJohn Baldwinis also provided that accepts the associated resource as the first argument 1169aa021d4SJohn Baldwinin place of the 1179aa021d4SJohn Baldwin.Xr bus_space 9 1189aa021d4SJohn Baldwintag and handle. 1199aa021d4SJohn BaldwinThe functions in this wrapper API are named similarly to the 1209aa021d4SJohn Baldwin.Xr bus_space 9 1219aa021d4SJohn BaldwinAPI except that 1229aa021d4SJohn Baldwin.Dq _space 1239aa021d4SJohn Baldwinis removed from their name. 1249aa021d4SJohn BaldwinFor example, 1259aa021d4SJohn Baldwin.Fn bus_read_4 1269aa021d4SJohn Baldwincan be used in place of 1279aa021d4SJohn Baldwin.Fn bus_space_read_4 . 1289aa021d4SJohn BaldwinThe wrapper API is preferred in new drivers. 1299aa021d4SJohn Baldwin.Pp 1309aa021d4SJohn BaldwinThese two statements both read a 32-bit register at the start of a 1319aa021d4SJohn Baldwinresource: 1329aa021d4SJohn Baldwin.Bd -literal 1339aa021d4SJohn Baldwin bus_space_read_4(rman_get_bustag(res), rman_get_bushandle(res), 0); 1349aa021d4SJohn Baldwin bus_read_4(res, 0); 1359aa021d4SJohn Baldwin.Ed 136ec33f2d5SWarner Losh.Sh RETURN VALUES 1373e1cee04SRuslan ErmilovZero is returned on success, otherwise an error is returned. 138ec33f2d5SWarner Losh.Sh SEE ALSO 139ec33f2d5SWarner Losh.Xr bus_alloc_resource 9 , 140cc981af2SJohn Baldwin.Xr bus_map_resource 9 , 141a7b81566SJohn Baldwin.Xr bus_space 9 , 142ec33f2d5SWarner Losh.Xr device 9 , 143ec33f2d5SWarner Losh.Xr driver 9 144ec33f2d5SWarner Losh.Sh AUTHORS 1453e1cee04SRuslan ErmilovThis manual page was written by 1468a7314fcSBaptiste Daroussin.An Warner Losh Aq Mt imp@FreeBSD.org . 147