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 /* 28*ba3594baSGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 29*ba3594baSGarrett 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 347c478bd9Sstevel@tonic-gate #ifndef _SYS_PROCESSOR_H 357c478bd9Sstevel@tonic-gate #define _SYS_PROCESSOR_H 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <sys/types.h> 387c478bd9Sstevel@tonic-gate #include <sys/procset.h> 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 417c478bd9Sstevel@tonic-gate extern "C" { 427c478bd9Sstevel@tonic-gate #endif 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * Definitions for p_online, processor_info & lgrp system calls. 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * Type for an lgrpid 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate typedef uint16_t lgrpid_t; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * Type for processor name (CPU number). 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate typedef int processorid_t; 577c478bd9Sstevel@tonic-gate typedef int chipid_t; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* 607c478bd9Sstevel@tonic-gate * Flags and return values for p_online(2), and pi_state for processor_info(2). 617c478bd9Sstevel@tonic-gate * These flags are *not* for in-kernel examination of CPU states. 627c478bd9Sstevel@tonic-gate * See <sys/cpuvar.h> for appropriate informational functions. 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate #define P_OFFLINE 0x0001 /* processor is offline, as quiet as possible */ 657c478bd9Sstevel@tonic-gate #define P_ONLINE 0x0002 /* processor is online */ 667c478bd9Sstevel@tonic-gate #define P_STATUS 0x0003 /* value passed to p_online to request status */ 677c478bd9Sstevel@tonic-gate #define P_FAULTED 0x0004 /* processor is offline, in faulted state */ 687c478bd9Sstevel@tonic-gate #define P_POWEROFF 0x0005 /* processor is powered off */ 697c478bd9Sstevel@tonic-gate #define P_NOINTR 0x0006 /* processor is online, but no I/O interrupts */ 707c478bd9Sstevel@tonic-gate #define P_SPARE 0x0007 /* processor is offline, can be reactivated */ 717c478bd9Sstevel@tonic-gate #define P_BAD P_FAULTED /* unused but defined by USL */ 727c478bd9Sstevel@tonic-gate #define P_FORCED 0x10000000 /* force processor offline */ 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * String names for processor states defined above. 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate #define PS_OFFLINE "off-line" 787c478bd9Sstevel@tonic-gate #define PS_ONLINE "on-line" 797c478bd9Sstevel@tonic-gate #define PS_FAULTED "faulted" 807c478bd9Sstevel@tonic-gate #define PS_POWEROFF "powered-off" 817c478bd9Sstevel@tonic-gate #define PS_NOINTR "no-intr" 827c478bd9Sstevel@tonic-gate #define PS_SPARE "spare" 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 85cf74e62bSmh27603 * Structure filled in by processor_info(2). This structure 86cf74e62bSmh27603 * SHOULD NOT BE MODIFIED. Changes to the structure would 87cf74e62bSmh27603 * negate ABI compatibility. 887c478bd9Sstevel@tonic-gate * 897c478bd9Sstevel@tonic-gate * The string fields are guaranteed to contain a NULL. 907c478bd9Sstevel@tonic-gate * 917c478bd9Sstevel@tonic-gate * The pi_fputypes field contains a (possibly empty) comma-separated 927c478bd9Sstevel@tonic-gate * list of floating point identifier strings. 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate #define PI_TYPELEN 16 /* max size of CPU type string */ 957c478bd9Sstevel@tonic-gate #define PI_FPUTYPE 32 /* max size of FPU types string */ 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate typedef struct { 987c478bd9Sstevel@tonic-gate int pi_state; /* processor state, see above */ 997c478bd9Sstevel@tonic-gate char pi_processor_type[PI_TYPELEN]; /* ASCII CPU type */ 1007c478bd9Sstevel@tonic-gate char pi_fputypes[PI_FPUTYPE]; /* ASCII FPU types */ 1017c478bd9Sstevel@tonic-gate int pi_clock; /* CPU clock freq in MHz */ 1027c478bd9Sstevel@tonic-gate } processor_info_t; 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* 1057c478bd9Sstevel@tonic-gate * Binding values for processor_bind(2) 1067c478bd9Sstevel@tonic-gate */ 1077c478bd9Sstevel@tonic-gate #define PBIND_NONE -1 /* LWP/thread is not bound */ 1087c478bd9Sstevel@tonic-gate #define PBIND_QUERY -2 /* don't set, just return the binding */ 1090b70c467Sakolb #define PBIND_HARD -3 /* prevents offlining CPU (default) */ 1100b70c467Sakolb #define PBIND_SOFT -4 /* allows offlining CPU */ 1110b70c467Sakolb #define PBIND_QUERY_TYPE -5 /* Return binding type */ 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate /* 1147c478bd9Sstevel@tonic-gate * User-level system call interface prototypes 1157c478bd9Sstevel@tonic-gate */ 1167c478bd9Sstevel@tonic-gate #ifndef _KERNEL 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate extern int p_online(processorid_t processorid, int flag); 1197c478bd9Sstevel@tonic-gate extern int processor_info(processorid_t processorid, 1207c478bd9Sstevel@tonic-gate processor_info_t *infop); 1217c478bd9Sstevel@tonic-gate extern int processor_bind(idtype_t idtype, id_t id, 1227c478bd9Sstevel@tonic-gate processorid_t processorid, processorid_t *obind); 1237c478bd9Sstevel@tonic-gate extern processorid_t getcpuid(void); 1247c478bd9Sstevel@tonic-gate extern lgrpid_t gethomelgroup(void); 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate /* 1297c478bd9Sstevel@tonic-gate * Internal interface prototypes 1307c478bd9Sstevel@tonic-gate */ 1317c478bd9Sstevel@tonic-gate extern int p_online_internal(processorid_t, int, int *); 132a3114836SGerry Liu extern int p_online_internal_locked(processorid_t, int, int *); 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */ 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1377c478bd9Sstevel@tonic-gate } 1387c478bd9Sstevel@tonic-gate #endif 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate #endif /* _SYS_PROCESSOR_H */ 141