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