]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/cddl/compat/opensolaris/sys/cpuvar.h
This commit was generated by cvs2svn to compensate for changes in r175261,
[FreeBSD/FreeBSD.git] / sys / cddl / compat / opensolaris / sys / cpuvar.h
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
32 #ifdef _KERNEL
33 #define CPU_CACHE_COHERENCE_SIZE        64
34
35 /*
36  * The cpu_core structure consists of per-CPU state available in any context.
37  * On some architectures, this may mean that the page(s) containing the
38  * NCPU-sized array of cpu_core structures must be locked in the TLB -- it
39  * is up to the platform to assure that this is performed properly.  Note that
40  * the structure is sized to avoid false sharing.
41  */
42 #define CPUC_SIZE               (sizeof (uint16_t) + sizeof (uintptr_t) + \
43                                 sizeof (kmutex_t))
44 #define CPUC_PADSIZE            CPU_CACHE_COHERENCE_SIZE - CPUC_SIZE
45
46 typedef struct cpu_core {
47         uint16_t        cpuc_dtrace_flags;      /* DTrace flags */
48         uint8_t         cpuc_pad[CPUC_PADSIZE]; /* padding */
49         uintptr_t       cpuc_dtrace_illval;     /* DTrace illegal value */
50         kmutex_t        cpuc_pid_lock;          /* DTrace pid provider lock */
51 } cpu_core_t;
52
53 extern cpu_core_t cpu_core[];
54 #endif /* _KERNEL */
55
56 /*
57  * DTrace flags.
58  */
59 #define CPU_DTRACE_NOFAULT      0x0001  /* Don't fault */
60 #define CPU_DTRACE_DROP         0x0002  /* Drop this ECB */
61 #define CPU_DTRACE_BADADDR      0x0004  /* DTrace fault: bad address */
62 #define CPU_DTRACE_BADALIGN     0x0008  /* DTrace fault: bad alignment */
63 #define CPU_DTRACE_DIVZERO      0x0010  /* DTrace fault: divide by zero */
64 #define CPU_DTRACE_ILLOP        0x0020  /* DTrace fault: illegal operation */
65 #define CPU_DTRACE_NOSCRATCH    0x0040  /* DTrace fault: out of scratch */
66 #define CPU_DTRACE_KPRIV        0x0080  /* DTrace fault: bad kernel access */
67 #define CPU_DTRACE_UPRIV        0x0100  /* DTrace fault: bad user access */
68 #define CPU_DTRACE_TUPOFLOW     0x0200  /* DTrace fault: tuple stack overflow */
69 #if defined(__sparc)
70 #define CPU_DTRACE_FAKERESTORE  0x0400  /* pid provider hint to getreg */
71 #endif
72 #define CPU_DTRACE_ENTRY        0x0800  /* pid provider hint to ustack() */
73 #define CPU_DTRACE_BADSTACK     0x1000  /* DTrace fault: bad stack */
74
75 #define CPU_DTRACE_FAULT        (CPU_DTRACE_BADADDR | CPU_DTRACE_BADALIGN | \
76                                 CPU_DTRACE_DIVZERO | CPU_DTRACE_ILLOP | \
77                                 CPU_DTRACE_NOSCRATCH | CPU_DTRACE_KPRIV | \
78                                 CPU_DTRACE_UPRIV | CPU_DTRACE_TUPOFLOW | \
79                                 CPU_DTRACE_BADSTACK)
80 #define CPU_DTRACE_ERROR        (CPU_DTRACE_FAULT | CPU_DTRACE_DROP)
81
82 typedef enum {
83         CPU_INIT,
84         CPU_CONFIG,
85         CPU_UNCONFIG,
86         CPU_ON,
87         CPU_OFF,
88         CPU_CPUPART_IN,
89         CPU_CPUPART_OUT
90 } cpu_setup_t;
91
92 typedef int cpu_setup_func_t(cpu_setup_t, int, void *);
93
94
95 #endif /* _COMPAT_OPENSOLARIS_SYS_CPUVAR_H */