xref: /freebsd/share/man/man4/cpuctl.4 (revision 54ebdd631db8c0bba2baab0155f603a8b5cf014a)
1.\" Copyright (c) 2006-2008 Stanislav Sedov <stas@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd May 31, 2008
28.Dt CPUCTL 4
29.Os
30.Sh NAME
31.Nm cpuctl
32.Nd cpuctl pseudo device
33.Sh SYNOPSIS
34To compile this driver into the kernel,
35place the following lines in your kernel
36configuration file:
37.Bd -ragged -offset indent
38.Cd "device cpuctl"
39.Ed
40.Pp
41Alternatively, to load the driver as a module
42at boot time, place the following in
43.Xr loader.conf 5 :
44.Bd -literal -offset indent
45cpuctl_load="YES"
46.Ed
47.Sh DESCRIPTION
48The special file
49.Pa /dev/cpuctl
50presents interace to the system CPU. It provides functionality to retrieve
51CPUID information, read/write machine specific registers (MSR) and perform
52cpu firmware updates.
53.Pp
54For each cpu present in the system, special file
55.Pa /dev/cpuctl%d
56with the appropriate index will be created. For multicore cpus the
57special file will be created for each core.
58.Pp
59Currently, only i386 and amd64 processors are
60supported.
61.Sh IOCTL INTERFACE
62All of the supported operations are invoked using the
63.Fr ioctl 2
64system call. Refer to that manpage for further information about
65this interface. Currently, the following ioctls are defined:
66.Bl -tag -width CPUCTL_UPDATE
67.It Dv CPUCTL_RDMSR Fa cpuctl_msr_args_t *args
68.It Dv CPUCTL_WRMSR Fa cpuctl_msr_args_t *args
69Read/write cpu machine specific register. The
70.Vt cpuctl_msr_args_t
71structure defined in
72.In sys/cpuctl.h
73as:
74.Pp
75.Bd -literal
76typedef struct {
77	int		msr;	/* MSR to read */
78	uint64_t	data;
79} cpuctl_msr_args_t;
80.Ed
81.It Dv CPUCTL_CPUID Fa cpuctl_cpuid_args_t *args
82Retrieve CPUID information. Arguments are supplied in
83the following struct:
84.Pp
85.Bd -literal
86typedef struct {
87	int		level;	/* CPUID level */
88	uint32_t	data[4];
89} cpuctl_cpuid_args_t;
90.Ed
91.Pp
92The
93.Va level
94field indicates the CPUID level to retrieve information for, while the
95.Va data
96used to store CPUID data received.
97.It Dv CPUCTL_UPDATE cpuctl_update_args_t *args
98Update cpu firmware (microcode). The structure defined in
99.In sys/cpuctl.h
100as:
101.Pp
102.Bd -literal
103typedef struct {
104	void	*data;
105	size_t	size;
106} cpuctl_update_args_t;
107.Ed
108.Pp
109The
110.Va data
111field should point to the firmware image of size
112.Va size .
113.El
114.Pp
115For additional information refer to
116.Pa cpuctl.h .
117.Sh RETURN VALUES
118.Bl -tag -width Er
119.It Bq Er ENXIO
120The operation requested is not supported by device (e.g. unsupported
121architecture or cpu was disabled)
122.It Bq Er EINVAL
123Incorrect request was supplied, or microcode image is not correct.
124.It Bq Er ENOMEM
125No physical memory was available to complete the request.
126.It Bq Er EFAULT
127The firmware image address points outside process address space.
128.El
129.Sh FILES
130.Bl -tag -width /dev/cpuctl -compact
131.It Pa /dev/cpuctl
132.El
133.Sh SEE ALSO
134.Xr hwpmc 4
135.Sh HISTORY
136The
137.Nm
138driver first appeared in
139.Fx 8.0
140.Sh BUGS
141Yes, probably, report if any.
142.Sh AUTHORS
143The
144.Nm
145module and this manual page was written by
146.An Stanislav Sedov Aq stas@FreeBSD.org .
147