xref: /illumos-gate/usr/src/uts/common/sys/processor.h (revision c3377ee9)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55cff7825Smh27603  * Common Development and Distribution License (the "License").
65cff7825Smh27603  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
227c478bd9Sstevel@tonic-gate  *	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
237c478bd9Sstevel@tonic-gate  *	  All Rights Reserved
247c478bd9Sstevel@tonic-gate  *
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
28ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
29ba3594baSGarrett D'Amore  *
300b70c467Sakolb  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
317c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
327c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate 
34*c3377ee9SJohn Levon /*
35*c3377ee9SJohn Levon  * Copyright 2019 Joyent, Inc.
36*c3377ee9SJohn Levon  */
37*c3377ee9SJohn Levon 
387c478bd9Sstevel@tonic-gate #ifndef _SYS_PROCESSOR_H
397c478bd9Sstevel@tonic-gate #define	_SYS_PROCESSOR_H
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #include <sys/types.h>
427c478bd9Sstevel@tonic-gate #include <sys/procset.h>
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
457c478bd9Sstevel@tonic-gate extern "C" {
467c478bd9Sstevel@tonic-gate #endif
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * Definitions for p_online, processor_info & lgrp system calls.
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * Type for an lgrpid
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate typedef uint16_t lgrpid_t;
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * Type for processor name (CPU number).
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate typedef	int	processorid_t;
617c478bd9Sstevel@tonic-gate typedef int	chipid_t;
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /*
647c478bd9Sstevel@tonic-gate  * Flags and return values for p_online(2), and pi_state for processor_info(2).
657c478bd9Sstevel@tonic-gate  * These flags are *not* for in-kernel examination of CPU states.
667c478bd9Sstevel@tonic-gate  * See <sys/cpuvar.h> for appropriate informational functions.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate #define	P_OFFLINE	0x0001	/* processor is offline, as quiet as possible */
697c478bd9Sstevel@tonic-gate #define	P_ONLINE	0x0002	/* processor is online */
707c478bd9Sstevel@tonic-gate #define	P_STATUS	0x0003	/* value passed to p_online to request status */
717c478bd9Sstevel@tonic-gate #define	P_FAULTED	0x0004	/* processor is offline, in faulted state */
727c478bd9Sstevel@tonic-gate #define	P_POWEROFF	0x0005	/* processor is powered off */
737c478bd9Sstevel@tonic-gate #define	P_NOINTR	0x0006	/* processor is online, but no I/O interrupts */
747c478bd9Sstevel@tonic-gate #define	P_SPARE		0x0007	/* processor is offline, can be reactivated */
75*c3377ee9SJohn Levon #define	P_DISABLED	0x0008	/* processor is explicitly disabled for use */
767c478bd9Sstevel@tonic-gate #define	P_BAD		P_FAULTED	/* unused but defined by USL */
777c478bd9Sstevel@tonic-gate #define	P_FORCED	0x10000000	/* force processor offline */
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate /*
807c478bd9Sstevel@tonic-gate  * String names for processor states defined above.
817c478bd9Sstevel@tonic-gate  */
827c478bd9Sstevel@tonic-gate #define	PS_OFFLINE	"off-line"
837c478bd9Sstevel@tonic-gate #define	PS_ONLINE	"on-line"
847c478bd9Sstevel@tonic-gate #define	PS_FAULTED	"faulted"
857c478bd9Sstevel@tonic-gate #define	PS_POWEROFF	"powered-off"
867c478bd9Sstevel@tonic-gate #define	PS_NOINTR	"no-intr"
877c478bd9Sstevel@tonic-gate #define	PS_SPARE	"spare"
88*c3377ee9SJohn Levon #define	PS_DISABLED	"disabled"
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate /*
91cf74e62bSmh27603  * Structure filled in by processor_info(2). This structure
92cf74e62bSmh27603  * SHOULD NOT BE MODIFIED. Changes to the structure would
93cf74e62bSmh27603  * negate ABI compatibility.
947c478bd9Sstevel@tonic-gate  *
957c478bd9Sstevel@tonic-gate  * The string fields are guaranteed to contain a NULL.
967c478bd9Sstevel@tonic-gate  *
977c478bd9Sstevel@tonic-gate  * The pi_fputypes field contains a (possibly empty) comma-separated
987c478bd9Sstevel@tonic-gate  * list of floating point identifier strings.
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate #define	PI_TYPELEN	16	/* max size of CPU type string */
1017c478bd9Sstevel@tonic-gate #define	PI_FPUTYPE	32	/* max size of FPU types string */
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate typedef struct {
1047c478bd9Sstevel@tonic-gate 	int	pi_state;			/* processor state, see above */
1057c478bd9Sstevel@tonic-gate 	char	pi_processor_type[PI_TYPELEN];	/* ASCII CPU type */
1067c478bd9Sstevel@tonic-gate 	char	pi_fputypes[PI_FPUTYPE];	/* ASCII FPU types */
1077c478bd9Sstevel@tonic-gate 	int	pi_clock;			/* CPU clock freq in MHz */
1087c478bd9Sstevel@tonic-gate } processor_info_t;
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * Binding values for processor_bind(2)
1127c478bd9Sstevel@tonic-gate  */
1137c478bd9Sstevel@tonic-gate #define	PBIND_NONE	-1	/* LWP/thread is not bound */
1147c478bd9Sstevel@tonic-gate #define	PBIND_QUERY	-2	/* don't set, just return the binding */
1150b70c467Sakolb #define	PBIND_HARD	-3	/* prevents offlining CPU (default) */
1160b70c467Sakolb #define	PBIND_SOFT	-4	/* allows offlining CPU */
1170b70c467Sakolb #define	PBIND_QUERY_TYPE	-5	/* Return binding type */
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /*
120*c3377ee9SJohn Levon  * Sentinel values for p_online(2)
121*c3377ee9SJohn Levon  */
122*c3377ee9SJohn Levon #define	P_ALL_SIBLINGS (-1)
123*c3377ee9SJohn Levon 
124*c3377ee9SJohn Levon /*
1257c478bd9Sstevel@tonic-gate  * User-level system call interface prototypes
1267c478bd9Sstevel@tonic-gate  */
1277c478bd9Sstevel@tonic-gate #ifndef _KERNEL
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate extern int	p_online(processorid_t processorid, int flag);
1307c478bd9Sstevel@tonic-gate extern int	processor_info(processorid_t processorid,
1317c478bd9Sstevel@tonic-gate 		    processor_info_t *infop);
1327c478bd9Sstevel@tonic-gate extern int	processor_bind(idtype_t idtype, id_t id,
1337c478bd9Sstevel@tonic-gate 		    processorid_t processorid, processorid_t *obind);
1347c478bd9Sstevel@tonic-gate extern processorid_t getcpuid(void);
1357c478bd9Sstevel@tonic-gate extern lgrpid_t gethomelgroup(void);
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate #else   /* _KERNEL */
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate /*
1407c478bd9Sstevel@tonic-gate  * Internal interface prototypes
1417c478bd9Sstevel@tonic-gate  */
1427c478bd9Sstevel@tonic-gate extern int	p_online_internal(processorid_t, int, int *);
143a3114836SGerry Liu extern int	p_online_internal_locked(processorid_t, int, int *);
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate #endif
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate #endif	/* _SYS_PROCESSOR_H */
152