xref: /illumos-gate/usr/src/uts/common/sys/processor.h (revision 5328fc53d11d7151861fa272e4fb0248b8f0e145)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  *	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
23  *	  All Rights Reserved
24  *
25  */
26 
27 /*
28  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
29  *
30  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
31  * Use is subject to license terms.
32  */
33 
34 /*
35  * Copyright 2019 Joyent, Inc.
36  */
37 
38 #ifndef _SYS_PROCESSOR_H
39 #define	_SYS_PROCESSOR_H
40 
41 #include <sys/types.h>
42 #include <sys/procset.h>
43 
44 #ifdef	__cplusplus
45 extern "C" {
46 #endif
47 
48 /*
49  * Definitions for p_online, processor_info & lgrp system calls.
50  */
51 
52 /*
53  * Type for an lgrpid
54  */
55 typedef uint16_t lgrpid_t;
56 
57 /*
58  * Type for processor name (CPU number).
59  */
60 typedef	int	processorid_t;
61 typedef int	chipid_t;
62 
63 /*
64  * Flags and return values for p_online(2), and pi_state for processor_info(2).
65  * These flags are *not* for in-kernel examination of CPU states.
66  * See <sys/cpuvar.h> for appropriate informational functions.
67  */
68 #define	P_OFFLINE	0x0001	/* processor is offline, as quiet as possible */
69 #define	P_ONLINE	0x0002	/* processor is online */
70 #define	P_STATUS	0x0003	/* value passed to p_online to request status */
71 #define	P_FAULTED	0x0004	/* processor is offline, in faulted state */
72 #define	P_POWEROFF	0x0005	/* processor is powered off */
73 #define	P_NOINTR	0x0006	/* processor is online, but no I/O interrupts */
74 #define	P_SPARE		0x0007	/* processor is offline, can be reactivated */
75 #define	P_DISABLED	0x0008	/* processor is explicitly disabled for use */
76 #define	P_BAD		P_FAULTED	/* unused but defined by USL */
77 #define	P_FORCED	0x10000000	/* force processor offline */
78 
79 /*
80  * String names for processor states defined above.
81  */
82 #define	PS_OFFLINE	"off-line"
83 #define	PS_ONLINE	"on-line"
84 #define	PS_FAULTED	"faulted"
85 #define	PS_POWEROFF	"powered-off"
86 #define	PS_NOINTR	"no-intr"
87 #define	PS_SPARE	"spare"
88 #define	PS_DISABLED	"disabled"
89 
90 /*
91  * Structure filled in by processor_info(2). This structure
92  * SHOULD NOT BE MODIFIED. Changes to the structure would
93  * negate ABI compatibility.
94  *
95  * The string fields are guaranteed to contain a NULL.
96  *
97  * The pi_fputypes field contains a (possibly empty) comma-separated
98  * list of floating point identifier strings.
99  */
100 #define	PI_TYPELEN	16	/* max size of CPU type string */
101 #define	PI_FPUTYPE	32	/* max size of FPU types string */
102 
103 typedef struct {
104 	int	pi_state;			/* processor state, see above */
105 	char	pi_processor_type[PI_TYPELEN];	/* ASCII CPU type */
106 	char	pi_fputypes[PI_FPUTYPE];	/* ASCII FPU types */
107 	int	pi_clock;			/* CPU clock freq in MHz */
108 } processor_info_t;
109 
110 /*
111  * Binding values for processor_bind(2)
112  */
113 #define	PBIND_NONE	-1	/* LWP/thread is not bound */
114 #define	PBIND_QUERY	-2	/* don't set, just return the binding */
115 #define	PBIND_HARD	-3	/* prevents offlining CPU (default) */
116 #define	PBIND_SOFT	-4	/* allows offlining CPU */
117 #define	PBIND_QUERY_TYPE	-5	/* Return binding type */
118 
119 /*
120  * Sentinel values for p_online(2)
121  */
122 #define	P_ALL_SIBLINGS (-1)
123 
124 /*
125  * User-level system call interface prototypes
126  */
127 #ifndef _KERNEL
128 
129 extern int	p_online(processorid_t processorid, int flag);
130 extern int	processor_info(processorid_t processorid,
131 		    processor_info_t *infop);
132 extern int	processor_bind(idtype_t idtype, id_t id,
133 		    processorid_t processorid, processorid_t *obind);
134 extern processorid_t getcpuid(void);
135 extern lgrpid_t gethomelgroup(void);
136 
137 #else   /* _KERNEL */
138 
139 /*
140  * Internal interface prototypes
141  */
142 extern int	p_online_internal(processorid_t, int, int *);
143 extern int	p_online_internal_locked(processorid_t, int, int *);
144 
145 #endif /* !_KERNEL */
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif	/* _SYS_PROCESSOR_H */
152