Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/mutex_irql.h
- This file was added.
/* | |||||
* | |||||
*/ | |||||
#include <sys/stdint.h> | |||||
#include <sys/param.h> | |||||
#include <sys/lock.h> | |||||
#include <sys/mutex.h> | |||||
#include <sys/kernel.h> | |||||
// interrupt level for X86/X64 with RT environment | |||||
#define MTX_IRQL_RT_LEVEL 0xE | |||||
// ----------------------------------------------------------------------------- | |||||
struct mtx_irql | |||||
{ | |||||
uint32_t irql; | |||||
volatile uint32_t iflag_n_irql; | |||||
volatile u_long lock; | |||||
const char* name; | |||||
}; | |||||
// ----------------------------------------------------------------------------- | |||||
void mtx_init_irql(struct mtx_irql* mtx, const char* name, uint32_t irql); | |||||
void mtx_destroy_irql(struct mtx_irql* mtx); | |||||
void mtx_lock_irql(struct mtx_irql* mtx); | |||||
void mtx_unlock_irql(struct mtx_irql* mtx); | |||||
// ----------------------------------------------------------------------------- | |||||
struct mtx_un | |||||
{ | |||||
uint32_t isbsd; | |||||
union | |||||
{ | |||||
struct mtx mtx_bsd; | |||||
struct mtx_irql mtx_irql; | |||||
}; | |||||
}; | |||||
// ----------------------------------------------------------------------------- | |||||
void mtx_init_un(struct mtx_un* mtx, const char* name, uint32_t irql); | |||||
void mtx_destroy_un(struct mtx_un* mtx); | |||||
void mtx_lock_un(struct mtx_un* mtx); | |||||
void mtx_unlock_un(struct mtx_un* mtx); | |||||
// ----------------------------------------------------------------------------- | |||||
void mtx_sysinit_un(const void* udata); | |||||
void mtx_sysuninit_un(const void* udata); | |||||
// ----------------------------------------------------------------------------- | |||||
struct mtx_un_args | |||||
{ | |||||
struct mtx_un* ma_mtx; | |||||
const char* ma_name; | |||||
uint32_t ma_irql; | |||||
}; | |||||
#define MTX_UN_SYSINIT(name, mtx, desc, irql) \ | |||||
static struct mtx_un_args name##_args = { \ | |||||
(mtx), \ | |||||
(desc), \ | |||||
(irql) \ | |||||
}; \ | |||||
SYSINIT(name##_mtx_un_sysinit, \ | |||||
SI_SUB_LOCK, SI_ORDER_MIDDLE, \ | |||||
mtx_sysinit_un, &name##_args); \ | |||||
SYSUNINIT(name##_mtx_un_sysuninit, \ | |||||
SI_SUB_LOCK, SI_ORDER_MIDDLE, \ | |||||
mtx_sysuninit_un, &name##_args) |