xref: /freebsd/sys/sys/cpuctl.h (revision 95ee2897)
1e085f869SStanislav Sedov /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3c4e20cadSPedro F. Giffuni  *
4e085f869SStanislav Sedov  * Copyright (c) 2006-2008 Stanislav Sedov <stas@FreeBSD.org>
5e085f869SStanislav Sedov  * All rights reserved.
6e085f869SStanislav Sedov  *
7e085f869SStanislav Sedov  * Redistribution and use in source and binary forms, with or without
8e085f869SStanislav Sedov  * modification, are permitted provided that the following conditions
9e085f869SStanislav Sedov  * are met:
10e085f869SStanislav Sedov  * 1. Redistributions of source code must retain the above copyright
11e085f869SStanislav Sedov  *    notice, this list of conditions and the following disclaimer.
12e085f869SStanislav Sedov  * 2. Redistributions in binary form must reproduce the above copyright
13e085f869SStanislav Sedov  *    notice, this list of conditions and the following disclaimer in the
14e085f869SStanislav Sedov  *    documentation and/or other materials provided with the distribution.
15e085f869SStanislav Sedov  *
16e085f869SStanislav Sedov  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17e085f869SStanislav Sedov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18e085f869SStanislav Sedov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19e085f869SStanislav Sedov  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20e085f869SStanislav Sedov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21e085f869SStanislav Sedov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22e085f869SStanislav Sedov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23e085f869SStanislav Sedov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24e085f869SStanislav Sedov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25e085f869SStanislav Sedov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26e085f869SStanislav Sedov  * SUCH DAMAGE.
27e085f869SStanislav Sedov  */
28e085f869SStanislav Sedov 
29e085f869SStanislav Sedov #ifndef _CPUCTL_H_
30e085f869SStanislav Sedov #define	_CPUCTL_H_
31e085f869SStanislav Sedov 
32e085f869SStanislav Sedov typedef struct {
33e085f869SStanislav Sedov 	int		msr;	/* MSR to read */
34e085f869SStanislav Sedov 	uint64_t	data;
35e085f869SStanislav Sedov } cpuctl_msr_args_t;
36e085f869SStanislav Sedov 
37e085f869SStanislav Sedov typedef struct {
38e085f869SStanislav Sedov 	int		level;		/* CPUID level */
39e085f869SStanislav Sedov 	uint32_t	data[4];
40e085f869SStanislav Sedov } cpuctl_cpuid_args_t;
41e085f869SStanislav Sedov 
42e085f869SStanislav Sedov typedef struct {
43cef789cdSKonstantin Belousov 	int		level;		/* CPUID level */
44cef789cdSKonstantin Belousov 	int		level_type;	/* CPUID level type */
45cef789cdSKonstantin Belousov 	uint32_t	data[4];
46cef789cdSKonstantin Belousov } cpuctl_cpuid_count_args_t;
47cef789cdSKonstantin Belousov 
48cef789cdSKonstantin Belousov typedef struct {
49e085f869SStanislav Sedov 	void	*data;
50e085f869SStanislav Sedov 	size_t	size;
51e085f869SStanislav Sedov } cpuctl_update_args_t;
52e085f869SStanislav Sedov 
53e085f869SStanislav Sedov #define	CPUCTL_RDMSR	_IOWR('c', 1, cpuctl_msr_args_t)
54e085f869SStanislav Sedov #define	CPUCTL_WRMSR	_IOWR('c', 2, cpuctl_msr_args_t)
55e085f869SStanislav Sedov #define	CPUCTL_CPUID	_IOWR('c', 3, cpuctl_cpuid_args_t)
56e085f869SStanislav Sedov #define	CPUCTL_UPDATE	_IOWR('c', 4, cpuctl_update_args_t)
57b2d75854SStanislav Sedov #define	CPUCTL_MSRSBIT	_IOWR('c', 5, cpuctl_msr_args_t)
58b2d75854SStanislav Sedov #define	CPUCTL_MSRCBIT	_IOWR('c', 6, cpuctl_msr_args_t)
59cef789cdSKonstantin Belousov #define	CPUCTL_CPUID_COUNT _IOWR('c', 7, cpuctl_cpuid_count_args_t)
600530a936SKonstantin Belousov #define	CPUCTL_EVAL_CPU_FEATURES	_IO('c', 8)
61e085f869SStanislav Sedov 
62e085f869SStanislav Sedov #endif /* _CPUCTL_H_ */
63