akaros/user/perfmon/pfmlib_intel_coreduo.c
<<
>>
Prefs
   1/*
   2 * pfmlib_intel_coreduo.c : Intel Core Duo/Solo (Yonah)
   3 *
   4 * Copyright (c) 2009, Google, Inc
   5 * Contributed by Stephane Eranian <eranian@gmail.com>
   6 *
   7 * Permission is hereby granted, free of charge, to any person obtaining a copy
   8 * of this software and associated documentation files (the "Software"), to deal
   9 * in the Software without restriction, including without limitation the rights
  10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  11 * of the Software, and to permit persons to whom the Software is furnished to do so,
  12 * subject to the following conditions:
  13 *
  14 * The above copyright notice and this permission notice shall be included in all
  15 * copies or substantial portions of the Software.
  16 *
  17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  18 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  19 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  21 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  22 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23 */
  24/* private headers */
  25#include "pfmlib_priv.h"                        /* library private */
  26#include "pfmlib_intel_x86_priv.h"              /* architecture private */
  27#include "events/intel_coreduo_events.h"
  28
  29static int
  30pfm_coreduo_detect(void *this)
  31{
  32        int ret;
  33
  34        ret = pfm_intel_x86_detect();
  35        if (ret != PFM_SUCCESS)
  36                return ret;
  37        /*
  38         * check for core solo/core duo
  39         */
  40        if (pfm_intel_x86_cfg.family != 6)
  41                return PFM_ERR_NOTSUPP;
  42
  43        if (pfm_intel_x86_cfg.model != 14)
  44                return PFM_ERR_NOTSUPP;
  45
  46        return PFM_SUCCESS;
  47}
  48
  49static int
  50pfm_coreduo_init(void *this)
  51{
  52        pfm_intel_x86_cfg.arch_version = 1;
  53        return PFM_SUCCESS;
  54}
  55
  56pfmlib_pmu_t intel_coreduo_support={
  57        .desc                   = "Intel Core Duo/Core Solo",
  58        .name                   = "coreduo",
  59        .pmu                    = PFM_PMU_COREDUO,
  60        .pme_count              = LIBPFM_ARRAY_SIZE(intel_coreduo_pe),
  61        .type                   = PFM_PMU_TYPE_CORE,
  62        .num_cntrs              = 2,
  63        .max_encoding           = 1,
  64        .pe                     = intel_coreduo_pe,
  65        .atdesc                 = intel_x86_mods,
  66        .flags                  = PFMLIB_PMU_FL_RAW_UMASK,
  67        .supported_plm          = INTEL_X86_PLM,
  68
  69        .pmu_detect             = pfm_coreduo_detect,
  70        .pmu_init               = pfm_coreduo_init,
  71
  72        .get_event_encoding[PFM_OS_NONE] = pfm_intel_x86_get_encoding,
  73         PFMLIB_ENCODE_PERF(pfm_intel_x86_get_perf_encoding),
  74
  75        .get_event_first        = pfm_intel_x86_get_event_first,
  76        .get_event_next         = pfm_intel_x86_get_event_next,
  77        .event_is_valid         = pfm_intel_x86_event_is_valid,
  78        .validate_table         = pfm_intel_x86_validate_table,
  79        .get_event_info         = pfm_intel_x86_get_event_info,
  80        .get_event_attr_info    = pfm_intel_x86_get_event_attr_info,
  81        PFMLIB_VALID_PERF_PATTRS(pfm_intel_x86_perf_validate_pattrs),
  82        .get_event_nattrs       = pfm_intel_x86_get_event_nattrs,
  83};
  84