cpu.h revision 1.20
11.20Spooka/*	$NetBSD: cpu.h,v 1.20 2014/03/15 15:15:26 pooka Exp $	*/
21.1Spooka
31.1Spooka/*
41.15Spooka * Copyright (c) 2008-2011 Antti Kantee.  All Rights Reserved.
51.1Spooka *
61.1Spooka * Redistribution and use in source and binary forms, with or without
71.1Spooka * modification, are permitted provided that the following conditions
81.1Spooka * are met:
91.1Spooka * 1. Redistributions of source code must retain the above copyright
101.1Spooka *    notice, this list of conditions and the following disclaimer.
111.1Spooka * 2. Redistributions in binary form must reproduce the above copyright
121.1Spooka *    notice, this list of conditions and the following disclaimer in the
131.1Spooka *    documentation and/or other materials provided with the distribution.
141.1Spooka *
151.1Spooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
161.1Spooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
171.1Spooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
181.1Spooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
191.1Spooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
201.1Spooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
211.1Spooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
221.1Spooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
231.1Spooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
241.1Spooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
251.1Spooka * SUCH DAMAGE.
261.1Spooka */
271.1Spooka
281.19Spooka/*
291.19Spooka * CPU defitions for a generic arch.  Unfortunately there are some
301.19Spooka * MD #ifdefs here.  They are required because of MD inlines and macros.
311.19Spooka */
321.19Spooka
331.1Spooka#ifndef _SYS_RUMP_CPU_H_
341.1Spooka#define _SYS_RUMP_CPU_H_
351.1Spooka
361.8Spooka#ifndef _LOCORE
371.8Spooka
381.1Spooka#include <sys/cpu_data.h>
391.5Spooka#include <machine/pcb.h>
401.1Spooka
411.20Spooka#include "rump_curlwp.h"
421.20Spooka
431.1Spookastruct cpu_info {
441.4Spooka	struct cpu_data ci_data;
451.2Spooka	cpuid_t ci_cpuid;
461.13Spooka	struct lwp *ci_curlwp;
471.4Spooka
481.14Spooka	struct cpu_info *ci_next;
491.14Spooka
501.18Schristos#ifdef __alpha__
511.18Schristos	uint64_t ci_pcc_freq;
521.18Schristos#endif
531.18Schristos
541.4Spooka#ifdef __vax__
551.4Spooka	int ci_ipimsgs;
561.4Spooka#define IPI_SEND_CNCHAR 0
571.4Spooka#define IPI_DDB 0
581.4Spooka#endif /* __vax__ */
591.9Spooka
601.9Spooka#ifdef __powerpc__
611.9Spooka	struct cache_info {
621.9Spooka		int dcache_size;
631.9Spooka		int dcache_line_size;
641.9Spooka		int icache_size;
651.9Spooka		int icache_line_size;
661.9Spooka	} ci_ci;
671.9Spooka#endif /* __powerpc */
681.1Spooka};
691.1Spooka
701.4Spooka#ifdef __vax__
711.4Spookastatic __inline void cpu_handle_ipi(void) {}
721.4Spooka#endif /* __vax__ */
731.4Spooka
741.9Spooka#ifdef __powerpc__
751.9Spookavoid __syncicache(void *, size_t);
761.19Spooka#endif /* __powerpc__ */
771.9Spooka
781.20Spooka#define curlwp rump_curlwp_fast()
791.3Spooka
801.11Spooka#define curcpu() (curlwp->l_cpu)
811.14Spooka#define cpu_number() (cpu_index(curcpu))
821.14Spooka
831.14Spookaextern struct cpu_info *rumpcpu_info_list;
841.17Smrg#define CPU_INFO_ITERATOR		int __unused
851.14Spooka#define CPU_INFO_FOREACH(_cii_, _ci_)	_cii_ = 0, _ci_ = rumpcpu_info_list; \
861.14Spooka					_ci_ != NULL; _ci_ = _ci_->ci_next
871.14Spooka#define CPU_IS_PRIMARY(_ci_)		(_ci_->ci_index == 0)
881.14Spooka
891.11Spooka
901.8Spooka#endif /* !_LOCORE */
911.8Spooka
921.1Spooka#endif /* _SYS_RUMP_CPU_H_ */
93