xref: /netbsd-src/sys/rump/include/machine/cpu.h (revision fd49f423fdb771e1d9f1b41d214a140bec891d54)
1 /*	$NetBSD: cpu.h,v 1.24 2019/12/04 03:04:52 riastradh 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 /*
29  * CPU defitions for a generic arch.  Unfortunately there are some
30  * MD #ifdefs here.  They are required because of MD inlines and macros.
31  */
32 
33 #ifndef _SYS_RUMP_CPU_H_
34 #define _SYS_RUMP_CPU_H_
35 
36 #ifndef _LOCORE
37 
38 #include <sys/cpu_data.h>
39 #include <machine/pcb.h>
40 
41 #include "rump_curlwp.h"
42 
43 struct cpu_info {
44 	struct cpu_data ci_data;
45 	cpuid_t ci_cpuid;
46 	struct lwp *ci_curlwp;
47 	struct lwp *ci_onproc;
48 
49 	struct cpu_info *ci_next;
50 
51 #ifdef __alpha__
52 	uint64_t ci_pcc_freq;
53 #endif
54 
55 #ifdef __vax__
56 	int ci_ipimsgs;
57 #define IPI_SEND_CNCHAR 0
58 #define IPI_DDB 0
59 #endif /* __vax__ */
60 
61 #ifdef __powerpc__
62 	struct cache_info {
63 		int dcache_size;
64 		int dcache_line_size;
65 		int icache_size;
66 		int icache_line_size;
67 	} ci_ci;
68 #endif /* __powerpc */
69 };
70 
71 #ifdef __vax__
cpu_handle_ipi(void)72 static __inline void cpu_handle_ipi(void) {}
73 #endif /* __vax__ */
74 
75 #ifdef __powerpc__
76 void __syncicache(void *, size_t);
77 #endif /* __powerpc__ */
78 
79 #define curlwp rump_curlwp_fast()
80 
81 #define curcpu() (curlwp->l_cpu)
82 #define cpu_number() (cpu_index(curcpu()))
83 
84 extern struct cpu_info *rumpcpu_info_list;
85 #define CPU_INFO_ITERATOR		int __unused
86 #define CPU_INFO_FOREACH(_cii_, _ci_)	_cii_ = 0, _ci_ = rumpcpu_info_list; \
87 					_ci_ != NULL; _ci_ = _ci_->ci_next
88 #define CPU_IS_PRIMARY(_ci_)		(_ci_->ci_index == 0)
89 
90 #define CLKF_USERMODE(framep)	0
91 #define CLKF_PC(framep)		0
92 #define CLKF_INTR(framep)	0
93 
94 #endif /* !_LOCORE */
95 
96 #endif /* _SYS_RUMP_CPU_H_ */
97