Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hwpmc/hwpmc_intel.c
Show All 40 Lines | |||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#include <machine/specialreg.h> | #include <machine/specialreg.h> | ||||
static int | static int | ||||
intel_switch_in(struct pmc_cpu *pc, struct pmc_process *pp) | intel_switch_in(struct pmc_cpu *pc, struct pmc_process *pp) | ||||
{ | { | ||||
(void) pc; | (void) pc; | ||||
PMCDBG(MDP,SWI,1, "pc=%p pp=%p enable-msr=%d", pc, pp, | PMCDBG3(MDP,SWI,1, "pc=%p pp=%p enable-msr=%d", pc, pp, | ||||
pp->pp_flags & PMC_PP_ENABLE_MSR_ACCESS); | pp->pp_flags & PMC_PP_ENABLE_MSR_ACCESS); | ||||
/* allow the RDPMC instruction if needed */ | /* allow the RDPMC instruction if needed */ | ||||
if (pp->pp_flags & PMC_PP_ENABLE_MSR_ACCESS) | if (pp->pp_flags & PMC_PP_ENABLE_MSR_ACCESS) | ||||
load_cr4(rcr4() | CR4_PCE); | load_cr4(rcr4() | CR4_PCE); | ||||
PMCDBG(MDP,SWI,1, "cr4=0x%jx", (uintmax_t) rcr4()); | PMCDBG1(MDP,SWI,1, "cr4=0x%jx", (uintmax_t) rcr4()); | ||||
return 0; | return 0; | ||||
} | } | ||||
static int | static int | ||||
intel_switch_out(struct pmc_cpu *pc, struct pmc_process *pp) | intel_switch_out(struct pmc_cpu *pc, struct pmc_process *pp) | ||||
{ | { | ||||
(void) pc; | (void) pc; | ||||
(void) pp; /* can be NULL */ | (void) pp; /* can be NULL */ | ||||
PMCDBG(MDP,SWO,1, "pc=%p pp=%p cr4=0x%jx", pc, pp, | PMCDBG3(MDP,SWO,1, "pc=%p pp=%p cr4=0x%jx", pc, pp, | ||||
(uintmax_t) rcr4()); | (uintmax_t) rcr4()); | ||||
/* always turn off the RDPMC instruction */ | /* always turn off the RDPMC instruction */ | ||||
load_cr4(rcr4() & ~CR4_PCE); | load_cr4(rcr4() & ~CR4_PCE); | ||||
return 0; | return 0; | ||||
} | } | ||||
struct pmc_mdep * | struct pmc_mdep * | ||||
pmc_intel_initialize(void) | pmc_intel_initialize(void) | ||||
{ | { | ||||
struct pmc_mdep *pmc_mdep; | struct pmc_mdep *pmc_mdep; | ||||
enum pmc_cputype cputype; | enum pmc_cputype cputype; | ||||
int error, model, nclasses, ncpus, stepping, verov; | int error, model, nclasses, ncpus, stepping, verov; | ||||
KASSERT(cpu_vendor_id == CPU_VENDOR_INTEL, | KASSERT(cpu_vendor_id == CPU_VENDOR_INTEL, | ||||
("[intel,%d] Initializing non-intel processor", __LINE__)); | ("[intel,%d] Initializing non-intel processor", __LINE__)); | ||||
PMCDBG(MDP,INI,0, "intel-initialize cpuid=0x%x", cpu_id); | PMCDBG1(MDP,INI,0, "intel-initialize cpuid=0x%x", cpu_id); | ||||
cputype = -1; | cputype = -1; | ||||
nclasses = 2; | nclasses = 2; | ||||
error = 0; | error = 0; | ||||
verov = 0; | verov = 0; | ||||
model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4); | model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4); | ||||
stepping = cpu_id & 0xF; | stepping = cpu_id & 0xF; | ||||
▲ Show 20 Lines • Show All 287 Lines • Show Last 20 Lines |