1 /* $NetBSD: cpu.h,v 1.20 2014/03/15 15:15:26 pooka 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 48 struct cpu_info *ci_next; 49 50 #ifdef __alpha__ 51 uint64_t ci_pcc_freq; 52 #endif 53 54 #ifdef __vax__ 55 int ci_ipimsgs; 56 #define IPI_SEND_CNCHAR 0 57 #define IPI_DDB 0 58 #endif /* __vax__ */ 59 60 #ifdef __powerpc__ 61 struct cache_info { 62 int dcache_size; 63 int dcache_line_size; 64 int icache_size; 65 int icache_line_size; 66 } ci_ci; 67 #endif /* __powerpc */ 68 }; 69 70 #ifdef __vax__ 71 static __inline void cpu_handle_ipi(void) {} 72 #endif /* __vax__ */ 73 74 #ifdef __powerpc__ 75 void __syncicache(void *, size_t); 76 #endif /* __powerpc__ */ 77 78 #define curlwp rump_curlwp_fast() 79 80 #define curcpu() (curlwp->l_cpu) 81 #define cpu_number() (cpu_index(curcpu)) 82 83 extern struct cpu_info *rumpcpu_info_list; 84 #define CPU_INFO_ITERATOR int __unused 85 #define CPU_INFO_FOREACH(_cii_, _ci_) _cii_ = 0, _ci_ = rumpcpu_info_list; \ 86 _ci_ != NULL; _ci_ = _ci_->ci_next 87 #define CPU_IS_PRIMARY(_ci_) (_ci_->ci_index == 0) 88 89 90 #endif /* !_LOCORE */ 91 92 #endif /* _SYS_RUMP_CPU_H_ */ 93