rman rman_activate_resource rman_await_resource rman_deactivate_resource rman_fini rman_init rman_manage_region rman_release_resource rman_reserve_resource rman_reserve_resource_bound rman_make_alignment_flags rman_get_start rman_get_end rman_get_device rman_get_size rman_get_flags rman_set_virtual rman_get_virtual rman_set_bustag rman_get_bustag rman_set_bushandle rman_get_bushandle rman_set_rid rman_get_rid - resource management functions
Each region has a set of bounds. Within these bounds, allocated segments may reside. Each segment, termed a resource, has several properties which are represented by a 16-bit flag register, as follows.
#define RF_ALLOCATED 0x0001 /* resource has been reserved */ #define RF_ACTIVE 0x0002 /* resource allocation has been activated */ #define RF_SHAREABLE 0x0004 /* resource permits contemporaneous sharing */ #define RF_TIMESHARE 0x0008 /* resource permits time-division sharing */ #define RF_WANTED 0x0010 /* somebody is waiting for this resource */ #define RF_FIRSTSHARE 0x0020 /* first in sharing list */ #define RF_PREFETCHABLE 0x0040 /* resource is prefetchable */
The remainder of the flag bits are used to represent the desired alignment of the resource within the region.
The
rman_init ();
function initializes the region descriptor, pointed to by the
Fa rm
argument, for use with the resource management functions.
It is required that the fields
rm_type
and
rm_descr
of
Vt struct rman
be set before calling
rman_init (.);
The field
rm_type
shall be set to
RMAN_ARRAY
The field
rm_descr
shall be set to a string that describes the resource to be managed.
It also initializes any mutexes associated with the structure.
If
rman_init ();
fails to initalize the mutex, it will return
Er ENOMEM ; otherwise it will return 0 and
Fa rm
will be initalized.
The
rman_fini ();
function frees any structures associated with the structure
pointed to by the
Fa rm
argument.
If any of the resources within the managed region have the
RF_ALLOCATED
flag set, it will return
Er EBUSY ;
otherwise, any mutexes associated with the structure will be released
and destroyed, and the function will return 0.
The
rman_manage_region ();
function establishes the concept of a region which is under
control.
The
Fa rman
argument points to the region descriptor.
The
Fa start
and
Fa end
arguments specify the bounds of the region.
If successful,
rman_manage_region ();
will return 0.
If the region overlaps with an existing region, it will return
Er EBUSY .
Er ENOMEM
will be return when
rman_manage_region ();
failed to allocate memory for the region.
The
rman_reserve_resource_bound ();
function is where the bulk of the
logic is located.
It attempts to reserve a contiguous range in the specified region
Fa rm
for the use of the device
Fa dev .
The caller can specify the
Fa start
and
Fa end
of an acceptable range, as well as
alignment, and the code will attempt to find a free segment which fits.
The
Fa start
argument is the lowest acceptable starting value of the resource.
The
Fa end
argument is the highest acceptable ending value of the resource.
Therefore,
Fa start No + Fa count No - 1
must be [<=]
Fa end
for any allocation to happen.
The default behavior is to allocate an exclusive segment, unless the
RF_SHAREABLE
or
RF_TIMESHARE
flags are set, in which case a shared
segment will be allocated.
If this shared segment already exists, the caller has its device
added to the list of consumers.
The
rman_reserve_resource ();
function is used to reserve resources within a previously established region.
It is a simplified interface to
rman_reserve_resource_bound ();
which passes 0 for the
Fa flags
argument.
The
rman_make_alignment_flags ();
function returns the flag mask corresponding to the desired alignment
Fa size .
This should be used when calling
rman_reserve_resource_bound (.);
The
rman_release_resource ();
function releases the reserved resource
Fa r .
It may attempt to merge adjacent free resources.
The
rman_activate_resource ();
function marks a resource as active, by setting the
RF_ACTIVE
flag.
If this is a time shared resource, and the caller has not yet acquired
the resource, the function returns
Er EBUSY .
The
rman_deactivate_resource ();
function marks a resource
Fa r
as inactive, by clearing the
RF_ACTIVE
flag.
If other consumers are waiting for this range, it will wakeup their threads.
The
rman_await_resource ();
function performs an asynchronous wait for a resource
Fa r
to become inactive, that is, for the
RF_ACTIVE
flag to be cleared.
It is used to enable cooperative sharing of a resource
which can only be safely used by one thread at a time.
The arguments
Fa pri
and
Fa timo
are passed to the
rman_await_resource ();
function.
The
rman_get_start (,);
rman_get_end (,);
rman_get_size (,);
and
rman_get_flags ();
functions return the bounds, size and flags of the previously reserved
resource
Fa r .
The
rman_set_bustag ();
function associates a
Vt bus_space_tag_t
Fa t
with the resource
Fa r .
The
rman_get_bustag ();
function is used to retrieve this tag once set.
The
rman_set_bushandle ();
function associates a
Vt bus_space_handle_t
Fa h
with the resource
Fa r .
The
rman_get_bushandle ();
function is used to retrieve this handle once set.
The
rman_set_virtual ();
function is used to associate a kernel virtual address with a resource
Fa r .
The
rman_get_virtual ();
function can be used to retrieve the KVA once set.
The
rman_set_rid ();
function associates a resource identifier with a resource
Fa r .
The
rman_get_rid ();
function retrieves this RID.
The
rman_get_device ();
function returns a pointer to the device which reserved the resource
Fa r .
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |