diff options
| author | Joseph Koshy <jkoshy@FreeBSD.org> | 2005-08-26 19:49:32 +0000 |
|---|---|---|
| committer | Joseph Koshy <jkoshy@FreeBSD.org> | 2005-08-26 19:49:32 +0000 |
| commit | b2bdd605bb3ae21ff0c98fc765cef3f6f9e383d9 (patch) | |
| tree | 569257bab0f18350b3706ba2cbbbd70d3c889ea8 /sys/dev/hwpmc | |
| parent | 133f7f47c18c462749e75b6f68ffb65cad48dc7f (diff) | |
Notes
Diffstat (limited to 'sys/dev/hwpmc')
| -rw-r--r-- | sys/dev/hwpmc/hwpmc_mod.c | 28 | ||||
| -rw-r--r-- | sys/dev/hwpmc/hwpmc_x86.c | 16 |
2 files changed, 37 insertions, 7 deletions
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 111eccb52ba6..ecd83d2a4e08 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -2790,10 +2790,24 @@ pmc_syscall_handler(struct thread *td, void *syscall_args) * All sampling mode PMCs need to be able to interrupt the * CPU. */ - if (PMC_IS_SAMPLING_MODE(mode)) caps |= PMC_CAP_INTERRUPT; + /* A valid class specifier should have been passed in. */ + for (n = 0; n < md->pmd_nclass; n++) + if (md->pmd_classes[n].pm_class == pa.pm_class) + break; + if (n == md->pmd_nclass) { + error = EINVAL; + break; + } + + /* The requested PMC capabilities should be feasible. */ + if ((md->pmd_classes[n].pm_caps & caps) != caps) { + error = EOPNOTSUPP; + break; + } + PMCDBG(PMC,ALL,2, "event=%d caps=0x%x mode=%d cpu=%d", pa.pm_ev, caps, mode, cpu); @@ -4033,10 +4047,16 @@ pmc_initialize(void) if (error == 0) { printf(PMC_MODULE_NAME ":"); - for (n = 0; n < (int) md->pmd_nclass; n++) - printf(" %s(%d)", + for (n = 0; n < (int) md->pmd_nclass; n++) { + printf(" %s/%d/0x%b", pmc_name_of_pmcclass[md->pmd_classes[n].pm_class], - md->pmd_nclasspmcs[n]); + md->pmd_nclasspmcs[n], + md->pmd_classes[n].pm_caps, + "\20" + "\1INT\2USR\3SYS\4EDG\5THR" + "\6REA\7WRI\10INV\11QUA\12PRC" + "\13TAG\14CSC"); + } printf("\n"); } diff --git a/sys/dev/hwpmc/hwpmc_x86.c b/sys/dev/hwpmc/hwpmc_x86.c index 089a63e17a5d..a742effc2a52 100644 --- a/sys/dev/hwpmc/hwpmc_x86.c +++ b/sys/dev/hwpmc/hwpmc_x86.c @@ -170,10 +170,20 @@ pmc_intel_initialize(void) struct pmc_mdep * pmc_md_initialize() { + int i; + struct pmc_mdep *md; + /* determine the CPU kind */ + md = NULL; if (strcmp(cpu_vendor, "AuthenticAMD") == 0) - return pmc_amd_initialize(); + md = pmc_amd_initialize(); else if (strcmp(cpu_vendor, "GenuineIntel") == 0) - return pmc_intel_initialize(); - return NULL; + md = pmc_intel_initialize(); + + /* disallow sampling if we do not have an LAPIC */ + if (md != NULL && lapic == NULL) + for (i = 1; i < md->pmd_nclass; i++) + md->pmd_classes[i].pm_caps &= ~PMC_CAP_INTERRUPT; + + return md; } |
