#define dprintf(...) do { } while(0)
#endif
-static lck_grp_attr_t *proc_uuid_policy_subsys_lck_grp_attr;
-static lck_grp_t *proc_uuid_policy_subsys_lck_grp;
-static lck_attr_t *proc_uuid_policy_subsys_lck_attr;
-static lck_mtx_t proc_uuid_policy_subsys_mutex;
+static LCK_GRP_DECLARE(proc_uuid_policy_subsys_lck_grp,
+ "proc_uuid_policy_subsys_lock");
+static LCK_MTX_DECLARE(proc_uuid_policy_subsys_mutex,
+ &proc_uuid_policy_subsys_lck_grp);
#define PROC_UUID_POLICY_SUBSYS_LOCK() lck_mtx_lock(&proc_uuid_policy_subsys_mutex)
#define PROC_UUID_POLICY_SUBSYS_UNLOCK() lck_mtx_unlock(&proc_uuid_policy_subsys_mutex)
uint32_t flags; /* policy flag for that UUID */
};
+/*
+ * If you need accounting for KM_PROC_UUID_POLICY consider using
+ * KALLOC_HEAP_DEFINE to define a view.
+ */
+#define KM_PROC_UUID_POLICY KHEAP_DEFAULT
+
static int
proc_uuid_policy_insert(uuid_t uuid, uint32_t flags);
void
proc_uuid_policy_init(void)
{
- proc_uuid_policy_subsys_lck_grp_attr = lck_grp_attr_alloc_init();
- proc_uuid_policy_subsys_lck_grp = lck_grp_alloc_init("proc_uuid_policy_subsys_lock", proc_uuid_policy_subsys_lck_grp_attr);
- proc_uuid_policy_subsys_lck_attr = lck_attr_alloc_init();
- lck_mtx_init(&proc_uuid_policy_subsys_mutex, proc_uuid_policy_subsys_lck_grp, proc_uuid_policy_subsys_lck_attr);
-
proc_uuid_policy_hashtbl = hashinit(PROC_UUID_POLICY_HASH_SIZE, M_PROC_UUID_POLICY, &proc_uuid_policy_hash_mask);
proc_uuid_policy_table_gencount = 1;
proc_uuid_policy_count = 0;
return EINVAL;
}
- MALLOC(entry, struct proc_uuid_policy_entry *, sizeof(*entry), M_PROC_UUID_POLICY, M_WAITOK | M_ZERO);
+ entry = kheap_alloc(KM_PROC_UUID_POLICY, sizeof(struct proc_uuid_policy_entry),
+ Z_WAITOK | Z_ZERO);
memcpy(entry->uuid, uuid, sizeof(uuid_t));
entry->flags = flags;
/* The UUID is already in the list. Update the flags. */
foundentry->flags |= flags;
error = 0;
- FREE(entry, M_PROC_UUID_POLICY);
+ kheap_free(KM_PROC_UUID_POLICY, entry, sizeof(struct proc_uuid_policy_entry));
entry = NULL;
BUMP_PROC_UUID_POLICY_GENERATION_COUNT();
} else {
PROC_UUID_POLICY_SUBSYS_UNLOCK();
if (error) {
- FREE(entry, M_PROC_UUID_POLICY);
+ kheap_free(KM_PROC_UUID_POLICY, entry, sizeof(struct proc_uuid_policy_entry));
dprintf("Failed to insert proc uuid policy (%s,0x%08x), table full\n", uuidstr, flags);
} else {
dprintf("Inserted proc uuid policy (%s,0x%08x)\n", uuidstr, flags);
/* If we had found a pre-existing entry, deallocate its memory now */
if (delentry && should_delete) {
- FREE(delentry, M_PROC_UUID_POLICY);
+ kheap_free(KM_PROC_UUID_POLICY, delentry, sizeof(struct proc_uuid_policy_entry));
}
if (error) {
/* Memory deallocation happens after the hash lock is dropped */
LIST_FOREACH_SAFE(searchentry, &deletehead, entries, tmpentry) {
LIST_REMOVE(searchentry, entries);
- FREE(searchentry, M_PROC_UUID_POLICY);
+ kheap_free(KM_PROC_UUID_POLICY, searchentry,
+ sizeof(struct proc_uuid_policy_entry));
}
dprintf("Clearing proc uuid policy table\n");