cpuvar.h revision 282748
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 * $FreeBSD: stable/10/sys/cddl/compat/opensolaris/sys/cpuvar.h 282748 2015-05-11 07:54:39Z avg $ 22 */ 23 24/* 25 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28 29#ifndef _COMPAT_OPENSOLARIS_SYS_CPUVAR_H 30#define _COMPAT_OPENSOLARIS_SYS_CPUVAR_H 31 32#include <sys/mutex.h> 33#include <sys/cpuvar_defs.h> 34 35#ifdef _KERNEL 36 37struct cyc_cpu; 38 39typedef struct { 40 int cpuid; 41 uint32_t cpu_flags; 42 uint_t cpu_intr_actv; 43 uintptr_t cpu_dtrace_caller; /* DTrace: caller, if any */ 44 hrtime_t cpu_dtrace_chillmark; /* DTrace: chill mark time */ 45 hrtime_t cpu_dtrace_chilled; /* DTrace: total chill time */ 46} solaris_cpu_t; 47 48/* Some code may choose to redefine this if pcpu_t would be more useful. */ 49#define cpu_t solaris_cpu_t 50#define cpu_id cpuid 51 52extern solaris_cpu_t solaris_cpu[]; 53 54#define CPU_CACHE_COHERENCE_SIZE 64 55 56/* 57 * The cpu_core structure consists of per-CPU state available in any context. 58 * On some architectures, this may mean that the page(s) containing the 59 * NCPU-sized array of cpu_core structures must be locked in the TLB -- it 60 * is up to the platform to assure that this is performed properly. Note that 61 * the structure is sized to avoid false sharing. 62 */ 63#define CPUC_SIZE (sizeof (uint16_t) + sizeof (uintptr_t) + \ 64 sizeof (kmutex_t)) 65#define CPUC_SIZE1 roundup(CPUC_SIZE, CPU_CACHE_COHERENCE_SIZE) 66#define CPUC_PADSIZE CPUC_SIZE1 - CPUC_SIZE 67 68typedef struct cpu_core { 69 uint16_t cpuc_dtrace_flags; /* DTrace flags */ 70 uint8_t cpuc_pad[CPUC_PADSIZE]; /* padding */ 71 uintptr_t cpuc_dtrace_illval; /* DTrace illegal value */ 72 kmutex_t cpuc_pid_lock; /* DTrace pid provider lock */ 73} cpu_core_t; 74 75extern cpu_core_t cpu_core[]; 76 77extern kmutex_t cpu_lock; 78#endif /* _KERNEL */ 79 80/* 81 * Flags in the CPU structure. 82 * 83 * These are protected by cpu_lock (except during creation). 84 * 85 * Offlined-CPUs have three stages of being offline: 86 * 87 * CPU_ENABLE indicates that the CPU is participating in I/O interrupts 88 * that can be directed at a number of different CPUs. If CPU_ENABLE 89 * is off, the CPU will not be given interrupts that can be sent elsewhere, 90 * but will still get interrupts from devices associated with that CPU only, 91 * and from other CPUs. 92 * 93 * CPU_OFFLINE indicates that the dispatcher should not allow any threads 94 * other than interrupt threads to run on that CPU. A CPU will not have 95 * CPU_OFFLINE set if there are any bound threads (besides interrupts). 96 * 97 * CPU_QUIESCED is set if p_offline was able to completely turn idle the 98 * CPU and it will not have to run interrupt threads. In this case it'll 99 * stay in the idle loop until CPU_QUIESCED is turned off. 100 * 101 * CPU_FROZEN is used only by CPR to mark CPUs that have been successfully 102 * suspended (in the suspend path), or have yet to be resumed (in the resume 103 * case). 104 * 105 * On some platforms CPUs can be individually powered off. 106 * The following flags are set for powered off CPUs: CPU_QUIESCED, 107 * CPU_OFFLINE, and CPU_POWEROFF. The following flags are cleared: 108 * CPU_RUNNING, CPU_READY, CPU_EXISTS, and CPU_ENABLE. 109 */ 110#define CPU_RUNNING 0x001 /* CPU running */ 111#define CPU_READY 0x002 /* CPU ready for cross-calls */ 112#define CPU_QUIESCED 0x004 /* CPU will stay in idle */ 113#define CPU_EXISTS 0x008 /* CPU is configured */ 114#define CPU_ENABLE 0x010 /* CPU enabled for interrupts */ 115#define CPU_OFFLINE 0x020 /* CPU offline via p_online */ 116#define CPU_POWEROFF 0x040 /* CPU is powered off */ 117#define CPU_FROZEN 0x080 /* CPU is frozen via CPR suspend */ 118#define CPU_SPARE 0x100 /* CPU offline available for use */ 119#define CPU_FAULTED 0x200 /* CPU offline diagnosed faulty */ 120 121typedef enum { 122 CPU_INIT, 123 CPU_CONFIG, 124 CPU_UNCONFIG, 125 CPU_ON, 126 CPU_OFF, 127 CPU_CPUPART_IN, 128 CPU_CPUPART_OUT 129} cpu_setup_t; 130 131typedef int cpu_setup_func_t(cpu_setup_t, int, void *); 132 133 134#endif /* _COMPAT_OPENSOLARIS_SYS_CPUVAR_H */ 135