]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ipc/ipc_kmsg.h
xnu-3248.20.55.tar.gz
[apple/xnu.git] / osfmk / ipc / ipc_kmsg.h
index 0c07ed8ea8ab262ab8737ccd8711dc9769ee82a1..c020a3d39daf8605a20a590133ef3cbcead7dcb0 100644 (file)
  *     of the message.
  */
 
  *     of the message.
  */
 
-struct ipc_labelh;
-
 struct ipc_kmsg {
 struct ipc_kmsg {
-       struct ipc_kmsg *ikm_next;
-       struct ipc_kmsg *ikm_prev;
-       ipc_port_t ikm_prealloc;        /* port we were preallocated from */
-       mach_msg_size_t ikm_size;
-       struct ipc_labelh *ikm_sender;
-       mach_msg_header_t *ikm_header;
+       mach_msg_size_t                         ikm_size;
+       struct ipc_kmsg                         *ikm_next;      /* next message on port/discard queue */
+       struct ipc_kmsg                         *ikm_prev;      /* prev message on port/discard queue */
+       mach_msg_header_t                       *ikm_header;
+       ipc_port_t                              ikm_prealloc;   /* port we were preallocated from */
+       ipc_port_t                              ikm_voucher;    /* voucher port carried */
+       struct ipc_importance_elem              *ikm_importance;/* inherited from */
+       queue_chain_t                           ikm_inheritance;/* inherited from link */
 };
 
 };
 
+#if defined(__i386__) || defined(__arm__)
+#define        IKM_SUPPORT_LEGACY      1
+#else
+#define        IKM_SUPPORT_LEGACY      0
+#endif
 
 #define        IKM_OVERHEAD            (sizeof(struct ipc_kmsg))
 
 
 #define        IKM_OVERHEAD            (sizeof(struct ipc_kmsg))
 
@@ -139,14 +144,14 @@ MACRO_END
 #define ikm_prealloc_clear_inuse(kmsg, port)                           \
 MACRO_BEGIN                                                            \
        (kmsg)->ikm_prealloc = IP_NULL;                                 \
 #define ikm_prealloc_clear_inuse(kmsg, port)                           \
 MACRO_BEGIN                                                            \
        (kmsg)->ikm_prealloc = IP_NULL;                                 \
-       ip_release(port);                                               \
 MACRO_END
 
 #define        ikm_init(kmsg, size)                                            \
 MACRO_BEGIN                                                            \
        (kmsg)->ikm_size = (size);                                      \
        (kmsg)->ikm_prealloc = IP_NULL;                                 \
 MACRO_END
 
 #define        ikm_init(kmsg, size)                                            \
 MACRO_BEGIN                                                            \
        (kmsg)->ikm_size = (size);                                      \
        (kmsg)->ikm_prealloc = IP_NULL;                                 \
-        (kmsg)->ikm_sender = NULL;                                     \
+        (kmsg)->ikm_voucher = IP_NULL;                                 \
+       (kmsg)->ikm_importance = IIE_NULL;                              \
        assert((kmsg)->ikm_prev = (kmsg)->ikm_next = IKM_BOGUS);        \
 MACRO_END
 
        assert((kmsg)->ikm_prev = (kmsg)->ikm_next = IKM_BOGUS);        \
 MACRO_END
 
@@ -157,6 +162,12 @@ MACRO_BEGIN                                                                \
        assert((kmsg)->ikm_next == IKM_BOGUS);                          \
 MACRO_END
 
        assert((kmsg)->ikm_next == IKM_BOGUS);                          \
 MACRO_END
 
+#define ikm_set_header(kmsg, mtsize)                                   \
+MACRO_BEGIN                                                            \
+       (kmsg)->ikm_header = (mach_msg_header_t *)                      \
+       ((vm_offset_t)((kmsg) + 1) + (kmsg)->ikm_size - (mtsize));      \
+MACRO_END
+
 struct ipc_kmsg_queue {
        struct ipc_kmsg *ikmq_base;
 };
 struct ipc_kmsg_queue {
        struct ipc_kmsg *ikmq_base;
 };
@@ -238,35 +249,6 @@ MACRO_BEGIN                                                                \
        }                                                               \
 MACRO_END
 
        }                                                               \
 MACRO_END
 
-/*
- *     extern void
- *     ipc_kmsg_send_always(ipc_kmsg_t);
- *
- *     Unfortunately, to avoid warnings/lint about unused variables
- *     when assertions are turned off, we need two versions of this.
- */
-#if    MACH_ASSERT
-
-#define        ipc_kmsg_send_always(kmsg)                                      \
-MACRO_BEGIN                                                            \
-       mach_msg_return_t mr2;                                          \
-                                                                       \
-       mr2 = ipc_kmsg_send((kmsg), MACH_SEND_ALWAYS,                   \
-                            MACH_MSG_TIMEOUT_NONE);                    \
-       assert(mr == MACH_MSG_SUCCESS);                                 \
-MACRO_END
-
-#else  /* MACH_ASSERT */
-
-#define        ipc_kmsg_send_always(kmsg)                                      \
-MACRO_BEGIN                                                            \
-       (void) ipc_kmsg_send((kmsg), MACH_SEND_ALWAYS,                  \
-                              MACH_MSG_TIMEOUT_NONE);                  \
-MACRO_END
-
-#endif /* MACH_ASSERT */
-
-
 /* Allocate a kernel message */
 extern ipc_kmsg_t ipc_kmsg_alloc(
         mach_msg_size_t size);
 /* Allocate a kernel message */
 extern ipc_kmsg_t ipc_kmsg_alloc(
         mach_msg_size_t size);
@@ -279,17 +261,23 @@ extern void ipc_kmsg_free(
 extern void ipc_kmsg_destroy(
        ipc_kmsg_t      kmsg);
 
 extern void ipc_kmsg_destroy(
        ipc_kmsg_t      kmsg);
 
-/* destroy kernel message and a reference on the dest */
-extern void ipc_kmsg_destroy_dest(
-       ipc_kmsg_t      kmsg);
+/* Enqueue kernel message for deferred destruction */
+extern boolean_t ipc_kmsg_delayed_destroy(
+       ipc_kmsg_t kmsg);
 
 
+/* Process all the delayed message destroys */
+extern void ipc_kmsg_reap_delayed(void);
 
 /* Preallocate a kernel message buffer */
 
 /* Preallocate a kernel message buffer */
+extern ipc_kmsg_t ipc_kmsg_prealloc(
+       mach_msg_size_t size);
+
+/* bind a preallocated message buffer to a port */
 extern void ipc_kmsg_set_prealloc(
        ipc_kmsg_t      kmsg,
        ipc_port_t      port);
 
 extern void ipc_kmsg_set_prealloc(
        ipc_kmsg_t      kmsg,
        ipc_port_t      port);
 
-/* Clear a kernel message buffer */
+/* Clear preallocated message buffer binding */
 extern void ipc_kmsg_clear_prealloc(
        ipc_kmsg_t      kmsg,
        ipc_port_t      port);
 extern void ipc_kmsg_clear_prealloc(
        ipc_kmsg_t      kmsg,
        ipc_port_t      port);
@@ -326,26 +314,31 @@ extern void ipc_kmsg_put_to_kernel(
 
 /* Copyin port rights in the header of a message */
 extern mach_msg_return_t ipc_kmsg_copyin_header(
 
 /* Copyin port rights in the header of a message */
 extern mach_msg_return_t ipc_kmsg_copyin_header(
-       mach_msg_header_t       *msg,
+       ipc_kmsg_t              kmsg,
        ipc_space_t             space,
        ipc_space_t             space,
-       mach_port_name_t        notify);
+       mach_msg_option_t       *optionp);
 
 /* Copyin port rights and out-of-line memory from a user message */
 extern mach_msg_return_t ipc_kmsg_copyin(
        ipc_kmsg_t              kmsg,
        ipc_space_t             space,
        vm_map_t                map,
 
 /* Copyin port rights and out-of-line memory from a user message */
 extern mach_msg_return_t ipc_kmsg_copyin(
        ipc_kmsg_t              kmsg,
        ipc_space_t             space,
        vm_map_t                map,
-       mach_port_name_t        notify);
+       mach_msg_option_t       *optionp);
 
 /* Copyin port rights and out-of-line memory from a kernel message */
 
 /* Copyin port rights and out-of-line memory from a kernel message */
-extern void ipc_kmsg_copyin_from_kernel(
+extern mach_msg_return_t ipc_kmsg_copyin_from_kernel(
        ipc_kmsg_t              kmsg);
 
        ipc_kmsg_t              kmsg);
 
+#if IKM_SUPPORT_LEGACY
+extern mach_msg_return_t ipc_kmsg_copyin_from_kernel_legacy(
+       ipc_kmsg_t      kmsg);
+#endif
+
 /* Copyout port rights in the header of a message */
 extern mach_msg_return_t ipc_kmsg_copyout_header(
 /* Copyout port rights in the header of a message */
 extern mach_msg_return_t ipc_kmsg_copyout_header(
-       mach_msg_header_t       *msg,
+       ipc_kmsg_t              kmsg,
        ipc_space_t             space,
        ipc_space_t             space,
-       mach_port_name_t        notify);
+       mach_msg_option_t       option);
 
 /* Copyout a port right returning a name */
 extern mach_msg_return_t ipc_kmsg_copyout_object(
 
 /* Copyout a port right returning a name */
 extern mach_msg_return_t ipc_kmsg_copyout_object(
@@ -359,8 +352,8 @@ extern mach_msg_return_t ipc_kmsg_copyout(
        ipc_kmsg_t              kmsg,
        ipc_space_t             space,
        vm_map_t                map,
        ipc_kmsg_t              kmsg,
        ipc_space_t             space,
        vm_map_t                map,
-       mach_port_name_t        notify,
-       mach_msg_body_t         *slist);
+       mach_msg_body_t         *slist,
+       mach_msg_option_t       option);
 
 /* Copyout port rights and out-of-line memory from the body of a message */
 extern mach_msg_return_t ipc_kmsg_copyout_body(
 
 /* Copyout port rights and out-of-line memory from the body of a message */
 extern mach_msg_return_t ipc_kmsg_copyout_body(
@@ -392,16 +385,17 @@ extern void ipc_kmsg_copyout_to_kernel(
        ipc_kmsg_t              kmsg,
        ipc_space_t             space);
 
        ipc_kmsg_t              kmsg,
        ipc_space_t             space);
 
-/* get a scatter list and check consistency */
-extern mach_msg_body_t *ipc_kmsg_get_scatter(
-        mach_vm_address_t       msg_addr,
-        mach_msg_size_t         slist_size,
-        ipc_kmsg_t              kmsg);
+#if IKM_SUPPORT_LEGACY
+extern void ipc_kmsg_copyout_to_kernel_legacy(
+       ipc_kmsg_t              kmsg,
+       ipc_space_t             space);
+#endif
 
 
-/* free a scatter list */
-extern void ipc_kmsg_free_scatter(
-        mach_msg_body_t        *slist,
-        mach_msg_size_t                slist_size);
+extern mach_msg_trailer_size_t
+ipc_kmsg_add_trailer(ipc_kmsg_t kmsg, ipc_space_t space, 
+               mach_msg_option_t option, thread_t thread, 
+               mach_port_seqno_t seqno, boolean_t minimal_trailer,
+               mach_vm_offset_t context);
 
 #endif /* _IPC_IPC_KMSG_H_ */
 
 
 #endif /* _IPC_IPC_KMSG_H_ */