Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.90.16.34
      1  1.90.16.34     cliff /*	$NetBSD: cpu.h,v 1.90.16.34 2011/02/08 06:01:08 cliff Exp $	*/
      2         1.8       cgd 
      3         1.1   deraadt /*-
      4         1.5     glass  * Copyright (c) 1992, 1993
      5         1.5     glass  *	The Regents of the University of California.  All rights reserved.
      6         1.1   deraadt  *
      7         1.1   deraadt  * This code is derived from software contributed to Berkeley by
      8         1.1   deraadt  * Ralph Campbell and Rick Macklem.
      9         1.1   deraadt  *
     10         1.1   deraadt  * Redistribution and use in source and binary forms, with or without
     11         1.1   deraadt  * modification, are permitted provided that the following conditions
     12         1.1   deraadt  * are met:
     13         1.1   deraadt  * 1. Redistributions of source code must retain the above copyright
     14         1.1   deraadt  *    notice, this list of conditions and the following disclaimer.
     15         1.1   deraadt  * 2. Redistributions in binary form must reproduce the above copyright
     16         1.1   deraadt  *    notice, this list of conditions and the following disclaimer in the
     17         1.1   deraadt  *    documentation and/or other materials provided with the distribution.
     18        1.71       agc  * 3. Neither the name of the University nor the names of its contributors
     19         1.1   deraadt  *    may be used to endorse or promote products derived from this software
     20         1.1   deraadt  *    without specific prior written permission.
     21         1.1   deraadt  *
     22         1.1   deraadt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23         1.1   deraadt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24         1.1   deraadt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25         1.1   deraadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26         1.1   deraadt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27         1.1   deraadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28         1.1   deraadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29         1.1   deraadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30         1.1   deraadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31         1.1   deraadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32         1.1   deraadt  * SUCH DAMAGE.
     33         1.1   deraadt  *
     34         1.8       cgd  *	@(#)cpu.h	8.4 (Berkeley) 1/4/94
     35         1.1   deraadt  */
     36         1.1   deraadt 
     37         1.1   deraadt #ifndef _CPU_H_
     38         1.1   deraadt #define _CPU_H_
     39         1.1   deraadt 
     40        1.54    simonb #include <mips/cpuregs.h>
     41        1.53    simonb 
     42         1.1   deraadt /*
     43        1.13  jonathan  * Exported definitions unique to NetBSD/mips cpu support.
     44         1.1   deraadt  */
     45        1.36     soren 
     46        1.68    simonb #ifdef _KERNEL
     47  1.90.16.19      matt 
     48        1.53    simonb #ifndef _LOCORE
     49        1.53    simonb #if defined(_KERNEL_OPT)
     50  1.90.16.24      matt #include "opt_cputype.h"
     51        1.53    simonb #include "opt_lockdebug.h"
     52  1.90.16.11      matt #include "opt_multiprocessor.h"
     53        1.53    simonb #endif
     54        1.53    simonb 
     55  1.90.16.33     cliff #include <sys/cpu_data.h>
     56  1.90.16.33     cliff #include <sys/device.h>
     57  1.90.16.33     cliff #include <sys/evcnt.h>
     58  1.90.16.33     cliff #include <mips/reg.h>
     59  1.90.16.33     cliff #include <mips/cpuset.h>
     60  1.90.16.33     cliff 
     61        1.53    simonb struct cpu_info {
     62        1.73      yamt 	struct cpu_data ci_data;	/* MI per-cpu data */
     63        1.85        ad 	struct cpu_info *ci_next;	/* Next CPU in list */
     64  1.90.16.26      matt 	struct cpu_softc *ci_softc;	/* chip-dependent hook */
     65  1.90.16.24      matt 	device_t ci_dev;		/* owning device */
     66        1.85        ad 	cpuid_t ci_cpuid;		/* Machine-level identifier */
     67  1.90.16.24      matt 	u_long ci_cctr_freq;		/* cycle counter frequency */
     68        1.58    simonb 	u_long ci_cpu_freq;		/* CPU frequency */
     69        1.58    simonb 	u_long ci_cycles_per_hz;	/* CPU freq / hz */
     70        1.58    simonb 	u_long ci_divisor_delay;	/* for delay/DELAY */
     71        1.90   tsutsui 	u_long ci_divisor_recip;	/* unused, for obsolete microtime(9) */
     72        1.82      yamt 	struct lwp *ci_curlwp;		/* currently running lwp */
     73  1.90.16.24      matt #ifndef NOFPU
     74        1.82      yamt 	struct lwp *ci_fpcurlwp;	/* the current FPU owner */
     75  1.90.16.24      matt #endif
     76  1.90.16.24      matt 	volatile int ci_want_resched;	/* user preemption pending */
     77        1.78        ad 	int ci_mtx_count;		/* negative count of held mutexes */
     78        1.78        ad 	int ci_mtx_oldspl;		/* saved SPL value */
     79        1.86        ad 	int ci_idepth;			/* hardware interrupt depth */
     80  1.90.16.19      matt 	int ci_cpl;			/* current [interrupt] priority level */
     81  1.90.16.28     cliff 	uint32_t ci_next_cp0_clk_intr;	/* for hard clock intr scheduling */
     82  1.90.16.28     cliff 	struct evcnt ci_count_compare_evcnt;		/* hard clock intr counter */
     83  1.90.16.28     cliff 	struct evcnt ci_count_compare_missed_evcnt;	/* hard clock miss counter */
     84  1.90.16.18      matt 	struct lwp *ci_softlwps[SOFTINT_COUNT];
     85  1.90.16.18      matt #define	ci_softints	ci_data.cpu_softints
     86  1.90.16.28     cliff 
     87  1.90.16.12      matt 	/*
     88  1.90.16.12      matt 	 * Per-cpu pmap information
     89  1.90.16.12      matt 	 */
     90  1.90.16.23      matt 	int ci_tlb_slot;		/* reserved tlb entry for cpu_info */
     91  1.90.16.32      matt 	u_int ci_pmap_asid_cur;		/* current ASID */
     92  1.90.16.24      matt 	struct pmap_tlb_info *ci_tlb_info; /* tlb information for this cpu */
     93  1.90.16.30      matt 	union segtab *ci_pmap_seg0tab;
     94  1.90.16.30      matt #ifdef _LP64
     95  1.90.16.30      matt 	union segtab *ci_pmap_segtab;
     96  1.90.16.30      matt #else
     97  1.90.16.15      matt 	vaddr_t ci_pmap_srcbase;	/* starting VA of ephemeral src space */
     98  1.90.16.15      matt 	vaddr_t ci_pmap_dstbase;	/* starting VA of ephemeral dst space */
     99  1.90.16.30      matt #endif
    100  1.90.16.28     cliff 
    101  1.90.16.28     cliff 
    102  1.90.16.24      matt #ifdef MULTIPROCESSOR
    103  1.90.16.25      matt 	volatile u_long ci_flags;
    104  1.90.16.28     cliff 	volatile uint64_t ci_request_ipis;
    105  1.90.16.28     cliff 					/* bitmask of IPIs requested */
    106  1.90.16.28     cliff 					/*  use on chips where hw cannot pass tag */
    107  1.90.16.24      matt 	uint64_t ci_active_ipis;	/* bitmask of IPIs being serviced */
    108  1.90.16.24      matt 	uint32_t ci_ksp_tlb_slot;	/* tlb entry for kernel stack */
    109  1.90.16.24      matt 	void *ci_fpsave_si;		/* FP sync softint handler */
    110  1.90.16.24      matt 	struct evcnt ci_evcnt_all_ipis;	/* aggregated IPI counter */
    111  1.90.16.24      matt 	struct evcnt ci_evcnt_per_ipi[NIPIS];	/* individual IPI counters*/
    112  1.90.16.27      matt 	struct evcnt ci_evcnt_synci_activate_rqst;
    113  1.90.16.27      matt 	struct evcnt ci_evcnt_synci_onproc_rqst;
    114  1.90.16.27      matt 	struct evcnt ci_evcnt_synci_deferred_rqst;
    115  1.90.16.27      matt 	struct evcnt ci_evcnt_synci_ipi_rqst;
    116  1.90.16.25      matt 
    117  1.90.16.25      matt #define	CPUF_PRIMARY	0x01		/* CPU is primary CPU */
    118  1.90.16.25      matt #define	CPUF_PRESENT	0x02		/* CPU is present */
    119  1.90.16.25      matt #define	CPUF_RUNNING	0x04		/* CPU is running */
    120  1.90.16.25      matt #define	CPUF_PAUSED	0x08		/* CPU is paused */
    121  1.90.16.25      matt #define	CPUF_FPUSAVE	0x10		/* CPU is currently in fpusave_cpu() */
    122  1.90.16.27      matt #define	CPUF_USERPMAP	0x20		/* CPU has a user pmap activated */
    123  1.90.16.24      matt #endif
    124  1.90.16.28     cliff 
    125        1.53    simonb };
    126        1.68    simonb 
    127        1.85        ad #define	CPU_INFO_ITERATOR		int
    128        1.85        ad #define	CPU_INFO_FOREACH(cii, ci)	\
    129        1.85        ad     (void)(cii), ci = &cpu_info_store; ci != NULL; ci = ci->ci_next
    130        1.85        ad 
    131        1.68    simonb #endif /* !_LOCORE */
    132        1.68    simonb #endif /* _KERNEL */
    133        1.53    simonb 
    134        1.36     soren /*
    135        1.36     soren  * CTL_MACHDEP definitions.
    136        1.36     soren  */
    137        1.36     soren #define CPU_CONSDEV		1	/* dev_t: console terminal device */
    138        1.36     soren #define CPU_BOOTED_KERNEL	2	/* string: booted kernel name */
    139        1.36     soren #define CPU_ROOT_DEVICE		3	/* string: root device name */
    140        1.66  gmcgarry #define CPU_LLSC		4	/* OS/CPU supports LL/SC instruction */
    141        1.43     jeffs 
    142        1.43     jeffs /*
    143        1.51       wiz  * Platform can override, but note this breaks userland compatibility
    144        1.43     jeffs  * with other mips platforms.
    145        1.43     jeffs  */
    146        1.43     jeffs #ifndef CPU_MAXID
    147        1.67      shin #define CPU_MAXID		5	/* number of valid machdep ids */
    148        1.42     jeffs #endif
    149        1.33    simonb 
    150        1.33    simonb #ifdef _KERNEL
    151        1.87        he #if defined(_LKM) || defined(_STANDALONE)
    152        1.87        he /* Assume all CPU architectures are valid for LKM's and standlone progs */
    153        1.77   tsutsui #define	MIPS1	1
    154        1.77   tsutsui #define	MIPS3	1
    155        1.77   tsutsui #define	MIPS4	1
    156        1.77   tsutsui #define	MIPS32	1
    157        1.77   tsutsui #define	MIPS64	1
    158        1.77   tsutsui #endif
    159        1.77   tsutsui 
    160        1.77   tsutsui #if (MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS64) == 0
    161        1.77   tsutsui #error at least one of MIPS1, MIPS3, MIPS4, MIPS32 or MIPS64 must be specified
    162        1.77   tsutsui #endif
    163        1.53    simonb 
    164        1.77   tsutsui /* Shortcut for MIPS3 or above defined */
    165        1.77   tsutsui #if defined(MIPS3) || defined(MIPS4) || defined(MIPS32) || defined(MIPS64)
    166        1.77   tsutsui #define	MIPS3_PLUS	1
    167  1.90.16.24      matt #define __HAVE_CPU_COUNTER
    168        1.77   tsutsui #else
    169        1.77   tsutsui #undef MIPS3_PLUS
    170        1.77   tsutsui #endif
    171        1.33    simonb 
    172        1.33    simonb /*
    173        1.21  jonathan  * Macros to find the CPU architecture we're on at run-time,
    174        1.21  jonathan  * or if possible, at compile-time.
    175        1.21  jonathan  */
    176        1.21  jonathan 
    177        1.58    simonb #define	CPU_ARCH_MIPSx	0		/* XXX unknown */
    178        1.46       cgd #define	CPU_ARCH_MIPS1	(1 << 0)
    179        1.46       cgd #define	CPU_ARCH_MIPS2	(1 << 1)
    180        1.46       cgd #define	CPU_ARCH_MIPS3	(1 << 2)
    181        1.46       cgd #define	CPU_ARCH_MIPS4	(1 << 3)
    182        1.46       cgd #define	CPU_ARCH_MIPS5	(1 << 4)
    183        1.46       cgd #define	CPU_ARCH_MIPS32	(1 << 5)
    184        1.46       cgd #define	CPU_ARCH_MIPS64	(1 << 6)
    185        1.46       cgd 
    186        1.82      yamt /* Note: must be kept in sync with -ffixed-?? Makefile.mips. */
    187  1.90.16.16      matt #define MIPS_CURLWP             $24
    188  1.90.16.16      matt #define MIPS_CURLWP_QUOTED      "$24"
    189  1.90.16.16      matt #define MIPS_CURLWP_LABEL	_L_T8
    190  1.90.16.21      matt #define MIPS_CURLWP_REG		_R_T8
    191  1.90.16.17      matt #define TF_MIPS_CURLWP(x)	TF_REG_T8(x)
    192        1.82      yamt 
    193        1.58    simonb #ifndef _LOCORE
    194        1.82      yamt 
    195        1.77   tsutsui extern struct cpu_info cpu_info_store;
    196        1.82      yamt register struct lwp *mips_curlwp asm(MIPS_CURLWP_QUOTED);
    197        1.77   tsutsui 
    198        1.82      yamt #define	curlwp			mips_curlwp
    199        1.82      yamt #define	curcpu()		(curlwp->l_cpu)
    200  1.90.16.19      matt #define	curpcb			(&curlwp->l_addr->u_pcb)
    201  1.90.16.13      matt #ifdef MULTIPROCESSOR
    202  1.90.16.34     cliff #define	cpu_number()		(curcpu()->ci_index)
    203  1.90.16.34     cliff #define	CPU_IS_PRIMARY(ci)	((ci)->ci_flags & CPUF_PRIMARY)
    204  1.90.16.13      matt #else
    205  1.90.16.28     cliff #define	cpu_number()		(0L)
    206  1.90.16.13      matt #endif
    207        1.77   tsutsui 
    208        1.58    simonb /* XXX simonb
    209        1.58    simonb  * Should the following be in a cpu_info type structure?
    210        1.58    simonb  * And how many of these are per-cpu vs. per-system?  (Ie,
    211        1.58    simonb  * we can assume that all cpus have the same mmu-type, but
    212        1.58    simonb  * maybe not that all cpus run at the same clock speed.
    213        1.58    simonb  * Some SGI's apparently support R12k and R14k in the same
    214        1.58    simonb  * box.)
    215        1.58    simonb  */
    216  1.90.16.13      matt struct mips_options {
    217  1.90.16.13      matt 	const struct pridtab *mips_cpu;
    218  1.90.16.13      matt 
    219  1.90.16.13      matt 	u_int mips_cpu_arch;
    220  1.90.16.14      matt 	u_int mips_cpu_mhz; /* CPU speed in MHz, estimated by mc_cpuspeed(). */
    221  1.90.16.13      matt 	u_int mips_cpu_flags;
    222  1.90.16.13      matt 	u_int mips_num_tlb_entries;
    223  1.90.16.13      matt 	mips_prid_t mips_cpu_id;
    224  1.90.16.13      matt 	mips_prid_t mips_fpu_id;
    225  1.90.16.13      matt 	bool mips_has_r4k_mmu;
    226  1.90.16.13      matt 	bool mips_has_llsc;
    227  1.90.16.14      matt 	u_int mips3_pg_shift;
    228  1.90.16.14      matt 	u_int mips3_pg_cached;
    229  1.90.16.13      matt #ifdef MIPS3_PLUS
    230   1.90.16.2      matt #ifdef _LP64
    231  1.90.16.13      matt 	uint64_t mips3_xkphys_cached;
    232   1.90.16.2      matt #endif
    233  1.90.16.13      matt 	uint64_t mips3_tlb_vpn_mask;
    234  1.90.16.13      matt 	uint64_t mips3_tlb_pfn_mask;
    235  1.90.16.13      matt 	uint32_t mips3_tlb_pg_mask;
    236  1.90.16.13      matt #endif
    237  1.90.16.13      matt };
    238  1.90.16.13      matt extern struct mips_options mips_options;
    239        1.58    simonb 
    240        1.58    simonb #define	CPU_MIPS_R4K_MMU		0x0001
    241        1.58    simonb #define	CPU_MIPS_NO_LLSC		0x0002
    242        1.58    simonb #define	CPU_MIPS_CAUSE_IV		0x0004
    243        1.58    simonb #define	CPU_MIPS_HAVE_SPECIAL_CCA	0x0008	/* Defaults to '3' if not set. */
    244        1.58    simonb #define	CPU_MIPS_CACHED_CCA_MASK	0x0070
    245        1.58    simonb #define	CPU_MIPS_CACHED_CCA_SHIFT	 4
    246        1.62    simonb #define	CPU_MIPS_DOUBLE_COUNT		0x0080	/* 1 cp0 count == 2 clock cycles */
    247        1.63    simonb #define	CPU_MIPS_USE_WAIT		0x0100	/* Use "wait"-based cpu_idle() */
    248        1.63    simonb #define	CPU_MIPS_NO_WAIT		0x0200	/* Inverse of previous, for mips32/64 */
    249        1.69    simonb #define	CPU_MIPS_D_CACHE_COHERENT	0x0400	/* D-cache is fully coherent */
    250        1.69    simonb #define	CPU_MIPS_I_D_CACHE_COHERENT	0x0800	/* I-cache funcs don't need to flush the D-cache */
    251   1.90.16.3      matt #define	CPU_MIPS_NO_LLADDR		0x1000
    252   1.90.16.5     cliff #define	CPU_MIPS_HAVE_MxCR		0x2000	/* have mfcr, mtcr insns */
    253        1.58    simonb #define	MIPS_NOT_SUPP			0x8000
    254        1.60    simonb 
    255        1.78        ad #endif	/* !_LOCORE */
    256        1.78        ad 
    257        1.78        ad #if ((MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS64) == 1) || defined(_LOCORE)
    258        1.78        ad 
    259        1.78        ad #if defined(MIPS1)
    260        1.78        ad 
    261        1.58    simonb # define CPUISMIPS3		0
    262        1.58    simonb # define CPUIS64BITS		0
    263        1.58    simonb # define CPUISMIPS32		0
    264        1.58    simonb # define CPUISMIPS64		0
    265        1.58    simonb # define CPUISMIPSNN		0
    266        1.58    simonb # define MIPS_HAS_R4K_MMU	0
    267        1.58    simonb # define MIPS_HAS_CLOCK		0
    268        1.58    simonb # define MIPS_HAS_LLSC		0
    269   1.90.16.4      matt # define MIPS_HAS_LLADDR	0
    270        1.58    simonb 
    271        1.78        ad #elif defined(MIPS3) || defined(MIPS4)
    272        1.78        ad 
    273        1.58    simonb # define CPUISMIPS3		1
    274        1.58    simonb # define CPUIS64BITS		1
    275        1.58    simonb # define CPUISMIPS32		0
    276        1.58    simonb # define CPUISMIPS64		0
    277        1.58    simonb # define CPUISMIPSNN		0
    278        1.58    simonb # define MIPS_HAS_R4K_MMU	1
    279        1.58    simonb # define MIPS_HAS_CLOCK		1
    280        1.78        ad # if defined(_LOCORE)
    281        1.78        ad #  if !defined(MIPS3_5900) && !defined(MIPS3_4100)
    282        1.78        ad #   define MIPS_HAS_LLSC	1
    283        1.78        ad #  else
    284        1.78        ad #   define MIPS_HAS_LLSC	0
    285        1.78        ad #  endif
    286        1.78        ad # else	/* _LOCORE */
    287  1.90.16.13      matt #  define MIPS_HAS_LLSC		(mips_options.mips_has_llsc)
    288        1.78        ad # endif	/* _LOCORE */
    289  1.90.16.13      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    290        1.78        ad 
    291        1.78        ad #elif defined(MIPS32)
    292        1.58    simonb 
    293        1.58    simonb # define CPUISMIPS3		1
    294        1.58    simonb # define CPUIS64BITS		0
    295        1.58    simonb # define CPUISMIPS32		1
    296        1.58    simonb # define CPUISMIPS64		0
    297        1.58    simonb # define CPUISMIPSNN		1
    298        1.58    simonb # define MIPS_HAS_R4K_MMU	1
    299        1.58    simonb # define MIPS_HAS_CLOCK		1
    300        1.58    simonb # define MIPS_HAS_LLSC		1
    301  1.90.16.13      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    302        1.58    simonb 
    303        1.80     oster #elif defined(MIPS64)
    304        1.78        ad 
    305        1.58    simonb # define CPUISMIPS3		1
    306        1.58    simonb # define CPUIS64BITS		1
    307        1.58    simonb # define CPUISMIPS32		0
    308        1.58    simonb # define CPUISMIPS64		1
    309        1.58    simonb # define CPUISMIPSNN		1
    310        1.58    simonb # define MIPS_HAS_R4K_MMU	1
    311        1.58    simonb # define MIPS_HAS_CLOCK		1
    312        1.58    simonb # define MIPS_HAS_LLSC		1
    313  1.90.16.13      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    314        1.78        ad 
    315        1.78        ad #endif
    316        1.21  jonathan 
    317        1.58    simonb #else /* run-time test */
    318        1.21  jonathan 
    319        1.78        ad #ifndef	_LOCORE
    320        1.78        ad 
    321  1.90.16.13      matt #define	MIPS_HAS_R4K_MMU	(mips_options.mips_has_r4k_mmu)
    322  1.90.16.13      matt #define	MIPS_HAS_LLSC		(mips_options.mips_has_llsc)
    323  1.90.16.13      matt #define	MIPS_HAS_LLADDR		((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    324        1.45       cgd 
    325        1.45       cgd /* This test is ... rather bogus */
    326  1.90.16.13      matt #define	CPUISMIPS3	((mips_options.mips_cpu_arch & \
    327        1.58    simonb 	(CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS32 | CPU_ARCH_MIPS64)) != 0)
    328        1.58    simonb 
    329        1.58    simonb /* And these aren't much better while the previous test exists as is... */
    330  1.90.16.13      matt #define	CPUISMIPS4	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS4) != 0)
    331  1.90.16.13      matt #define	CPUISMIPS5	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS5) != 0)
    332  1.90.16.13      matt #define	CPUISMIPS32	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS32) != 0)
    333  1.90.16.13      matt #define	CPUISMIPS64	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS64) != 0)
    334  1.90.16.13      matt #define	CPUISMIPSNN	((mips_options.mips_cpu_arch & (CPU_ARCH_MIPS32 | CPU_ARCH_MIPS64)) != 0)
    335  1.90.16.13      matt #define	CPUIS64BITS	((mips_options.mips_cpu_arch & \
    336        1.58    simonb 	(CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS64)) != 0)
    337        1.58    simonb 
    338  1.90.16.13      matt #define	MIPS_HAS_CLOCK	(mips_options.mips_cpu_arch >= CPU_ARCH_MIPS3)
    339        1.78        ad 
    340        1.78        ad #else	/* !_LOCORE */
    341        1.78        ad 
    342        1.78        ad #define	MIPS_HAS_LLSC	0
    343        1.78        ad 
    344        1.78        ad #endif	/* !_LOCORE */
    345        1.78        ad 
    346        1.21  jonathan #endif /* run-time test */
    347        1.21  jonathan 
    348        1.78        ad #ifndef	_LOCORE
    349        1.58    simonb 
    350        1.21  jonathan /*
    351         1.1   deraadt  * definitions of cpu-dependent requirements
    352         1.1   deraadt  * referenced in generic code
    353         1.1   deraadt  */
    354        1.11       cgd #define	cpu_swapout(p)			panic("cpu_swapout: can't get here");
    355        1.42     jeffs 
    356  1.90.16.19      matt /*
    357  1.90.16.33     cliff  * Send an inter-processor interupt to each other CPU (excludes curcpu())
    358  1.90.16.33     cliff  */
    359  1.90.16.33     cliff void cpu_broadcast_ipi(int);
    360  1.90.16.33     cliff 
    361  1.90.16.33     cliff /*
    362  1.90.16.33     cliff  * Send an inter-processor interupt to CPUs in cpuset (excludes curcpu())
    363  1.90.16.33     cliff  */
    364  1.90.16.33     cliff void cpu_multicast_ipi(mips_cpuset_t, int);
    365  1.90.16.33     cliff 
    366  1.90.16.33     cliff /*
    367  1.90.16.21      matt  * Send an inter-processor interupt to another CPU.
    368  1.90.16.21      matt  */
    369  1.90.16.21      matt int cpu_send_ipi(struct cpu_info *, int);
    370  1.90.16.21      matt 
    371  1.90.16.21      matt /*
    372  1.90.16.19      matt  * cpu_intr(ppl, pc, status);  (most state needed by clockframe)
    373  1.90.16.19      matt  */
    374  1.90.16.19      matt void cpu_intr(int, vaddr_t, uint32_t);
    375         1.1   deraadt 
    376         1.1   deraadt /*
    377         1.1   deraadt  * Arguments to hardclock and gatherstats encapsulate the previous
    378         1.1   deraadt  * machine state in an opaque clockframe.
    379         1.1   deraadt  */
    380         1.5     glass struct clockframe {
    381  1.90.16.19      matt 	vaddr_t		pc;	/* program counter at time of interrupt */
    382   1.90.16.8     cliff 	uint32_t	sr;	/* status register at time of interrupt */
    383  1.90.16.19      matt 	bool		intr;	/* interrupted a interrupt */
    384         1.5     glass };
    385         1.1   deraadt 
    386        1.14  jonathan /*
    387        1.79        ad  * A port must provde CLKF_USERMODE() for use in machine-independent code.
    388        1.79        ad  * These differ on r4000 and r3000 systems; provide them in the
    389        1.79        ad  * port-dependent file that includes this one, using the macros below.
    390        1.14  jonathan  */
    391        1.14  jonathan 
    392        1.21  jonathan /* mips1 versions */
    393        1.22  jonathan #define	MIPS1_CLKF_USERMODE(framep)	((framep)->sr & MIPS_SR_KU_PREV)
    394        1.14  jonathan 
    395        1.21  jonathan /* mips3 versions */
    396        1.22  jonathan #define	MIPS3_CLKF_USERMODE(framep)	((framep)->sr & MIPS_SR_KSU_USER)
    397        1.56       uch 
    398         1.1   deraadt #define	CLKF_PC(framep)		((framep)->pc)
    399  1.90.16.19      matt #define	CLKF_INTR(framep)	((framep)->intr)
    400        1.18  jonathan 
    401        1.58    simonb #if defined(MIPS3_PLUS) && !defined(MIPS1)		/* XXX bogus! */
    402        1.21  jonathan #define	CLKF_USERMODE(framep)	MIPS3_CLKF_USERMODE(framep)
    403        1.21  jonathan #endif
    404        1.21  jonathan 
    405        1.58    simonb #if !defined(MIPS3_PLUS) && defined(MIPS1)		/* XXX bogus! */
    406        1.21  jonathan #define	CLKF_USERMODE(framep)	MIPS1_CLKF_USERMODE(framep)
    407        1.21  jonathan #endif
    408        1.21  jonathan 
    409        1.58    simonb #if defined(MIPS3_PLUS) && defined(MIPS1)		/* XXX bogus! */
    410        1.21  jonathan #define CLKF_USERMODE(framep) \
    411        1.21  jonathan     ((CPUISMIPS3) ? MIPS3_CLKF_USERMODE(framep):  MIPS1_CLKF_USERMODE(framep))
    412        1.18  jonathan #endif
    413        1.18  jonathan 
    414        1.47   thorpej /*
    415  1.90.16.20      matt  * Misc prototypes and variable declarations.
    416        1.47   thorpej  */
    417  1.90.16.20      matt struct lwp;
    418  1.90.16.20      matt struct user;
    419         1.1   deraadt 
    420         1.1   deraadt /*
    421         1.1   deraadt  * Preempt the current process if in interrupt from user mode,
    422         1.1   deraadt  * or after the current trap/syscall if in system mode.
    423         1.1   deraadt  */
    424        1.82      yamt void	cpu_need_resched(struct cpu_info *, int);
    425         1.1   deraadt /*
    426        1.81    simonb  * Notify the current lwp (l) that it has a signal pending,
    427         1.1   deraadt  * process as soon as possible.
    428         1.1   deraadt  */
    429  1.90.16.20      matt void	cpu_signotify(struct lwp *);
    430         1.1   deraadt 
    431        1.23   thorpej /*
    432  1.90.16.20      matt  * Give a profiling tick to the current process when the user profiling
    433  1.90.16.20      matt  * buffer pages are invalid.  On the MIPS, request an ast to send us
    434  1.90.16.20      matt  * through trap, marking the proc as needing a profiling tick.
    435        1.23   thorpej  */
    436  1.90.16.20      matt void	cpu_need_proftick(struct lwp *);
    437  1.90.16.20      matt void	cpu_set_curpri(int);
    438        1.37    simonb 
    439   1.90.16.9      matt extern int mips_poolpage_vmfreelist;	/* freelist to allocate poolpages */
    440        1.25  jonathan 
    441  1.90.16.24      matt struct cpu_info *
    442  1.90.16.32      matt 	cpu_info_alloc(struct pmap_tlb_info *, cpuid_t, cpuid_t, cpuid_t,
    443  1.90.16.32      matt 	    cpuid_t);
    444  1.90.16.24      matt void	cpu_attach_common(device_t, struct cpu_info *);
    445  1.90.16.24      matt void	cpu_startup_common(void);
    446  1.90.16.31      matt #ifdef _LP64
    447  1.90.16.31      matt void	cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t);
    448  1.90.16.31      matt #endif
    449  1.90.16.33     cliff 
    450  1.90.16.25      matt #ifdef MULTIPROCESSOR
    451  1.90.16.25      matt void	cpu_hatch(struct cpu_info *ci);
    452  1.90.16.25      matt void	cpu_trampoline(void);
    453  1.90.16.25      matt void	cpu_boot_secondary_processors(void);
    454  1.90.16.33     cliff void	cpu_halt(void);
    455  1.90.16.33     cliff void	cpu_halt_others(void);
    456  1.90.16.33     cliff void	cpu_pause(struct reg *);
    457  1.90.16.33     cliff void	cpu_pause_others(void);
    458  1.90.16.33     cliff void	cpu_resume(int);
    459  1.90.16.33     cliff void	cpu_resume_others(void);
    460  1.90.16.33     cliff int	cpu_is_paused(int);
    461  1.90.16.33     cliff void	cpu_debug_dump(void);
    462  1.90.16.33     cliff 
    463  1.90.16.33     cliff extern volatile mips_cpuset_t cpus_running;
    464  1.90.16.33     cliff extern volatile mips_cpuset_t cpus_hatched;
    465  1.90.16.33     cliff extern volatile mips_cpuset_t cpus_paused;
    466  1.90.16.33     cliff extern volatile mips_cpuset_t cpus_resumed;
    467  1.90.16.33     cliff extern volatile mips_cpuset_t cpus_halted;
    468  1.90.16.25      matt #endif
    469  1.90.16.24      matt 
    470   1.90.16.6      matt /* copy.S */
    471   1.90.16.6      matt int8_t	ufetch_int8(void *);
    472   1.90.16.6      matt int16_t	ufetch_int16(void *);
    473   1.90.16.6      matt int32_t ufetch_int32(void *);
    474   1.90.16.6      matt uint8_t	ufetch_uint8(void *);
    475   1.90.16.6      matt uint16_t ufetch_uint16(void *);
    476   1.90.16.6      matt uint32_t ufetch_uint32(void *);
    477   1.90.16.6      matt int8_t	ufetch_int8_intrsafe(void *);
    478   1.90.16.6      matt int16_t	ufetch_int16_intrsafe(void *);
    479   1.90.16.6      matt int32_t ufetch_int32_intrsafe(void *);
    480   1.90.16.6      matt uint8_t	ufetch_uint8_intrsafe(void *);
    481   1.90.16.6      matt uint16_t ufetch_uint16_intrsafe(void *);
    482   1.90.16.6      matt uint32_t ufetch_uint32_intrsafe(void *);
    483   1.90.16.6      matt #ifdef _LP64
    484   1.90.16.6      matt int64_t ufetch_int64(void *);
    485   1.90.16.6      matt uint64_t ufetch_uint64(void *);
    486   1.90.16.6      matt int64_t ufetch_int64_intrsafe(void *);
    487   1.90.16.6      matt uint64_t ufetch_uint64_intrsafe(void *);
    488   1.90.16.6      matt #endif
    489   1.90.16.6      matt char	ufetch_char(void *);
    490   1.90.16.6      matt short	ufetch_short(void *);
    491   1.90.16.6      matt int	ufetch_int(void *);
    492   1.90.16.6      matt long	ufetch_long(void *);
    493   1.90.16.6      matt char	ufetch_char_intrsafe(void *);
    494   1.90.16.6      matt short	ufetch_short_intrsafe(void *);
    495   1.90.16.6      matt int	ufetch_int_intrsafe(void *);
    496   1.90.16.6      matt long	ufetch_long_intrsafe(void *);
    497   1.90.16.6      matt 
    498   1.90.16.6      matt u_char	ufetch_uchar(void *);
    499   1.90.16.6      matt u_short	ufetch_ushort(void *);
    500   1.90.16.6      matt u_int	ufetch_uint(void *);
    501   1.90.16.6      matt u_long	ufetch_ulong(void *);
    502   1.90.16.6      matt u_char	ufetch_uchar_intrsafe(void *);
    503   1.90.16.6      matt u_short	ufetch_ushort_intrsafe(void *);
    504   1.90.16.6      matt u_int	ufetch_uint_intrsafe(void *);
    505   1.90.16.6      matt u_long	ufetch_ulong_intrsafe(void *);
    506   1.90.16.6      matt void 	*ufetch_ptr(void *);
    507   1.90.16.6      matt 
    508   1.90.16.6      matt int	ustore_int8(void *, int8_t);
    509   1.90.16.6      matt int	ustore_int16(void *, int16_t);
    510   1.90.16.6      matt int	ustore_int32(void *, int32_t);
    511   1.90.16.6      matt int	ustore_uint8(void *, uint8_t);
    512   1.90.16.7      matt int	ustore_uint16(void *, uint16_t);
    513   1.90.16.6      matt int	ustore_uint32(void *, uint32_t);
    514   1.90.16.6      matt int	ustore_int8_intrsafe(void *, int8_t);
    515   1.90.16.6      matt int	ustore_int16_intrsafe(void *, int16_t);
    516   1.90.16.6      matt int	ustore_int32_intrsafe(void *, int32_t);
    517   1.90.16.6      matt int	ustore_uint8_intrsafe(void *, uint8_t);
    518   1.90.16.6      matt int	ustore_uint16_intrsafe(void *, uint16_t);
    519   1.90.16.6      matt int	ustore_uint32_intrsafe(void *, uint32_t);
    520   1.90.16.6      matt #ifdef _LP64
    521   1.90.16.6      matt int	ustore_int64(void *, int64_t);
    522   1.90.16.6      matt int	ustore_uint64(void *, uint64_t);
    523   1.90.16.6      matt int	ustore_int64_intrsafe(void *, int64_t);
    524   1.90.16.6      matt int	ustore_uint64_intrsafe(void *, uint64_t);
    525   1.90.16.6      matt #endif
    526   1.90.16.6      matt int	ustore_char(void *, char);
    527   1.90.16.6      matt int	ustore_char_intrsafe(void *, char);
    528   1.90.16.6      matt int	ustore_short(void *, short);
    529   1.90.16.6      matt int	ustore_short_intrsafe(void *, short);
    530   1.90.16.6      matt int	ustore_int(void *, int);
    531   1.90.16.6      matt int	ustore_int_intrsafe(void *, int);
    532   1.90.16.6      matt int	ustore_long(void *, long);
    533   1.90.16.6      matt int	ustore_long_intrsafe(void *, long);
    534   1.90.16.6      matt int	ustore_uchar(void *, u_char);
    535   1.90.16.6      matt int	ustore_uchar_intrsafe(void *, u_char);
    536   1.90.16.6      matt int	ustore_ushort(void *, u_short);
    537   1.90.16.6      matt int	ustore_ushort_intrsafe(void *, u_short);
    538   1.90.16.6      matt int	ustore_uint(void *, u_int);
    539   1.90.16.6      matt int	ustore_uint_intrsafe(void *, u_int);
    540   1.90.16.6      matt int	ustore_ulong(void *, u_long);
    541   1.90.16.6      matt int	ustore_ulong_intrsafe(void *, u_long);
    542   1.90.16.6      matt int 	ustore_ptr(void *, void *);
    543   1.90.16.6      matt int	ustore_ptr_intrsafe(void *, void *);
    544   1.90.16.6      matt 
    545   1.90.16.6      matt int	ustore_uint32_isync(void *, uint32_t);
    546   1.90.16.6      matt 
    547        1.28    castor /* trap.c */
    548        1.58    simonb void	netintr(void);
    549        1.58    simonb int	kdbpeek(vaddr_t);
    550        1.23   thorpej 
    551  1.90.16.24      matt /* mips_fpu.c */
    552  1.90.16.24      matt void	fpu_init(void);
    553  1.90.16.24      matt void	fpudiscard_lwp(struct lwp *);
    554  1.90.16.24      matt void	fpuload_lwp(struct lwp *);
    555  1.90.16.24      matt void	fpusave_lwp(struct lwp *);
    556  1.90.16.24      matt void	fpusave_cpu(struct cpu_info *);
    557  1.90.16.24      matt 
    558        1.28    castor /* mips_machdep.c */
    559   1.90.16.9      matt struct mips_vmfreelist;
    560   1.90.16.9      matt struct phys_ram_seg;
    561        1.58    simonb void	dumpsys(void);
    562        1.58    simonb int	savectx(struct user *);
    563        1.58    simonb void	mips_init_msgbuf(void);
    564   1.90.16.9      matt void	mips_init_lwp0_uarea(void);
    565   1.90.16.9      matt void	mips_page_physload(vaddr_t, vaddr_t,
    566   1.90.16.9      matt 	    const struct phys_ram_seg *, size_t,
    567   1.90.16.9      matt 	    const struct mips_vmfreelist *, size_t);
    568  1.90.16.13      matt void	cpu_identify(device_t);
    569        1.13  jonathan 
    570        1.61    simonb /* locore*.S */
    571        1.58    simonb int	badaddr(void *, size_t);
    572        1.61    simonb int	badaddr64(uint64_t, size_t);
    573        1.25  jonathan 
    574  1.90.16.18      matt /* vm_machdep.c */
    575  1.90.16.18      matt void	cpu_uarea_remap(struct lwp *);
    576  1.90.16.18      matt 
    577        1.33    simonb #endif /* ! _LOCORE */
    578        1.28    castor #endif /* _KERNEL */
    579         1.1   deraadt #endif /* _CPU_H_ */
    580