FreeBSD kernel kern code
subr_kobj.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/kobj.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
Include dependency graph for subr_kobj.c:

Go to the source code of this file.

Macros

#define KOBJ_LOCK()   mtx_lock(&kobj_mtx)
 
#define KOBJ_UNLOCK()   mtx_unlock(&kobj_mtx)
 
#define KOBJ_ASSERT(what)   mtx_assert(&kobj_mtx, what);
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static MALLOC_DEFINE (M_KOBJ,"kobj","Kernel object structures")
 
 SYSCTL_INT (_kern, OID_AUTO, kobj_methodcount, CTLFLAG_RD,&kobj_next_id, 0,"")
 
static void kobj_init_mutex (void *arg)
 
 SYSINIT (kobj, SI_SUB_LOCK, SI_ORDER_ANY, kobj_init_mutex, NULL)
 
int kobj_error_method (void)
 
static void kobj_class_compile_common (kobj_class_t cls, kobj_ops_t ops)
 
void kobj_class_compile (kobj_class_t cls)
 
void kobj_class_compile_static (kobj_class_t cls, kobj_ops_t ops)
 
static kobj_method_t * kobj_lookup_method_class (kobj_class_t cls, kobjop_desc_t desc)
 
static kobj_method_t * kobj_lookup_method_mi (kobj_class_t cls, kobjop_desc_t desc)
 
kobj_method_t * kobj_lookup_method (kobj_class_t cls, kobj_method_t **cep, kobjop_desc_t desc)
 
void kobj_class_free (kobj_class_t cls)
 
kobj_t kobj_create (kobj_class_t cls, struct malloc_type *mtype, int mflags)
 
static void kobj_init_common (kobj_t obj, kobj_class_t cls)
 
void kobj_init (kobj_t obj, kobj_class_t cls)
 
void kobj_init_static (kobj_t obj, kobj_class_t cls)
 
void kobj_delete (kobj_t obj, struct malloc_type *mtype)
 

Variables

static struct mtx kobj_mtx
 
static int kobj_mutex_inited
 
static int kobj_next_id = 1
 
static struct kobj_method null_method
 

Macro Definition Documentation

#define KOBJ_ASSERT (   what)    mtx_assert(&kobj_mtx, what);

Definition at line 65 of file subr_kobj.c.

Referenced by kobj_class_compile(), kobj_class_free(), kobj_delete(), and kobj_init().

#define KOBJ_LOCK ( )    mtx_lock(&kobj_mtx)

Definition at line 63 of file subr_kobj.c.

Referenced by kobj_class_compile(), kobj_class_free(), kobj_delete(), and kobj_init().

#define KOBJ_UNLOCK ( )    mtx_unlock(&kobj_mtx)

Definition at line 64 of file subr_kobj.c.

Referenced by kobj_class_compile(), kobj_class_free(), kobj_delete(), and kobj_init().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
void kobj_class_compile ( kobj_class_t  cls)

Definition at line 127 of file subr_kobj.c.

References free(), KOBJ_ASSERT, kobj_class_compile_common(), KOBJ_LOCK, KOBJ_UNLOCK, malloc(), and panic().

Referenced by devclass_add_driver(), kobj_init(), linker_add_class(), and root_bus_module_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

static void kobj_class_compile_common ( kobj_class_t  cls,
kobj_ops_t  ops 
)
static

Definition at line 98 of file subr_kobj.c.

References kobj_next_id, and null_method.

Referenced by kobj_class_compile(), and kobj_class_compile_static().

Here is the caller graph for this function:

void kobj_class_compile_static ( kobj_class_t  cls,
kobj_ops_t  ops 
)

Definition at line 158 of file subr_kobj.c.

References kobj_class_compile_common(), and kobj_mutex_inited.

Here is the call graph for this function:

void kobj_class_free ( kobj_class_t  cls)

Definition at line 233 of file subr_kobj.c.

References free(), KOBJ_ASSERT, KOBJ_LOCK, and KOBJ_UNLOCK.

Referenced by devclass_delete_driver(), and kobj_delete().

Here is the call graph for this function:

Here is the caller graph for this function:

kobj_t kobj_create ( kobj_class_t  cls,
struct malloc_type *  mtype,
int  mflags 
)

Definition at line 264 of file subr_kobj.c.

References kobj_init(), and malloc().

Referenced by linker_make_file().

Here is the call graph for this function:

Here is the caller graph for this function:

void kobj_delete ( kobj_t  obj,
struct malloc_type *  mtype 
)

Definition at line 326 of file subr_kobj.c.

References free(), KOBJ_ASSERT, kobj_class_free(), KOBJ_LOCK, and KOBJ_UNLOCK.

Referenced by device_delete_child(), device_set_driver(), linker_file_unload(), and make_device().

Here is the call graph for this function:

Here is the caller graph for this function:

int kobj_error_method ( void  )

Definition at line 91 of file subr_kobj.c.

void kobj_init ( kobj_t  obj,
kobj_class_t  cls 
)

Definition at line 290 of file subr_kobj.c.

References KOBJ_ASSERT, kobj_class_compile(), kobj_init_common(), KOBJ_LOCK, and KOBJ_UNLOCK.

Referenced by device_set_driver(), kobj_create(), make_device(), and root_bus_module_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

static void kobj_init_common ( kobj_t  obj,
kobj_class_t  cls 
)
static

Definition at line 282 of file subr_kobj.c.

Referenced by kobj_init(), and kobj_init_static().

Here is the caller graph for this function:

static void kobj_init_mutex ( void *  arg)
static

Definition at line 71 of file subr_kobj.c.

References kobj_mtx, kobj_mutex_inited, and mtx_init().

Here is the call graph for this function:

void kobj_init_static ( kobj_t  obj,
kobj_class_t  cls 
)

Definition at line 316 of file subr_kobj.c.

References kobj_init_common(), and kobj_mutex_inited.

Here is the call graph for this function:

kobj_method_t* kobj_lookup_method ( kobj_class_t  cls,
kobj_method_t **  cep,
kobjop_desc_t  desc 
)

Definition at line 210 of file subr_kobj.c.

References kobj_lookup_method_mi().

Here is the call graph for this function:

static kobj_method_t* kobj_lookup_method_class ( kobj_class_t  cls,
kobjop_desc_t  desc 
)
static

Definition at line 172 of file subr_kobj.c.

Referenced by kobj_lookup_method_mi().

Here is the caller graph for this function:

static kobj_method_t* kobj_lookup_method_mi ( kobj_class_t  cls,
kobjop_desc_t  desc 
)
static

Definition at line 187 of file subr_kobj.c.

References kobj_lookup_method_class().

Referenced by kobj_lookup_method().

Here is the call graph for this function:

Here is the caller graph for this function:

static MALLOC_DEFINE ( M_KOBJ  ,
"kobj"  ,
"Kernel object structures"   
)
static
SYSCTL_INT ( _kern  ,
OID_AUTO  ,
kobj_methodcount  ,
CTLFLAG_RD  ,
kobj_next_id,
,
""   
)
SYSINIT ( kobj  ,
SI_SUB_LOCK  ,
SI_ORDER_ANY  ,
kobj_init_mutex  ,
NULL   
)

Variable Documentation

struct mtx kobj_mtx
static

Definition at line 59 of file subr_kobj.c.

Referenced by kobj_init_mutex().

int kobj_mutex_inited
static

Definition at line 60 of file subr_kobj.c.

Referenced by kobj_class_compile_static(), kobj_init_mutex(), and kobj_init_static().

int kobj_next_id = 1
static

Definition at line 61 of file subr_kobj.c.

Referenced by kobj_class_compile_common().

struct kobj_method null_method
static
Initial value:
= {
0, 0,
}

Definition at line 86 of file subr_kobj.c.

Referenced by kobj_class_compile_common().