|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Copyright (C) IBM Corporation, 2009. All rights reserved.
|
|
Packit |
577717 |
* Contributed by Corey Ashford (cjashfor@us.ibm.com)
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
Packit |
577717 |
* copy of this software and associated documentation files (the "Software"),
|
|
Packit |
577717 |
* to deal in the Software without restriction, including without limitation
|
|
Packit |
577717 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
Packit |
577717 |
* and/or sell copies of the Software, and to permit persons to whom the
|
|
Packit |
577717 |
* Software is furnished to do so, subject to the following conditions:
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* The above copyright notice and this permission notice shall be included in
|
|
Packit |
577717 |
* all copies or substantial portions of the Software.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit |
577717 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit |
577717 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit |
577717 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
Packit |
577717 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
Packit |
577717 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
Packit |
577717 |
* IN THE SOFTWARE.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* pfmlib_gen_powerpc.c
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Support for libpfm4 for the PowerPC 970, 970MP, Power4,4+,5,5+,6,7 processors.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include <string.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* private headers */
|
|
Packit |
577717 |
#include "pfmlib_priv.h"
|
|
Packit |
577717 |
#include "pfmlib_power_priv.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
pfm_gen_powerpc_get_event_info(void *this, int pidx, pfm_event_info_t *info)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
pfmlib_pmu_t *pmu = this;
|
|
Packit |
577717 |
const pme_power_entry_t *pe = this_pe(this);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* pmu and idx filled out by caller
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
info->name = pe[pidx].pme_name;
|
|
Packit |
577717 |
info->desc = pe[pidx].pme_long_desc;
|
|
Packit |
577717 |
info->code = pe[pidx].pme_code;
|
|
Packit |
577717 |
info->equiv = NULL;
|
|
Packit |
577717 |
info->idx = pidx; /* private index */
|
|
Packit |
577717 |
info->pmu = pmu->pmu;
|
|
Packit |
577717 |
info->is_precise = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
info->nattrs = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return PFM_SUCCESS;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
pfm_gen_powerpc_get_event_attr_info(void *this, int pidx, int umask_idx, pfmlib_event_attr_info_t *info)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
/* No attributes are supported */
|
|
Packit |
577717 |
return PFM_ERR_ATTR;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
pfm_gen_powerpc_get_encoding(void *this, pfmlib_event_desc_t *e)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
const pme_power_entry_t *pe = this_pe(this);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
e->count = 1;
|
|
Packit |
577717 |
e->codes[0] = (uint64_t)pe[e->event].pme_code;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
evt_strcat(e->fstr, "%s", pe[e->event].pme_name);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return PFM_SUCCESS;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
pfm_gen_powerpc_get_event_first(void *this)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
pfm_gen_powerpc_get_event_next(void *this, int idx)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
pfmlib_pmu_t *p = this;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (idx >= (p->pme_count-1))
|
|
Packit |
577717 |
return -1;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return idx+1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
pfm_gen_powerpc_event_is_valid(void *this, int pidx)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
pfmlib_pmu_t *p = this;
|
|
Packit |
577717 |
return pidx >= 0 && pidx < p->pme_count;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
pfm_gen_powerpc_validate_table(void *this, FILE *fp)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
pfmlib_pmu_t *pmu = this;
|
|
Packit |
577717 |
const pme_power_entry_t *pe = this_pe(this);
|
|
Packit |
577717 |
int i;
|
|
Packit |
577717 |
int ret = PFM_ERR_INVAL;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for(i=0; i < pmu->pme_count; i++) {
|
|
Packit |
577717 |
if (!pe[i].pme_name) {
|
|
Packit |
577717 |
fprintf(fp, "pmu: %s event%d: :: no name\n", pmu->name, i);
|
|
Packit |
577717 |
goto error;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if (!pe[i].pme_long_desc) {
|
|
Packit |
577717 |
fprintf(fp, "pmu: %s event%d: %s :: no description\n", pmu->name, i, pe[i].pme_name);
|
|
Packit |
577717 |
goto error;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
ret = PFM_SUCCESS;
|
|
Packit |
577717 |
error:
|
|
Packit |
577717 |
return ret;
|
|
Packit |
577717 |
}
|