1168404Spjd/* 2168404Spjd * CDDL HEADER START 3168404Spjd * 4168404Spjd * The contents of this file are subject to the terms of the 5185029Spjd * Common Development and Distribution License (the "License"). 6185029Spjd * You may not use this file except in compliance with the License. 7168404Spjd * 8168404Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9168404Spjd * or http://www.opensolaris.org/os/licensing. 10168404Spjd * See the License for the specific language governing permissions 11168404Spjd * and limitations under the License. 12168404Spjd * 13168404Spjd * When distributing Covered Code, include this CDDL HEADER in each 14168404Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15168404Spjd * If applicable, add the following below this CDDL HEADER, with the 16168404Spjd * fields enclosed by brackets "[]" replaced with your own identifying 17168404Spjd * information: Portions Copyright [yyyy] [name of copyright owner] 18168404Spjd * 19168404Spjd * CDDL HEADER END 20168404Spjd */ 21168404Spjd/* 22168404Spjd * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T 23168404Spjd * All Rights Reserved 24168404Spjd * 25168404Spjd */ 26168404Spjd 27168404Spjd/* 28270382Sdelphij * Copyright 2014 Garrett D'Amore <garrett@damore.org> 29270382Sdelphij * 30185029Spjd * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 31168404Spjd * Use is subject to license terms. 32168404Spjd */ 33168404Spjd 34168404Spjd#ifndef _SYS_PROCESSOR_H 35168404Spjd#define _SYS_PROCESSOR_H 36168404Spjd 37168404Spjd#include <sys/types.h> 38168404Spjd#include <sys/procset.h> 39168404Spjd 40168404Spjd#ifdef __cplusplus 41168404Spjdextern "C" { 42168404Spjd#endif 43168404Spjd 44168404Spjd/* 45168404Spjd * Definitions for p_online, processor_info & lgrp system calls. 46168404Spjd */ 47168404Spjd 48168404Spjd/* 49168404Spjd * Type for an lgrpid 50168404Spjd */ 51168404Spjdtypedef uint16_t lgrpid_t; 52168404Spjd 53168404Spjd/* 54168404Spjd * Type for processor name (CPU number). 55168404Spjd */ 56168404Spjdtypedef int processorid_t; 57168404Spjdtypedef int chipid_t; 58168404Spjd 59168404Spjd/* 60168404Spjd * Flags and return values for p_online(2), and pi_state for processor_info(2). 61168404Spjd * These flags are *not* for in-kernel examination of CPU states. 62168404Spjd * See <sys/cpuvar.h> for appropriate informational functions. 63168404Spjd */ 64168404Spjd#define P_OFFLINE 0x0001 /* processor is offline, as quiet as possible */ 65168404Spjd#define P_ONLINE 0x0002 /* processor is online */ 66168404Spjd#define P_STATUS 0x0003 /* value passed to p_online to request status */ 67168404Spjd#define P_FAULTED 0x0004 /* processor is offline, in faulted state */ 68168404Spjd#define P_POWEROFF 0x0005 /* processor is powered off */ 69168404Spjd#define P_NOINTR 0x0006 /* processor is online, but no I/O interrupts */ 70168404Spjd#define P_SPARE 0x0007 /* processor is offline, can be reactivated */ 71168404Spjd#define P_BAD P_FAULTED /* unused but defined by USL */ 72168404Spjd#define P_FORCED 0x10000000 /* force processor offline */ 73168404Spjd 74168404Spjd/* 75168404Spjd * String names for processor states defined above. 76168404Spjd */ 77168404Spjd#define PS_OFFLINE "off-line" 78168404Spjd#define PS_ONLINE "on-line" 79168404Spjd#define PS_FAULTED "faulted" 80168404Spjd#define PS_POWEROFF "powered-off" 81168404Spjd#define PS_NOINTR "no-intr" 82168404Spjd#define PS_SPARE "spare" 83168404Spjd 84168404Spjd/* 85185029Spjd * Structure filled in by processor_info(2). This structure 86185029Spjd * SHOULD NOT BE MODIFIED. Changes to the structure would 87185029Spjd * negate ABI compatibility. 88168404Spjd * 89168404Spjd * The string fields are guaranteed to contain a NULL. 90168404Spjd * 91168404Spjd * The pi_fputypes field contains a (possibly empty) comma-separated 92168404Spjd * list of floating point identifier strings. 93168404Spjd */ 94168404Spjd#define PI_TYPELEN 16 /* max size of CPU type string */ 95168404Spjd#define PI_FPUTYPE 32 /* max size of FPU types string */ 96168404Spjd 97168404Spjdtypedef struct { 98168404Spjd int pi_state; /* processor state, see above */ 99168404Spjd char pi_processor_type[PI_TYPELEN]; /* ASCII CPU type */ 100168404Spjd char pi_fputypes[PI_FPUTYPE]; /* ASCII FPU types */ 101168404Spjd int pi_clock; /* CPU clock freq in MHz */ 102168404Spjd} processor_info_t; 103168404Spjd 104168404Spjd/* 105168404Spjd * Binding values for processor_bind(2) 106168404Spjd */ 107168404Spjd#define PBIND_NONE -1 /* LWP/thread is not bound */ 108168404Spjd#define PBIND_QUERY -2 /* don't set, just return the binding */ 109185029Spjd#define PBIND_HARD -3 /* prevents offlining CPU (default) */ 110185029Spjd#define PBIND_SOFT -4 /* allows offlining CPU */ 111185029Spjd#define PBIND_QUERY_TYPE -5 /* Return binding type */ 112168404Spjd 113168404Spjd/* 114168404Spjd * User-level system call interface prototypes 115168404Spjd */ 116168404Spjd#ifndef _KERNEL 117168404Spjd 118168404Spjdextern int p_online(processorid_t processorid, int flag); 119168404Spjdextern int processor_info(processorid_t processorid, 120168404Spjd processor_info_t *infop); 121168404Spjdextern int processor_bind(idtype_t idtype, id_t id, 122168404Spjd processorid_t processorid, processorid_t *obind); 123168404Spjdextern processorid_t getcpuid(void); 124168404Spjdextern lgrpid_t gethomelgroup(void); 125168404Spjd 126168404Spjd#else /* _KERNEL */ 127168404Spjd 128168404Spjd/* 129168404Spjd * Internal interface prototypes 130168404Spjd */ 131168404Spjdextern int p_online_internal(processorid_t, int, int *); 132219089Spjdextern int p_online_internal_locked(processorid_t, int, int *); 133168404Spjd 134168404Spjd#endif /* !_KERNEL */ 135168404Spjd 136168404Spjd#ifdef __cplusplus 137168404Spjd} 138168404Spjd#endif 139168404Spjd 140168404Spjd#endif /* _SYS_PROCESSOR_H */ 141