xref: /netbsd-src/sys/rump/include/machine/cpu.h (revision 6a493d6bc668897c91594964a732d38505b70cbb)
1 /*	$NetBSD: cpu.h,v 1.17 2013/10/30 08:42:45 mrg Exp $	*/
2 
3 /*
4  * Copyright (c) 2008-2011 Antti Kantee.  All Rights Reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #ifndef _SYS_RUMP_CPU_H_
29 #define _SYS_RUMP_CPU_H_
30 
31 #ifndef _LOCORE
32 
33 #include <sys/cpu_data.h>
34 #include <machine/pcb.h>
35 
36 struct cpu_info {
37 	struct cpu_data ci_data;
38 	cpuid_t ci_cpuid;
39 	struct lwp *ci_curlwp;
40 
41 	struct cpu_info *ci_next;
42 
43 /*
44  * XXX: horrible workaround for vax lock.h.
45  * I eventually want to nuke rump include/machine, so don't waste
46  * energy fighting with this.
47  */
48 #ifdef __vax__
49 	int ci_ipimsgs;
50 #define IPI_SEND_CNCHAR 0
51 #define IPI_DDB 0
52 #endif /* __vax__ */
53 
54 /*
55  * More stinky hacks, this time for powerpc.  Will go away eventually.
56  */
57 #ifdef __powerpc__
58 	struct cache_info {
59 		int dcache_size;
60 		int dcache_line_size;
61 		int icache_size;
62 		int icache_line_size;
63 	} ci_ci;
64 #endif /* __powerpc */
65 };
66 
67 /* more dirty rotten vax kludges */
68 #ifdef __vax__
69 static __inline void cpu_handle_ipi(void) {}
70 #endif /* __vax__ */
71 
72 #ifdef __powerpc__
73 void __syncicache(void *, size_t);
74 #endif
75 
76 struct lwp *rumpuser_curlwp(void);
77 #define curlwp rumpuser_curlwp()
78 
79 #define curcpu() (curlwp->l_cpu)
80 #define cpu_number() (cpu_index(curcpu))
81 
82 extern struct cpu_info *rumpcpu_info_list;
83 #define CPU_INFO_ITERATOR		int __unused
84 #define CPU_INFO_FOREACH(_cii_, _ci_)	_cii_ = 0, _ci_ = rumpcpu_info_list; \
85 					_ci_ != NULL; _ci_ = _ci_->ci_next
86 #define CPU_IS_PRIMARY(_ci_)		(_ci_->ci_index == 0)
87 
88 
89 #endif /* !_LOCORE */
90 
91 #endif /* _SYS_RUMP_CPU_H_ */
92