diff options
author | rab <none@none> | 2006-09-22 14:03:54 -0700 |
---|---|---|
committer | rab <none@none> | 2006-09-22 14:03:54 -0700 |
commit | 5d3a5ad8d2a9319e80861563ceff0e6d8d530a32 (patch) | |
tree | 5cef53e1478902ee1e73fb844fd1e699877c8d73 | |
parent | 014a7923f9b48f6ab3ba1a38049a3dacddc587cb (diff) | |
download | illumos-joyent-5d3a5ad8d2a9319e80861563ceff0e6d8d530a32.tar.gz |
5033325 x86 CPC backends should accept raw event codes
-rw-r--r-- | usr/src/cmd/cpc/common/strtoset.c | 33 | ||||
-rw-r--r-- | usr/src/lib/libcpc/common/libcpc.c | 24 | ||||
-rw-r--r-- | usr/src/uts/intel/pcbe/opteron_pcbe.c | 17 | ||||
-rw-r--r-- | usr/src/uts/intel/pcbe/p123_pcbe.c | 32 |
4 files changed, 87 insertions, 19 deletions
diff --git a/usr/src/cmd/cpc/common/strtoset.c b/usr/src/cmd/cpc/common/strtoset.c index e1e465204c..1becfe7e2c 100644 --- a/usr/src/cmd/cpc/common/strtoset.c +++ b/usr/src/cmd/cpc/common/strtoset.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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 * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -118,8 +117,25 @@ static int event_valid(int picnum, char *event) { found = 0; + cpc_walk_events_pic(cpc, picnum, event, event_walker); - return (found); + + if (found) + return (1); + + /* + * Before assuming this is an invalid event, see if we have been given + * a raw event code. An event code of '0' is not recognized, as it + * already has a corresponding event name in existing backends and it + * is the only reasonable way to know if strtol() succeeded. + */ + if (strtol(event, NULL, 0) != 0) + /* + * Success - this is a valid raw code in hex, decimal, or octal. + */ + return (1); + + return (0); } /* @@ -137,6 +153,13 @@ find_event(char *event) int i; /* + * Event names cannot have '=' in them. If present here, it means we + * have encountered an unknown token (foo=bar, for example). + */ + if (strchr(event, '=') != NULL) + return (0); + + /* * Find the first unavailable pic, after which we must start our search. */ for (i = ncounters - 1; i >= 0; i--) { diff --git a/usr/src/lib/libcpc/common/libcpc.c b/usr/src/lib/libcpc/common/libcpc.c index 8b0f3b48fd..bb18b2f090 100644 --- a/usr/src/lib/libcpc/common/libcpc.c +++ b/usr/src/lib/libcpc/common/libcpc.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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 * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1077,7 +1076,22 @@ cpc_valid_event(cpc_t *cpc, uint_t pic, const char *ev) pr.name = ev; cpc_walk_events_pic(cpc, pic, &pr, ev_walker); - return (pr.found); + if (pr.found) + return (1); + + /* + * Before assuming this is an invalid event, see if we have been given + * a raw event code. An event code of '0' is not recognized, as it + * already has a corresponding event name in existing backends and it + * is the only reasonable way to know if strtol() succeeded. + */ + if (strtol(ev, NULL, 0) != 0) + /* + * Success - this is a valid raw code in hex, decimal, or octal. + */ + return (1); + + return (0); } static int diff --git a/usr/src/uts/intel/pcbe/opteron_pcbe.c b/usr/src/uts/intel/pcbe/opteron_pcbe.c index 51374453af..10f6a15de3 100644 --- a/usr/src/uts/intel/pcbe/opteron_pcbe.c +++ b/usr/src/uts/intel/pcbe/opteron_pcbe.c @@ -41,6 +41,8 @@ #include <sys/archsystm.h> #include <sys/x86_archext.h> #include <sys/privregs.h> +#include <sys/ddi.h> +#include <sys/sunddi.h> static int opt_pcbe_init(void); static uint_t opt_pcbe_ncounters(void); @@ -342,6 +344,7 @@ opt_pcbe_configure(uint_t picnum, char *event, uint64_t preset, uint32_t flags, { opt_pcbe_config_t *cfg; opt_event_t *evp; + opt_event_t ev_raw = { "raw", 0, 0xFF }; int i; uint32_t evsel = 0; @@ -358,8 +361,18 @@ opt_pcbe_configure(uint_t picnum, char *event, uint64_t preset, uint32_t flags, if (picnum >= 4) return (CPC_INVALID_PICNUM); - if ((evp = find_event(event)) == NULL) - return (CPC_INVALID_EVENT); + if ((evp = find_event(event)) == NULL) { + long tmp; + + /* + * If ddi_strtol() likes this event, use it as a raw event code. + */ + if (ddi_strtol(event, NULL, 0, &tmp) != 0) + return (CPC_INVALID_EVENT); + + ev_raw.emask = tmp; + evp = &ev_raw; + } evsel |= evp->emask; diff --git a/usr/src/uts/intel/pcbe/p123_pcbe.c b/usr/src/uts/intel/pcbe/p123_pcbe.c index bbc5821cab..0d17b1f80f 100644 --- a/usr/src/uts/intel/pcbe/p123_pcbe.c +++ b/usr/src/uts/intel/pcbe/p123_pcbe.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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 * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -42,6 +41,8 @@ #include <sys/sdt.h> #include <sys/archsystm.h> #include <sys/privregs.h> +#include <sys/ddi.h> +#include <sys/sunddi.h> static int64_t diff3931(uint64_t sample, uint64_t old); static uint64_t trunc3931(uint64_t value); @@ -104,7 +105,7 @@ typedef struct _ptm_pcbe_config { } ptm_pcbe_config_t; struct nametable { - const uint8_t bits; + uint8_t bits; const char *name; }; @@ -600,6 +601,7 @@ ptm_pcbe_configure(uint_t picnum, char *eventname, uint64_t preset, { ptm_pcbe_config_t *conf; const struct nametable *n; + struct nametable nt_raw = { 0, "raw" }; int i; int ptm_flags = 0; @@ -616,8 +618,24 @@ ptm_pcbe_configure(uint_t picnum, char *eventname, uint64_t preset, if (picnum != 0 && picnum != 1) return (CPC_INVALID_PICNUM); - if ((n = find_event(picnum, eventname)) == NULL) - return (CPC_INVALID_EVENT); + if ((n = find_event(picnum, eventname)) == NULL) { + long tmp; + + /* + * If ddi_strtol() likes this event, use it as a raw event code. + */ + if (ddi_strtol(eventname, NULL, 0, &tmp) != 0) + return (CPC_INVALID_EVENT); + + nt_raw.bits = tmp; + + if (ptm_ver == PTM_VER_P5) + nt_raw.bits &= CPC_P5_CESR_ES0_MASK; + else + nt_raw.bits &= CPC_P6_PES_PIC0_MASK; + + n = &nt_raw; + } conf = kmem_alloc(sizeof (ptm_pcbe_config_t), KM_SLEEP); |