15f616912SHiten Pandya.\" 25f616912SHiten Pandya.\" Copyright (c) 2003 Bruce M Simpson <bms@spc.org> 35f616912SHiten Pandya.\" All rights reserved. 45f616912SHiten Pandya.\" 55f616912SHiten Pandya.\" Redistribution and use in source and binary forms, with or without 65f616912SHiten Pandya.\" modification, are permitted provided that the following conditions 75f616912SHiten Pandya.\" are met: 85f616912SHiten Pandya.\" 1. Redistributions of source code must retain the above copyright 95f616912SHiten Pandya.\" notice, this list of conditions and the following disclaimer. 105f616912SHiten Pandya.\" 2. Redistributions in binary form must reproduce the above copyright 115f616912SHiten Pandya.\" notice, this list of conditions and the following disclaimer in the 125f616912SHiten Pandya.\" documentation and/or other materials provided with the distribution. 135f616912SHiten Pandya.\" 145f616912SHiten Pandya.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 155f616912SHiten Pandya.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 165f616912SHiten Pandya.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 175f616912SHiten Pandya.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 185f616912SHiten Pandya.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 195f616912SHiten Pandya.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 205f616912SHiten Pandya.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 215f616912SHiten Pandya.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 225f616912SHiten Pandya.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 235f616912SHiten Pandya.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 245f616912SHiten Pandya.\" SUCH DAMAGE. 255f616912SHiten Pandya.\" 265f616912SHiten Pandya.\" $FreeBSD$ 275f616912SHiten Pandya.\" 28cc981af2SJohn Baldwin.Dd May 20, 2016 295f616912SHiten Pandya.Dt RMAN 9 305f616912SHiten Pandya.Os 315f616912SHiten Pandya.Sh NAME 325f616912SHiten Pandya.Nm rman , 335f616912SHiten Pandya.Nm rman_activate_resource , 34bb82622cSJohn Baldwin.Nm rman_adjust_resource , 355f616912SHiten Pandya.Nm rman_deactivate_resource , 365f616912SHiten Pandya.Nm rman_fini , 375f616912SHiten Pandya.Nm rman_init , 38bb82622cSJohn Baldwin.Nm rman_init_from_resource , 39bb82622cSJohn Baldwin.Nm rman_is_region_manager , 405f616912SHiten Pandya.Nm rman_manage_region , 41bb82622cSJohn Baldwin.Nm rman_first_free_region , 42bb82622cSJohn Baldwin.Nm rman_last_free_region , 435f616912SHiten Pandya.Nm rman_release_resource , 445f616912SHiten Pandya.Nm rman_reserve_resource , 455f616912SHiten Pandya.Nm rman_reserve_resource_bound , 465f616912SHiten Pandya.Nm rman_make_alignment_flags , 475f616912SHiten Pandya.Nm rman_get_start , 485f616912SHiten Pandya.Nm rman_get_end , 4911053af5SHiten Pandya.Nm rman_get_device , 505f616912SHiten Pandya.Nm rman_get_size , 515f616912SHiten Pandya.Nm rman_get_flags , 52cc981af2SJohn Baldwin.Nm rman_set_mapping , 53cc981af2SJohn Baldwin.Nm rman_get_mapping , 545f616912SHiten Pandya.Nm rman_set_virtual , 555f616912SHiten Pandya.Nm rman_get_virtual , 565f616912SHiten Pandya.Nm rman_set_bustag , 575f616912SHiten Pandya.Nm rman_get_bustag , 585f616912SHiten Pandya.Nm rman_set_bushandle , 595f616912SHiten Pandya.Nm rman_get_bushandle , 605f616912SHiten Pandya.Nm rman_set_rid , 615f616912SHiten Pandya.Nm rman_get_rid 625f616912SHiten Pandya.Nd resource management functions 635f616912SHiten Pandya.Sh SYNOPSIS 649f6985c4SWarner Losh.In sys/types.h 655f616912SHiten Pandya.In sys/rman.h 665f616912SHiten Pandya.Ft int 675f616912SHiten Pandya.Fn rman_activate_resource "struct resource *r" 685f616912SHiten Pandya.Ft int 692dd1bdf1SJustin Hibbits.Fn rman_adjust_resource "struct resource *r" "rman_res_t start" "rman_res_t end" 70bb82622cSJohn Baldwin.Ft int 715f616912SHiten Pandya.Fn rman_deactivate_resource "struct resource *r" 725f616912SHiten Pandya.Ft int 735f616912SHiten Pandya.Fn rman_fini "struct rman *rm" 745f616912SHiten Pandya.Ft int 755f616912SHiten Pandya.Fn rman_init "struct rman *rm" 765f616912SHiten Pandya.Ft int 77bb82622cSJohn Baldwin.Fn rman_init_from_resource "struct rman *rm" "struct resource *r" 78bb82622cSJohn Baldwin.Ft int 79bb82622cSJohn Baldwin.Fn rman_is_region_manager "struct resource *r" "struct rman *rm" 80bb82622cSJohn Baldwin.Ft int 812dd1bdf1SJustin Hibbits.Fn rman_manage_region "struct rman *rm" "rman_res_t start" "rman_res_t end" 825f616912SHiten Pandya.Ft int 832dd1bdf1SJustin Hibbits.Fn rman_first_free_region "struct rman *rm" "rman_res_t *start" "rman_res_t *end" 84bb82622cSJohn Baldwin.Ft int 852dd1bdf1SJustin Hibbits.Fn rman_last_free_region "struct rman *rm" "rman_res_t *start" "rman_res_t *end" 86bb82622cSJohn Baldwin.Ft int 875f616912SHiten Pandya.Fn rman_release_resource "struct resource *r" 883e1cee04SRuslan Ermilov.Ft "struct resource *" 893e1cee04SRuslan Ermilov.Fo rman_reserve_resource 902dd1bdf1SJustin Hibbits.Fa "struct rman *rm" "rman_res_t start" "rman_res_t end" "rman_res_t count" 913e1cee04SRuslan Ermilov.Fa "u_int flags" "struct device *dev" 923e1cee04SRuslan Ermilov.Fc 933e1cee04SRuslan Ermilov.Ft "struct resource *" 943e1cee04SRuslan Ermilov.Fo rman_reserve_resource_bound 952dd1bdf1SJustin Hibbits.Fa "struct rman *rm" "rman_res_t start" "rman_res_t end" "rman_res_t count" 962dd1bdf1SJustin Hibbits.Fa "rman_res_t bound" "u_int flags" "struct device *dev" 973e1cee04SRuslan Ermilov.Fc 985f616912SHiten Pandya.Ft uint32_t 995f616912SHiten Pandya.Fn rman_make_alignment_flags "uint32_t size" 1002dd1bdf1SJustin Hibbits.Ft rman_res_t 1013e1cee04SRuslan Ermilov.Fn rman_get_start "struct resource *r" 1022dd1bdf1SJustin Hibbits.Ft rman_res_t 1033e1cee04SRuslan Ermilov.Fn rman_get_end "struct resource *r" 10411053af5SHiten Pandya.Ft "struct device *" 10511053af5SHiten Pandya.Fn rman_get_device "struct resource *r" 1062dd1bdf1SJustin Hibbits.Ft rman_res_t 1073e1cee04SRuslan Ermilov.Fn rman_get_size "struct resource *r" 1085f616912SHiten Pandya.Ft u_int 1093e1cee04SRuslan Ermilov.Fn rman_get_flags "struct resource *r" 1105f616912SHiten Pandya.Ft void 111cc981af2SJohn Baldwin.Fn rman_set_mapping "struct resource *r" "struct resource_map *map" 112cc981af2SJohn Baldwin.Ft void 113cc981af2SJohn Baldwin.Fn rman_get_mapping "struct resource *r" "struct resource_map *map" 114cc981af2SJohn Baldwin.Ft void 1153e1cee04SRuslan Ermilov.Fn rman_set_virtual "struct resource *r" "void *v" 1163e1cee04SRuslan Ermilov.Ft "void *" 1173e1cee04SRuslan Ermilov.Fn rman_get_virtual "struct resource *r" 1185f616912SHiten Pandya.Ft void 1193e1cee04SRuslan Ermilov.Fn rman_set_bustag "struct resource *r" "bus_space_tag_t t" 1205f616912SHiten Pandya.Ft bus_space_tag_t 1213e1cee04SRuslan Ermilov.Fn rman_get_bustag "struct resource *r" 1225f616912SHiten Pandya.Ft void 1233e1cee04SRuslan Ermilov.Fn rman_set_bushandle "struct resource *r" "bus_space_handle_t h" 1245f616912SHiten Pandya.Ft bus_space_handle_t 1253e1cee04SRuslan Ermilov.Fn rman_get_bushandle "struct resource *r" 1265f616912SHiten Pandya.Ft void 1273e1cee04SRuslan Ermilov.Fn rman_set_rid "struct resource *r" "int rid" 1285f616912SHiten Pandya.Ft int 1293e1cee04SRuslan Ermilov.Fn rman_get_rid "struct resource *r" 1305f616912SHiten Pandya.Sh DESCRIPTION 1315f616912SHiten PandyaThe 1325f616912SHiten Pandya.Nm 1335f616912SHiten Pandyaset of functions provides a flexible resource management abstraction. 1345f616912SHiten PandyaIt is used extensively by the bus management code. 1355f616912SHiten PandyaIt implements the abstractions of region and resource. 1365f616912SHiten PandyaA region descriptor is used to manage a region; this could be memory or 1375f616912SHiten Pandyasome other form of bus space. 1385f616912SHiten Pandya.Pp 1395f616912SHiten PandyaEach region has a set of bounds. 1405f616912SHiten PandyaWithin these bounds, allocated segments may reside. 1415f616912SHiten PandyaEach segment, termed a resource, has several properties which are 1425f616912SHiten Pandyarepresented by a 16-bit flag register, as follows. 1435f616912SHiten Pandya.Bd -literal 1445f616912SHiten Pandya#define RF_ALLOCATED 0x0001 /* resource has been reserved */ 1455f616912SHiten Pandya#define RF_ACTIVE 0x0002 /* resource allocation has been activated */ 1465f616912SHiten Pandya#define RF_SHAREABLE 0x0004 /* resource permits contemporaneous sharing */ 1475f616912SHiten Pandya#define RF_FIRSTSHARE 0x0020 /* first in sharing list */ 1485f616912SHiten Pandya#define RF_PREFETCHABLE 0x0040 /* resource is prefetchable */ 149cc981af2SJohn Baldwin#define RF_UNMAPPED 0x0100 /* don't map resource when activating */ 1505f616912SHiten Pandya.Ed 1515f616912SHiten Pandya.Pp 152d3a68794SDon LewisBits 15:10 of the flag register are used to represent the desired alignment 1535f616912SHiten Pandyaof the resource within the region. 1545f616912SHiten Pandya.Pp 1555f616912SHiten PandyaThe 1565f616912SHiten Pandya.Fn rman_init 1575f616912SHiten Pandyafunction initializes the region descriptor, pointed to by the 1585f616912SHiten Pandya.Fa rm 1595f616912SHiten Pandyaargument, for use with the resource management functions. 160bc956811SJohn-Mark GurneyIt is required that the fields 161bc956811SJohn-Mark Gurney.Va rm_type 162bc956811SJohn-Mark Gurneyand 163bc956811SJohn-Mark Gurney.Va rm_descr 164bc956811SJohn-Mark Gurneyof 165bc956811SJohn-Mark Gurney.Vt "struct rman" 166bc956811SJohn-Mark Gurneybe set before calling 167bc956811SJohn-Mark Gurney.Fn rman_init . 168bc956811SJohn-Mark GurneyThe field 169bc956811SJohn-Mark Gurney.Va rm_type 170bc956811SJohn-Mark Gurneyshall be set to 171bc956811SJohn-Mark Gurney.Dv RMAN_ARRAY . 172bc956811SJohn-Mark GurneyThe field 173bc956811SJohn-Mark Gurney.Va rm_descr 174bc956811SJohn-Mark Gurneyshall be set to a string that describes the resource to be managed. 175bb82622cSJohn BaldwinThe 176bb82622cSJohn Baldwin.Va rm_start 177bb82622cSJohn Baldwinand 178bb82622cSJohn Baldwin.Va rm_end 179bb82622cSJohn Baldwinfields may be set to limit the range of acceptable resource addresses. 180bb82622cSJohn BaldwinIf these fields are not set, 181bb82622cSJohn Baldwin.Fn rman_init 182bb82622cSJohn Baldwinwill initialize them to allow the entire range of resource addresses. 1835f616912SHiten PandyaIt also initializes any mutexes associated with the structure. 184ebf750a9SJohn-Mark GurneyIf 185ebf750a9SJohn-Mark Gurney.Fn rman_init 186f6ac2391SJoel Dahlfails to initialize the mutex, it will return 187ebf750a9SJohn-Mark Gurney.Er ENOMEM ; otherwise it will return 0 and 188ebf750a9SJohn-Mark Gurney.Fa rm 189f6ac2391SJoel Dahlwill be initialized. 1905f616912SHiten Pandya.Pp 1915f616912SHiten PandyaThe 1925f616912SHiten Pandya.Fn rman_fini 1935f616912SHiten Pandyafunction frees any structures associated with the structure 1945f616912SHiten Pandyapointed to by the 1955f616912SHiten Pandya.Fa rm 1963e1cee04SRuslan Ermilovargument. 1973e1cee04SRuslan ErmilovIf any of the resources within the managed region have the 1985f616912SHiten Pandya.Dv RF_ALLOCATED 1995f616912SHiten Pandyaflag set, it will return 2005f616912SHiten Pandya.Er EBUSY ; 2015f616912SHiten Pandyaotherwise, any mutexes associated with the structure will be released 2025f616912SHiten Pandyaand destroyed, and the function will return 0. 2035f616912SHiten Pandya.Pp 2045f616912SHiten PandyaThe 2055f616912SHiten Pandya.Fn rman_manage_region 2065f616912SHiten Pandyafunction establishes the concept of a region which is under 2075f616912SHiten Pandya.Nm 2085f616912SHiten Pandyacontrol. 2095f616912SHiten PandyaThe 2105f616912SHiten Pandya.Fa rman 2115f616912SHiten Pandyaargument points to the region descriptor. 2123e1cee04SRuslan ErmilovThe 2133e1cee04SRuslan Ermilov.Fa start 2143e1cee04SRuslan Ermilovand 2153e1cee04SRuslan Ermilov.Fa end 2163e1cee04SRuslan Ermilovarguments specify the bounds of the region. 217ebf750a9SJohn-Mark GurneyIf successful, 218ebf750a9SJohn-Mark Gurney.Fn rman_manage_region 219ebf750a9SJohn-Mark Gurneywill return 0. 220ebf750a9SJohn-Mark GurneyIf the region overlaps with an existing region, it will return 221ebf750a9SJohn-Mark Gurney.Er EBUSY . 222bb82622cSJohn BaldwinIf any part of the region falls outside of the valid address range for 223bb82622cSJohn Baldwin.Fa rm , 224bb82622cSJohn Baldwinit will return 225bb82622cSJohn Baldwin.Er EINVAL . 226ebf750a9SJohn-Mark Gurney.Er ENOMEM 227bb82622cSJohn Baldwinwill be returned when 228ebf750a9SJohn-Mark Gurney.Fn rman_manage_region 229ebf750a9SJohn-Mark Gurneyfailed to allocate memory for the region. 2305f616912SHiten Pandya.Pp 2315f616912SHiten PandyaThe 232bb82622cSJohn Baldwin.Fn rman_init_from_resource 233bb82622cSJohn Baldwinfunction is a wrapper routine to create a resource manager backed by an 234bb82622cSJohn Baldwinexisting resource. 235bb82622cSJohn BaldwinIt initializes 236bb82622cSJohn Baldwin.Fa rm 237bb82622cSJohn Baldwinusing 238bb82622cSJohn Baldwin.Fn rman_init 239bb82622cSJohn Baldwinand then adds a region to 240bb82622cSJohn Baldwin.Fa rm 241bb82622cSJohn Baldwincorresponding to the address range allocated to 242bb82622cSJohn Baldwin.Fa r 243bb82622cSJohn Baldwinvia 244bb82622cSJohn Baldwin.Fn rman_manage_region . 245bb82622cSJohn Baldwin.Pp 246bb82622cSJohn BaldwinThe 247bb82622cSJohn Baldwin.Fn rman_first_free_region 248bb82622cSJohn Baldwinand 249bb82622cSJohn Baldwin.Fn rman_last_free_region 250bb82622cSJohn Baldwinfunctions can be used to query a resource manager for its first 251bb82622cSJohn Baldwin.Pq or last 252bb82622cSJohn Baldwinunallocated region. 253bb82622cSJohn BaldwinIf 254bb82622cSJohn Baldwin.Fa rm 255bb82622cSJohn Baldwincontains no free region, 256bb82622cSJohn Baldwinthese functions will return 257bb82622cSJohn Baldwin.Er ENOENT . 258bb82622cSJohn BaldwinOtherwise, 259bb82622cSJohn Baldwin.Fa *start 260bb82622cSJohn Baldwinand 261bb82622cSJohn Baldwin.Fa *end 262bb82622cSJohn Baldwinare set to the bounds of the free region and zero is returned. 263bb82622cSJohn Baldwin.Pp 264bb82622cSJohn BaldwinThe 2655f616912SHiten Pandya.Fn rman_reserve_resource_bound 2665f616912SHiten Pandyafunction is where the bulk of the 2673e1cee04SRuslan Ermilov.Nm 2683e1cee04SRuslan Ermilovlogic is located. 2695f616912SHiten PandyaIt attempts to reserve a contiguous range in the specified region 2705f616912SHiten Pandya.Fa rm 2715f616912SHiten Pandyafor the use of the device 2725f616912SHiten Pandya.Fa dev . 2733e1cee04SRuslan ErmilovThe caller can specify the 2743e1cee04SRuslan Ermilov.Fa start 2753e1cee04SRuslan Ermilovand 2763e1cee04SRuslan Ermilov.Fa end 277bb82622cSJohn Baldwinof an acceptable range, 278bb82622cSJohn Baldwinas well as a boundary restriction and required aligment, 279bb82622cSJohn Baldwinand the code will attempt to find a free segment which fits. 280f3011a7cSWarner LoshThe 281f3011a7cSWarner Losh.Fa start 282f3011a7cSWarner Loshargument is the lowest acceptable starting value of the resource. 283f3011a7cSWarner LoshThe 284f3011a7cSWarner Losh.Fa end 285f3011a7cSWarner Loshargument is the highest acceptable ending value of the resource. 286f3011a7cSWarner LoshTherefore, 2874f068961SRuslan Ermilov.Fa start No + Fa count No \- 1 2884f068961SRuslan Ermilovmust be \[<=] 289f3011a7cSWarner Losh.Fa end 290f3011a7cSWarner Loshfor any allocation to happen. 291bb82622cSJohn BaldwinThe aligment requirement 292bb82622cSJohn Baldwin.Pq if any 293bb82622cSJohn Baldwinis specified in 294bb82622cSJohn Baldwin.Fa flags . 295bb82622cSJohn BaldwinThe 296bb82622cSJohn Baldwin.Fa bound 297bb82622cSJohn Baldwinargument may be set to specify a boundary restriction such that an 298bb82622cSJohn Baldwinallocated region may cross an address that is a multiple of the 299bb82622cSJohn Baldwinboundary. 300bb82622cSJohn BaldwinThe 301bb82622cSJohn Baldwin.Fa bound 302bb82622cSJohn Baldwinargument must be a power of two. 303bb82622cSJohn BaldwinIt may be set to zero to specify no boundary restriction. 304d3a68794SDon LewisA shared segment will be allocated if the 3055f616912SHiten Pandya.Dv RF_SHAREABLE 306d3a68794SDon Lewisflag is set, otherwise an exclusive segment will be allocated. 3075f616912SHiten PandyaIf this shared segment already exists, the caller has its device 3085f616912SHiten Pandyaadded to the list of consumers. 3095f616912SHiten Pandya.Pp 3105f616912SHiten PandyaThe 3115f616912SHiten Pandya.Fn rman_reserve_resource 3125f616912SHiten Pandyafunction is used to reserve resources within a previously established region. 3135f616912SHiten PandyaIt is a simplified interface to 3145f616912SHiten Pandya.Fn rman_reserve_resource_bound 3155f616912SHiten Pandyawhich passes 0 for the 316bb82622cSJohn Baldwin.Fa bound 3175f616912SHiten Pandyaargument. 3185f616912SHiten Pandya.Pp 3195f616912SHiten PandyaThe 3205f616912SHiten Pandya.Fn rman_make_alignment_flags 3215f616912SHiten Pandyafunction returns the flag mask corresponding to the desired alignment 3225f616912SHiten Pandya.Fa size . 3235f616912SHiten PandyaThis should be used when calling 3245f616912SHiten Pandya.Fn rman_reserve_resource_bound . 3255f616912SHiten Pandya.Pp 3265f616912SHiten PandyaThe 327bb82622cSJohn Baldwin.Fn rman_is_region_manager 328bb82622cSJohn Baldwinfunction returns true if the allocated resource 329bb82622cSJohn Baldwin.Fa r 330bb82622cSJohn Baldwinwas allocated from 331bb82622cSJohn Baldwin.Fa rm . 332bb82622cSJohn BaldwinOtherwise, 333bb82622cSJohn Baldwinit returns false. 334bb82622cSJohn Baldwin.Pp 335bb82622cSJohn BaldwinThe 336bb82622cSJohn Baldwin.Fn rman_adjust_resource 337bb82622cSJohn Baldwinfunction is used to adjust the reserved address range of an allocated resource 338bb82622cSJohn Baldwinto reserve 339bb82622cSJohn Baldwin.Fa start 340bb82622cSJohn Baldwinthrough 341bb82622cSJohn Baldwin.Fa end . 342bb82622cSJohn BaldwinIt can be used to grow or shrink one or both ends of the resource range. 343bb82622cSJohn BaldwinThe current implementation does not support entirely relocating the resource 344bb82622cSJohn Baldwinand will fail with 345bb82622cSJohn Baldwin.Er EINVAL 346bb82622cSJohn Baldwinif the new resource range does not overlap the old resource range. 347bb82622cSJohn BaldwinIf either end of the resource range grows and the new resource range would 348bb82622cSJohn Baldwinconflict with another allocated resource, 349bb82622cSJohn Baldwinthe function will fail with 350bb82622cSJohn Baldwin.Er EBUSY . 351bb82622cSJohn BaldwinThe 352bb82622cSJohn Baldwin.Fn rman_adjust_resource 353bb82622cSJohn Baldwinfunction does not support adjusting the resource range for shared resources 354bb82622cSJohn Baldwinand will fail such attempts with 355bb82622cSJohn Baldwin.Er EINVAL . 356bb82622cSJohn BaldwinUpon success, 357bb82622cSJohn Baldwinthe resource 358bb82622cSJohn Baldwin.Fa r 359bb82622cSJohn Baldwinwill have a start address of 360bb82622cSJohn Baldwin.Fa start 361bb82622cSJohn Baldwinand an end address of 362bb82622cSJohn Baldwin.Fa end 363bb82622cSJohn Baldwinand the function will return zero. 364bb82622cSJohn BaldwinNote that none of the constraints of the original allocation request such 365bb82622cSJohn Baldwinas alignment or boundary restrictions are checked by 366bb82622cSJohn Baldwin.Fn rman_adjust_resource . 367bb82622cSJohn BaldwinIt is the caller's responsibility to enforce any such requirements. 368bb82622cSJohn Baldwin.Pp 369bb82622cSJohn BaldwinThe 3705f616912SHiten Pandya.Fn rman_release_resource 3715f616912SHiten Pandyafunction releases the reserved resource 3725f616912SHiten Pandya.Fa r . 3735f616912SHiten PandyaIt may attempt to merge adjacent free resources. 3745f616912SHiten Pandya.Pp 3755f616912SHiten PandyaThe 3765f616912SHiten Pandya.Fn rman_activate_resource 3775f616912SHiten Pandyafunction marks a resource as active, by setting the 3785f616912SHiten Pandya.Dv RF_ACTIVE 3795f616912SHiten Pandyaflag. 3805f616912SHiten PandyaIf this is a time shared resource, and the caller has not yet acquired 3815f616912SHiten Pandyathe resource, the function returns 3825f616912SHiten Pandya.Er EBUSY . 3835f616912SHiten Pandya.Pp 3845f616912SHiten PandyaThe 3855f616912SHiten Pandya.Fn rman_deactivate_resource 3865f616912SHiten Pandyafunction marks a resource 3875f616912SHiten Pandya.Fa r 3885f616912SHiten Pandyaas inactive, by clearing the 3895f616912SHiten Pandya.Dv RF_ACTIVE 3905f616912SHiten Pandyaflag. 3915f616912SHiten PandyaIf other consumers are waiting for this range, it will wakeup their threads. 3925f616912SHiten Pandya.Pp 3935f616912SHiten PandyaThe 3945f616912SHiten Pandya.Fn rman_get_start , 3955f616912SHiten Pandya.Fn rman_get_end , 3963e1cee04SRuslan Ermilov.Fn rman_get_size , 3973e1cee04SRuslan Ermilovand 3985f616912SHiten Pandya.Fn rman_get_flags 3995f616912SHiten Pandyafunctions return the bounds, size and flags of the previously reserved 4005f616912SHiten Pandyaresource 4015f616912SHiten Pandya.Fa r . 4025f616912SHiten Pandya.Pp 4035f616912SHiten PandyaThe 4045f616912SHiten Pandya.Fn rman_set_bustag 4053e1cee04SRuslan Ermilovfunction associates a 4063e1cee04SRuslan Ermilov.Vt bus_space_tag_t 4075f616912SHiten Pandya.Fa t 4085f616912SHiten Pandyawith the resource 4095f616912SHiten Pandya.Fa r . 4105f616912SHiten PandyaThe 4115f616912SHiten Pandya.Fn rman_get_bustag 4125f616912SHiten Pandyafunction is used to retrieve this tag once set. 4135f616912SHiten Pandya.Pp 4145f616912SHiten PandyaThe 4155f616912SHiten Pandya.Fn rman_set_bushandle 4163e1cee04SRuslan Ermilovfunction associates a 4173e1cee04SRuslan Ermilov.Vt bus_space_handle_t 4185f616912SHiten Pandya.Fa h 4195f616912SHiten Pandyawith the resource 4205f616912SHiten Pandya.Fa r . 4215f616912SHiten PandyaThe 4225f616912SHiten Pandya.Fn rman_get_bushandle 4235f616912SHiten Pandyafunction is used to retrieve this handle once set. 4245f616912SHiten Pandya.Pp 4255f616912SHiten PandyaThe 4265f616912SHiten Pandya.Fn rman_set_virtual 4275f616912SHiten Pandyafunction is used to associate a kernel virtual address with a resource 4285f616912SHiten Pandya.Fa r . 4295f616912SHiten PandyaThe 4305f616912SHiten Pandya.Fn rman_get_virtual 4315f616912SHiten Pandyafunction can be used to retrieve the KVA once set. 4325f616912SHiten Pandya.Pp 4335f616912SHiten PandyaThe 434cc981af2SJohn Baldwin.Fn rman_set_mapping 435cc981af2SJohn Baldwinfunction is used to associate a resource mapping with a resource 436cc981af2SJohn Baldwin.Fa r . 437cc981af2SJohn BaldwinThe mapping must cover the entire resource. 438cc981af2SJohn BaldwinSetting a mapping sets the associated 439cc981af2SJohn Baldwin.Xr bus_space 9 440cc981af2SJohn Baldwinhandle and tag for 441cc981af2SJohn Baldwin.Fa r 442cc981af2SJohn Baldwinas well as the kernel virtual address if the mapping contains one. 443cc981af2SJohn BaldwinThese individual values can be retrieved via 444cc981af2SJohn Baldwin.Fn rman_get_bushandle , 445cc981af2SJohn Baldwin.Fn rman_get_bustag , 446cc981af2SJohn Baldwinand 447cc981af2SJohn Baldwin.Fn rman_get_virtual . 448cc981af2SJohn Baldwin.Pp 449cc981af2SJohn BaldwinThe 450cc981af2SJohn Baldwin.Fn rman_get_mapping 451cc981af2SJohn Baldwinfunction can be used to retrieve the associated resource mapping once set. 452cc981af2SJohn Baldwin.Pp 453cc981af2SJohn BaldwinThe 4545f616912SHiten Pandya.Fn rman_set_rid 4555f616912SHiten Pandyafunction associates a resource identifier with a resource 4565f616912SHiten Pandya.Fa r . 4573e1cee04SRuslan ErmilovThe 4583e1cee04SRuslan Ermilov.Fn rman_get_rid 4593e1cee04SRuslan Ermilovfunction retrieves this RID. 4605f616912SHiten Pandya.Pp 4615f616912SHiten PandyaThe 4625f616912SHiten Pandya.Fn rman_get_device 4635f616912SHiten Pandyafunction returns a pointer to the device which reserved the resource 4645f616912SHiten Pandya.Fa r . 4655f616912SHiten Pandya.Sh SEE ALSO 4665f616912SHiten Pandya.Xr bus_activate_resource 9 , 46785ee63c9SJohn Baldwin.Xr bus_adjust_resource 9 , 4685f616912SHiten Pandya.Xr bus_alloc_resource 9 , 469cc981af2SJohn Baldwin.Xr bus_map_resource 9 , 4705f616912SHiten Pandya.Xr bus_release_resource 9 , 4715f616912SHiten Pandya.Xr bus_set_resource 9 , 472*c85d7166SChristian Brueffer.Xr bus_space 9 , 4735f616912SHiten Pandya.Xr mutex 9 4745f616912SHiten Pandya.Sh AUTHORS 475571dba6eSHiten PandyaThis manual page was written by 4768a7314fcSBaptiste Daroussin.An Bruce M Simpson Aq Mt bms@spc.org . 477