Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/kernel.h
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
/* for intrhook below */ | /* for intrhook below */ | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
/* for timestamping SYSINITs; other files may assume this is included here */ | /* for timestamping SYSINITs; other files may assume this is included here */ | ||||
#include <sys/tslog.h> | #include <sys/tslog.h> | ||||
#include <sys/automation.h> | |||||
/* Global variables for the kernel. */ | /* Global variables for the kernel. */ | ||||
/* 1.1 */ | /* 1.1 */ | ||||
extern char kernelname[MAXPATHLEN]; | extern char kernelname[MAXPATHLEN]; | ||||
extern int tick; /* usec per tick (1000000 / hz) */ | extern int tick; /* usec per tick (1000000 / hz) */ | ||||
extern int hz; /* system clock's frequency */ | extern int hz; /* system clock's frequency */ | ||||
extern int psratio; /* ratio: prof / stat */ | extern int psratio; /* ratio: prof / stat */ | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | |||||
struct sysinit { | struct sysinit { | ||||
enum sysinit_sub_id subsystem; /* subsystem identifier*/ | enum sysinit_sub_id subsystem; /* subsystem identifier*/ | ||||
enum sysinit_elem_order order; /* init order within subsystem*/ | enum sysinit_elem_order order; /* init order within subsystem*/ | ||||
sysinit_cfunc_t func; /* function */ | sysinit_cfunc_t func; /* function */ | ||||
const void *udata; /* multiplexer/argument */ | const void *udata; /* multiplexer/argument */ | ||||
}; | }; | ||||
/* | /* | ||||
* Helper macros for automating sysinits. | |||||
* | |||||
* The __SI_EXPORT() macro builds a NUL terminated ASCII string, being | |||||
* parsed by automation.mk later on. | |||||
*/ | |||||
#define __SI_EXPORT(type, sub, order, var, uniq) \ | |||||
_Static_assert((sub) >= 0 && (sub) <= SI_SUB_LAST, "Subsystem is out of range"); \ | |||||
_Static_assert((order) >= 0 && (order) <= SI_ORDER_ANY, "Order is out of range"); \ | |||||
EXPORT_AUTOMATION(struct { \ | |||||
char a[sizeof(#type) - 1]; \ | |||||
char b[1]; \ | |||||
char c[11]; \ | |||||
char d[11]; \ | |||||
char e[sizeof(#type "_" #var "_" #uniq)]; \ | |||||
} export_##type##_##var, \ | |||||
{ #type }, \ | |||||
{ ' ' }, \ | |||||
{'0','x',EXPORT_HEX_U32(sub),' '}, \ | |||||
{'0','x',EXPORT_HEX_U32(order),' '}, \ | |||||
{ #type "_" #var "_" #uniq }); \ | |||||
extern struct sysinit type##_##var##_##uniq; \ | |||||
struct sysinit type##_##var##_##uniq | |||||
#define _SI_EXPORT(...) \ | |||||
__SI_EXPORT(__VA_ARGS__) | |||||
#define SI_EXPORT(...) \ | |||||
_SI_EXPORT(__VA_ARGS__, AUTOMATION_HINT) | |||||
/* | |||||
* Default: no special processing | * Default: no special processing | ||||
* | * | ||||
* The C_ version of SYSINIT is for data pointers to const | * The C_ version of SYSINIT is for data pointers to const | ||||
* data ( and functions taking data pointers to const data ). | * data ( and functions taking data pointers to const data ). | ||||
* At the moment it is no different from SYSINIT and thus | * At the moment it is no different from SYSINIT and thus | ||||
* still results in warnings. | * still results in warnings. | ||||
* | * | ||||
* The casts are necessary to have the compiler produce the | * The casts are necessary to have the compiler produce the | ||||
Show All 10 Lines | |||||
sysinit_tslog_shim(const void * data) | sysinit_tslog_shim(const void * data) | ||||
{ | { | ||||
const struct sysinit_tslog * x = data; | const struct sysinit_tslog * x = data; | ||||
TSRAW(curthread, TS_ENTER, "SYSINIT", x->name); | TSRAW(curthread, TS_ENTER, "SYSINIT", x->name); | ||||
(x->func)(x->data); | (x->func)(x->data); | ||||
TSRAW(curthread, TS_EXIT, "SYSINIT", x->name); | TSRAW(curthread, TS_EXIT, "SYSINIT", x->name); | ||||
} | } | ||||
#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ | #define C_SYSINIT(uniq, subsystem, order, func, arg) \ | ||||
static struct sysinit_tslog uniquifier ## _sys_init_tslog = { \ | static const struct sysinit_tslog sysinit_tslog_##uniq = \ | ||||
{ \ | |||||
func, \ | func, \ | ||||
(ident), \ | arg, \ | ||||
#uniquifier \ | #uniq \ | ||||
}; \ | }; \ | ||||
static struct sysinit uniquifier ## _sys_init = { \ | SI_EXPORT(sysinit, subsystem, order, uniq) = \ | ||||
{ \ | |||||
subsystem, \ | subsystem, \ | ||||
order, \ | order, \ | ||||
sysinit_tslog_shim, \ | sysinit_tslog_shim, \ | ||||
&uniquifier ## _sys_init_tslog \ | &sysinit_tslog_##uniq, \ | ||||
}; \ | } | ||||
DATA_WSET(sysinit_set,uniquifier ## _sys_init) | |||||
#else | #else | ||||
#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ | #define C_SYSINIT(uniq, subsystem, order, func, arg) \ | ||||
static struct sysinit uniquifier ## _sys_init = { \ | SI_EXPORT(sysinit, subsystem, order, uniq) = \ | ||||
{ \ | |||||
subsystem, \ | subsystem, \ | ||||
order, \ | order, \ | ||||
func, \ | func, \ | ||||
(ident) \ | arg \ | ||||
}; \ | } | ||||
DATA_WSET(sysinit_set,uniquifier ## _sys_init) | |||||
#endif | #endif | ||||
#define SYSINIT(uniquifier, subsystem, order, func, ident) \ | #define SYSINIT(uniquifier, subsystem, order, func, arg) \ | ||||
C_SYSINIT(uniquifier, subsystem, order, \ | C_SYSINIT(uniquifier, subsystem, order, \ | ||||
(sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)(ident)) | (sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)(arg)) | ||||
/* | /* | ||||
* Called on module unload: no special processing | * Called on module unload: no special processing | ||||
*/ | */ | ||||
#define C_SYSUNINIT(uniquifier, subsystem, order, func, ident) \ | #define C_SYSUNINIT(uniq, subsystem, order, func, arg) \ | ||||
static struct sysinit uniquifier ## _sys_uninit = { \ | SI_EXPORT(sysuninit, subsystem, order, uniq) = \ | ||||
subsystem, \ | { \ | ||||
order, \ | subsystem ^ SI_SUB_LAST, \ | ||||
order ^ SI_ORDER_ANY, \ | |||||
func, \ | func, \ | ||||
(ident) \ | arg \ | ||||
}; \ | } | ||||
DATA_WSET(sysuninit_set,uniquifier ## _sys_uninit) | |||||
#define SYSUNINIT(uniquifier, subsystem, order, func, ident) \ | #define SYSUNINIT(uniquifier, subsystem, order, func, arg) \ | ||||
C_SYSUNINIT(uniquifier, subsystem, order, \ | C_SYSUNINIT(uniquifier, subsystem, order, \ | ||||
(sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)(ident)) | (sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)(arg)) | ||||
void sysinit_add(struct sysinit **set, struct sysinit **set_end); | void sysinit_add(struct sysinit **set, struct sysinit **set_end); | ||||
void sysinit_sort(struct sysinit **set, struct sysinit **set_end); | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
/* | /* | ||||
* Infrastructure for tunable 'constants'. Value may be specified at compile | * Infrastructure for tunable 'constants'. Value may be specified at compile | ||||
* time or kernel load time. Rules relating tunables together can be placed | * time or kernel load time. Rules relating tunables together can be placed | ||||
* in a SYSINIT function at SI_SUB_TUNABLES with SI_ORDER_ANY. | * in a SYSINIT function at SI_SUB_TUNABLES with SI_ORDER_ANY. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |