FreeBSD kernel kern code
subr_rman.c File Reference
#include "opt_ddb.h"
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <sys/sysctl.h>
Include dependency graph for subr_rman.c:

Go to the source code of this file.

Data Structures

struct  resource_i
 

Macros

#define DPRINTF(params)   if (rman_debug) printf params
 
#define SHARE_TYPE(f)   (f & (RF_SHAREABLE | RF_PREFETCHABLE))
 

Functions

 __FBSDID ("$BSDSUniX$")
 
 TUNABLE_INT ("debug.rman_debug",&rman_debug)
 
 SYSCTL_INT (_debug, OID_AUTO, rman_debug, CTLFLAG_RW,&rman_debug, 0,"rman debug")
 
static MALLOC_DEFINE (M_RMAN,"rman","Resource manager")
 
static int int_rman_release_resource (struct rman *rm, struct resource_i *r)
 
static __inline struct resource_iint_alloc_resource (int malloc_flag)
 
int rman_init (struct rman *rm)
 
int rman_manage_region (struct rman *rm, u_long start, u_long end)
 
int rman_init_from_resource (struct rman *rm, struct resource *r)
 
int rman_fini (struct rman *rm)
 
int rman_first_free_region (struct rman *rm, u_long *start, u_long *end)
 
int rman_last_free_region (struct rman *rm, u_long *start, u_long *end)
 
int rman_adjust_resource (struct resource *rr, u_long start, u_long end)
 
struct resource * rman_reserve_resource_bound (struct rman *rm, u_long start, u_long end, u_long count, u_long bound, u_int flags, struct device *dev)
 
struct resource * rman_reserve_resource (struct rman *rm, u_long start, u_long end, u_long count, u_int flags, struct device *dev)
 
int rman_activate_resource (struct resource *re)
 
int rman_deactivate_resource (struct resource *r)
 
int rman_release_resource (struct resource *re)
 
uint32_t rman_make_alignment_flags (uint32_t size)
 
void rman_set_start (struct resource *r, u_long start)
 
u_long rman_get_start (struct resource *r)
 
void rman_set_end (struct resource *r, u_long end)
 
u_long rman_get_end (struct resource *r)
 
u_long rman_get_size (struct resource *r)
 
u_int rman_get_flags (struct resource *r)
 
void rman_set_virtual (struct resource *r, void *v)
 
void * rman_get_virtual (struct resource *r)
 
void rman_set_bustag (struct resource *r, bus_space_tag_t t)
 
bus_space_tag_t rman_get_bustag (struct resource *r)
 
void rman_set_bushandle (struct resource *r, bus_space_handle_t h)
 
bus_space_handle_t rman_get_bushandle (struct resource *r)
 
void rman_set_rid (struct resource *r, int rid)
 
int rman_get_rid (struct resource *r)
 
void rman_set_device (struct resource *r, struct device *dev)
 
struct devicerman_get_device (struct resource *r)
 
int rman_is_region_manager (struct resource *r, struct rman *rm)
 
static int sysctl_rman (SYSCTL_HANDLER_ARGS)
 
static SYSCTL_NODE (_hw_bus, OID_AUTO, rman, CTLFLAG_RD, sysctl_rman,"kernel resource manager")
 

Variables

static int rman_debug = 0
 
struct rman_head rman_head
 
static struct mtx rman_mtx
 

Macro Definition Documentation

#define DPRINTF (   params)    if (rman_debug) printf params

Definition at line 107 of file subr_rman.c.

Referenced by rman_manage_region(), and rman_reserve_resource_bound().

#define SHARE_TYPE (   f)    (f & (RF_SHAREABLE | RF_PREFETCHABLE))

Definition at line 430 of file subr_rman.c.

Referenced by rman_reserve_resource_bound().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static __inline struct resource_i* int_alloc_resource ( int  malloc_flag)
static

Definition at line 116 of file subr_rman.c.

References malloc(), and resource_i::r_r.

Referenced by rman_adjust_resource(), rman_manage_region(), and rman_reserve_resource_bound().

Here is the call graph for this function:

Here is the caller graph for this function:

static int int_rman_release_resource ( struct rman *  rm,
struct resource_i r 
)
static

Definition at line 675 of file subr_rman.c.

References free().

Referenced by rman_release_resource().

Here is the call graph for this function:

Here is the caller graph for this function:

static MALLOC_DEFINE ( M_RMAN  ,
"rman"  ,
"Resource manager"   
)
static
int rman_activate_resource ( struct resource *  re)

Definition at line 649 of file subr_rman.c.

int rman_adjust_resource ( struct resource *  rr,
u_long  start,
u_long  end 
)

Definition at line 310 of file subr_rman.c.

References free(), int_alloc_resource(), panic(), and start.

Here is the call graph for this function:

int rman_deactivate_resource ( struct resource *  r)

Definition at line 663 of file subr_rman.c.

int rman_fini ( struct rman *  rm)

Definition at line 241 of file subr_rman.c.

References free(), mtx_destroy(), rman_head, and rman_mtx.

Here is the call graph for this function:

int rman_first_free_region ( struct rman *  rm,
u_long *  start,
u_long *  end 
)

Definition at line 273 of file subr_rman.c.

bus_space_handle_t rman_get_bushandle ( struct resource *  r)

Definition at line 879 of file subr_rman.c.

bus_space_tag_t rman_get_bustag ( struct resource *  r)

Definition at line 865 of file subr_rman.c.

struct device* rman_get_device ( struct resource *  r)

Definition at line 907 of file subr_rman.c.

Referenced by resource_list_purge().

Here is the caller graph for this function:

u_long rman_get_end ( struct resource *  r)

Definition at line 823 of file subr_rman.c.

Referenced by resource_list_alloc().

Here is the caller graph for this function:

u_int rman_get_flags ( struct resource *  r)

Definition at line 837 of file subr_rman.c.

Referenced by resource_list_busy(), and resource_list_release().

Here is the caller graph for this function:

int rman_get_rid ( struct resource *  r)

Definition at line 893 of file subr_rman.c.

Referenced by bus_free_resource().

Here is the caller graph for this function:

u_long rman_get_size ( struct resource *  r)

Definition at line 830 of file subr_rman.c.

u_long rman_get_start ( struct resource *  r)

Definition at line 809 of file subr_rman.c.

Referenced by resource_list_alloc().

Here is the caller graph for this function:

void* rman_get_virtual ( struct resource *  r)

Definition at line 851 of file subr_rman.c.

int rman_init ( struct rman *  rm)

Definition at line 128 of file subr_rman.c.

References malloc(), mtx_init(), panic(), rman_head, and rman_mtx.

Referenced by rman_init_from_resource().

Here is the call graph for this function:

Here is the caller graph for this function:

int rman_init_from_resource ( struct rman *  rm,
struct resource *  r 
)

Definition at line 231 of file subr_rman.c.

References rman_init(), and rman_manage_region().

Here is the call graph for this function:

int rman_is_region_manager ( struct resource *  r,
struct rman *  rm 
)

Definition at line 914 of file subr_rman.c.

int rman_last_free_region ( struct rman *  rm,
u_long *  start,
u_long *  end 
)

Definition at line 291 of file subr_rman.c.

uint32_t rman_make_alignment_flags ( uint32_t  size)

Definition at line 784 of file subr_rman.c.

int rman_manage_region ( struct rman *  rm,
u_long  start,
u_long  end 
)

Definition at line 158 of file subr_rman.c.

References DPRINTF, free(), int_alloc_resource(), and start.

Referenced by rman_init_from_resource().

Here is the call graph for this function:

Here is the caller graph for this function:

int rman_release_resource ( struct resource *  re)

Definition at line 769 of file subr_rman.c.

References int_rman_release_resource().

Here is the call graph for this function:

struct resource* rman_reserve_resource ( struct rman *  rm,
u_long  start,
u_long  end,
u_long  count,
u_int  flags,
struct device dev 
)

Definition at line 640 of file subr_rman.c.

References rman_reserve_resource_bound().

Here is the call graph for this function:

struct resource* rman_reserve_resource_bound ( struct rman *  rm,
u_long  start,
u_long  end,
u_long  count,
u_long  bound,
u_int  flags,
struct device dev 
)

Definition at line 433 of file subr_rman.c.

References device_get_nameunit(), DPRINTF, free(), int_alloc_resource(), malloc(), resource_i::r_r, and SHARE_TYPE.

Referenced by rman_reserve_resource().

Here is the call graph for this function:

Here is the caller graph for this function:

void rman_set_bushandle ( struct resource *  r,
bus_space_handle_t  h 
)

Definition at line 872 of file subr_rman.c.

void rman_set_bustag ( struct resource *  r,
bus_space_tag_t  t 
)

Definition at line 858 of file subr_rman.c.

void rman_set_device ( struct resource *  r,
struct device dev 
)

Definition at line 900 of file subr_rman.c.

void rman_set_end ( struct resource *  r,
u_long  end 
)

Definition at line 816 of file subr_rman.c.

void rman_set_rid ( struct resource *  r,
int  rid 
)

Definition at line 886 of file subr_rman.c.

void rman_set_start ( struct resource *  r,
u_long  start 
)

Definition at line 802 of file subr_rman.c.

References start.

void rman_set_virtual ( struct resource *  r,
void *  v 
)

Definition at line 844 of file subr_rman.c.

SYSCTL_INT ( _debug  ,
OID_AUTO  ,
rman_debug  ,
CTLFLAG_RW  ,
rman_debug,
,
"rman debug"   
)
static SYSCTL_NODE ( _hw_bus  ,
OID_AUTO  ,
rman  ,
CTLFLAG_RD  ,
sysctl_rman  ,
"kernel resource manager"   
)
static
static int sysctl_rman ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 927 of file subr_rman.c.

References bus_data_generation_check(), device_get_name(), device_get_unit(), name, rman_head, rman_mtx, and snprintf().

Here is the call graph for this function:

TUNABLE_INT ( "debug.rman_debug"  ,
rman_debug 
)

Variable Documentation

int rman_debug = 0
static

Definition at line 102 of file subr_rman.c.

struct rman_head rman_head

Definition at line 111 of file subr_rman.c.

Referenced by rman_fini(), rman_init(), and sysctl_rman().

struct mtx rman_mtx
static

Definition at line 112 of file subr_rman.c.

Referenced by rman_fini(), rman_init(), and sysctl_rman().