|
Packit |
577717 |
/* Maynard Johnson
|
|
Packit |
577717 |
* PPC64-specific code.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <sys/ucontext.h>
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include <string.h>
|
|
Packit |
577717 |
#include "libperfctr.h"
|
|
Packit |
577717 |
#include "arch.h"
|
|
Packit |
577717 |
#include "ppc64.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
unsigned long ucontext_pc(const struct ucontext *uc)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
/* glibc-2.3.3 (YDL4) changed the type of uc->uc_mcontext,
|
|
Packit |
577717 |
* breaking code which worked in glibc-2.3.1 (YDL3.0.1).
|
|
Packit |
577717 |
* This formulation works with both, and is cleaner than
|
|
Packit |
577717 |
* selecting glibc-2.3.3 specific code with "#ifdef NGREG".
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
return uc->uc_mcontext.regs->nip;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
void do_setup(const struct perfctr_info *info,
|
|
Packit |
577717 |
struct perfctr_cpu_control *cpu_control)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
memset(cpu_control, 0, sizeof *cpu_control);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
cpu_control->tsc_on = 1;
|
|
Packit |
577717 |
cpu_control->nractrs = 0;
|
|
Packit |
577717 |
cpu_control->nrictrs = 1;
|
|
Packit |
577717 |
cpu_control->pmc_map[0] = 3;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* FLOPS COMPLETED */
|
|
Packit |
577717 |
if ((info->cpu_type == PERFCTR_PPC64_POWER4) ||
|
|
Packit |
577717 |
(info->cpu_type == PERFCTR_PPC64_POWER4p)) {
|
|
Packit |
577717 |
cpu_control->ppc64.mmcr0 = 0x00000810ULL;
|
|
Packit |
577717 |
cpu_control->ppc64.mmcr1 = 0x00000000420E84A0ULL;
|
|
Packit |
577717 |
cpu_control->ppc64.mmcra = 0x00002000ULL;
|
|
Packit |
577717 |
} else if (info->cpu_type == PERFCTR_PPC64_POWER5) {
|
|
Packit |
577717 |
cpu_control->ppc64.mmcr0 = 0x00000000ULL;
|
|
Packit |
577717 |
cpu_control->ppc64.mmcr1 = 0x0000000020202010ULL;
|
|
Packit |
577717 |
cpu_control->ppc64.mmcra = 0x00000000ULL;
|
|
Packit |
577717 |
} else if (info->cpu_type == PERFCTR_PPC64_970 ||
|
|
Packit |
577717 |
info->cpu_type == PERFCTR_PPC64_970MP) {
|
|
Packit |
577717 |
cpu_control->ppc64.mmcr0 = 0x00000000ULL;
|
|
Packit |
577717 |
cpu_control->ppc64.mmcr1 = 0x00000000001E0480ULL;
|
|
Packit |
577717 |
cpu_control->ppc64.mmcra = 0x00002000ULL;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* not kernel mode, enable PMCj interrupts */
|
|
Packit |
577717 |
cpu_control->ppc64.mmcr0 |= MMCR0_FCS | MMCR0_PMCjCE;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* overflow after 100 events */
|
|
Packit |
577717 |
cpu_control->ireset[0] = 0x80000000 - 100;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
}
|