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 ("$FreeBSD$")
 
static MALLOC_DEFINE (M_KOBJ, "kobj", "Kernel object structures")
 
 SYSCTL_INT (_kern, OID_AUTO, kobj_methodcount, CTLFLAG_RD, &kobj_next_id, 0, "Number of kernel object methods registered")
 
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)
 
static int kobj_class_compile1 (kobj_class_t cls, int mflags)
 
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)
 
static void kobj_init_common (kobj_t obj, kobj_class_t cls)
 
static int kobj_init1 (kobj_t obj, kobj_class_t cls, int mflags)
 
kobj_t kobj_create (kobj_class_t cls, struct malloc_type *mtype, int mflags)
 
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 const struct kobj_method null_method
 

Macro Definition Documentation

◆ KOBJ_ASSERT

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

Definition at line 67 of file subr_kobj.c.

◆ KOBJ_LOCK

#define KOBJ_LOCK ( )    mtx_lock(&kobj_mtx)

Definition at line 65 of file subr_kobj.c.

◆ KOBJ_UNLOCK

#define KOBJ_UNLOCK ( )    mtx_unlock(&kobj_mtx)

Definition at line 66 of file subr_kobj.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ kobj_class_compile()

void kobj_class_compile ( kobj_class_t  cls)

Definition at line 157 of file subr_kobj.c.

References kobj_class_compile1().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kobj_class_compile1()

static int kobj_class_compile1 ( kobj_class_t  cls,
int  mflags 
)
static

Definition at line 130 of file subr_kobj.c.

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

Referenced by kobj_class_compile(), and kobj_init1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kobj_class_compile_common()

static void kobj_class_compile_common ( kobj_class_t  cls,
kobj_ops_t  ops 
)
static

Definition at line 101 of file subr_kobj.c.

References kobj_next_id, and null_method.

Referenced by kobj_class_compile1(), and kobj_class_compile_static().

Here is the caller graph for this function:

◆ kobj_class_compile_static()

void kobj_class_compile_static ( kobj_class_t  cls,
kobj_ops_t  ops 
)

Definition at line 166 of file subr_kobj.c.

References kobj_class_compile_common(), and kobj_mutex_inited.

Here is the call graph for this function:

◆ kobj_class_free()

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_create()

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

Definition at line 295 of file subr_kobj.c.

References free(), kobj_init1(), and malloc().

Referenced by linker_make_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kobj_delete()

void kobj_delete ( kobj_t  obj,
struct malloc_type *  mtype 
)

Definition at line 330 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:

◆ kobj_error_method()

int kobj_error_method ( void  )

Definition at line 94 of file subr_kobj.c.

◆ kobj_init()

void kobj_init ( kobj_t  obj,
kobj_class_t  cls 
)

Definition at line 310 of file subr_kobj.c.

References kobj_init1(), and panic().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kobj_init1()

static int kobj_init1 ( kobj_t  obj,
kobj_class_t  cls,
int  mflags 
)
static

Definition at line 272 of file subr_kobj.c.

References kobj_class_compile1(), kobj_init_common(), KOBJ_LOCK, and KOBJ_UNLOCK.

Referenced by kobj_create(), and kobj_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kobj_init_common()

static void kobj_init_common ( kobj_t  obj,
kobj_class_t  cls 
)
static

Definition at line 264 of file subr_kobj.c.

Referenced by kobj_init1(), and kobj_init_static().

Here is the caller graph for this function:

◆ kobj_init_mutex()

static void kobj_init_mutex ( void *  arg)
static

Definition at line 74 of file subr_kobj.c.

References kobj_mtx, and kobj_mutex_inited.

◆ kobj_init_static()

void kobj_init_static ( kobj_t  obj,
kobj_class_t  cls 
)

Definition at line 320 of file subr_kobj.c.

References kobj_init_common(), and kobj_mutex_inited.

Here is the call graph for this function:

◆ kobj_lookup_method()

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

Definition at line 218 of file subr_kobj.c.

References kobj_lookup_method_mi().

Here is the call graph for this function:

◆ kobj_lookup_method_class()

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

Definition at line 180 of file subr_kobj.c.

Referenced by kobj_lookup_method_mi().

Here is the caller graph for this function:

◆ kobj_lookup_method_mi()

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

Definition at line 195 of file subr_kobj.c.

References kobj_lookup_method_class(), and kobj_lookup_method_mi().

Referenced by kobj_lookup_method(), and kobj_lookup_method_mi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_KOBJ  ,
"kobj"  ,
"Kernel object structures"   
)
static

◆ SYSCTL_INT()

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
kobj_methodcount  ,
CTLFLAG_RD  ,
kobj_next_id,
,
"Number of kernel object methods registered"   
)

◆ SYSINIT()

SYSINIT ( kobj  ,
SI_SUB_LOCK  ,
SI_ORDER_ANY  ,
kobj_init_mutex  ,
NULL   
)

Variable Documentation

◆ kobj_mtx

struct mtx kobj_mtx
static

Definition at line 61 of file subr_kobj.c.

Referenced by kobj_init_mutex().

◆ kobj_mutex_inited

int kobj_mutex_inited
static

Definition at line 62 of file subr_kobj.c.

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

◆ kobj_next_id

int kobj_next_id = 1
static

Definition at line 63 of file subr_kobj.c.

Referenced by kobj_class_compile_common().

◆ null_method

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

Definition at line 89 of file subr_kobj.c.

Referenced by kobj_class_compile_common().