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>
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 */
48 /* Some code may choose to redefine this if pcpu_t would be more useful. */
49 #define cpu_t solaris_cpu_t
52 extern solaris_cpu_t solaris_cpu[];
54 #define CPU_CACHE_COHERENCE_SIZE 64
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.
63 #define CPUC_SIZE (sizeof (uint16_t) + sizeof (uintptr_t) + \
65 #define CPUC_SIZE1 roundup(CPUC_SIZE, CPU_CACHE_COHERENCE_SIZE)
66 #define CPUC_PADSIZE CPUC_SIZE1 - CPUC_SIZE
68 typedef 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 */
75 extern cpu_core_t cpu_core[];
77 extern kmutex_t cpu_lock;
81 * Flags in the CPU structure.
83 * These are protected by cpu_lock (except during creation).
85 * Offlined-CPUs have three stages of being offline:
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.
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).
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.
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
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.
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 */
131 typedef int cpu_setup_func_t(cpu_setup_t, int, void *);
134 #endif /* _COMPAT_OPENSOLARIS_SYS_CPUVAR_H */