FreeBSD/Linux Kernel Cross Reference
sys/sys/cpu.h
1 /* $NetBSD: cpu.h,v 1.23.4.3 2009/02/02 03:19:32 snj Exp $ */
2
3 /*-
4 * Copyright (c) 2007 YAMAMOTO Takashi,
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #ifndef _SYS_CPU_H_
30 #define _SYS_CPU_H_
31
32 #ifndef _LOCORE
33
34 #include <machine/cpu.h>
35
36 #include <sys/lwp.h>
37
38 struct cpu_info;
39
40 #ifndef cpu_idle
41 void cpu_idle(void);
42 #endif
43
44 /*
45 * cpu_need_resched() must always be called with the target CPU
46 * locked (via spc_lock() or another route), unless called locally.
47 * If called locally, the caller need only be at IPL_SCHED.
48 */
49 #ifndef cpu_need_resched
50 void cpu_need_resched(struct cpu_info *, int);
51 #endif
52
53 #ifndef cpu_did_resched
54 #define cpu_did_resched(l) /* nothing */
55 #endif
56
57 #ifndef CPU_INFO_ITERATOR
58 #define CPU_INFO_ITERATOR int
59 #define CPU_INFO_FOREACH(cii, ci) \
60 (void)cii, ci = curcpu(); ci != NULL; ci = NULL
61 #endif
62
63 #ifndef CPU_IS_PRIMARY
64 #define CPU_IS_PRIMARY(ci) ((void)ci, 1)
65 #endif
66
67 #ifdef __HAVE_MD_CPU_OFFLINE
68 void cpu_offline_md(void);
69 #endif
70
71 lwp_t *cpu_switchto(lwp_t *, lwp_t *, bool);
72 struct cpu_info *cpu_lookup(u_int);
73 int cpu_setstate(struct cpu_info *, bool);
74 bool cpu_intr_p(void);
75 bool cpu_kpreempt_enter(uintptr_t, int);
76 void cpu_kpreempt_exit(uintptr_t);
77 bool cpu_kpreempt_disabled(void);
78
79 CIRCLEQ_HEAD(cpuqueue, cpu_info);
80
81 extern kmutex_t cpu_lock;
82 extern u_int maxcpus;
83 extern struct cpuqueue cpu_queue;
84
85 static inline u_int
86 cpu_index(struct cpu_info *ci)
87 {
88 return ci->ci_index;
89 }
90
91 #endif /* !_LOCORE */
92
93 /* flags for cpu_need_resched */
94 #define RESCHED_LAZY 0x01
95 #define RESCHED_IMMED 0x02
96 #define RESCHED_KPREEMPT 0x04
97
98 #endif /* !_SYS_CPU_H_ */
Cache object: ad09ed42d4abcb44c3ebcfd3b0e9f2ef
|