]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/ipc_kobject.c
xnu-344.49.tar.gz
[apple/xnu.git] / osfmk / kern / ipc_kobject.c
index 5eaef10b7c87ab3b3380e049ae26e7b4b45c31c5..06898cc5f0b03697813c954a562e3d9d83bffbad 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 <mach_rt.h>
 #include <platforms.h>
 
-#include <kern/ast.h>
+#include <mach/mig.h>
 #include <mach/port.h>
 #include <mach/kern_return.h>
 #include <mach/message.h>
 #include <mach/mig_errors.h>
 #include <mach/notify.h>
+
 #include <kern/etap_macros.h>
 #include <kern/ipc_mig.h>
 #include <kern/ipc_kobject.h>
 #include <kern/misc_protos.h>
 #include <kern/mk_timer.h>
-#include <ipc/ipc_object.h>
 #include <ipc/ipc_kmsg.h>
 #include <ipc/ipc_port.h>
 #include <kern/counters.h>
 
 
-void
-                def_pager_hash_insert(
-                               ipc_port_t name_port);
-void             pager_mux_hash_insert(
-                                ipc_port_t              port,
-                                rpc_subsystem_t         rec);
-void             pager_mux_hash_delete(
-                                ipc_port_t              port);
-rpc_subsystem_t  pager_mux_hash_lookup(
-                                ipc_port_t              port);
-
-
 /*
  *     Routine:        ipc_kobject_notify
  *     Purpose:
@@ -156,43 +147,40 @@ mach_msg_size_t mig_reply_size;
 #endif /* XK_PROXY */
 
 
-rpc_subsystem_t mig_e[] = {
-        (rpc_subsystem_t)&mach_port_subsystem,
-        (rpc_subsystem_t)&mach_host_subsystem,
-        (rpc_subsystem_t)&host_priv_subsystem,
-        (rpc_subsystem_t)&host_security_subsystem,
-        (rpc_subsystem_t)&clock_subsystem,
-        (rpc_subsystem_t)&clock_priv_subsystem,
-        (rpc_subsystem_t)&processor_subsystem,
-        (rpc_subsystem_t)&processor_set_subsystem,
-        (rpc_subsystem_t)&is_iokit_subsystem,
-        (rpc_subsystem_t)&dp_memory_object_subsystem,
-        (rpc_subsystem_t)&dp_memory_object_default_subsystem,
-        (rpc_subsystem_t)&memory_object_name_subsystem,
-       (rpc_subsystem_t)&default_pager_object_subsystem,
-       (rpc_subsystem_t)&lock_set_subsystem,
-       (rpc_subsystem_t)&ledger_subsystem,
-       (rpc_subsystem_t)&semaphore_subsystem,
-       (rpc_subsystem_t)&task_subsystem,
-       (rpc_subsystem_t)&thread_act_subsystem,
-       (rpc_subsystem_t)&vm_map_subsystem,
-       (rpc_subsystem_t)&UNDReply_subsystem,
+mig_subsystem_t mig_e[] = {
+        (mig_subsystem_t)&mach_port_subsystem,
+        (mig_subsystem_t)&mach_host_subsystem,
+        (mig_subsystem_t)&host_priv_subsystem,
+        (mig_subsystem_t)&host_security_subsystem,
+        (mig_subsystem_t)&clock_subsystem,
+        (mig_subsystem_t)&clock_priv_subsystem,
+        (mig_subsystem_t)&processor_subsystem,
+        (mig_subsystem_t)&processor_set_subsystem,
+        (mig_subsystem_t)&is_iokit_subsystem,
+        (mig_subsystem_t)&memory_object_name_subsystem,
+       (mig_subsystem_t)&lock_set_subsystem,
+       (mig_subsystem_t)&ledger_subsystem,
+       (mig_subsystem_t)&semaphore_subsystem,
+       (mig_subsystem_t)&task_subsystem,
+       (mig_subsystem_t)&thread_act_subsystem,
+       (mig_subsystem_t)&vm_map_subsystem,
+       (mig_subsystem_t)&UNDReply_subsystem,
 
 #if     XK_PROXY
-        (rpc_subsystem_t)&do_uproxy_xk_uproxy_subsystem,
+        (mig_subsystem_t)&do_uproxy_xk_uproxy_subsystem,
 #endif /* XK_PROXY */
 #if     MACH_MACHINE_ROUTINES
-        (rpc_subsystem_t)&MACHINE_SUBSYSTEM,
+        (mig_subsystem_t)&MACHINE_SUBSYSTEM,
 #endif  /* MACH_MACHINE_ROUTINES */
 #if     MCMSG && iPSC860
-       (rpc_subsystem_t)&mcmsg_info_subsystem,
+       (mig_subsystem_t)&mcmsg_info_subsystem,
 #endif  /* MCMSG && iPSC860 */
 };
 
 void
 mig_init(void)
 {
-    register unsigned int i, n = sizeof(mig_e)/sizeof(rpc_subsystem_t);
+    register unsigned int i, n = sizeof(mig_e)/sizeof(mig_subsystem_t);
     register unsigned int howmany;
     register mach_msg_id_t j, pos, nentry, range;
        
@@ -228,112 +216,7 @@ mig_init(void)
          }
        }
     }
-}
-
-
-#define PAGER_MUX_HASH_COUNT 127
-
-
-struct pager_mux_entry {
-       queue_chain_t   links;
-       ipc_port_t      name;
-       rpc_subsystem_t pager_object;
-};
-typedef struct pager_mux_entry *pager_mux_entry_t;
-
-queue_head_t   pager_mux_hashtable[PAGER_MUX_HASH_COUNT];
-zone_t         pager_mux_hash_zone;
-
-decl_mutex_data(,pager_mux_hash_lock)
-
-#define        pager_mux_hash(name_port) \
-               (((natural_t)(name_port) & 0xffffff) % PAGER_MUX_HASH_COUNT)
-
-
-rpc_subsystem_t
-pager_mux_hash_lookup(
-       ipc_port_t      name_port)
-{
-       register queue_t        bucket;
-       register pager_mux_entry_t      entry;
-       register rpc_subsystem_t        pager_object;
-
-       bucket = &pager_mux_hashtable[pager_mux_hash(name_port)];
-
-       mutex_lock(&pager_mux_hash_lock);
-       for (entry = (pager_mux_entry_t)queue_first(bucket);
-            !queue_end(bucket, &entry->links);
-            entry = (pager_mux_entry_t)queue_next(&entry->links)) {
-           if (entry->name == name_port) {
-               pager_object = entry->pager_object;
-               /* don't need to reference the object, it can't disappear */
-               /* pager_mux_reference(pager_object); */
-               mutex_unlock(&pager_mux_hash_lock);
-               return (pager_object);
-           }
-       }
-       mutex_unlock(&pager_mux_hash_lock);
-       return (rpc_subsystem_t)0;
-}
-
-
-void
-pager_mux_hash_init(void)
-{
-       register int    i;
-       register vm_size_t      size;
-
-       size = sizeof(struct pager_mux_entry);
-       pager_mux_hash_zone = zinit(
-                               size,
-                               size * 2000,
-                               PAGE_SIZE,
-                               "pager mux port hash");
-       for (i = 0; i < PAGER_MUX_HASH_COUNT; i++)
-           queue_init(&pager_mux_hashtable[i]);
-       mutex_init(&pager_mux_hash_lock, ETAP_IO_DEV_PAGEH);
-}
-
-
-void
-pager_mux_hash_insert(
-       ipc_port_t      name_port,
-       rpc_subsystem_t pager_object)
-{
-       register pager_mux_entry_t new_entry;
-
-       new_entry = (pager_mux_entry_t) zalloc(pager_mux_hash_zone);
-       new_entry->links.prev = (queue_entry_t) 0;
-       new_entry->links.next = (queue_entry_t) 0;
-       new_entry->name = name_port;
-       new_entry->pager_object = pager_object;
-
-       mutex_lock(&pager_mux_hash_lock);
-       queue_enter((&pager_mux_hashtable[pager_mux_hash(name_port)]),
-                       new_entry, pager_mux_entry_t, links);
-       mutex_unlock(&pager_mux_hash_lock);
-}
-
-void
-pager_mux_hash_delete(
-       ipc_port_t      name_port)
-{
-       register queue_t        bucket;
-       register pager_mux_entry_t      entry;
-
-       bucket = &pager_mux_hashtable[pager_mux_hash(name_port)];
-
-       mutex_lock(&pager_mux_hash_lock);
-       for (entry = (pager_mux_entry_t)queue_first(bucket);
-            !queue_end(bucket, &entry->links);
-            entry = (pager_mux_entry_t)queue_next(&entry->links)) {
-           if (entry->name == name_port) {
-               queue_remove(bucket, entry, pager_mux_entry_t, links);
-               zfree(pager_mux_hash_zone, (vm_offset_t)entry);
-               break;
-           }
-       }
-       mutex_unlock(&pager_mux_hash_lock);
+    printf("mig_table_max_displ = %d\n", mig_table_max_displ);
 }
 
 
@@ -468,7 +351,7 @@ ipc_kobject_server(
                    break;
                
                default:
-                   panic("ipc_object_destroy: strange destination rights");
+                   panic("ipc_kobject_server: strange destination rights");
        }
        *destp = IP_NULL;
 
@@ -609,12 +492,7 @@ ipc_kobject_destroy(
                mach_destroy_memory_entry(port);
                break;
 
-       case IKOT_UPL:
-               mach_destroy_upl(port);
-               break;
-
        default:        /* XXX (bogon) */
-               vm_object_destroy(port);
                break;
        }
 }
@@ -628,7 +506,7 @@ ipc_kobject_notify(
        mach_msg_header_t *reply_header)
 {
        ipc_port_t port = (ipc_port_t) request_header->msgh_remote_port;
-       rpc_subsystem_t         paging_subsystem_object;
+       mig_subsystem_t         paging_subsystem_object;
        mach_port_seqno_t       seqno;
 
        ((mig_reply_error_t *) reply_header)->RetCode = MIG_NO_REPLY;
@@ -646,32 +524,19 @@ ipc_kobject_notify(
                        ipc_port_destroy(port); /* releases lock */
                        return TRUE;
                   }
-                  paging_subsystem_object = pager_mux_hash_lookup(
-                               (ipc_port_t)request_header->msgh_remote_port);
-                  if(paging_subsystem_object == (rpc_subsystem_t)
-                                       &dp_memory_object_subsystem) {
-                     default_pager_no_senders(
-                        (ipc_port_t)request_header->msgh_remote_port, 
-                        seqno, 
-                        (mach_port_mscount_t) 
-                        ((mach_no_senders_notification_t *) 
-                        request_header)->not_count);
-                     (ipc_port_t)reply_header->msgh_remote_port
-                         = MACH_PORT_NULL;
-                     return TRUE;
-                  }
-                  if(paging_subsystem_object == (rpc_subsystem_t)
-                                       &vnode_pager_workaround) {
-                     vnode_pager_no_senders(
-                        (ipc_port_t)request_header->msgh_remote_port, 
-                        (mach_port_mscount_t) 
-                        ((mach_no_senders_notification_t *) 
-                        request_header)->not_count);
-                     (ipc_port_t)reply_header->msgh_remote_port
-                         = MACH_PORT_NULL;
-                     return TRUE;
+                  if (ip_kotype(port) == IKOT_UPL) {
+                          upl_no_senders(
+                               (ipc_port_t)request_header->msgh_remote_port, 
+                               (mach_port_mscount_t) 
+                               ((mach_no_senders_notification_t *) 
+                                request_header)->not_count);
+                          (ipc_port_t)reply_header->msgh_remote_port
+                                  = MACH_PORT_NULL;
+                          return TRUE;
                   }
+                               
                   break;
+
                case MACH_NOTIFY_PORT_DELETED:
                case MACH_NOTIFY_PORT_DESTROYED:
                case MACH_NOTIFY_SEND_ONCE:
@@ -726,7 +591,7 @@ kobjserver_stats_clear(void)
 void
 kobjserver_stats(void)
 {
-    register unsigned int i, n = sizeof(mig_e)/sizeof(rpc_subsystem_t);
+    register unsigned int i, n = sizeof(mig_e)/sizeof(mig_subsystem_t);
     register unsigned int howmany;
     register mach_msg_id_t j, pos, nentry, range;