X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/39236c6e673c41db228275375ab7fdb0f837b292..7e41aa883dd258f888d0470250eead40a53ef1f5:/osfmk/ipc/ipc_mqueue.h diff --git a/osfmk/ipc/ipc_mqueue.h b/osfmk/ipc/ipc_mqueue.h index 26aa7fe0d..401a3cae3 100644 --- a/osfmk/ipc/ipc_mqueue.h +++ b/osfmk/ipc/ipc_mqueue.h @@ -74,7 +74,7 @@ #include #include #include -#include +#include #include #include @@ -85,43 +85,50 @@ typedef struct ipc_mqueue { union { struct { - struct wait_queue wait_queue; + struct waitq waitq; struct ipc_kmsg_queue messages; - mach_port_msgcount_t msgcount; - mach_port_msgcount_t qlimit; mach_port_seqno_t seqno; mach_port_name_t receiver_name; - boolean_t fullwaiters; - natural_t pset_count; - } port; + uint16_t msgcount; + uint16_t qlimit; + } __attribute__((__packed__)) port; struct { - struct wait_queue_set set_queue; + struct waitq_set setq; mach_port_name_t local_name; - } pset; + } __attribute__((__packed__)) pset; } data; } *ipc_mqueue_t; #define IMQ_NULL ((ipc_mqueue_t) 0) -#define imq_wait_queue data.port.wait_queue +#define imq_wait_queue data.port.waitq #define imq_messages data.port.messages #define imq_msgcount data.port.msgcount #define imq_qlimit data.port.qlimit #define imq_seqno data.port.seqno #define imq_receiver_name data.port.receiver_name -#define imq_fullwaiters data.port.fullwaiters -#define imq_pset_count data.port.pset_count -#define imq_set_queue data.pset.set_queue -#define imq_setlinks data.pset.set_queue.wqs_setlinks -#define imq_preposts data.pset.set_queue.wqs_preposts +/* + * we can use the 'eventmask' bits of the waitq b/c + * they are only used by global queues + */ +#define imq_fullwaiters data.port.waitq.waitq_eventmask +#define imq_in_pset data.port.waitq.waitq_set_id + +#define imq_set_queue data.pset.setq #define imq_local_name data.pset.local_name -#define imq_is_set(mq) wait_queue_is_set(&(mq)->imq_set_queue) +#define imq_is_set(mq) waitqs_is_set(&(mq)->imq_set_queue) + +#define imq_lock(mq) waitq_lock(&(mq)->imq_wait_queue) +#define imq_lock_try(mq) waitq_lock_try(&(mq)->imq_wait_queue) +#define imq_unlock(mq) waitq_unlock(&(mq)->imq_wait_queue) +#define imq_held(mq) waitq_held(&(mq)->imq_wait_queue) -#define imq_lock(mq) wait_queue_lock(&(mq)->imq_wait_queue) -#define imq_lock_try(mq) wait_queue_lock_try(&(mq)->imq_wait_queue) -#define imq_unlock(mq) wait_queue_unlock(&(mq)->imq_wait_queue) -#define imq_held(mq) wait_queue_held(&(mq)->imq_wait_queue) +extern void imq_reserve_and_lock(ipc_mqueue_t mq, + uint64_t *reserved_prepost, spl_t *spl); + +extern void imq_release_and_unlock(ipc_mqueue_t mq, + uint64_t reserved_prepost, spl_t spl); #define imq_full(mq) ((mq)->imq_msgcount >= (mq)->imq_qlimit) #define imq_full_kernel(mq) ((mq)->imq_msgcount >= MACH_PORT_QLIMIT_KERNEL) @@ -139,7 +146,12 @@ extern int ipc_mqueue_full; /* Initialize a newly-allocated message queue */ extern void ipc_mqueue_init( ipc_mqueue_t mqueue, - boolean_t is_set); + boolean_t is_set, + uint64_t *reserved_link); + +/* de-initialize / cleanup an mqueue (specifically waitq resources) */ +extern void ipc_mqueue_deinit( + ipc_mqueue_t mqueue); /* destroy an mqueue */ extern void ipc_mqueue_destroy( @@ -153,7 +165,8 @@ extern void ipc_mqueue_changed( extern kern_return_t ipc_mqueue_add( ipc_mqueue_t mqueue, ipc_mqueue_t set_mqueue, - wait_queue_link_t wql); + uint64_t *reserved_link, + uint64_t *reserved_prepost); /* Check to see if mqueue is member of set_mqueue */ extern boolean_t ipc_mqueue_member( @@ -163,18 +176,15 @@ extern boolean_t ipc_mqueue_member( /* Remove an mqueue from a specific set */ extern kern_return_t ipc_mqueue_remove( ipc_mqueue_t mqueue, - ipc_mqueue_t set_mqueue, - wait_queue_link_t *wqlp); + ipc_mqueue_t set_mqueue); /* Remove an mqueue from all sets */ extern void ipc_mqueue_remove_from_all( - ipc_mqueue_t mqueue, - queue_t links); + ipc_mqueue_t mqueue); /* Remove all the members of the specifiied set */ extern void ipc_mqueue_remove_all( - ipc_mqueue_t mqueue, - queue_t links); + ipc_mqueue_t mqueue); /* Send a message to a port */ extern mach_msg_return_t ipc_mqueue_send( @@ -220,7 +230,8 @@ extern void ipc_mqueue_receive_continue( /* Select a message from a queue and try to post it to ourself */ extern void ipc_mqueue_select_on_thread( - ipc_mqueue_t mqueue, + ipc_mqueue_t port_mq, + ipc_mqueue_t set_mq, mach_msg_option_t option, mach_msg_size_t max_size, thread_t thread); @@ -239,14 +250,16 @@ extern unsigned ipc_mqueue_set_peek( /* Gather the names of member port for a given set */ extern void ipc_mqueue_set_gather_member_names( - ipc_mqueue_t mqueue, + ipc_space_t space, + ipc_mqueue_t set_mq, ipc_entry_num_t maxnames, mach_port_name_t *names, ipc_entry_num_t *actualp); /* Clear a message count reservation */ extern void ipc_mqueue_release_msgcount( - ipc_mqueue_t mqueue); + ipc_mqueue_t port_mq, + ipc_mqueue_t set_mq); /* Change a queue limit */ extern void ipc_mqueue_set_qlimit(