]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ipc/ipc_port.c
xnu-517.tar.gz
[apple/xnu.git] / osfmk / ipc / ipc_port.c
index 7cd8a39f7792a0388c7413965f8e825666c744e7..bddaecf3da5caa5f43c01798b6c1c5a048767eb2 100644 (file)
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2002,2000 Apple Computer, Inc. All rights reserved.
  *
  * @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@
  */
@@ -66,9 +69,7 @@
 #include <mach/kern_return.h>
 #include <kern/lock.h>
 #include <kern/ipc_kobject.h>
-#include <kern/ipc_subsystem.h>
 #include <kern/thread.h>
-#include <kern/thread_pool.h>
 #include <kern/misc_protos.h>
 #include <kern/wait_queue.h>
 #include <ipc/ipc_entry.h>
@@ -413,8 +414,8 @@ ipc_port_clear_receiver(
         * pull ourselves from any sets.
         */
        if (port->ip_pset_count != 0) {
-               ipc_pset_remove_all(port);
-               port->ip_pset_count = 0;
+               ipc_pset_remove_from_all(port);
+               assert(port->ip_pset_count == 0);
        }
 
        /*
@@ -459,10 +460,6 @@ ipc_port_init(
        port->ip_pset_count = 0;
        port->ip_premsg = IKM_NULL;
 
-       thread_pool_init(&port->ip_thread_pool);
-
-       port->ip_subsystem = RPC_SUBSYSTEM_NULL;
-       
 #if    MACH_ASSERT
        ipc_port_init_debug(port);
 #endif /* MACH_ASSERT */
@@ -504,6 +501,10 @@ ipc_port_alloc(
 
        ipc_port_init(port, space, name);
 
+       if (task_is_classic(current_task())) {
+               IP_SET_CLASSIC(port);
+       }
+
        *namep = name;
        *portp = port;
 
@@ -543,6 +544,10 @@ ipc_port_alloc_name(
 
        ipc_port_init(port, space, name);
 
+       if (task_is_classic(current_task())) {
+               IP_SET_CLASSIC(port);
+       }
+
        *portp = port;
 
        return KERN_SUCCESS;
@@ -602,7 +607,6 @@ ipc_port_destroy(
        ipc_kmsg_queue_t kmqueue;
        ipc_kmsg_t kmsg;
        ipc_port_request_t dnrequests;
-       thread_pool_t thread_pool;
 
        assert(ip_active(port));
        /* port->ip_receiver_name is garbage */
@@ -622,24 +626,9 @@ ipc_port_destroy(
                port->ip_destination = IP_NULL;
                ip_unlock(port);
 
-               if (!ipc_port_check_circularity(port, pdrequest)) {
-                       /* consumes our refs for port and pdrequest */
-                       ipc_notify_port_destroyed(pdrequest, port);
-                       return;
-               } else {
-                       /* consume pdrequest and destroy port */
-                       ipc_port_release_sonce(pdrequest);
-               }
-
-               ip_lock(port);
-               assert(ip_active(port));
-               assert(port->ip_pset_count == 0);
-               assert(port->ip_mscount == 0);
-               assert(port->ip_pdrequest == IP_NULL);
-               assert(port->ip_receiver_name == MACH_PORT_NULL);
-               assert(port->ip_destination == IP_NULL);
-
-               /* fall through and destroy the port */
+               /* consumes our refs for port and pdrequest */
+               ipc_notify_port_destroyed(pdrequest, port);
+               return;
        }
 
        /* once port is dead, we don't need to keep it locked */
@@ -653,30 +642,19 @@ ipc_port_destroy(
 
        /*
         * If the port has a preallocated message buffer and that buffer
-        * is not inuse, free it.  If it has and inuse one, then the kmsg
+        * is not inuse, free it.  If it has an inuse one, then the kmsg
         * free will detect that we freed the association and it can free it
         * like a normal buffer.
         */
        if (IP_PREALLOC(port)) {
                kmsg = port->ip_premsg;
                assert(kmsg != IKM_NULL);
-               if (!ikm_prealloc_inuse(kmsg)) {
-                       ikm_prealloc_clear_inuse(kmsg, port);
-                       IP_CLEAR_PREALLOC(port, kmsg);
+               IP_CLEAR_PREALLOC(port, kmsg);
+               if (!ikm_prealloc_inuse(kmsg))
                        ipc_kmsg_free(kmsg);
-               } else {
-                       assert(ikm_prealloc_inuse_port(kmsg) == port);
-                       ikm_prealloc_clear_inuse(kmsg, port);
-                       IP_CLEAR_PREALLOC(port, kmsg);
-               }
        }
-
        ip_unlock(port);
 
-       /* wakeup any threads waiting on this pool port for an activation */
-       if ((thread_pool = &port->ip_thread_pool) != THREAD_POOL_NULL)
-               thread_pool_wakeup(thread_pool);
-
        /* throw away no-senders request */
 
        nsrequest = port->ip_nsrequest;
@@ -694,12 +672,6 @@ ipc_port_destroy(
 
        ipc_kobject_destroy(port);
 
-       if (port->ip_subsystem != RPC_SUBSYSTEM_NULL) {
-               subsystem_deallocate((subsystem_t) port->ip_kobject);
-       }
-
-       /* XXXX Perhaps should verify that ip_thread_pool is empty! */
-
        ipc_port_release(port); /* consume caller's ref */
 }
 
@@ -888,29 +860,51 @@ ipc_port_lookup_notify(
 }
 
 /*
- *     Routine:        ipc_port_make_send
+ *     Routine:        ipc_port_make_send_locked
  *     Purpose:
  *             Make a naked send right from a receive right.
+ *
  *     Conditions:
- *             The port is not locked but it is active.
+ *             port locked and active.
  */
-
 ipc_port_t
-ipc_port_make_send(
+ipc_port_make_send_locked(
        ipc_port_t      port)
 {
-       assert(IP_VALID(port));
-
-       ip_lock(port);
        assert(ip_active(port));
        port->ip_mscount++;
        port->ip_srights++;
        ip_reference(port);
        ip_unlock(port);
-
        return port;
 }
 
+/*
+ *     Routine:        ipc_port_make_send
+ *     Purpose:
+ *             Make a naked send right from a receive right.
+ */
+
+ipc_port_t
+ipc_port_make_send(
+       ipc_port_t      port)
+{
+       
+       if (!IP_VALID(port))
+               return port;
+
+       ip_lock(port);
+       if (ip_active(port)) {
+               port->ip_mscount++;
+               port->ip_srights++;
+               ip_reference(port);
+               ip_unlock(port);
+               return port;
+       }
+       ip_unlock(port);
+       return IP_DEAD;
+}
+
 /*
  *     Routine:        ipc_port_copy_send
  *     Purpose:
@@ -1158,7 +1152,7 @@ ipc_port_dealloc_special(
 {
        ip_lock(port);
        assert(ip_active(port));
-       assert(port->ip_receiver_name != MACH_PORT_NULL);
+//     assert(port->ip_receiver_name != MACH_PORT_NULL);
        assert(port->ip_receiver == space);
 
        /*
@@ -1330,7 +1324,6 @@ ipc_port_print(
        ipc_object_print(&port->ip_object);
 
        if (ipc_port_print_long) {
-               iprintf("pool=0x%x", port->ip_thread_pool);
                printf("\n");
        }
 
@@ -1535,8 +1528,8 @@ print_ports(void)
        PRINT_ONE_PORT_TYPE(PSET);
        PRINT_ONE_PORT_TYPE(PSET_NAME);
        PRINT_ONE_PORT_TYPE(PAGING_REQUEST);
-       PRINT_ONE_PORT_TYPE(XMM_OBJECT);
-       PRINT_ONE_PORT_TYPE(DEVICE);
+       PRINT_ONE_PORT_TYPE(MEMORY_OBJECT);
+       PRINT_ONE_PORT_TYPE(MIG);
        PRINT_ONE_PORT_TYPE(XMM_PAGER);
        PRINT_ONE_PORT_TYPE(XMM_KERNEL);
        PRINT_ONE_PORT_TYPE(XMM_REPLY);