cpu.h revision 1.17
11.17Smrg/*	$NetBSD: cpu.h,v 1.17 2013/10/30 08:42:45 mrg 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.1Spooka#ifndef _SYS_RUMP_CPU_H_
291.1Spooka#define _SYS_RUMP_CPU_H_
301.1Spooka
311.8Spooka#ifndef _LOCORE
321.8Spooka
331.1Spooka#include <sys/cpu_data.h>
341.5Spooka#include <machine/pcb.h>
351.1Spooka
361.1Spookastruct cpu_info {
371.4Spooka	struct cpu_data ci_data;
381.2Spooka	cpuid_t ci_cpuid;
391.13Spooka	struct lwp *ci_curlwp;
401.4Spooka
411.14Spooka	struct cpu_info *ci_next;
421.14Spooka
431.4Spooka/*
441.4Spooka * XXX: horrible workaround for vax lock.h.
451.4Spooka * I eventually want to nuke rump include/machine, so don't waste
461.4Spooka * energy fighting with this.
471.4Spooka */
481.4Spooka#ifdef __vax__
491.4Spooka	int ci_ipimsgs;
501.4Spooka#define IPI_SEND_CNCHAR 0
511.4Spooka#define IPI_DDB 0
521.4Spooka#endif /* __vax__ */
531.9Spooka
541.9Spooka/*
551.9Spooka * More stinky hacks, this time for powerpc.  Will go away eventually.
561.9Spooka */
571.9Spooka#ifdef __powerpc__
581.9Spooka	struct cache_info {
591.9Spooka		int dcache_size;
601.9Spooka		int dcache_line_size;
611.9Spooka		int icache_size;
621.9Spooka		int icache_line_size;
631.9Spooka	} ci_ci;
641.9Spooka#endif /* __powerpc */
651.1Spooka};
661.1Spooka
671.4Spooka/* more dirty rotten vax kludges */
681.4Spooka#ifdef __vax__
691.4Spookastatic __inline void cpu_handle_ipi(void) {}
701.4Spooka#endif /* __vax__ */
711.4Spooka
721.9Spooka#ifdef __powerpc__
731.9Spookavoid __syncicache(void *, size_t);
741.9Spooka#endif
751.9Spooka
761.16Spookastruct lwp *rumpuser_curlwp(void);
771.16Spooka#define curlwp rumpuser_curlwp()
781.3Spooka
791.11Spooka#define curcpu() (curlwp->l_cpu)
801.14Spooka#define cpu_number() (cpu_index(curcpu))
811.14Spooka
821.14Spookaextern struct cpu_info *rumpcpu_info_list;
831.17Smrg#define CPU_INFO_ITERATOR		int __unused
841.14Spooka#define CPU_INFO_FOREACH(_cii_, _ci_)	_cii_ = 0, _ci_ = rumpcpu_info_list; \
851.14Spooka					_ci_ != NULL; _ci_ = _ci_->ci_next
861.14Spooka#define CPU_IS_PRIMARY(_ci_)		(_ci_->ci_index == 0)
871.14Spooka
881.11Spooka
891.8Spooka#endif /* !_LOCORE */
901.8Spooka
911.1Spooka#endif /* _SYS_RUMP_CPU_H_ */
92