]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ppc/machine_routines.c
xnu-792.12.6.tar.gz
[apple/xnu.git] / osfmk / ppc / machine_routines.c
index e424bed03d7627e21e35cb0caf6e83e9118387d6..0db64aa1d0266ea82cb916931b871f077e2176d2 100644 (file)
@@ -1,23 +1,31 @@
 /*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_LICENSE_OSREFERENCE_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.
- * 
- * This 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.
- * 
- * @APPLE_LICENSE_HEADER_END@
+ * 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@
  */
 
 #include <mach/mach_types.h>
@@ -380,9 +388,9 @@ ml_processor_register(
        else
                proc_info->time_base_enable = (void(*)(cpu_id_t, boolean_t ))NULL;
 
-       if (proc_info->pf.pfPowerModes & pmPowerTune) {
-         proc_info->pf.pfPowerTune0 = in_processor_info->power_mode_0;
-         proc_info->pf.pfPowerTune1 = in_processor_info->power_mode_1;
+       if((proc_info->pf.pfPowerModes & pmType) == pmPowerTune) {
+               proc_info->pf.pfPowerTune0 = in_processor_info->power_mode_0;
+               proc_info->pf.pfPowerTune1 = in_processor_info->power_mode_1;
        }
 
        donap = in_processor_info->supports_nap;        /* Assume we use requested nap */
@@ -626,57 +634,64 @@ void
 ml_set_processor_speed(unsigned long speed)
 {
        struct per_proc_info    *proc_info;
-       uint32_t                powerModes, cpu;
+       uint32_t                cpu;
        kern_return_t           result;
        boolean_t               current_state;
         unsigned int           i;
   
        proc_info = PerProcTable[master_cpu].ppe_vaddr;
-       powerModes = proc_info->pf.pfPowerModes;
-
-       if (powerModes & pmDualPLL) {
-
-               ml_set_processor_speed_dpll(speed);
-
-       } else if (powerModes & pmDFS) {
 
-               for (cpu = 0; cpu < real_ncpus; cpu++) {
-                       /*
-                        * cpu_signal() returns after .5ms if it fails to signal a running cpu
-                        * retry cpu_signal() for .1s to deal with long interrupt latency at boot
-                        */
-                       for (i=200; i>0; i--) {
-                               current_state = ml_set_interrupts_enabled(FALSE);
-                               if (cpu != cpu_number()) {
-                                       if (PerProcTable[cpu].ppe_vaddr->cpu_flags & SignalReady)
-                                               /*
-                                                * Target cpu is off-line, skip
-                                                */
+       switch (proc_info->pf.pfPowerModes & pmType) {  /* Figure specific type */
+               case pmDualPLL:
+
+                       ml_set_processor_speed_dpll(speed);
+                       break;
+                       
+               case pmDFS:
+
+                       for (cpu = 0; cpu < real_ncpus; cpu++) {
+                               /*
+                                * cpu_signal() returns after .5ms if it fails to signal a running cpu
+                                * retry cpu_signal() for .1s to deal with long interrupt latency at boot
+                                */
+                               for (i=200; i>0; i--) {
+                                       current_state = ml_set_interrupts_enabled(FALSE);
+                                       if (cpu != cpu_number()) {
+                                                       if (PerProcTable[cpu].ppe_vaddr->cpu_flags & SignalReady)
+                                                       /*
+                                                        * Target cpu is off-line, skip
+                                                        */
+                                                       result = KERN_SUCCESS;
+                                               else {
+                                                       simple_lock(&spsLock);
+                                                       result = cpu_signal(cpu, SIGPcpureq, CPRQsps, speed);   
+                                                       if (result == KERN_SUCCESS) 
+                                                               thread_sleep_simple_lock(&spsLock, &spsLock, THREAD_UNINT);
+                                                       simple_unlock(&spsLock);
+                                               }
+                                       } else {
+                                               ml_set_processor_speed_dfs(speed);
                                                result = KERN_SUCCESS;
-                                       else {
-                                               simple_lock(&spsLock);
-                                               result = cpu_signal(cpu, SIGPcpureq, CPRQsps, speed);   
-                                               if (result == KERN_SUCCESS) 
-                                                       thread_sleep_simple_lock(&spsLock, &spsLock, THREAD_UNINT);
-                                               simple_unlock(&spsLock);
                                        }
-                               } else {
-                                       ml_set_processor_speed_dfs(speed);
-                                       result = KERN_SUCCESS;
+                                       (void) ml_set_interrupts_enabled(current_state);
+                                       if (result == KERN_SUCCESS)
+                                               break;
                                }
-                               (void) ml_set_interrupts_enabled(current_state);
-                               if (result == KERN_SUCCESS)
-                                       break;
+                               if (result != KERN_SUCCESS)
+                                       panic("ml_set_processor_speed(): Fail to set cpu%d speed\n", cpu);
                        }
-                       if (result != KERN_SUCCESS)
-                               panic("ml_set_processor_speed(): Fail to set cpu%d speed\n", cpu);
-               }
-
-       } else if (powerModes & pmPowerTune) {
-
-               ml_set_processor_speed_powertune(speed);
+                       break;
+                       
+               case pmPowerTune:
+       
+                       ml_set_processor_speed_powertune(speed);
+                       break;
+                       
+               default:                                        
+                       break;
 
        }
+       return;
 }
 
 /*