]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ipc/ipc_kmsg.c
xnu-517.12.7.tar.gz
[apple/xnu.git] / osfmk / ipc / ipc_kmsg.c
index 58a91459339e668fd5dcbe38bc8f58f6f519007d..46267f0184f0c29aa9842629425f06b7348f2c4f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
 
 #include <string.h>
 
+#ifdef ppc
+#include <ppc/Firmware.h>
+#include <ppc/low_trace.h>
+#endif
+
+
 extern vm_map_t                ipc_kernel_copy_map;
 extern vm_size_t       ipc_kmsg_max_vm_space;
 extern vm_size_t       msg_ool_size_small;
@@ -647,7 +653,7 @@ ipc_kmsg_get(
 {
        mach_msg_size_t                 msg_and_trailer_size;
        ipc_kmsg_t                      kmsg;
-       mach_msg_format_0_trailer_t     *trailer;
+       mach_msg_max_trailer_t          *trailer;
        mach_port_name_t                dest_name;
        ipc_entry_t                     dest_entry;
        ipc_port_t                      dest_port;
@@ -675,11 +681,17 @@ ipc_kmsg_get(
         * is initialized to the minimum (sizeof(mach_msg_trailer_t)), to optimize
         * the cases where no implicit data is requested.
         */
-       trailer = (mach_msg_format_0_trailer_t *) ((vm_offset_t)&kmsg->ikm_header + size);
-       trailer->msgh_sender = current_thread()->top_act->task->sec_token;
+       trailer = (mach_msg_max_trailer_t *) ((vm_offset_t)&kmsg->ikm_header + size);
+       trailer->msgh_sender = current_act()->task->sec_token;
+       trailer->msgh_audit = current_act()->task->audit_token;
        trailer->msgh_trailer_type = MACH_MSG_TRAILER_FORMAT_0;
        trailer->msgh_trailer_size = MACH_MSG_TRAILER_MINIMUM_SIZE;
-
+       
+#ifdef ppc
+       if(trcWork.traceMask) dbgTrace((unsigned int)kmsg->ikm_header.msgh_id, 
+               (unsigned int)kmsg->ikm_header.msgh_remote_port, 
+               (unsigned int)kmsg->ikm_header.msgh_local_port, 0); 
+#endif
        *kmsgp = kmsg;
        return MACH_MSG_SUCCESS;
 }
@@ -706,7 +718,7 @@ ipc_kmsg_get_from_kernel(
 {
        ipc_kmsg_t      kmsg;
        mach_msg_size_t msg_and_trailer_size;
-       mach_msg_format_0_trailer_t *trailer;
+       mach_msg_max_trailer_t *trailer;
        ipc_port_t      dest_port;
 
        assert(size >= sizeof(mach_msg_header_t));
@@ -756,9 +768,10 @@ ipc_kmsg_get_from_kernel(
         * is initialized to the minimum (sizeof(mach_msg_trailer_t)), to
         * optimize the cases where no implicit data is requested.
         */
-       trailer = (mach_msg_format_0_trailer_t *) 
+       trailer = (mach_msg_max_trailer_t *) 
                  ((vm_offset_t)&kmsg->ikm_header + size);
        trailer->msgh_sender = KERNEL_SECURITY_TOKEN;
+       trailer->msgh_audit = KERNEL_AUDIT_TOKEN;
        trailer->msgh_trailer_type = MACH_MSG_TRAILER_FORMAT_0;
        trailer->msgh_trailer_size = MACH_MSG_TRAILER_MINIMUM_SIZE;
 
@@ -1391,7 +1404,7 @@ ipc_kmsg_copyin_body(
                         * Out-of-line memory descriptor, accumulate kernel
                         * memory requirements
                         */
-                       space_needed += round_page(sstart->out_of_line.size);
+                       space_needed += round_page_32(sstart->out_of_line.size);
                        if (space_needed > ipc_kmsg_max_vm_space) {
 
                                /*
@@ -1498,7 +1511,7 @@ ipc_kmsg_copyin_body(
                         */
                        if (!page_aligned(length)) {
                                (void) memset((void *) (paddr + length), 0,
-                                       round_page(length) - length);
+                                       round_page_32(length) - length);
                        }
                        if (vm_map_copyin(ipc_kernel_copy_map, paddr, length,
                                           TRUE, &copy) != KERN_SUCCESS) {
@@ -1507,8 +1520,8 @@ ipc_kmsg_copyin_body(
                            return MACH_MSG_VM_KERNEL;
                        }
                        dsc->address = (void *) copy;
-                       paddr += round_page(length);
-                       space_needed -= round_page(length);
+                       paddr += round_page_32(length);
+                       space_needed -= round_page_32(length);
                } else {
 
                        /*
@@ -1591,9 +1604,8 @@ ipc_kmsg_copyin_body(
 
                        for(k = 0; k < j; k++) {
                            object = objects[k];
-                           if (!MACH_PORT_VALID(port))
-                               continue;
-                           ipc_object_destroy(object, dsc->disposition);
+                           if (IPC_OBJECT_VALID(object))
+                               ipc_object_destroy(object, dsc->disposition);
                        }
                        kfree(data, length);
                        ipc_kmsg_clean_partial(kmsg, i, paddr, space_needed);