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