xref: /illumos-gate/usr/src/uts/common/sys/cpuid_drv.h (revision 0250c53ad267726f2438e3c6556199a0bbf588a2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /*
27  * Copyright 2019 Joyent, Inc.
28  * Copyright 2022 Oxide Computer Company
29  */
30 
31 #ifndef	_SYS_CPUID_DRV_H
32 #define	_SYS_CPUID_DRV_H
33 
34 #include <sys/types.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * /dev names:
42  *	/dev/cpu/			- containing directory
43  *		self/			- describes current cpu
44  *			cpuid		- cpu identification
45  */
46 
47 #define	CPUID_DRIVER_NAME	"cpuid"
48 #define	CPUID_DRIVER_SELF_NODE	"self"
49 
50 #define	CPUID_DIR_NAME		"cpu"
51 #define	CPUID_SELF_DIR_NAME	"self"
52 #define	CPUID_NAME		"cpuid"
53 #define	CPUID_SELF_NAME		\
54 	CPUID_DIR_NAME "/" CPUID_SELF_DIR_NAME "/" CPUID_NAME
55 
56 /*
57  * This minor number corresponds to the cpu we're running on at
58  * the time we invoke its interfaces.
59  */
60 #define	CPUID_SELF_CPUID_MINOR	((minor_t)0x3fffful)
61 
62 /*
63  * ioctl numbers: not an exported interface
64  */
65 #define	CPUID_IOC		(('c'<<24)|('i'<<16)|('d'<<8))
66 
67 #define	CPUID_GET_HWCAP		(CPUID_IOC|0)
68 #define	CPUID_RDMSR		(CPUID_IOC|1)
69 
70 struct cpuid_get_hwcap {
71 	char *cgh_archname;
72 	uint_t cgh_hwcap[3];
73 };
74 
75 struct cpuid_rdmsr {
76 	uint64_t cr_msr_nr;
77 	uint64_t cr_msr_val;
78 };
79 
80 #if defined(_SYSCALL32_IMPL)
81 
82 #include <sys/types32.h>
83 
84 struct cpuid_get_hwcap32 {
85 	caddr32_t cgh_archname;
86 	uint32_t cgh_hwcap[3];
87 };
88 
89 #endif	/* _SYSCALL32_IMPL */
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 #endif	/* _SYS_CPUID_DRV_H */
96