]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/Diagnostics.c
xnu-1228.tar.gz
[apple/xnu.git] / osfmk / i386 / Diagnostics.c
index 911e5e437123cda840b90cdc0f20cb43097011e5..34209af9eb825fea6ff0d9364d1a6b94b3073981 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2005-2006 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -78,24 +78,76 @@ diagWork        dgWork;
 uint64_t        lastNapClear = 0ULL;
 uint64_t        lastRuptClear = 0ULL;
 
-typedef struct pmdata {
-       uint64_t        pmNapDur;       /* Time since last query */
-       pmStats_t       pmd;    /* Powermanagement statistics */
-}               pmdata;
-
-
 
 int 
-diagCall64(__unused x86_saved_state_t * regs)
+diagCall64(x86_saved_state_t * state)
 {
-        panic("diagCall not yet supported for 64 bit tasks\n");
+       uint64_t        curpos, i, j;
+       uint64_t        selector, data;
+       uint64_t        currNap, durNap;
+       x86_saved_state64_t     *regs;
+
+       assert(is_saved_state64(state));
+       regs = saved_state64(state);
+
+       if (!(dgWork.dgFlags & enaDiagSCs))
+               return 0;       /* If not enabled, cause an exception */
+
+       selector = regs->rdi;
+
+       switch (selector) {     /* Select the routine */
+       case dgRuptStat:        /* Suck Interruption statistics */
+               data = regs->rsi; /* Get the number of processors */
+
+               if (data == 0) { /* If no location is specified for data, clear all
+                                 * counts
+                                 */
+                       for (i = 0; i < real_ncpus; i++) {      /* Cycle through
+                                                                * processors */
+                               for (j = 0; j < 256; j++)
+                                       cpu_data_ptr[i]->cpu_hwIntCnt[j] = 0;
+                       }
+
+                       lastRuptClear = mach_absolute_time();   /* Get the time of clear */
+                       return 1;       /* Normal return */
+               }
+
+               (void) copyout((char *) &real_ncpus, data, sizeof(real_ncpus)); /* Copy out number of
+                                                                                * processors */
+
+               currNap = mach_absolute_time(); /* Get the time now */
+               durNap = currNap - lastRuptClear;       /* Get the last interval
+                                                        * duration */
+               if (durNap == 0)
+                       durNap = 1;     /* This is a very short time, make it
+                                        * bigger */
+
+               curpos = data + sizeof(real_ncpus);     /* Point to the next
+                                                        * available spot */
+
+               for (i = 0; i < real_ncpus; i++) {      /* Move 'em all out */
+                       (void) copyout((char *) &durNap, curpos, 8);    /* Copy out the time
+                                                                        * since last clear */
+                       (void) copyout((char *) &cpu_data_ptr[i]->cpu_hwIntCnt, curpos + 8, 256 * sizeof(uint32_t));    /* Copy out interrupt
+                                                                                                                        * data for this
+                                                                                                                        * processor */
+                       curpos = curpos + (256 * sizeof(uint32_t) + 8); /* Point to next out put
+                                                                        * slot */
+               }
+               break;
+
+       default:                /* Handle invalid ones */
+               return 0;       /* Return an exception */
+
+       }
+
+       return 1;               /* Normal non-ast check return */
 }
 
 
 int 
 diagCall(x86_saved_state_t * state)
 {
-
        uint32_t        stk, curpos, i, j;
        uint32_t        selector, data;
        int             err;
@@ -114,7 +166,6 @@ diagCall(x86_saved_state_t * state)
                return 0;       /* Failed to fetch stack */
        }
        switch (selector) {     /* Select the routine */
-
        case dgRuptStat:        /* Suck Interruption statistics */
 
                err = copyin((user_addr_t) (stk + 8), (char *) &data, sizeof(uint32_t));        /* Get the selector */
@@ -130,7 +181,6 @@ diagCall(x86_saved_state_t * state)
                        lastRuptClear = mach_absolute_time();   /* Get the time of clear */
                        return 1;       /* Normal return */
                }
-               err = copyin((user_addr_t) (stk + 8), (char *) &data, sizeof(uint32_t));        /* Get the selector */
 
                (void) copyout((char *) &real_ncpus, data, sizeof(real_ncpus)); /* Copy out number of
                                                                                 * processors */