xref: /titanic_41/usr/src/uts/common/sys/processor.h (revision 7568150a58e78021968b6c22bc28e9787b33496a)
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 2008 Sun Microsystems, Inc.  All rights reserved.
29  * Use is subject to license terms.
30  */
31 
32 #ifndef _SYS_PROCESSOR_H
33 #define	_SYS_PROCESSOR_H
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #include <sys/types.h>
38 #include <sys/procset.h>
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * Definitions for p_online, processor_info & lgrp system calls.
46  */
47 
48 /*
49  * Type for an lgrpid
50  */
51 typedef uint16_t lgrpid_t;
52 
53 /*
54  * Type for processor name (CPU number).
55  */
56 typedef	int	processorid_t;
57 typedef int	chipid_t;
58 
59 /*
60  * Flags and return values for p_online(2), and pi_state for processor_info(2).
61  * These flags are *not* for in-kernel examination of CPU states.
62  * See <sys/cpuvar.h> for appropriate informational functions.
63  */
64 #define	P_OFFLINE	0x0001	/* processor is offline, as quiet as possible */
65 #define	P_ONLINE	0x0002	/* processor is online */
66 #define	P_STATUS	0x0003	/* value passed to p_online to request status */
67 #define	P_FAULTED	0x0004	/* processor is offline, in faulted state */
68 #define	P_POWEROFF	0x0005	/* processor is powered off */
69 #define	P_NOINTR	0x0006	/* processor is online, but no I/O interrupts */
70 #define	P_SPARE		0x0007	/* processor is offline, can be reactivated */
71 #define	P_BAD		P_FAULTED	/* unused but defined by USL */
72 #define	P_FORCED 	0x10000000	/* force processor offline */
73 
74 /*
75  * String names for processor states defined above.
76  */
77 #define	PS_OFFLINE	"off-line"
78 #define	PS_ONLINE	"on-line"
79 #define	PS_FAULTED	"faulted"
80 #define	PS_POWEROFF	"powered-off"
81 #define	PS_NOINTR	"no-intr"
82 #define	PS_SPARE	"spare"
83 
84 /*
85  * Structure filled in by processor_info(2). This structure
86  * SHOULD NOT BE MODIFIED. Changes to the structure would
87  * negate ABI compatibility.
88  *
89  * The string fields are guaranteed to contain a NULL.
90  *
91  * The pi_fputypes field contains a (possibly empty) comma-separated
92  * list of floating point identifier strings.
93  */
94 #define	PI_TYPELEN	16	/* max size of CPU type string */
95 #define	PI_FPUTYPE	32	/* max size of FPU types string */
96 
97 typedef struct {
98 	int	pi_state;  			/* processor state, see above */
99 	char	pi_processor_type[PI_TYPELEN];	/* ASCII CPU type */
100 	char	pi_fputypes[PI_FPUTYPE];	/* ASCII FPU types */
101 	int	pi_clock;			/* CPU clock freq in MHz */
102 } processor_info_t;
103 
104 /*
105  * Binding values for processor_bind(2)
106  */
107 #define	PBIND_NONE	-1	/* LWP/thread is not bound */
108 #define	PBIND_QUERY	-2	/* don't set, just return the binding */
109 #define	PBIND_HARD	-3	/* prevents offlining CPU (default) */
110 #define	PBIND_SOFT	-4	/* allows offlining CPU */
111 #define	PBIND_QUERY_TYPE	-5	/* Return binding type */
112 
113 /*
114  * User-level system call interface prototypes
115  */
116 #ifndef _KERNEL
117 #ifdef __STDC__
118 
119 extern int	p_online(processorid_t processorid, int flag);
120 extern int	processor_info(processorid_t processorid,
121 		    processor_info_t *infop);
122 extern int	processor_bind(idtype_t idtype, id_t id,
123 		    processorid_t processorid, processorid_t *obind);
124 extern processorid_t getcpuid(void);
125 extern lgrpid_t gethomelgroup(void);
126 
127 #else
128 
129 extern int	p_online();
130 extern int	processor_info();
131 extern int	processor_bind();
132 extern processorid_t getcpuid();
133 extern lgrpid_t gethomelgroup();
134 
135 #endif /* __STDC__ */
136 
137 #else   /* _KERNEL */
138 
139 /*
140  * Internal interface prototypes
141  */
142 extern int	p_online_internal(processorid_t, int, int *);
143 
144 #endif /* !_KERNEL */
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif	/* _SYS_PROCESSOR_H */
151