]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ipc/ipc_kmsg.c
xnu-344.21.73.tar.gz
[apple/xnu.git] / osfmk / ipc / ipc_kmsg.c
index 04932517e3379972e95ad18d585c8a5ef0f7735e..34ecc07d662f874ee3e579ef81959a1b88385f15 100644 (file)
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 
 #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;
@@ -236,7 +245,7 @@ ipc_kmsg_free(
                        ip_unlock(port);
                        return;
                }
-               ip_unlock(port);
+               ip_check_unlock(port);  /* May be last reference */
                goto free_it;
        }
 
@@ -679,7 +688,12 @@ ipc_kmsg_get(
        trailer->msgh_sender = current_thread()->top_act->task->sec_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;
 }
@@ -1337,7 +1351,6 @@ ipc_kmsg_copyin_body(
     mach_msg_descriptor_t      *saddr, *eaddr;
     boolean_t                  complex;
     mach_msg_return_t          mr;
-    boolean_t                  use_page_lists, steal_pages;
     int                                i;
     kern_return_t              kr;
     vm_size_t                  space_needed = 0;
@@ -1350,8 +1363,6 @@ ipc_kmsg_copyin_body(
      */
     dest = (ipc_object_t) kmsg->ikm_header.msgh_remote_port;
     complex = FALSE;
-    use_page_lists = ipc_kobject_vm_page_list(ip_kotype((ipc_port_t)dest));
-    steal_pages = ipc_kobject_vm_page_steal(ip_kotype((ipc_port_t)dest));
 
     body = (mach_msg_body_t *) (&kmsg->ikm_header + 1);
     saddr = (mach_msg_descriptor_t *) (body + 1);
@@ -1377,9 +1388,6 @@ ipc_kmsg_copyin_body(
        if (sstart->type.type == MACH_MSG_OOL_DESCRIPTOR ||
            sstart->type.type == MACH_MSG_OOL_VOLATILE_DESCRIPTOR) {
 
-               assert(!(sstart->out_of_line.copy == MACH_MSG_PHYSICAL_COPY &&
-                      (use_page_lists || steal_pages)));
-
                if (sstart->out_of_line.copy != MACH_MSG_PHYSICAL_COPY &&
                    sstart->out_of_line.copy != MACH_MSG_VIRTUAL_COPY) {
                    /*
@@ -1397,7 +1405,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) {
 
                                /*
@@ -1477,51 +1485,6 @@ ipc_kmsg_copyin_body(
                
                if (length == 0) {
                    dsc->address = 0;
-               } else if (use_page_lists) {
-                   int options;
-
-                   /*
-                    * Use page list copy mechanism if specified.
-                    */
-                   if (steal_pages == FALSE) {
-                       /*
-                        * XXX Temporary Hackaround.
-                        * XXX Because the same page
-                        * XXX might be in more than one
-                        * XXX out of line region, steal
-                        * XXX (busy) pages from previous
-                        * XXX region so that this copyin
-                        * XXX won't block (permanently).
-                        */
-                       if (copy != VM_MAP_COPY_NULL)
-                           vm_map_copy_steal_pages(copy);
-                   }
-
-                   /*
-                    *  Set up options for copying in page list.
-                    *  If deallocating, steal pages to prevent
-                    *  vm code from lazy evaluating deallocation.
-                    */
-                   options = VM_PROT_READ;
-                   if (dealloc) {
-                       options |= VM_MAP_COPYIN_OPT_SRC_DESTROY |
-                                       VM_MAP_COPYIN_OPT_STEAL_PAGES;
-                   }
-                   else if (steal_pages) {
-                       options |= VM_MAP_COPYIN_OPT_STEAL_PAGES;
-                   }
-
-                   if (vm_map_copyin_page_list(map, addr, length, options,
-                                               &copy, FALSE)
-                       != KERN_SUCCESS) {
-
-                       ipc_kmsg_clean_partial(kmsg, i, paddr, space_needed);
-                       return MACH_SEND_INVALID_MEMORY;
-                   }
-
-                   dsc->address = (void *) copy;
-                   dsc->copy = MACH_MSG_PAGE_LIST_COPY_T;
-
                } else if ((length >= MSG_OOL_SIZE_SMALL) &&
                           (dsc->copy == MACH_MSG_PHYSICAL_COPY) && !dealloc) {
 
@@ -1549,7 +1512,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) {
@@ -1558,8 +1521,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 {
 
                        /*
@@ -2333,7 +2296,6 @@ ipc_kmsg_copyout_body(
                dsc = &saddr->out_of_line;
 
                assert(dsc->copy != MACH_MSG_KALLOC_COPY_T);
-               assert(dsc->copy != MACH_MSG_PAGE_LIST_COPY_T);
 
                copy_option = dsc->copy;
 
@@ -3017,9 +2979,6 @@ mm_copy_options_string(
            case MACH_MSG_KALLOC_COPY_T:
                name = "KALLOC_COPY_T";
                break;
-           case MACH_MSG_PAGE_LIST_COPY_T:
-               name = "PAGE_LIST_COPY_T";
-               break;
            default:
                name = "unknown";
                break;