]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ppc/machine_routines.c
xnu-1228.tar.gz
[apple/xnu.git] / osfmk / ppc / machine_routines.c
index 6e2d0bddae31a7794c21e0765ec5aafd94d4af35..7f127ee81e844fa5b832e8027ffade5102fc4f5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -39,6 +39,8 @@
 #include <ppc/mem.h>
 #include <ppc/new_screen.h>
 #include <ppc/proc_reg.h>
+#include <ppc/machine_cpu.h> /* for cpu_signal_handler() */
+#include <ppc/fpu_protos.h>
 #include <kern/kern_types.h>
 #include <kern/processor.h>
 #include <kern/machine.h>
@@ -88,11 +90,6 @@ extern unsigned int mulckePatch_eieio;
 extern unsigned int sulckPatch_eieio;
 extern unsigned int rwlesPatch_eieio;
 extern unsigned int rwldPatch_eieio;
-#if     !MACH_LDEBUG
-extern unsigned int entfsectPatch_isync;
-extern unsigned int retfsectPatch_isync;
-extern unsigned int retfsectPatch_eieio;
-#endif
 
 struct patch_up {
         unsigned int    *addr;
@@ -131,11 +128,6 @@ patch_up_t patch_up_table[] = {
        {&sulckPatch_eieio,             0x60000000},
        {&rwlesPatch_eieio,             0x60000000},
        {&rwldPatch_eieio,              0x60000000},
-#if     !MACH_LDEBUG
-       {&entfsectPatch_isync,          0x60000000},
-       {&retfsectPatch_isync,          0x60000000},
-       {&retfsectPatch_eieio,          0x60000000},
-#endif
        {NULL,                          0x00000000}
 };
 
@@ -255,7 +247,48 @@ void ml_install_interrupt_handler(
        proc_info->interrupts_enabled = TRUE;  
        (void) ml_set_interrupts_enabled(current_state);
 
-       initialize_screen(0, kPEAcquireScreen);
+       initialize_screen(NULL, kPEAcquireScreen);
+}
+
+/*
+ *     Routine:        ml_nofault_copy
+ *     Function:       Perform a physical mode copy if the source and
+ *                     destination have valid translations in the kernel pmap.
+ *                     If translations are present, they are assumed to
+ *                     be wired; i.e. no attempt is made to guarantee that the
+ *                     translations obtained remained valid for
+ *                     the duration of their use.
+ */
+
+vm_size_t ml_nofault_copy(
+       vm_offset_t virtsrc, vm_offset_t virtdst, vm_size_t size)
+{
+       addr64_t cur_phys_dst, cur_phys_src;
+       uint32_t count, pindex, nbytes = 0;
+
+       while (size > 0) {
+               if (!(cur_phys_src = kvtophys(virtsrc)))
+                       break;
+               if (!(cur_phys_dst = kvtophys(virtdst)))
+                       break;
+               if (!mapping_phys_lookup((cur_phys_src>>12), &pindex) ||
+                   !mapping_phys_lookup((cur_phys_dst>>12), &pindex))
+                       break;
+               count = PAGE_SIZE - (cur_phys_src & PAGE_MASK);
+               if (count > (PAGE_SIZE - (cur_phys_dst & PAGE_MASK)))
+                       count = PAGE_SIZE - (cur_phys_dst & PAGE_MASK);
+               if (count > size)
+                       count = size;
+
+               bcopy_phys(cur_phys_src, cur_phys_dst, count);
+
+               nbytes += count;
+               virtsrc += count;
+               virtdst += count;
+               size -= count;
+       }
+
+       return nbytes;
 }
 
 /*
@@ -311,14 +344,9 @@ void ml_cause_interrupt(void)
  */
 void ml_thread_policy(
        thread_t thread,
-       unsigned policy_id,
+__unused       unsigned policy_id,
        unsigned policy_info)
 {
-
-       if ((policy_id == MACHINE_GROUP) &&
-               ((PerProcTable[master_cpu].ppe_vaddr->pf.Available) & pfSMPcap))
-                       thread_bind(thread, master_processor);
-
        if (policy_info & MACHINE_NETWORK_WORKLOOP) {
                spl_t           s = splsched();
 
@@ -412,8 +440,9 @@ ml_processor_register(
        }
 
        if (!boot_processor) {
-               (void)hw_atomic_add((uint32_t *)&saveanchor.savetarget, FreeListMin);   /* saveareas for this processor */
-               processor_init((struct processor *)proc_info->processor, proc_info->cpu_number);
+               (void)hw_atomic_add(&saveanchor.savetarget, FreeListMin);   /* saveareas for this processor */
+               processor_init((struct processor *)proc_info->processor,
+                                                               proc_info->cpu_number, processor_pset(master_processor));
        }
 
        *processor_out = (struct processor *)proc_info->processor;
@@ -522,8 +551,8 @@ ml_get_max_cpus(void)
                mcpus_state |= MAX_CPUS_WAIT;
                thread_sleep_mutex((event_t)&mcpus_state,
                                         &mcpus_lock, THREAD_UNINT);
-       } else
-               mutex_unlock(&mcpus_lock);
+       }
+       mutex_unlock(&mcpus_lock);
        return(machine_info.max_cpus);
 }
 
@@ -534,8 +563,8 @@ ml_get_max_cpus(void)
 void
 ml_cpu_up(void)
 {
-       hw_atomic_add(&machine_info.physical_cpu, 1);
-       hw_atomic_add(&machine_info.logical_cpu, 1);
+       (void)hw_atomic_add(&machine_info.physical_cpu, 1);
+       (void)hw_atomic_add(&machine_info.logical_cpu, 1);
 }
 
 /*
@@ -545,8 +574,8 @@ ml_cpu_up(void)
 void
 ml_cpu_down(void)
 {
-       hw_atomic_sub(&machine_info.physical_cpu, 1);
-       hw_atomic_sub(&machine_info.logical_cpu, 1);
+       (void)hw_atomic_sub(&machine_info.physical_cpu, 1);
+       (void)hw_atomic_sub(&machine_info.logical_cpu, 1);
 }
 
 /*
@@ -630,8 +659,6 @@ ml_enable_cache_level(int cache_level, int enable)
 }
 
 
-decl_simple_lock_data(, spsLock);
-
 /*
  *      Routine:        ml_set_processor_speed
  *      Function:
@@ -662,7 +689,7 @@ ml_set_processor_speed(unsigned long speed)
                                 */
                                for (i=200; i>0; i--) {
                                        current_state = ml_set_interrupts_enabled(FALSE);
-                                       if (cpu != cpu_number()) {
+                                       if (cpu != (unsigned)cpu_number()) {
                                                        if (PerProcTable[cpu].ppe_vaddr->cpu_flags & SignalReady)
                                                        /*
                                                         * Target cpu is off-line, skip
@@ -777,49 +804,6 @@ machine_processor_shutdown(
        return((thread_t)(getPerProc()->old_thread));
 }
 
-/*
- *     Routine:        set_be_bit
- *     Function:
- */
-int
-set_be_bit(
-       void)
-{
-       boolean_t current_state;
-
-       current_state = ml_set_interrupts_enabled(FALSE);
-       getPerProc()->cpu_flags |= traceBE;
-       (void) ml_set_interrupts_enabled(current_state);
-       return(1);
-}
-
-/*
- *     Routine:        clr_be_bit
- *     Function:
- */
-int
-clr_be_bit(
-       void)
-{
-       boolean_t current_state;
-
-       current_state = ml_set_interrupts_enabled(FALSE);
-       getPerProc()->cpu_flags &= ~traceBE;
-       (void) ml_set_interrupts_enabled(current_state);
-       return(1);
-}
-
-/*
- *     Routine:        be_tracing
- *     Function:
- */
-int
-be_tracing(
-       void)
-{
-  return(getPerProc()->cpu_flags & traceBE);
-}
-
 
 void ml_mem_backoff(void) {