diff --git a/lib/libarch/i386/Makefile.inc b/lib/libarch/i386/Makefile.inc index 780719afd60d..a171f36f3a1b 100644 --- a/lib/libarch/i386/Makefile.inc +++ b/lib/libarch/i386/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.10 2001/09/10 10:20:32 fvdl Exp $ +# $NetBSD: Makefile.inc,v 1.11 2001/11/10 06:40:58 gmcgarry Exp $ .if (${MACHINE_ARCH} == "i386") SRCS+= i386_get_ldt.c i386_set_ldt.c \ @@ -7,8 +7,13 @@ SRCS+= i386_get_ldt.c i386_set_ldt.c \ .endif MAN+= i386_get_ldt.2 \ + i386_get_mtrr.2 \ i386_iopl.2 i386_get_ioperm.2 \ + i386_pmc_info.2 \ i386_vm86.2 MLINKS+=i386_get_ldt.2 i386_set_ldt.2 \ - i386_get_ioperm.2 i386_set_ioperm.2 + i386_get_mtrr.2 i386_set_mtrr.2 \ + i386_get_ioperm.2 i386_set_ioperm.2 \ + i386_pmc_info.2 i386_pmc_startstop.2 \ + i386_pmc_info.2 i386_pmc_read.2 diff --git a/lib/libarch/i386/i386_get_mtrr.2 b/lib/libarch/i386/i386_get_mtrr.2 new file mode 100644 index 000000000000..7b896ccab327 --- /dev/null +++ b/lib/libarch/i386/i386_get_mtrr.2 @@ -0,0 +1,109 @@ +.\" $NetBSD: i386_get_mtrr.2,v 1.1 2001/11/10 06:40:59 gmcgarry Exp $ +.\" +.\" Copyright (c) 2001 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Gregory McGarry. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation nor the names of its +.\" contributors may be used to endorse or promote products derived +.\" from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd November 10, 2001 +.Dt i386_GET_MTRR 3 i386 +.Os +.Sh NAME +.Nm i386_get_mtrr , +.Nm i386_set_mtrr +.Nd access MTRR registers +.Sh LIBRARY +.Lb libi386 +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Fd #include +.Ft int +.Fn i386_get_mtrr "struct mtrr *mtrrp" "int *n" +.Ft int +.Fn i386_set_mtrr "struct mtrr *mtrrp" "int *n" +.Sh DESCRIPTION +These functions provide an interface to the MTRR registers found on +686-class processors. +.Pp +The argument +.Fa mtrrp +has the following structure: +.Bd -literal +struct mtrr { + uint64_t base; + uint64_t len; + uint8_t type; + int flags; + pid_t owner; +}; +.Ed +.Pp +The location of the mapping is described by its base address +.Em base +and length +.Em len . +Valid values for +.Em type +are: +.Pp +.Bl -tag -offset indent -width MTRR_TYPE_UNDEF1 -compact +.It MTRR_TYPE_UC +.It MTRR_TYPE_WC +.It MTRR_TYPE_UNDEF1 +.It MTRR_TYPE_UNDEF2 +.It MTRR_TYPE_WT +.It MTRR_TYPE_WP +.It MTRR_TYPE_WB +.El +.Pp +Valid values for +.Em flags +are: +.Pp +.Bl -tag -offset indent -width MTRR_PRIVATE -compact +.It MTRR_PRIVATE +own range, reset at exit +.It MTRR_FIXED +use fixed range MTRR +.It MTRR_VALID +entry is valid +.El +.Pp +The +.Em owner +member the PID of the user process which claims the mapping. It is +only valid if MTRR_PRIVATE is set in +.Em flags . +.Sh RETURN VALUES +Upon successful completion zero is returned, otherwise -1 is returned +on failure. \ No newline at end of file diff --git a/lib/libarch/i386/i386_pmc_info.2 b/lib/libarch/i386/i386_pmc_info.2 new file mode 100644 index 000000000000..1b58a80d0185 --- /dev/null +++ b/lib/libarch/i386/i386_pmc_info.2 @@ -0,0 +1,140 @@ +.\" $NetBSD: i386_pmc_info.2,v 1.1 2001/11/10 06:40:59 gmcgarry Exp $ +.\" +.\" Copyright (c) 2001 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Gregory McGarry. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation nor the names of its +.\" contributors may be used to endorse or promote products derived +.\" from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd November 10, 2001 +.Dt i386_PMC_INFO 3 i386 +.Os +.Sh NAME +.Nm i386_pmc_info , +.Nm i386_pmc_startstop , +.Nm i386_pmc_read , +.Nd interface to CPU performance counters +.Sh LIBRARY +.Lb libi386 +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Fd #include +.Ft int +.Fn i386_pmc_info "struct i386_pmc_info_args *ia" +.Ft int +.Fn i386_pmc_startstop "struct i386_pmc_startstop_args *ssa" +.Ft int +.Fn i386_pmc_read "struct i386_pmc_read_args *ra" +.Sh DESCRIPTION +These functions provide an interface to the CPU performance counters +on the 586-class and 686-class processors. +.Pp +.Fn i386_pmc_info +will return information about the available CPU counters. The +information is returned in +.Fa ia +having the following structure: +.Bd -literal +struct i386_pmc_info_args { + int type; + int flags; +}; +.Ed +.Pp +The +.Em type +member describes the class of performance counters available. Valid +values are PMC_TYPE_NONE, PMC_TYPE_I586, and PMC_TYPE_I686. The +.Em flags +member describes additional capabilities of the processor. Valid +values are PMC_INFO_HASTSC. +.Pp +.Fn i386_pmc_startstop +is used to start and stop the measurement of the CPU performance +counters. The argument +.Fa ssa +has the following structure: +.Bd -literal +struct i386_pmc_startstop_args { + int counter; + u_int64_t val; + u_int8_t event; + u_int8_t unit; + u_int8_t compare; + u_int8_t flags; +}; +.Ed +.Pp +The counter specified by the member +.Em counter +is started if the member +.Em flags +has PMC_SETUP_KERNEL or PMC_SETUP_USER set, otherwise the counter is +stopped. The initial value of the counter is set to +.Em val . +Additional values for the +.Em flags +member are PMC_SETUP_EDGE and PMC_SETUP_INV. The +.Em event +member specifies some event written to the control register. The +.Em unit +member specifies the measurement units. The +.Em compare +member is a mask for the counter. +.Pp +.Fn i386_pmc_read +will return information about a specific CPU counter measured during +the last measurement period determined by the calling of +.Fn i386_pmc_startstop . +The information is returned in +.Fa ra +having the following structure: +.Bd -literal +struct i386_pmc_read_args { + int counter; + u_int64_t val; + u_int64_t time; +}; +.Ed +.Pp +The counter to read should be specified by the +.Em counter +member. Counters are numbered from 0 to PMC_NCOUNTERS. The value of +the counter is returned in the +.Em val +member. The time since epoch, measured in CPU clock cycles, is +returned in the +.Em time +member. +.Sh RETURN VALUES +Upon successful completion zero is returned, otherwise -1 is returned +on failure.