]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/bsd_kern.c
xnu-1504.7.4.tar.gz
[apple/xnu.git] / osfmk / kern / bsd_kern.c
index c13e4082616e4673db1af7aa1eeeaa7ef1a151d3..822c07ce955b5403365beffc0529ba6278578952 100644 (file)
@@ -26,6 +26,7 @@
  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 #include <mach/mach_types.h>
+#include <mach/machine/vm_param.h>
 
 #include <kern/kern_types.h>
 #include <kern/processor.h>
@@ -277,12 +278,12 @@ int is_64signalregset(void)
 }
 
 /*
- * The old map reference is returned.
+ * Swap in a new map for the task/thread pair; the old map reference is
+ * returned.
  */
 vm_map_t
-swap_task_map(task_t task,vm_map_t map)
+swap_task_map(task_t task, thread_t thread, vm_map_t map)
 {
-       thread_t thread = current_thread();
        vm_map_t old_map;
 
        if (task != thread->task)
@@ -293,7 +294,9 @@ swap_task_map(task_t task,vm_map_t map)
        thread->map = task->map = map;
        task_unlock(task);
 
+#if (defined(__i386__) || defined(__x86_64__)) && NCOPY_WINDOWS > 0
        inval_copy_windows(thread);
+#endif
 
        return old_map;
 }
@@ -306,6 +309,17 @@ pmap_t  get_task_pmap(task_t t)
        return(t->map->pmap);
 }
 
+/*
+ *
+ */
+uint64_t get_task_resident_size(task_t task) 
+{
+       vm_map_t map;
+       
+       map = (task == kernel_task) ? kernel_map: task->map;
+       return((uint64_t)pmap_resident_count(map->pmap) * PAGE_SIZE_64);
+}
+
 /*
  *
  */
@@ -586,7 +600,7 @@ fill_taskthreadinfo(task_t task, uint64_t thaddr, struct proc_threadinfo_interna
                        !queue_end(&task->threads, (queue_entry_t)thact); ) {
 #if defined(__ppc__) || defined(__arm__)
                if (thact->machine.cthread_self == thaddr)
-#elif defined (__i386__)
+#elif defined (__i386__) || defined (__x86_64__)
                if (thact->machine.pcb->cthread_self == thaddr)
 #else
 #error architecture not supported
@@ -617,6 +631,7 @@ fill_taskthreadinfo(task_t task, uint64_t thaddr, struct proc_threadinfo_interna
                        
                        if ((vpp != NULL) && (thact->uthread != NULL)) 
                                bsd_threadcdir(thact->uthread, vpp, vidp);
+                       bsd_getthreadname(thact->uthread,ptinfo->pth_name);
                        err = 0;
                        goto out; 
                }
@@ -645,7 +660,7 @@ fill_taskthreadlist(task_t task, void * buffer, int thcount)
                        !queue_end(&task->threads, (queue_entry_t)thact); ) {
 #if defined(__ppc__) || defined(__arm__)
                thaddr = thact->machine.cthread_self;
-#elif defined (__i386__)
+#elif defined (__i386__) || defined (__x86_64__)
                thaddr = thact->machine.pcb->cthread_self;
 #else
 #error architecture not supported
@@ -659,7 +674,7 @@ fill_taskthreadlist(task_t task, void * buffer, int thcount)
 
 out:
        task_unlock(task);
-       return(numthr * sizeof(uint64_t));
+       return (int)(numthr * sizeof(uint64_t));
        
 }