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.\" 26*b30a80b6SJohn Baldwin.Dd March 13, 2024 275f616912SHiten Pandya.Dt RMAN 9 285f616912SHiten Pandya.Os 295f616912SHiten Pandya.Sh NAME 305f616912SHiten Pandya.Nm rman , 315f616912SHiten Pandya.Nm rman_activate_resource , 32bb82622cSJohn Baldwin.Nm rman_adjust_resource , 335f616912SHiten Pandya.Nm rman_deactivate_resource , 345f616912SHiten Pandya.Nm rman_fini , 355f616912SHiten Pandya.Nm rman_init , 36bb82622cSJohn Baldwin.Nm rman_init_from_resource , 37bb82622cSJohn Baldwin.Nm rman_is_region_manager , 385f616912SHiten Pandya.Nm rman_manage_region , 39bb82622cSJohn Baldwin.Nm rman_first_free_region , 40bb82622cSJohn Baldwin.Nm rman_last_free_region , 415f616912SHiten Pandya.Nm rman_release_resource , 425f616912SHiten Pandya.Nm rman_reserve_resource , 435f616912SHiten Pandya.Nm rman_reserve_resource_bound , 445f616912SHiten Pandya.Nm rman_make_alignment_flags , 455f616912SHiten Pandya.Nm rman_get_start , 465f616912SHiten Pandya.Nm rman_get_end , 4711053af5SHiten Pandya.Nm rman_get_device , 485f616912SHiten Pandya.Nm rman_get_size , 495f616912SHiten Pandya.Nm rman_get_flags , 50cc981af2SJohn Baldwin.Nm rman_set_mapping , 51cc981af2SJohn Baldwin.Nm rman_get_mapping , 525f616912SHiten Pandya.Nm rman_set_virtual , 535f616912SHiten Pandya.Nm rman_get_virtual , 545f616912SHiten Pandya.Nm rman_set_bustag , 555f616912SHiten Pandya.Nm rman_get_bustag , 565f616912SHiten Pandya.Nm rman_set_bushandle , 575f616912SHiten Pandya.Nm rman_get_bushandle , 585f616912SHiten Pandya.Nm rman_set_rid , 59*b30a80b6SJohn Baldwin.Nm rman_get_rid , 60*b30a80b6SJohn Baldwin.Nm rman_set_type , 61*b30a80b6SJohn Baldwin.Nm rman_get_type 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" 91dfff3776SMark Johnston.Fa "u_int flags" "device_t 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" 96dfff3776SMark Johnston.Fa "rman_res_t bound" "u_int flags" "device_t 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" 104dfff3776SMark Johnston.Ft "device_t" 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" 130*b30a80b6SJohn Baldwin.Ft void 131*b30a80b6SJohn Baldwin.Fn rman_set_type "struct resource *r" "int type" 132*b30a80b6SJohn Baldwin.Ft int 133*b30a80b6SJohn Baldwin.Fn rman_get_type "struct resource *r" 1345f616912SHiten Pandya.Sh DESCRIPTION 1355f616912SHiten PandyaThe 1365f616912SHiten Pandya.Nm 1375f616912SHiten Pandyaset of functions provides a flexible resource management abstraction. 1385f616912SHiten PandyaIt is used extensively by the bus management code. 1395f616912SHiten PandyaIt implements the abstractions of region and resource. 1405f616912SHiten PandyaA region descriptor is used to manage a region; this could be memory or 1415f616912SHiten Pandyasome other form of bus space. 1425f616912SHiten Pandya.Pp 1435f616912SHiten PandyaEach region has a set of bounds. 1445f616912SHiten PandyaWithin these bounds, allocated segments may reside. 1455f616912SHiten PandyaEach segment, termed a resource, has several properties which are 1465f616912SHiten Pandyarepresented by a 16-bit flag register, as follows. 1475f616912SHiten Pandya.Bd -literal 1485f616912SHiten Pandya#define RF_ALLOCATED 0x0001 /* resource has been reserved */ 1495f616912SHiten Pandya#define RF_ACTIVE 0x0002 /* resource allocation has been activated */ 1505f616912SHiten Pandya#define RF_SHAREABLE 0x0004 /* resource permits contemporaneous sharing */ 1515f616912SHiten Pandya#define RF_FIRSTSHARE 0x0020 /* first in sharing list */ 1525f616912SHiten Pandya#define RF_PREFETCHABLE 0x0040 /* resource is prefetchable */ 153cc981af2SJohn Baldwin#define RF_UNMAPPED 0x0100 /* don't map resource when activating */ 1545f616912SHiten Pandya.Ed 1555f616912SHiten Pandya.Pp 156d3a68794SDon LewisBits 15:10 of the flag register are used to represent the desired alignment 1575f616912SHiten Pandyaof the resource within the region. 1585f616912SHiten Pandya.Pp 1595f616912SHiten PandyaThe 1605f616912SHiten Pandya.Fn rman_init 1615f616912SHiten Pandyafunction initializes the region descriptor, pointed to by the 1625f616912SHiten Pandya.Fa rm 1635f616912SHiten Pandyaargument, for use with the resource management functions. 164bc956811SJohn-Mark GurneyIt is required that the fields 165bc956811SJohn-Mark Gurney.Va rm_type 166bc956811SJohn-Mark Gurneyand 167bc956811SJohn-Mark Gurney.Va rm_descr 168bc956811SJohn-Mark Gurneyof 169bc956811SJohn-Mark Gurney.Vt "struct rman" 170bc956811SJohn-Mark Gurneybe set before calling 171bc956811SJohn-Mark Gurney.Fn rman_init . 172bc956811SJohn-Mark GurneyThe field 173bc956811SJohn-Mark Gurney.Va rm_type 174bc956811SJohn-Mark Gurneyshall be set to 175bc956811SJohn-Mark Gurney.Dv RMAN_ARRAY . 176bc956811SJohn-Mark GurneyThe field 177bc956811SJohn-Mark Gurney.Va rm_descr 178bc956811SJohn-Mark Gurneyshall be set to a string that describes the resource to be managed. 179bb82622cSJohn BaldwinThe 180bb82622cSJohn Baldwin.Va rm_start 181bb82622cSJohn Baldwinand 182bb82622cSJohn Baldwin.Va rm_end 183bb82622cSJohn Baldwinfields may be set to limit the range of acceptable resource addresses. 184bb82622cSJohn BaldwinIf these fields are not set, 185bb82622cSJohn Baldwin.Fn rman_init 186bb82622cSJohn Baldwinwill initialize them to allow the entire range of resource addresses. 1875f616912SHiten PandyaIt also initializes any mutexes associated with the structure. 188ebf750a9SJohn-Mark GurneyIf 189ebf750a9SJohn-Mark Gurney.Fn rman_init 190f6ac2391SJoel Dahlfails to initialize the mutex, it will return 191ebf750a9SJohn-Mark Gurney.Er ENOMEM ; otherwise it will return 0 and 192ebf750a9SJohn-Mark Gurney.Fa rm 193f6ac2391SJoel Dahlwill be initialized. 1945f616912SHiten Pandya.Pp 1955f616912SHiten PandyaThe 1965f616912SHiten Pandya.Fn rman_fini 1975f616912SHiten Pandyafunction frees any structures associated with the structure 1985f616912SHiten Pandyapointed to by the 1995f616912SHiten Pandya.Fa rm 2003e1cee04SRuslan Ermilovargument. 2013e1cee04SRuslan ErmilovIf any of the resources within the managed region have the 2025f616912SHiten Pandya.Dv RF_ALLOCATED 2035f616912SHiten Pandyaflag set, it will return 2045f616912SHiten Pandya.Er EBUSY ; 2055f616912SHiten Pandyaotherwise, any mutexes associated with the structure will be released 2065f616912SHiten Pandyaand destroyed, and the function will return 0. 2075f616912SHiten Pandya.Pp 2085f616912SHiten PandyaThe 2095f616912SHiten Pandya.Fn rman_manage_region 2105f616912SHiten Pandyafunction establishes the concept of a region which is under 2115f616912SHiten Pandya.Nm 2125f616912SHiten Pandyacontrol. 2135f616912SHiten PandyaThe 2145f616912SHiten Pandya.Fa rman 2155f616912SHiten Pandyaargument points to the region descriptor. 2163e1cee04SRuslan ErmilovThe 2173e1cee04SRuslan Ermilov.Fa start 2183e1cee04SRuslan Ermilovand 2193e1cee04SRuslan Ermilov.Fa end 2203e1cee04SRuslan Ermilovarguments specify the bounds of the region. 221ebf750a9SJohn-Mark GurneyIf successful, 222ebf750a9SJohn-Mark Gurney.Fn rman_manage_region 223ebf750a9SJohn-Mark Gurneywill return 0. 224ebf750a9SJohn-Mark GurneyIf the region overlaps with an existing region, it will return 225ebf750a9SJohn-Mark Gurney.Er EBUSY . 226bb82622cSJohn BaldwinIf any part of the region falls outside of the valid address range for 227bb82622cSJohn Baldwin.Fa rm , 228bb82622cSJohn Baldwinit will return 229bb82622cSJohn Baldwin.Er EINVAL . 230ebf750a9SJohn-Mark Gurney.Er ENOMEM 231bb82622cSJohn Baldwinwill be returned when 232ebf750a9SJohn-Mark Gurney.Fn rman_manage_region 233ebf750a9SJohn-Mark Gurneyfailed to allocate memory for the region. 2345f616912SHiten Pandya.Pp 2355f616912SHiten PandyaThe 236bb82622cSJohn Baldwin.Fn rman_init_from_resource 237bb82622cSJohn Baldwinfunction is a wrapper routine to create a resource manager backed by an 238bb82622cSJohn Baldwinexisting resource. 239bb82622cSJohn BaldwinIt initializes 240bb82622cSJohn Baldwin.Fa rm 241bb82622cSJohn Baldwinusing 242bb82622cSJohn Baldwin.Fn rman_init 243bb82622cSJohn Baldwinand then adds a region to 244bb82622cSJohn Baldwin.Fa rm 245bb82622cSJohn Baldwincorresponding to the address range allocated to 246bb82622cSJohn Baldwin.Fa r 247bb82622cSJohn Baldwinvia 248bb82622cSJohn Baldwin.Fn rman_manage_region . 249bb82622cSJohn Baldwin.Pp 250bb82622cSJohn BaldwinThe 251bb82622cSJohn Baldwin.Fn rman_first_free_region 252bb82622cSJohn Baldwinand 253bb82622cSJohn Baldwin.Fn rman_last_free_region 254bb82622cSJohn Baldwinfunctions can be used to query a resource manager for its first 255bb82622cSJohn Baldwin.Pq or last 256bb82622cSJohn Baldwinunallocated region. 257bb82622cSJohn BaldwinIf 258bb82622cSJohn Baldwin.Fa rm 259bb82622cSJohn Baldwincontains no free region, 260bb82622cSJohn Baldwinthese functions will return 261bb82622cSJohn Baldwin.Er ENOENT . 262bb82622cSJohn BaldwinOtherwise, 263bb82622cSJohn Baldwin.Fa *start 264bb82622cSJohn Baldwinand 265bb82622cSJohn Baldwin.Fa *end 266bb82622cSJohn Baldwinare set to the bounds of the free region and zero is returned. 267bb82622cSJohn Baldwin.Pp 268bb82622cSJohn BaldwinThe 2695f616912SHiten Pandya.Fn rman_reserve_resource_bound 2705f616912SHiten Pandyafunction is where the bulk of the 2713e1cee04SRuslan Ermilov.Nm 2723e1cee04SRuslan Ermilovlogic is located. 2735f616912SHiten PandyaIt attempts to reserve a contiguous range in the specified region 2745f616912SHiten Pandya.Fa rm 2755f616912SHiten Pandyafor the use of the device 2765f616912SHiten Pandya.Fa dev . 2773e1cee04SRuslan ErmilovThe caller can specify the 2783e1cee04SRuslan Ermilov.Fa start 2793e1cee04SRuslan Ermilovand 2803e1cee04SRuslan Ermilov.Fa end 281bb82622cSJohn Baldwinof an acceptable range, 282a1581cd7SGordon Berglingas well as a boundary restriction and required alignment, 283bb82622cSJohn Baldwinand the code will attempt to find a free segment which fits. 284f3011a7cSWarner LoshThe 285f3011a7cSWarner Losh.Fa start 286f3011a7cSWarner Loshargument is the lowest acceptable starting value of the resource. 287f3011a7cSWarner LoshThe 288f3011a7cSWarner Losh.Fa end 289f3011a7cSWarner Loshargument is the highest acceptable ending value of the resource. 290f3011a7cSWarner LoshTherefore, 2914f068961SRuslan Ermilov.Fa start No + Fa count No \- 1 2924f068961SRuslan Ermilovmust be \[<=] 293f3011a7cSWarner Losh.Fa end 294f3011a7cSWarner Loshfor any allocation to happen. 295a1581cd7SGordon BerglingThe alignment requirement 296bb82622cSJohn Baldwin.Pq if any 297bb82622cSJohn Baldwinis specified in 298bb82622cSJohn Baldwin.Fa flags . 299bb82622cSJohn BaldwinThe 300bb82622cSJohn Baldwin.Fa bound 301bb82622cSJohn Baldwinargument may be set to specify a boundary restriction such that an 302bb82622cSJohn Baldwinallocated region may cross an address that is a multiple of the 303bb82622cSJohn Baldwinboundary. 304bb82622cSJohn BaldwinThe 305bb82622cSJohn Baldwin.Fa bound 306bb82622cSJohn Baldwinargument must be a power of two. 307bb82622cSJohn BaldwinIt may be set to zero to specify no boundary restriction. 308d3a68794SDon LewisA shared segment will be allocated if the 3095f616912SHiten Pandya.Dv RF_SHAREABLE 310d3a68794SDon Lewisflag is set, otherwise an exclusive segment will be allocated. 3115f616912SHiten PandyaIf this shared segment already exists, the caller has its device 3125f616912SHiten Pandyaadded to the list of consumers. 3135f616912SHiten Pandya.Pp 3145f616912SHiten PandyaThe 3155f616912SHiten Pandya.Fn rman_reserve_resource 3165f616912SHiten Pandyafunction is used to reserve resources within a previously established region. 3175f616912SHiten PandyaIt is a simplified interface to 3185f616912SHiten Pandya.Fn rman_reserve_resource_bound 3195f616912SHiten Pandyawhich passes 0 for the 320bb82622cSJohn Baldwin.Fa bound 3215f616912SHiten Pandyaargument. 3225f616912SHiten Pandya.Pp 3235f616912SHiten PandyaThe 3245f616912SHiten Pandya.Fn rman_make_alignment_flags 3255f616912SHiten Pandyafunction returns the flag mask corresponding to the desired alignment 3265f616912SHiten Pandya.Fa size . 3275f616912SHiten PandyaThis should be used when calling 3285f616912SHiten Pandya.Fn rman_reserve_resource_bound . 3295f616912SHiten Pandya.Pp 3305f616912SHiten PandyaThe 331bb82622cSJohn Baldwin.Fn rman_is_region_manager 332bb82622cSJohn Baldwinfunction returns true if the allocated resource 333bb82622cSJohn Baldwin.Fa r 334bb82622cSJohn Baldwinwas allocated from 335bb82622cSJohn Baldwin.Fa rm . 336bb82622cSJohn BaldwinOtherwise, 337bb82622cSJohn Baldwinit returns false. 338bb82622cSJohn Baldwin.Pp 339bb82622cSJohn BaldwinThe 340bb82622cSJohn Baldwin.Fn rman_adjust_resource 341bb82622cSJohn Baldwinfunction is used to adjust the reserved address range of an allocated resource 342bb82622cSJohn Baldwinto reserve 343bb82622cSJohn Baldwin.Fa start 344bb82622cSJohn Baldwinthrough 345bb82622cSJohn Baldwin.Fa end . 346bb82622cSJohn BaldwinIt can be used to grow or shrink one or both ends of the resource range. 347bb82622cSJohn BaldwinThe current implementation does not support entirely relocating the resource 348bb82622cSJohn Baldwinand will fail with 349bb82622cSJohn Baldwin.Er EINVAL 350bb82622cSJohn Baldwinif the new resource range does not overlap the old resource range. 351bb82622cSJohn BaldwinIf either end of the resource range grows and the new resource range would 352bb82622cSJohn Baldwinconflict with another allocated resource, 353bb82622cSJohn Baldwinthe function will fail with 354bb82622cSJohn Baldwin.Er EBUSY . 355bb82622cSJohn BaldwinThe 356bb82622cSJohn Baldwin.Fn rman_adjust_resource 357bb82622cSJohn Baldwinfunction does not support adjusting the resource range for shared resources 358bb82622cSJohn Baldwinand will fail such attempts with 359bb82622cSJohn Baldwin.Er EINVAL . 360bb82622cSJohn BaldwinUpon success, 361bb82622cSJohn Baldwinthe resource 362bb82622cSJohn Baldwin.Fa r 363bb82622cSJohn Baldwinwill have a start address of 364bb82622cSJohn Baldwin.Fa start 365bb82622cSJohn Baldwinand an end address of 366bb82622cSJohn Baldwin.Fa end 367bb82622cSJohn Baldwinand the function will return zero. 368bb82622cSJohn BaldwinNote that none of the constraints of the original allocation request such 369bb82622cSJohn Baldwinas alignment or boundary restrictions are checked by 370bb82622cSJohn Baldwin.Fn rman_adjust_resource . 371bb82622cSJohn BaldwinIt is the caller's responsibility to enforce any such requirements. 372bb82622cSJohn Baldwin.Pp 373bb82622cSJohn BaldwinThe 3745f616912SHiten Pandya.Fn rman_release_resource 3755f616912SHiten Pandyafunction releases the reserved resource 3765f616912SHiten Pandya.Fa r . 3775f616912SHiten PandyaIt may attempt to merge adjacent free resources. 3785f616912SHiten Pandya.Pp 3795f616912SHiten PandyaThe 3805f616912SHiten Pandya.Fn rman_activate_resource 3815f616912SHiten Pandyafunction marks a resource as active, by setting the 3825f616912SHiten Pandya.Dv RF_ACTIVE 3835f616912SHiten Pandyaflag. 3845f616912SHiten PandyaIf this is a time shared resource, and the caller has not yet acquired 3855f616912SHiten Pandyathe resource, the function returns 3865f616912SHiten Pandya.Er EBUSY . 3875f616912SHiten Pandya.Pp 3885f616912SHiten PandyaThe 3895f616912SHiten Pandya.Fn rman_deactivate_resource 3905f616912SHiten Pandyafunction marks a resource 3915f616912SHiten Pandya.Fa r 3925f616912SHiten Pandyaas inactive, by clearing the 3935f616912SHiten Pandya.Dv RF_ACTIVE 3945f616912SHiten Pandyaflag. 3955f616912SHiten PandyaIf other consumers are waiting for this range, it will wakeup their threads. 3965f616912SHiten Pandya.Pp 3975f616912SHiten PandyaThe 3985f616912SHiten Pandya.Fn rman_get_start , 3995f616912SHiten Pandya.Fn rman_get_end , 4003e1cee04SRuslan Ermilov.Fn rman_get_size , 4013e1cee04SRuslan Ermilovand 4025f616912SHiten Pandya.Fn rman_get_flags 4035f616912SHiten Pandyafunctions return the bounds, size and flags of the previously reserved 4045f616912SHiten Pandyaresource 4055f616912SHiten Pandya.Fa r . 4065f616912SHiten Pandya.Pp 4075f616912SHiten PandyaThe 4085f616912SHiten Pandya.Fn rman_set_bustag 4093e1cee04SRuslan Ermilovfunction associates a 4103e1cee04SRuslan Ermilov.Vt bus_space_tag_t 4115f616912SHiten Pandya.Fa t 4125f616912SHiten Pandyawith the resource 4135f616912SHiten Pandya.Fa r . 4145f616912SHiten PandyaThe 4155f616912SHiten Pandya.Fn rman_get_bustag 4165f616912SHiten Pandyafunction is used to retrieve this tag once set. 4175f616912SHiten Pandya.Pp 4185f616912SHiten PandyaThe 4195f616912SHiten Pandya.Fn rman_set_bushandle 4203e1cee04SRuslan Ermilovfunction associates a 4213e1cee04SRuslan Ermilov.Vt bus_space_handle_t 4225f616912SHiten Pandya.Fa h 4235f616912SHiten Pandyawith the resource 4245f616912SHiten Pandya.Fa r . 4255f616912SHiten PandyaThe 4265f616912SHiten Pandya.Fn rman_get_bushandle 4275f616912SHiten Pandyafunction is used to retrieve this handle once set. 4285f616912SHiten Pandya.Pp 4295f616912SHiten PandyaThe 4305f616912SHiten Pandya.Fn rman_set_virtual 4315f616912SHiten Pandyafunction is used to associate a kernel virtual address with a resource 4325f616912SHiten Pandya.Fa r . 4335f616912SHiten PandyaThe 4345f616912SHiten Pandya.Fn rman_get_virtual 4355f616912SHiten Pandyafunction can be used to retrieve the KVA once set. 4365f616912SHiten Pandya.Pp 4375f616912SHiten PandyaThe 438cc981af2SJohn Baldwin.Fn rman_set_mapping 439cc981af2SJohn Baldwinfunction is used to associate a resource mapping with a resource 440cc981af2SJohn Baldwin.Fa r . 441cc981af2SJohn BaldwinThe mapping must cover the entire resource. 442cc981af2SJohn BaldwinSetting a mapping sets the associated 443cc981af2SJohn Baldwin.Xr bus_space 9 444cc981af2SJohn Baldwinhandle and tag for 445cc981af2SJohn Baldwin.Fa r 446cc981af2SJohn Baldwinas well as the kernel virtual address if the mapping contains one. 447cc981af2SJohn BaldwinThese individual values can be retrieved via 448cc981af2SJohn Baldwin.Fn rman_get_bushandle , 449cc981af2SJohn Baldwin.Fn rman_get_bustag , 450cc981af2SJohn Baldwinand 451cc981af2SJohn Baldwin.Fn rman_get_virtual . 452cc981af2SJohn Baldwin.Pp 453cc981af2SJohn BaldwinThe 454cc981af2SJohn Baldwin.Fn rman_get_mapping 455cc981af2SJohn Baldwinfunction can be used to retrieve the associated resource mapping once set. 456cc981af2SJohn Baldwin.Pp 457cc981af2SJohn BaldwinThe 4585f616912SHiten Pandya.Fn rman_set_rid 4595f616912SHiten Pandyafunction associates a resource identifier with a resource 4605f616912SHiten Pandya.Fa r . 4613e1cee04SRuslan ErmilovThe 4623e1cee04SRuslan Ermilov.Fn rman_get_rid 4633e1cee04SRuslan Ermilovfunction retrieves this RID. 4645f616912SHiten Pandya.Pp 4655f616912SHiten PandyaThe 466*b30a80b6SJohn Baldwin.Fn rman_set_type 467*b30a80b6SJohn Baldwinfunction associates a resource type with a resource 468*b30a80b6SJohn Baldwin.Fa r . 469*b30a80b6SJohn BaldwinThe 470*b30a80b6SJohn Baldwin.Fn rman_get_type 471*b30a80b6SJohn Baldwinfunction retrieves this type. 472*b30a80b6SJohn Baldwin.Pp 473*b30a80b6SJohn BaldwinThe 4745f616912SHiten Pandya.Fn rman_get_device 4755f616912SHiten Pandyafunction returns a pointer to the device which reserved the resource 4765f616912SHiten Pandya.Fa r . 4775f616912SHiten Pandya.Sh SEE ALSO 4785f616912SHiten Pandya.Xr bus_activate_resource 9 , 47985ee63c9SJohn Baldwin.Xr bus_adjust_resource 9 , 4805f616912SHiten Pandya.Xr bus_alloc_resource 9 , 481cc981af2SJohn Baldwin.Xr bus_map_resource 9 , 4825f616912SHiten Pandya.Xr bus_release_resource 9 , 4835f616912SHiten Pandya.Xr bus_set_resource 9 , 484c85d7166SChristian Brueffer.Xr bus_space 9 , 4855f616912SHiten Pandya.Xr mutex 9 4865f616912SHiten Pandya.Sh AUTHORS 487571dba6eSHiten PandyaThis manual page was written by 4888a7314fcSBaptiste Daroussin.An Bruce M Simpson Aq Mt bms@spc.org . 489