cpu.h revision 1.18
1/* $NetBSD: cpu.h,v 1.18 2014/01/22 23:38:21 christos 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 36struct 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#ifdef __alpha__ 44 uint64_t ci_pcc_freq; 45#endif 46 47/* 48 * XXX: horrible workaround for vax lock.h. 49 * I eventually want to nuke rump include/machine, so don't waste 50 * energy fighting with this. 51 */ 52#ifdef __vax__ 53 int ci_ipimsgs; 54#define IPI_SEND_CNCHAR 0 55#define IPI_DDB 0 56#endif /* __vax__ */ 57 58/* 59 * More stinky hacks, this time for powerpc. Will go away eventually. 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/* more dirty rotten vax kludges */ 72#ifdef __vax__ 73static __inline void cpu_handle_ipi(void) {} 74#endif /* __vax__ */ 75 76#ifdef __powerpc__ 77void __syncicache(void *, size_t); 78#endif 79 80struct lwp *rumpuser_curlwp(void); 81#define curlwp rumpuser_curlwp() 82 83#define curcpu() (curlwp->l_cpu) 84#define cpu_number() (cpu_index(curcpu)) 85 86extern struct cpu_info *rumpcpu_info_list; 87#define CPU_INFO_ITERATOR int __unused 88#define CPU_INFO_FOREACH(_cii_, _ci_) _cii_ = 0, _ci_ = rumpcpu_info_list; \ 89 _ci_ != NULL; _ci_ = _ci_->ci_next 90#define CPU_IS_PRIMARY(_ci_) (_ci_->ci_index == 0) 91 92 93#endif /* !_LOCORE */ 94 95#endif /* _SYS_RUMP_CPU_H_ */ 96