unsigned int kdlog_value3 = 0;
unsigned int kdlog_value4 = 0;
-static lck_spin_t * kdw_spin_lock;
-static lck_spin_t * kds_spin_lock;
+static LCK_GRP_DECLARE(kdebug_lck_grp, "kdebug");
+static LCK_SPIN_DECLARE(kdw_spin_lock, &kdebug_lck_grp);
+static LCK_SPIN_DECLARE(kds_spin_lock, &kdebug_lck_grp);
kd_threadmap *kd_mapptr = 0;
vm_size_t kd_mapsize = 0;
}
}
-static lck_grp_t *kdebug_lck_grp = NULL;
-
static void
kdbg_set_tracing_enabled(bool enabled, uint32_t trace_type)
{
NULL);
int s = ml_set_interrupts_enabled(false);
- lck_spin_lock_grp(kds_spin_lock, kdebug_lck_grp);
+ lck_spin_lock_grp(&kds_spin_lock, &kdebug_lck_grp);
if (enabled) {
/*
kd_ctrl_page.enabled = 0;
commpage_update_kdebug_state();
}
- lck_spin_unlock(kds_spin_lock);
+ lck_spin_unlock(&kds_spin_lock);
ml_set_interrupts_enabled(s);
if (enabled) {
kdbg_set_flags(int slowflag, int enableflag, bool enabled)
{
int s = ml_set_interrupts_enabled(false);
- lck_spin_lock_grp(kds_spin_lock, kdebug_lck_grp);
+ lck_spin_lock_grp(&kds_spin_lock, &kdebug_lck_grp);
if (enabled) {
kd_ctrl_page.kdebug_slowcheck |= slowflag;
kdebug_enable &= ~enableflag;
}
- lck_spin_unlock(kds_spin_lock);
+ lck_spin_unlock(&kds_spin_lock);
ml_set_interrupts_enabled(s);
}
{
bool wrapped;
int s = ml_set_interrupts_enabled(false);
- lck_spin_lock_grp(kds_spin_lock, kdebug_lck_grp);
+ lck_spin_lock_grp(&kds_spin_lock, &kdebug_lck_grp);
*old_slowcheck = kd_ctrl_page.kdebug_slowcheck;
*old_flags = kd_ctrl_page.kdebug_flags;
kd_ctrl_page.kdebug_flags &= ~KDBG_WRAPPED;
kd_ctrl_page.kdebug_flags |= KDBG_NOWRAP;
- lck_spin_unlock(kds_spin_lock);
+ lck_spin_unlock(&kds_spin_lock);
ml_set_interrupts_enabled(s);
return wrapped;
enable_wrap(uint32_t old_slowcheck)
{
int s = ml_set_interrupts_enabled(false);
- lck_spin_lock_grp(kds_spin_lock, kdebug_lck_grp);
+ lck_spin_lock_grp(&kds_spin_lock, &kdebug_lck_grp);
kd_ctrl_page.kdebug_flags &= ~KDBG_NOWRAP;
kd_ctrl_page.kdebug_slowcheck &= ~SLOW_NOLOG;
}
- lck_spin_unlock(kds_spin_lock);
+ lck_spin_unlock(&kds_spin_lock);
ml_set_interrupts_enabled(s);
}
kdsp.raw = kdsp_raw;
s = ml_set_interrupts_enabled(false);
- lck_spin_lock_grp(kds_spin_lock, kdebug_lck_grp);
+ lck_spin_lock_grp(&kds_spin_lock, &kdebug_lck_grp);
kdbp = &kdbip[cpu];
kd_ctrl_page.kds_inuse_count--;
}
- lck_spin_unlock(kds_spin_lock);
+ lck_spin_unlock(&kds_spin_lock);
ml_set_interrupts_enabled(s);
}
int s = 0;
s = ml_set_interrupts_enabled(false);
- lck_spin_lock_grp(kds_spin_lock, kdebug_lck_grp);
+ lck_spin_lock_grp(&kds_spin_lock, &kdebug_lck_grp);
kdbp = &kdbip[cpu];
}
kdbp->kd_list_tail = kdsp;
out:
- lck_spin_unlock(kds_spin_lock);
+ lck_spin_unlock(&kds_spin_lock);
ml_set_interrupts_enabled(s);
return retval;
return 0;
}
-static void
-kdbg_lock_init(void)
-{
- static lck_grp_attr_t *kdebug_lck_grp_attr = NULL;
- static lck_attr_t *kdebug_lck_attr = NULL;
-
- if (kd_ctrl_page.kdebug_flags & KDBG_LOCKINIT) {
- return;
- }
-
- assert(kdebug_lck_grp_attr == NULL);
- kdebug_lck_grp_attr = lck_grp_attr_alloc_init();
- kdebug_lck_grp = lck_grp_alloc_init("kdebug", kdebug_lck_grp_attr);
- kdebug_lck_attr = lck_attr_alloc_init();
-
- kds_spin_lock = lck_spin_alloc_init(kdebug_lck_grp, kdebug_lck_attr);
- kdw_spin_lock = lck_spin_alloc_init(kdebug_lck_grp, kdebug_lck_attr);
-
- kd_ctrl_page.kdebug_flags |= KDBG_LOCKINIT;
-}
-
int
kdbg_bootstrap(bool early_trace)
{
{
ktrace_assert_lock_held();
- kdbg_lock_init();
-
kdbg_clear();
if (kdbg_typefilter) {
typefilter_reject_all(kdbg_typefilter);
if (!s) {
panic("kdbg_wait() called with interrupts disabled");
}
- lck_spin_lock_grp(kdw_spin_lock, kdebug_lck_grp);
+ lck_spin_lock_grp(&kdw_spin_lock, &kdebug_lck_grp);
if (!locked_wait) {
/* drop the mutex to allow others to access trace */
kds_waiter = 1;
if (abstime) {
- wait_result = lck_spin_sleep_deadline(kdw_spin_lock, 0, &kds_waiter, THREAD_ABORTSAFE, abstime);
+ wait_result = lck_spin_sleep_deadline(&kdw_spin_lock, 0, &kds_waiter, THREAD_ABORTSAFE, abstime);
} else {
- wait_result = lck_spin_sleep(kdw_spin_lock, 0, &kds_waiter, THREAD_ABORTSAFE);
+ wait_result = lck_spin_sleep(&kdw_spin_lock, 0, &kds_waiter, THREAD_ABORTSAFE);
}
kds_waiter = 0;
/* check the count under the spinlock */
bool threshold_exceeded = (kd_ctrl_page.kds_inuse_count >= n_storage_threshold);
- lck_spin_unlock(kdw_spin_lock);
+ lck_spin_unlock(&kdw_spin_lock);
ml_set_interrupts_enabled(s);
if (!locked_wait) {
*/
bool s = ml_set_interrupts_enabled(false);
- if (lck_spin_try_lock(kdw_spin_lock)) {
+ if (lck_spin_try_lock(&kdw_spin_lock)) {
if (kds_waiter &&
(kd_ctrl_page.kds_inuse_count >= n_storage_threshold)) {
kds_waiter = 0;
need_kds_wakeup = true;
}
- lck_spin_unlock(kdw_spin_lock);
+ lck_spin_unlock(&kdw_spin_lock);
}
ml_set_interrupts_enabled(s);
value = name[1];
}
- kdbg_lock_init();
- assert(kd_ctrl_page.kdebug_flags & KDBG_LOCKINIT);
-
ktrace_lock();
/*
ktrace_start_single_threaded();
- kdbg_lock_init();
-
ktrace_kernel_configure(KTRACE_KDEBUG);
kdbg_set_nkdbufs(n_events);