niagara_pcbe.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Niagara Performance Counter Backend
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/cpc_impl.h>
#include <sys/cpc_pcbe.h>
#include <sys/machsystm.h>
#include <sys/niagararegs.h>
static int ni_pcbe_init(void);
static uint_t ni_pcbe_ncounters(void);
static const char *ni_pcbe_impl_name(void);
static const char *ni_pcbe_cpuref(void);
static char *ni_pcbe_list_attrs(void);
static uint64_t ni_pcbe_overflow_bitmap(void);
void *token);
static void ni_pcbe_program(void *token);
static void ni_pcbe_allstop(void);
static void ni_pcbe_sample(void *token);
static void ni_pcbe_free(void *config);
extern void ultra_setpcr(uint64_t);
extern uint64_t ultra_getpcr(void);
extern void ultra_setpic(uint64_t);
extern uint64_t ultra_getpic(void);
extern uint64_t ultra_gettick(void);
};
typedef struct _ni_pcbe_config {
struct nametable {
const char *name;
};
#define NT_END 0xFF
static const struct nametable Niagara_names1[] = {
{0x00, "Instr_cnt"},
{NT_END, ""}
};
static const struct nametable Niagara_names0[] = {
{0x0, "SB_full"},
{0x1, "FP_instr_cnt"},
{0x2, "IC_miss"},
{0x3, "DC_miss"},
{0x4, "ITLB_miss"},
{0x5, "DTLB_miss"},
{0x6, "L2_imiss"},
{0x7, "L2_dmiss_ld"},
{NT_END, ""}
};
};
static const char *ni_impl_name = "UltraSPARC T1";
static char *pic_events[2];
static uint16_t pcr_pic0_mask;
static uint16_t pcr_pic1_mask;
#define CPU_REF_URL " Documentation for Sun processors can be found at: " \
static const char *niagara_cpuref = "See the \"UltraSPARC T1 User's Manual\" "
"for descriptions of these events." CPU_REF_URL;
static int
ni_pcbe_init(void)
{
const struct nametable *n;
int i;
/*
* Initialize the list of events for each PIC.
* Do two passes: one to compute the size necessary and another
* to copy the strings. Need room for event, comma, and NULL terminator.
*/
for (i = 0; i < 2; i++) {
size = 0;
*pic_events[i] = '\0';
}
/*
* Remove trailing comma.
*/
}
return (0);
}
static uint_t
ni_pcbe_ncounters(void)
{
return (2);
}
static const char *
ni_pcbe_impl_name(void)
{
return (ni_impl_name);
}
static const char *
ni_pcbe_cpuref(void)
{
return (niagara_cpuref);
}
static char *
{
return (pic_events[picnum]);
}
static char *
ni_pcbe_list_attrs(void)
{
return ("");
}
static const struct nametable *
{
const struct nametable *n;
return (n);
return (NULL);
}
static uint64_t
ni_pcbe_event_coverage(char *event)
{
bitmap = 0x1;
bitmap |= 0x2;
return (bitmap);
}
/*
* These processors cannot tell which counter overflowed. The PCBE interface
* requires such processors to act as if _all_ counters had overflowed.
*/
static uint64_t
ni_pcbe_overflow_bitmap(void)
{
pcr = ultra_getpcr();
#if 0
/*
* Not needed if the CPC framework is responsible to stop counters
* and that action ends up clearing overflow flags.
*/
if (overflow)
#endif
return (overflow);
}
/*ARGSUSED*/
static int
{
const struct nametable *n;
/*
* If we've been handed an existing configuration, we need only preset
* the counter value.
*/
return (0);
}
return (CPC_INVALID_PICNUM);
if (nattrs != 0)
return (CPC_INVALID_ATTRIBUTE);
/*
* Find other requests that will be programmed with this one, and ensure
* the flags don't conflict.
*/
return (CPC_CONFLICTING_REQS);
return (CPC_INVALID_EVENT);
return (0);
}
static void
ni_pcbe_program(void *token)
{
NULL)
}
if (pic0->pcbe_picno != 0) {
/*
* pic0 is counter 1, so if we need the empty config it should
* be counter 0.
*/
empty.pcbe_picno = 0;
#if 0
/* no selection for counter 0 */
#endif
}
/*
* UltraSPARC does not allow pic0 to be configured differently
* from pic1. If the flags on these two configurations are
* different, they are incompatible. This condition should be
* caught at configure time.
*/
/*
* On UltraSPARC, only read-to-read counts are accurate. We cannot
* expect the value we wrote into the PIC, above, to be there after
* starting the counter. We must sample the counter value now and use
* that as the baseline for future samples.
*/
curpic = ultra_getpic();
}
static void
ni_pcbe_allstop(void)
{
}
static void
ni_pcbe_sample(void *token)
{
curpic = ultra_getpic();
}
if (pic0->pcbe_picno != 0) {
empty.pcbe_picno = 0;
}
if (diff < 0)
if (diff < 0)
}
static void
ni_pcbe_free(void *config)
{
}
"UltraSPARC T1 Performance Counters v%I%",
};
static struct modlinkage modl = {
&modlpcbe,
};
int
_init(void)
{
if (ni_pcbe_init() != 0)
return (ENOTSUP);
return (mod_install(&modl));
}
int
_fini(void)
{
return (mod_remove(&modl));
}
int
{
}