]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ppc/cpu.c
xnu-517.7.7.tar.gz
[apple/xnu.git] / osfmk / ppc / cpu.c
index 97a56d260879650957e8e835a6a2876e7bdf8b54..3e66ab9c0e59fce009bcb82c144310a39ff68b45 100644 (file)
@@ -3,22 +3,19 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 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 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
+ * 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * 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@
  */
@@ -46,6 +43,7 @@
 #include <kern/cpu_data.h>
 #include <ppc/mappings.h>
 #include <ppc/Diagnostics.h>
+#include <ppc/trap.h>
 
 /* TODO: BOGUS TO BE REMOVED */
 int real_ncpus = 1;
@@ -425,8 +423,6 @@ cpu_start(
                proc_info->debstack_top_ss = proc_info->debstackptr;
 #endif  /* MACH_KDP || MACH_KDB */
                proc_info->interrupts_enabled = 0;
-               proc_info->active_kloaded = (unsigned int)&active_kloaded[cpu];
-               proc_info->active_stacks = (unsigned int)&active_stacks[cpu];
                proc_info->need_ast = (unsigned int)&need_ast[cpu];
                proc_info->FPU_owner = 0;
                proc_info->VMX_owner = 0;
@@ -473,6 +469,8 @@ cpu_start(
        }
 }
 
+perfTrap perfCpuSigHook = 0;            /* Pointer to CHUD cpu signal hook routine */
+
 /*
  *     Here is where we implement the receiver of the signaling protocol.
  *     We wait for the signal status area to be passed to us. Then we snarf
@@ -571,6 +569,21 @@ cpu_signal_handler(
                                                        timebaseAddr->done = TRUE;
 
                                                        return;
+
+                                               case CPRQsegload:
+                                                       return;
+                                               
+                                               case CPRQchud:
+                                                       parmAddr = (unsigned int *)holdParm2;   /* Get the destination address */
+                                                       if(perfCpuSigHook) {
+                                                               struct savearea *ssp = current_act()->mact.pcb;
+                                                               if(ssp) {
+                                                                       (perfCpuSigHook)(parmAddr[1] /* request */, ssp, 0, 0);
+                                                               }
+                                                       }
+                                                       parmAddr[1] = 0;
+                                                       parmAddr[0] = 0;                /* Show we're done */
+                                                       return;
                                                
                                                case CPRQscom:
                                                        fwSCOM((scomcomm *)holdParm2);  /* Do the function */
@@ -697,7 +710,7 @@ cpu_doshutdown(
        void)
 {
        enable_preemption();
-       processor_doshutdown(current_processor());
+       processor_offline(current_processor());
 }
 
 void
@@ -705,7 +718,8 @@ cpu_sleep(
        void)
 {
        struct per_proc_info    *proc_info;
-       unsigned int    cpu;
+       unsigned int    cpu, i;
+       unsigned int    wait_ncpus_sleep, ncpus_sleep;
        facility_context *fowner;
        extern vm_offset_t      intstack;
        extern vm_offset_t      debstack;
@@ -750,6 +764,16 @@ cpu_sleep(
                        __asm__ volatile("sync");
                        __asm__ volatile("isync");
                }
+
+               wait_ncpus_sleep = real_ncpus-1; 
+               ncpus_sleep = 0;
+               while (wait_ncpus_sleep != ncpus_sleep) {
+                       ncpus_sleep = 0;
+                       for(i=1; i < real_ncpus ; i++) {
+                               if ((*(volatile short *)&per_proc_info[i].cpu_flags) & SleepState)
+                                       ncpus_sleep++;
+                       }
+               }
        }
 
        PE_cpu_machine_quiesce(proc_info->cpu_id);