xref: /dragonfly/share/man/man4/cpuctl.4 (revision 896f2e3a)
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: release/10.0.0/share/man/man4/cpuctl.4 235317 2012-05-12 03:25:46Z gjb $
26.\"
27.Dd November 18, 2014
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 device
49.Pa /dev/cpuctl
50presents interface to the system CPU.
51It provides functionality to retrieve
52CPUID information, read/write machine specific registers (MSR) and perform
53CPU firmware updates.
54.Pp
55For each CPU present in the system, the special device
56.Pa /dev/cpuctl%d
57with the appropriate index will be created.
58For multicore CPUs such a
59special device will be created for each core.
60.Pp
61Currently, only i386 and x86_64 processors are
62supported.
63.Sh IOCTL INTERFACE
64All of the supported operations are invoked using the
65.Xr ioctl 2
66system call.
67Currently, the following ioctls are defined:
68.Bl -tag -width CPUCTL_UPDATE
69.It Dv CPUCTL_RDMSR Fa cpuctl_msr_args_t *args
70.It Dv CPUCTL_WRMSR Fa cpuctl_msr_args_t *args
71Read/write CPU machine specific register.
72The
73.Vt cpuctl_msr_args_t
74structure is defined in
75.In sys/cpuctl.h
76as:
77.Bd -literal
78typedef struct {
79	int		msr;	/* MSR to read */
80	uint64_t	data;
81} cpuctl_msr_args_t;
82.Ed
83.It Dv CPUCTL_MSRSBIT Fa cpuctl_msr_args_t *args
84.It Dv CPUCTL_MSRCBIT Fa cpuctl_msr_args_t *args
85Set/clear MSR bits according to the mask given in the
86.Va data
87field.
88.It Dv CPUCTL_CPUID Fa cpuctl_cpuid_args_t *args
89Retrieve CPUID information.
90Arguments are supplied in
91the following struct:
92.Bd -literal
93typedef struct {
94	int		level;	/* CPUID level */
95	uint32_t	data[4];
96} cpuctl_cpuid_args_t;
97.Ed
98.Pp
99The
100.Va level
101field indicates the CPUID level to retrieve information for, while the
102.Va data
103field is used to store the received CPUID data.
104.It Dv CPUCTL_UPDATE cpuctl_update_args_t *args
105Update CPU firmware (microcode).
106The structure is defined in
107.In sys/cpuctl.h
108as:
109.Bd -literal
110typedef struct {
111	void	*data;
112	size_t	size;
113} cpuctl_update_args_t;
114.Ed
115.Pp
116The
117.Va data
118field should point to the firmware image of size
119.Va size .
120.El
121.Pp
122For additional information refer to
123.Pa cpuctl.h .
124.Sh FILES
125.Bl -tag -width /dev/cpuctl -compact
126.It Pa /dev/cpuctl
127.El
128.Sh ERRORS
129.Bl -tag -width Er
130.It Bq Er ENXIO
131The operation requested is not supported by the device (e.g., unsupported
132architecture or the CPU is disabled).
133.It Bq Er EINVAL
134Incorrect request was supplied, or microcode image is not correct.
135.It Bq Er ENOMEM
136No physical memory was available to complete the request.
137.It Bq Er EFAULT
138The firmware image address points outside the process address space.
139.El
140.Sh SEE ALSO
141.\".Xr hwpmc 4 ,
142.Xr cpucontrol 8
143.Sh HISTORY
144The
145.Nm
146driver first appeared in
147.Fx 7.2 .
148.Sh AUTHORS
149The
150.Nm
151module and this manual page were written by
152.An Stanislav Sedov Aq Mt stas@FreeBSD.org .
153.Sh BUGS
154Yes, probably, report if any.
155