]> 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 3216af3ea2a443e82c1c5911098cdceb6bc2af8e..7f127ee81e844fa5b832e8027ffade5102fc4f5b 100644 (file)
@@ -1,31 +1,29 @@
 /*
- * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
  *
- * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * 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.  The rights granted to you under the 
- * License may not be used to create, or enable the creation or 
- * redistribution of, unlawful or unlicensed copies of an Apple operating 
- * system, or to circumvent, violate, or enable the circumvention or 
- * violation of, any terms of an Apple operating system software license 
- * agreement.
- *
- * 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, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
- * Please see the License for the specific language governing rights and 
+ * 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. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ * 
+ * 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
  * limitations under the License.
- *
- * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
+ * 
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 
 #include <mach/mach_types.h>
@@ -41,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>
@@ -90,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;
@@ -133,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}
 };
 
@@ -257,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;
 }
 
 /*
@@ -313,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();
 
@@ -414,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;
@@ -524,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);
 }
 
@@ -536,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);
 }
 
 /*
@@ -547,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);
 }
 
 /*
@@ -632,8 +659,6 @@ ml_enable_cache_level(int cache_level, int enable)
 }
 
 
-decl_simple_lock_data(, spsLock);
-
 /*
  *      Routine:        ml_set_processor_speed
  *      Function:
@@ -664,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
@@ -779,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) {