#ifndef _ATM_ATM_INTERNAL_H_
#define _ATM_ATM_INTERNAL_H_
#include <stdint.h>
#include <mach/mach_types.h>
#include <atm/atm_types.h>
#ifdef MACH_KERNEL_PRIVATE
#include <kern/thread.h>
#include <kern/locks.h>
#include <kern/queue.h>
#include <ipc/ipc_voucher.h>
#define ATM_TASK_DEAD 0x1
#define VAM_DEFAULT_VALUE NULL
typedef mach_voucher_attr_value_handle_t atm_voucher_id_t;
struct atm_task_descriptor {
decl_lck_mtx_data(, lock)
mach_port_t trace_buffer;
uint64_t trace_buffer_size;
uint32_t reference_count;
uint8_t flags;
#if DEVELOPMENT || DEBUG
task_t task;
queue_chain_t descriptor_elt;
#endif
};
#define atm_task_desc_reference_internal(elem) \
(hw_atomic_add(&(elem)->reference_count, 1))
#define atm_task_desc_release_internal(elem) \
(hw_atomic_sub(&(elem)->reference_count, 1))
typedef struct atm_task_descriptor *atm_task_descriptor_t;
#define ATM_TASK_DESCRIPTOR_NULL NULL
struct atm_value {
aid_t aid;
queue_head_t listeners;
decl_lck_mtx_data(, listener_lock)
queue_chain_t vid_hash_elt;
#if DEVELOPMENT || DEBUG
queue_chain_t value_elt;
#endif
uint32_t sync;
uint32_t listener_count;
uint32_t reference_count;
};
#define atm_value_reference_internal(elem) \
(hw_atomic_add(&(elem)->reference_count, 1))
#define atm_value_release_internal(elem) \
(hw_atomic_sub(&(elem)->reference_count, 1))
#define atm_listener_count_incr_internal(elem) \
(hw_atomic_add(&(elem)->listener_count, 1))
#define atm_listener_count_decr_internal(elem) \
(hw_atomic_sub(&(elem)->listener_count, 1))
#define atm_sync_reference_internal(elem) \
(hw_atomic_add(&(elem)->sync, 1))
typedef struct atm_value *atm_value_t;
#define ATM_VALUE_NULL NULL
#define ATM_LINK_REMOVE 0x1
struct atm_link_object {
atm_task_descriptor_t descriptor;
queue_chain_t listeners_element;
atm_guard_t guard;
uint32_t reference_count;
};
typedef struct atm_link_object *atm_link_object_t;
#define atm_link_object_reference_internal(elem) \
(hw_atomic_add(&(elem)->reference_count, 1))
#define atm_link_object_release_internal(elem) \
(hw_atomic_sub(&(elem)->reference_count, 1))
struct atm_value_hash {
queue_head_t hash_list;
decl_lck_mtx_data(, hash_list_lock)
};
typedef struct atm_value_hash *atm_value_hash_t;
void atm_init(void);
void atm_task_descriptor_destroy(atm_task_descriptor_t task_descriptor);
kern_return_t atm_register_trace_memory(task_t task, uint64_t trace_buffer_address, uint64_t buffer_size);
kern_return_t atm_send_proc_inspect_notification(task_t task, int32_t traced_pid, uint64_t traced_uniqueid);
#endif
kern_return_t atm_set_diagnostic_config(uint32_t);
uint32_t atm_get_diagnostic_config(void);
#endif