Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.99
      1  1.99      matt /*	$NetBSD: cpu.h,v 1.99 2011/03/15 07:39:22 matt 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.55    simonb 
     48  1.53    simonb #if defined(_KERNEL_OPT)
     49  1.98      matt #include "opt_cputype.h"
     50  1.53    simonb #include "opt_lockdebug.h"
     51  1.98      matt #include "opt_multiprocessor.h"
     52  1.53    simonb #endif
     53  1.53    simonb 
     54  1.98      matt #ifndef _LOCORE
     55  1.98      matt #include <sys/cpu_data.h>
     56  1.98      matt #include <sys/device_if.h>
     57  1.98      matt #include <sys/evcnt.h>
     58  1.94      matt 
     59  1.53    simonb struct cpu_info {
     60  1.73      yamt 	struct cpu_data ci_data;	/* MI per-cpu data */
     61  1.85        ad 	struct cpu_info *ci_next;	/* Next CPU in list */
     62  1.98      matt 	struct cpu_softc *ci_softc;	/* chip-dependent hook */
     63  1.98      matt 	device_t ci_dev;		/* owning device */
     64  1.85        ad 	cpuid_t ci_cpuid;		/* Machine-level identifier */
     65  1.98      matt 	u_long ci_cctr_freq;		/* cycle counter frequency */
     66  1.58    simonb 	u_long ci_cpu_freq;		/* CPU frequency */
     67  1.58    simonb 	u_long ci_cycles_per_hz;	/* CPU freq / hz */
     68  1.58    simonb 	u_long ci_divisor_delay;	/* for delay/DELAY */
     69  1.90   tsutsui 	u_long ci_divisor_recip;	/* unused, for obsolete microtime(9) */
     70  1.82      yamt 	struct lwp *ci_curlwp;		/* currently running lwp */
     71  1.98      matt 	volatile int ci_want_resched;	/* user preemption pending */
     72  1.78        ad 	int ci_mtx_count;		/* negative count of held mutexes */
     73  1.78        ad 	int ci_mtx_oldspl;		/* saved SPL value */
     74  1.86        ad 	int ci_idepth;			/* hardware interrupt depth */
     75  1.98      matt 	int ci_cpl;			/* current [interrupt] priority level */
     76  1.98      matt 	uint32_t ci_next_cp0_clk_intr;	/* for hard clock intr scheduling */
     77  1.98      matt 	struct evcnt ci_ev_count_compare;		/* hard clock intr counter */
     78  1.98      matt 	struct evcnt ci_ev_count_compare_missed;	/* hard clock miss counter */
     79  1.98      matt 	struct lwp *ci_softlwps[SOFTINT_COUNT];
     80  1.98      matt 	volatile u_int ci_softints;
     81  1.98      matt 	struct evcnt ci_ev_fpu_loads;	/* fpu load counter */
     82  1.98      matt 	struct evcnt ci_ev_fpu_saves;	/* fpu save counter */
     83  1.98      matt 	struct evcnt ci_ev_tlbmisses;
     84  1.98      matt 
     85  1.98      matt 	/*
     86  1.98      matt 	 * Per-cpu pmap information
     87  1.98      matt 	 */
     88  1.98      matt 	int ci_tlb_slot;		/* reserved tlb entry for cpu_info */
     89  1.98      matt 	u_int ci_pmap_asid_cur;		/* current ASID */
     90  1.98      matt 	struct pmap_tlb_info *ci_tlb_info; /* tlb information for this cpu */
     91  1.98      matt 	union segtab *ci_pmap_seg0tab;
     92  1.98      matt #ifdef _LP64
     93  1.98      matt 	union segtab *ci_pmap_segtab;
     94  1.98      matt #else
     95  1.98      matt 	vaddr_t ci_pmap_srcbase;	/* starting VA of ephemeral src space */
     96  1.98      matt 	vaddr_t ci_pmap_dstbase;	/* starting VA of ephemeral dst space */
     97  1.98      matt #endif
     98  1.98      matt 
     99  1.98      matt 
    100  1.98      matt #ifdef MULTIPROCESSOR
    101  1.98      matt 	volatile u_long ci_flags;
    102  1.98      matt 	volatile uint64_t ci_request_ipis;
    103  1.98      matt 					/* bitmask of IPIs requested */
    104  1.98      matt 					/*  use on chips where hw cannot pass tag */
    105  1.98      matt 	uint64_t ci_active_ipis;	/* bitmask of IPIs being serviced */
    106  1.98      matt 	uint32_t ci_ksp_tlb_slot;	/* tlb entry for kernel stack */
    107  1.98      matt 	struct evcnt ci_evcnt_all_ipis;	/* aggregated IPI counter */
    108  1.98      matt 	struct evcnt ci_evcnt_per_ipi[NIPIS];	/* individual IPI counters*/
    109  1.98      matt 	struct evcnt ci_evcnt_synci_activate_rqst;
    110  1.98      matt 	struct evcnt ci_evcnt_synci_onproc_rqst;
    111  1.98      matt 	struct evcnt ci_evcnt_synci_deferred_rqst;
    112  1.98      matt 	struct evcnt ci_evcnt_synci_ipi_rqst;
    113  1.98      matt 
    114  1.98      matt #define	CPUF_PRIMARY	0x01		/* CPU is primary CPU */
    115  1.98      matt #define	CPUF_PRESENT	0x02		/* CPU is present */
    116  1.98      matt #define	CPUF_RUNNING	0x04		/* CPU is running */
    117  1.98      matt #define	CPUF_PAUSED	0x08		/* CPU is paused */
    118  1.98      matt #define	CPUF_USERPMAP	0x20		/* CPU has a user pmap activated */
    119  1.98      matt #endif
    120  1.98      matt 
    121  1.53    simonb };
    122  1.68    simonb 
    123  1.85        ad #define	CPU_INFO_ITERATOR		int
    124  1.85        ad #define	CPU_INFO_FOREACH(cii, ci)	\
    125  1.85        ad     (void)(cii), ci = &cpu_info_store; ci != NULL; ci = ci->ci_next
    126  1.85        ad 
    127  1.68    simonb #endif /* !_LOCORE */
    128  1.68    simonb #endif /* _KERNEL */
    129  1.53    simonb 
    130  1.36     soren /*
    131  1.36     soren  * CTL_MACHDEP definitions.
    132  1.36     soren  */
    133  1.36     soren #define CPU_CONSDEV		1	/* dev_t: console terminal device */
    134  1.36     soren #define CPU_BOOTED_KERNEL	2	/* string: booted kernel name */
    135  1.36     soren #define CPU_ROOT_DEVICE		3	/* string: root device name */
    136  1.66  gmcgarry #define CPU_LLSC		4	/* OS/CPU supports LL/SC instruction */
    137  1.43     jeffs 
    138  1.43     jeffs /*
    139  1.51       wiz  * Platform can override, but note this breaks userland compatibility
    140  1.43     jeffs  * with other mips platforms.
    141  1.43     jeffs  */
    142  1.43     jeffs #ifndef CPU_MAXID
    143  1.67      shin #define CPU_MAXID		5	/* number of valid machdep ids */
    144  1.42     jeffs #endif
    145  1.33    simonb 
    146  1.33    simonb #ifdef _KERNEL
    147  1.98      matt #if defined(_MODULAR) || defined(_LKM) || defined(_STANDALONE)
    148  1.87        he /* Assume all CPU architectures are valid for LKM's and standlone progs */
    149  1.77   tsutsui #define	MIPS1	1
    150  1.77   tsutsui #define	MIPS3	1
    151  1.77   tsutsui #define	MIPS4	1
    152  1.77   tsutsui #define	MIPS32	1
    153  1.77   tsutsui #define	MIPS64	1
    154  1.77   tsutsui #endif
    155  1.77   tsutsui 
    156  1.99      matt #if (MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) == 0
    157  1.99      matt #error at least one of MIPS1, MIPS3, MIPS4, MIPS32, MIPS32R2, MIPS64, or MIPS64RR2 must be specified
    158  1.77   tsutsui #endif
    159  1.53    simonb 
    160  1.77   tsutsui /* Shortcut for MIPS3 or above defined */
    161  1.99      matt #if defined(MIPS3) || defined(MIPS4) \
    162  1.99      matt     || defined(MIPS32) || defined(MIPS32R2) \
    163  1.99      matt     || defined(MIPS64) || defined(MIPS64R2)
    164  1.99      matt 
    165  1.77   tsutsui #define	MIPS3_PLUS	1
    166  1.98      matt #define __HAVE_CPU_COUNTER
    167  1.77   tsutsui #else
    168  1.77   tsutsui #undef MIPS3_PLUS
    169  1.77   tsutsui #endif
    170  1.33    simonb 
    171  1.33    simonb /*
    172  1.21  jonathan  * Macros to find the CPU architecture we're on at run-time,
    173  1.21  jonathan  * or if possible, at compile-time.
    174  1.21  jonathan  */
    175  1.21  jonathan 
    176  1.99      matt #define	CPU_ARCH_MIPSx		0		/* XXX unknown */
    177  1.99      matt #define	CPU_ARCH_MIPS1		(1 << 0)
    178  1.99      matt #define	CPU_ARCH_MIPS2		(1 << 1)
    179  1.99      matt #define	CPU_ARCH_MIPS3		(1 << 2)
    180  1.99      matt #define	CPU_ARCH_MIPS4		(1 << 3)
    181  1.99      matt #define	CPU_ARCH_MIPS5		(1 << 4)
    182  1.99      matt #define	CPU_ARCH_MIPS32		(1 << 5)
    183  1.99      matt #define	CPU_ARCH_MIPS64		(1 << 6)
    184  1.99      matt #define	CPU_ARCH_MIPS32R2	(1 << 7)
    185  1.99      matt #define	CPU_ARCH_MIPS64R2	(1 << 8)
    186  1.46       cgd 
    187  1.82      yamt /* Note: must be kept in sync with -ffixed-?? Makefile.mips. */
    188  1.98      matt #define MIPS_CURLWP             $24
    189  1.98      matt #define MIPS_CURLWP_QUOTED      "$24"
    190  1.98      matt #define MIPS_CURLWP_LABEL	_L_T8
    191  1.98      matt #define MIPS_CURLWP_REG		_R_T8
    192  1.98      matt #define TF_MIPS_CURLWP(x)	TF_REG_T8(x)
    193  1.82      yamt 
    194  1.58    simonb #ifndef _LOCORE
    195  1.82      yamt 
    196  1.77   tsutsui extern struct cpu_info cpu_info_store;
    197  1.82      yamt register struct lwp *mips_curlwp asm(MIPS_CURLWP_QUOTED);
    198  1.77   tsutsui 
    199  1.82      yamt #define	curlwp			mips_curlwp
    200  1.82      yamt #define	curcpu()		(curlwp->l_cpu)
    201  1.92     rmind #define	curpcb			((struct pcb *)lwp_getpcb(curlwp))
    202  1.98      matt #ifdef MULTIPROCESSOR
    203  1.98      matt #define	cpu_number()		(curcpu()->ci_index)
    204  1.98      matt #define	CPU_IS_PRIMARY(ci)	((ci)->ci_flags & CPUF_PRIMARY)
    205  1.98      matt #else
    206  1.82      yamt #define	cpu_number()		(0)
    207  1.98      matt #define	CPU_IS_PRIMARY(ci)	(true)
    208  1.98      matt #endif
    209  1.77   tsutsui 
    210  1.58    simonb /* XXX simonb
    211  1.58    simonb  * Should the following be in a cpu_info type structure?
    212  1.58    simonb  * And how many of these are per-cpu vs. per-system?  (Ie,
    213  1.58    simonb  * we can assume that all cpus have the same mmu-type, but
    214  1.58    simonb  * maybe not that all cpus run at the same clock speed.
    215  1.58    simonb  * Some SGI's apparently support R12k and R14k in the same
    216  1.58    simonb  * box.)
    217  1.58    simonb  */
    218  1.98      matt struct mips_options {
    219  1.98      matt 	const struct pridtab *mips_cpu;
    220  1.98      matt 
    221  1.98      matt 	u_int mips_cpu_arch;
    222  1.98      matt 	u_int mips_cpu_mhz; /* CPU speed in MHz, estimated by mc_cpuspeed(). */
    223  1.98      matt 	u_int mips_cpu_flags;
    224  1.98      matt 	u_int mips_num_tlb_entries;
    225  1.98      matt 	mips_prid_t mips_cpu_id;
    226  1.98      matt 	mips_prid_t mips_fpu_id;
    227  1.98      matt 	bool mips_has_r4k_mmu;
    228  1.98      matt 	bool mips_has_llsc;
    229  1.98      matt 	u_int mips3_pg_shift;
    230  1.98      matt 	u_int mips3_pg_cached;
    231  1.98      matt #ifdef MIPS3_PLUS
    232  1.94      matt #ifdef _LP64
    233  1.98      matt 	uint64_t mips3_xkphys_cached;
    234  1.98      matt #endif
    235  1.98      matt 	uint64_t mips3_tlb_vpn_mask;
    236  1.98      matt 	uint64_t mips3_tlb_pfn_mask;
    237  1.98      matt 	uint32_t mips3_tlb_pg_mask;
    238  1.94      matt #endif
    239  1.98      matt };
    240  1.98      matt extern struct mips_options mips_options;
    241  1.58    simonb 
    242  1.58    simonb #define	CPU_MIPS_R4K_MMU		0x0001
    243  1.58    simonb #define	CPU_MIPS_NO_LLSC		0x0002
    244  1.58    simonb #define	CPU_MIPS_CAUSE_IV		0x0004
    245  1.58    simonb #define	CPU_MIPS_HAVE_SPECIAL_CCA	0x0008	/* Defaults to '3' if not set. */
    246  1.58    simonb #define	CPU_MIPS_CACHED_CCA_MASK	0x0070
    247  1.58    simonb #define	CPU_MIPS_CACHED_CCA_SHIFT	 4
    248  1.62    simonb #define	CPU_MIPS_DOUBLE_COUNT		0x0080	/* 1 cp0 count == 2 clock cycles */
    249  1.63    simonb #define	CPU_MIPS_USE_WAIT		0x0100	/* Use "wait"-based cpu_idle() */
    250  1.63    simonb #define	CPU_MIPS_NO_WAIT		0x0200	/* Inverse of previous, for mips32/64 */
    251  1.69    simonb #define	CPU_MIPS_D_CACHE_COHERENT	0x0400	/* D-cache is fully coherent */
    252  1.69    simonb #define	CPU_MIPS_I_D_CACHE_COHERENT	0x0800	/* I-cache funcs don't need to flush the D-cache */
    253  1.94      matt #define	CPU_MIPS_NO_LLADDR		0x1000
    254  1.94      matt #define	CPU_MIPS_HAVE_MxCR		0x2000	/* have mfcr, mtcr insns */
    255  1.58    simonb #define	MIPS_NOT_SUPP			0x8000
    256  1.60    simonb 
    257  1.78        ad #endif	/* !_LOCORE */
    258  1.78        ad 
    259  1.99      matt #if ((MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) == 1) || defined(_LOCORE)
    260  1.78        ad 
    261  1.78        ad #if defined(MIPS1)
    262  1.78        ad 
    263  1.58    simonb # define CPUISMIPS3		0
    264  1.58    simonb # define CPUIS64BITS		0
    265  1.58    simonb # define CPUISMIPS32		0
    266  1.99      matt # define CPUISMIPS32R2		0
    267  1.58    simonb # define CPUISMIPS64		0
    268  1.99      matt # define CPUISMIPS64R2		0
    269  1.58    simonb # define CPUISMIPSNN		0
    270  1.58    simonb # define MIPS_HAS_R4K_MMU	0
    271  1.58    simonb # define MIPS_HAS_CLOCK		0
    272  1.58    simonb # define MIPS_HAS_LLSC		0
    273  1.94      matt # define MIPS_HAS_LLADDR	0
    274  1.58    simonb 
    275  1.78        ad #elif defined(MIPS3) || defined(MIPS4)
    276  1.78        ad 
    277  1.58    simonb # define CPUISMIPS3		1
    278  1.58    simonb # define CPUIS64BITS		1
    279  1.58    simonb # define CPUISMIPS32		0
    280  1.99      matt # define CPUISMIPS32R2		0
    281  1.58    simonb # define CPUISMIPS64		0
    282  1.99      matt # define CPUISMIPS64R2		0
    283  1.58    simonb # define CPUISMIPSNN		0
    284  1.58    simonb # define MIPS_HAS_R4K_MMU	1
    285  1.58    simonb # define MIPS_HAS_CLOCK		1
    286  1.78        ad # if defined(_LOCORE)
    287  1.98      matt #  if !defined(MIPS3_4100)
    288  1.78        ad #   define MIPS_HAS_LLSC	1
    289  1.78        ad #  else
    290  1.78        ad #   define MIPS_HAS_LLSC	0
    291  1.78        ad #  endif
    292  1.78        ad # else	/* _LOCORE */
    293  1.98      matt #  define MIPS_HAS_LLSC		(mips_options.mips_has_llsc)
    294  1.78        ad # endif	/* _LOCORE */
    295  1.98      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    296  1.78        ad 
    297  1.78        ad #elif defined(MIPS32)
    298  1.58    simonb 
    299  1.58    simonb # define CPUISMIPS3		1
    300  1.58    simonb # define CPUIS64BITS		0
    301  1.58    simonb # define CPUISMIPS32		1
    302  1.99      matt # define CPUISMIPS32R2		0
    303  1.99      matt # define CPUISMIPS64		0
    304  1.99      matt # define CPUISMIPS64R2		0
    305  1.99      matt # define CPUISMIPSNN		1
    306  1.99      matt # define MIPS_HAS_R4K_MMU	1
    307  1.99      matt # define MIPS_HAS_CLOCK		1
    308  1.99      matt # define MIPS_HAS_LLSC		1
    309  1.99      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    310  1.99      matt 
    311  1.99      matt #elif defined(MIPS32R2)
    312  1.99      matt 
    313  1.99      matt # define CPUISMIPS3		1
    314  1.99      matt # define CPUIS64BITS		0
    315  1.99      matt # define CPUISMIPS32		0
    316  1.99      matt # define CPUISMIPS32R2		1
    317  1.58    simonb # define CPUISMIPS64		0
    318  1.99      matt # define CPUISMIPS64R2		0
    319  1.58    simonb # define CPUISMIPSNN		1
    320  1.58    simonb # define MIPS_HAS_R4K_MMU	1
    321  1.58    simonb # define MIPS_HAS_CLOCK		1
    322  1.58    simonb # define MIPS_HAS_LLSC		1
    323  1.98      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    324  1.58    simonb 
    325  1.80     oster #elif defined(MIPS64)
    326  1.78        ad 
    327  1.58    simonb # define CPUISMIPS3		1
    328  1.58    simonb # define CPUIS64BITS		1
    329  1.58    simonb # define CPUISMIPS32		0
    330  1.99      matt # define CPUISMIPS32R2		0
    331  1.58    simonb # define CPUISMIPS64		1
    332  1.99      matt # define CPUISMIPS64R2		0
    333  1.99      matt # define CPUISMIPSNN		1
    334  1.99      matt # define MIPS_HAS_R4K_MMU	1
    335  1.99      matt # define MIPS_HAS_CLOCK		1
    336  1.99      matt # define MIPS_HAS_LLSC		1
    337  1.99      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    338  1.99      matt 
    339  1.99      matt #elif defined(MIPS64R2)
    340  1.99      matt 
    341  1.99      matt # define CPUISMIPS3		1
    342  1.99      matt # define CPUIS64BITS		1
    343  1.99      matt # define CPUISMIPS32		0
    344  1.99      matt # define CPUISMIPS32R2		0
    345  1.99      matt # define CPUISMIPS64		0
    346  1.99      matt # define CPUISMIPS64R2		1
    347  1.58    simonb # define CPUISMIPSNN		1
    348  1.58    simonb # define MIPS_HAS_R4K_MMU	1
    349  1.58    simonb # define MIPS_HAS_CLOCK		1
    350  1.58    simonb # define MIPS_HAS_LLSC		1
    351  1.98      matt # define MIPS_HAS_LLADDR	((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    352  1.78        ad 
    353  1.78        ad #endif
    354  1.21  jonathan 
    355  1.58    simonb #else /* run-time test */
    356  1.21  jonathan 
    357  1.78        ad #ifndef	_LOCORE
    358  1.78        ad 
    359  1.98      matt #define	MIPS_HAS_R4K_MMU	(mips_options.mips_has_r4k_mmu)
    360  1.98      matt #define	MIPS_HAS_LLSC		(mips_options.mips_has_llsc)
    361  1.98      matt #define	MIPS_HAS_LLADDR		((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
    362  1.45       cgd 
    363  1.45       cgd /* This test is ... rather bogus */
    364  1.98      matt #define	CPUISMIPS3	((mips_options.mips_cpu_arch & \
    365  1.58    simonb 	(CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS32 | CPU_ARCH_MIPS64)) != 0)
    366  1.58    simonb 
    367  1.58    simonb /* And these aren't much better while the previous test exists as is... */
    368  1.98      matt #define	CPUISMIPS4	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS4) != 0)
    369  1.98      matt #define	CPUISMIPS5	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS5) != 0)
    370  1.98      matt #define	CPUISMIPS32	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS32) != 0)
    371  1.99      matt #define	CPUISMIPS32R2	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS32R2) != 0)
    372  1.98      matt #define	CPUISMIPS64	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS64) != 0)
    373  1.99      matt #define	CPUISMIPS64R2	((mips_options.mips_cpu_arch & CPU_ARCH_MIPS64R2) != 0)
    374  1.99      matt #define	CPUISMIPSNN	((mips_options.mips_cpu_arch & (CPU_ARCH_MIPS32 | CPU_ARCH_MIPS32R2 | CPU_ARCH_MIPS64 | CPU_ARCH_MIPS64R2)) != 0)
    375  1.98      matt #define	CPUIS64BITS	((mips_options.mips_cpu_arch & \
    376  1.99      matt 	(CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS64 | CPU_ARCH_MIPS64R2)) != 0)
    377  1.58    simonb 
    378  1.98      matt #define	MIPS_HAS_CLOCK	(mips_options.mips_cpu_arch >= CPU_ARCH_MIPS3)
    379  1.78        ad 
    380  1.78        ad #else	/* !_LOCORE */
    381  1.78        ad 
    382  1.78        ad #define	MIPS_HAS_LLSC	0
    383  1.78        ad 
    384  1.78        ad #endif	/* !_LOCORE */
    385  1.78        ad 
    386  1.21  jonathan #endif /* run-time test */
    387  1.21  jonathan 
    388  1.78        ad #ifndef	_LOCORE
    389  1.58    simonb 
    390  1.21  jonathan /*
    391   1.1   deraadt  * definitions of cpu-dependent requirements
    392   1.1   deraadt  * referenced in generic code
    393   1.1   deraadt  */
    394  1.42     jeffs 
    395  1.98      matt /*
    396  1.98      matt  * Send an inter-processor interupt to each other CPU (excludes curcpu())
    397  1.98      matt  */
    398  1.98      matt void cpu_broadcast_ipi(int);
    399  1.98      matt 
    400  1.98      matt /*
    401  1.98      matt  * Send an inter-processor interupt to CPUs in cpuset (excludes curcpu())
    402  1.98      matt  */
    403  1.98      matt void cpu_multicast_ipi(__cpuset_t, int);
    404  1.98      matt 
    405  1.98      matt /*
    406  1.98      matt  * Send an inter-processor interupt to another CPU.
    407  1.98      matt  */
    408  1.98      matt int cpu_send_ipi(struct cpu_info *, int);
    409  1.98      matt 
    410  1.98      matt /*
    411  1.98      matt  * cpu_intr(ppl, pc, status);  (most state needed by clockframe)
    412  1.98      matt  */
    413  1.98      matt void cpu_intr(int, vaddr_t, uint32_t);
    414   1.1   deraadt 
    415   1.1   deraadt /*
    416   1.1   deraadt  * Arguments to hardclock and gatherstats encapsulate the previous
    417   1.1   deraadt  * machine state in an opaque clockframe.
    418   1.1   deraadt  */
    419   1.5     glass struct clockframe {
    420  1.98      matt 	vaddr_t		pc;	/* program counter at time of interrupt */
    421  1.94      matt 	uint32_t	sr;	/* status register at time of interrupt */
    422  1.98      matt 	bool		intr;	/* interrupted a interrupt */
    423   1.5     glass };
    424   1.1   deraadt 
    425  1.14  jonathan /*
    426  1.79        ad  * A port must provde CLKF_USERMODE() for use in machine-independent code.
    427  1.79        ad  * These differ on r4000 and r3000 systems; provide them in the
    428  1.79        ad  * port-dependent file that includes this one, using the macros below.
    429  1.14  jonathan  */
    430  1.14  jonathan 
    431  1.21  jonathan /* mips1 versions */
    432  1.22  jonathan #define	MIPS1_CLKF_USERMODE(framep)	((framep)->sr & MIPS_SR_KU_PREV)
    433  1.14  jonathan 
    434  1.21  jonathan /* mips3 versions */
    435  1.22  jonathan #define	MIPS3_CLKF_USERMODE(framep)	((framep)->sr & MIPS_SR_KSU_USER)
    436  1.56       uch 
    437   1.1   deraadt #define	CLKF_PC(framep)		((framep)->pc)
    438  1.98      matt #define	CLKF_INTR(framep)	((framep)->intr)
    439  1.18  jonathan 
    440  1.58    simonb #if defined(MIPS3_PLUS) && !defined(MIPS1)		/* XXX bogus! */
    441  1.21  jonathan #define	CLKF_USERMODE(framep)	MIPS3_CLKF_USERMODE(framep)
    442  1.21  jonathan #endif
    443  1.21  jonathan 
    444  1.58    simonb #if !defined(MIPS3_PLUS) && defined(MIPS1)		/* XXX bogus! */
    445  1.21  jonathan #define	CLKF_USERMODE(framep)	MIPS1_CLKF_USERMODE(framep)
    446  1.21  jonathan #endif
    447  1.21  jonathan 
    448  1.58    simonb #if defined(MIPS3_PLUS) && defined(MIPS1)		/* XXX bogus! */
    449  1.21  jonathan #define CLKF_USERMODE(framep) \
    450  1.21  jonathan     ((CPUISMIPS3) ? MIPS3_CLKF_USERMODE(framep):  MIPS1_CLKF_USERMODE(framep))
    451  1.18  jonathan #endif
    452  1.18  jonathan 
    453  1.47   thorpej /*
    454  1.98      matt  * Misc prototypes and variable declarations.
    455  1.47   thorpej  */
    456  1.98      matt #define	LWP_PC(l)	cpu_lwp_pc(l)
    457  1.98      matt 
    458  1.98      matt struct proc;
    459  1.98      matt struct lwp;
    460  1.98      matt struct pcb;
    461  1.98      matt struct reg;
    462   1.1   deraadt 
    463   1.1   deraadt /*
    464   1.1   deraadt  * Preempt the current process if in interrupt from user mode,
    465   1.1   deraadt  * or after the current trap/syscall if in system mode.
    466   1.1   deraadt  */
    467  1.82      yamt void	cpu_need_resched(struct cpu_info *, int);
    468  1.98      matt /*
    469  1.98      matt  * Notify the current lwp (l) that it has a signal pending,
    470  1.98      matt  * process as soon as possible.
    471  1.98      matt  */
    472  1.98      matt void	cpu_signotify(struct lwp *);
    473   1.1   deraadt 
    474   1.1   deraadt /*
    475   1.1   deraadt  * Give a profiling tick to the current process when the user profiling
    476  1.13  jonathan  * buffer pages are invalid.  On the MIPS, request an ast to send us
    477   1.1   deraadt  * through trap, marking the proc as needing a profiling tick.
    478   1.1   deraadt  */
    479  1.98      matt void	cpu_need_proftick(struct lwp *);
    480  1.98      matt void	cpu_set_curpri(int);
    481   1.1   deraadt 
    482  1.98      matt extern int mips_poolpage_vmfreelist;	/* freelist to allocate poolpages */
    483   1.1   deraadt 
    484  1.98      matt struct cpu_info *
    485  1.98      matt 	cpu_info_alloc(struct pmap_tlb_info *, cpuid_t, cpuid_t, cpuid_t,
    486  1.98      matt 	    cpuid_t);
    487  1.98      matt void	cpu_attach_common(device_t, struct cpu_info *);
    488  1.98      matt void	cpu_startup_common(void);
    489  1.98      matt #ifdef _LP64
    490  1.98      matt void	cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t);
    491  1.98      matt #endif
    492   1.1   deraadt 
    493  1.98      matt #ifdef MULTIPROCESSOR
    494  1.98      matt void	cpu_hatch(struct cpu_info *ci);
    495  1.98      matt void	cpu_trampoline(void);
    496  1.98      matt void	cpu_boot_secondary_processors(void);
    497  1.98      matt void	cpu_halt(void);
    498  1.98      matt void	cpu_halt_others(void);
    499  1.98      matt void	cpu_pause(struct reg *);
    500  1.98      matt void	cpu_pause_others(void);
    501  1.98      matt void	cpu_resume(int);
    502  1.98      matt void	cpu_resume_others(void);
    503  1.98      matt int	cpu_is_paused(int);
    504  1.98      matt void	cpu_debug_dump(void);
    505  1.98      matt 
    506  1.98      matt extern volatile __cpuset_t cpus_running;
    507  1.98      matt extern volatile __cpuset_t cpus_hatched;
    508  1.98      matt extern volatile __cpuset_t cpus_paused;
    509  1.98      matt extern volatile __cpuset_t cpus_resumed;
    510  1.98      matt extern volatile __cpuset_t cpus_halted;
    511  1.98      matt #endif
    512  1.25  jonathan 
    513  1.94      matt /* copy.S */
    514  1.94      matt int8_t	ufetch_int8(void *);
    515  1.94      matt int16_t	ufetch_int16(void *);
    516  1.94      matt int32_t ufetch_int32(void *);
    517  1.94      matt uint8_t	ufetch_uint8(void *);
    518  1.94      matt uint16_t ufetch_uint16(void *);
    519  1.94      matt uint32_t ufetch_uint32(void *);
    520  1.94      matt int8_t	ufetch_int8_intrsafe(void *);
    521  1.94      matt int16_t	ufetch_int16_intrsafe(void *);
    522  1.94      matt int32_t ufetch_int32_intrsafe(void *);
    523  1.94      matt uint8_t	ufetch_uint8_intrsafe(void *);
    524  1.94      matt uint16_t ufetch_uint16_intrsafe(void *);
    525  1.94      matt uint32_t ufetch_uint32_intrsafe(void *);
    526  1.94      matt #ifdef _LP64
    527  1.94      matt int64_t ufetch_int64(void *);
    528  1.94      matt uint64_t ufetch_uint64(void *);
    529  1.94      matt int64_t ufetch_int64_intrsafe(void *);
    530  1.94      matt uint64_t ufetch_uint64_intrsafe(void *);
    531  1.94      matt #endif
    532  1.94      matt char	ufetch_char(void *);
    533  1.94      matt short	ufetch_short(void *);
    534  1.94      matt int	ufetch_int(void *);
    535  1.94      matt long	ufetch_long(void *);
    536  1.94      matt char	ufetch_char_intrsafe(void *);
    537  1.94      matt short	ufetch_short_intrsafe(void *);
    538  1.94      matt int	ufetch_int_intrsafe(void *);
    539  1.94      matt long	ufetch_long_intrsafe(void *);
    540  1.94      matt 
    541  1.94      matt u_char	ufetch_uchar(void *);
    542  1.94      matt u_short	ufetch_ushort(void *);
    543  1.94      matt u_int	ufetch_uint(void *);
    544  1.94      matt u_long	ufetch_ulong(void *);
    545  1.94      matt u_char	ufetch_uchar_intrsafe(void *);
    546  1.94      matt u_short	ufetch_ushort_intrsafe(void *);
    547  1.94      matt u_int	ufetch_uint_intrsafe(void *);
    548  1.94      matt u_long	ufetch_ulong_intrsafe(void *);
    549  1.94      matt void 	*ufetch_ptr(void *);
    550  1.94      matt 
    551  1.94      matt int	ustore_int8(void *, int8_t);
    552  1.94      matt int	ustore_int16(void *, int16_t);
    553  1.94      matt int	ustore_int32(void *, int32_t);
    554  1.94      matt int	ustore_uint8(void *, uint8_t);
    555  1.94      matt int	ustore_uint16(void *, uint16_t);
    556  1.94      matt int	ustore_uint32(void *, uint32_t);
    557  1.94      matt int	ustore_int8_intrsafe(void *, int8_t);
    558  1.94      matt int	ustore_int16_intrsafe(void *, int16_t);
    559  1.94      matt int	ustore_int32_intrsafe(void *, int32_t);
    560  1.94      matt int	ustore_uint8_intrsafe(void *, uint8_t);
    561  1.94      matt int	ustore_uint16_intrsafe(void *, uint16_t);
    562  1.94      matt int	ustore_uint32_intrsafe(void *, uint32_t);
    563  1.94      matt #ifdef _LP64
    564  1.94      matt int	ustore_int64(void *, int64_t);
    565  1.94      matt int	ustore_uint64(void *, uint64_t);
    566  1.94      matt int	ustore_int64_intrsafe(void *, int64_t);
    567  1.94      matt int	ustore_uint64_intrsafe(void *, uint64_t);
    568  1.94      matt #endif
    569  1.94      matt int	ustore_char(void *, char);
    570  1.94      matt int	ustore_char_intrsafe(void *, char);
    571  1.94      matt int	ustore_short(void *, short);
    572  1.94      matt int	ustore_short_intrsafe(void *, short);
    573  1.94      matt int	ustore_int(void *, int);
    574  1.94      matt int	ustore_int_intrsafe(void *, int);
    575  1.94      matt int	ustore_long(void *, long);
    576  1.94      matt int	ustore_long_intrsafe(void *, long);
    577  1.94      matt int	ustore_uchar(void *, u_char);
    578  1.94      matt int	ustore_uchar_intrsafe(void *, u_char);
    579  1.94      matt int	ustore_ushort(void *, u_short);
    580  1.94      matt int	ustore_ushort_intrsafe(void *, u_short);
    581  1.94      matt int	ustore_uint(void *, u_int);
    582  1.94      matt int	ustore_uint_intrsafe(void *, u_int);
    583  1.94      matt int	ustore_ulong(void *, u_long);
    584  1.94      matt int	ustore_ulong_intrsafe(void *, u_long);
    585  1.94      matt int 	ustore_ptr(void *, void *);
    586  1.94      matt int	ustore_ptr_intrsafe(void *, void *);
    587  1.94      matt 
    588  1.94      matt int	ustore_uint32_isync(void *, uint32_t);
    589  1.94      matt 
    590  1.28    castor /* trap.c */
    591  1.58    simonb void	netintr(void);
    592  1.58    simonb int	kdbpeek(vaddr_t);
    593  1.23   thorpej 
    594  1.98      matt /* mips_fpu.c */
    595  1.98      matt void	fpu_init(void);
    596  1.98      matt void	fpu_discard(void);
    597  1.98      matt void	fpu_load(void);
    598  1.98      matt void	fpu_save(void);
    599  1.98      matt void	fpu_save_lwp(struct lwp *);
    600  1.98      matt bool	fpu_used_p(struct lwp *);
    601  1.98      matt 
    602  1.28    castor /* mips_machdep.c */
    603  1.58    simonb void	dumpsys(void);
    604  1.93     rmind int	savectx(struct pcb *);
    605  1.98      matt void	cpu_identify(device_t);
    606  1.13  jonathan 
    607  1.61    simonb /* locore*.S */
    608  1.58    simonb int	badaddr(void *, size_t);
    609  1.61    simonb int	badaddr64(uint64_t, size_t);
    610  1.25  jonathan 
    611  1.98      matt /* vm_machdep.c */
    612  1.98      matt void *	cpu_uarea_alloc(bool);
    613  1.98      matt bool	cpu_uarea_free(void *);
    614  1.98      matt void	cpu_proc_fork(struct proc *, struct proc *);
    615  1.98      matt vaddr_t	cpu_lwp_pc(struct lwp *);
    616  1.98      matt int	ioaccess(vaddr_t, paddr_t, vsize_t);
    617  1.98      matt int	iounaccess(vaddr_t, vsize_t);
    618  1.27   thorpej 
    619  1.33    simonb #endif /* ! _LOCORE */
    620  1.28    castor #endif /* _KERNEL */
    621   1.1   deraadt #endif /* _CPU_H_ */
    622